Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync csa branch with main #285

Merged
merged 7 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,24 @@ RUN curl https://raw.githubusercontent.com/restyled-io/restyler/master/bin/resty
&& chmod +x /usr/local/bin/restyle-path \
&& :

RUN mkdir -p /opt/sdk/sdks/ \
RUN mkdir -p /opt/android/sdk \
&& chown -R $USERNAME:$USERNAME \
/opt/sdk/sdks/ `# NXP uses a patch_sdk script to change SDK files` \
/opt/android/sdk `# NXP uses a patch_sdk script to change SDK files` \
$ANDROID_HOME \
$IDF_TOOLS_PATH \
&& find $AMEBA_PATH -name "inc_lp" -print0 | xargs -0 chown -R $USERNAME:$USERNAME \
&& find $AMEBA_PATH -name "inc_hp" -print0 | xargs -0 chown -R $USERNAME:$USERNAME \
&& find $AMEBA_PATH -name "project_lp" -print0 | xargs -0 chown -R $USERNAME:$USERNAME \
&& find $AMEBA_PATH -name "project_hp" -print0 | xargs -0 chown -R $USERNAME:$USERNAME \
&& chmod -R +x \
$ANDROID_HOME/tools/bin `# sdkmanager for accepting licenses`\
$ANDROID_HOME/cmdline-tools/10.0/bin `# sdkmanager for accepting licenses`\
&& chmod -R +w \
$IDF_TOOLS_PATH \
&& find $AMEBA_PATH -name "inc_lp" -print0 | xargs -0 chmod -R +w \
&& find $AMEBA_PATH -name "inc_hp" -print0 | xargs -0 chmod -R +w \
&& find $AMEBA_PATH -name "project_lp" -print0 | xargs -0 chmod -R +w \
&& find $AMEBA_PATH -name "project_hp" -print0 | xargs -0 chmod -R +w \
# Safe directory is preffered over chown.
# Safe directory is preferred over chown.
&& git config --global --add safe.directory "*" \
&& :

Expand Down
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ updates:
- dependency-name: "third_party/java_deps/repo"
- dependency-name: "third_party/jlink/repo"
- dependency-name: "third_party/jsoncpp/repo"
- dependency-name: "third_party/libdatachannel/repo"
- dependency-name: "third_party/libwebsockets/repo"
- dependency-name: "third_party/lwip/repo"
- dependency-name: "third_party/mbed-mcu-boot/repo"
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,16 @@ jobs:
- name: Find changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
# Exclude all files under "third_party/"
files-ignore: |
third_party/
- name: Clang-tidy validation
# NOTE: clang-tidy crashes on CodegenDataModel_Write due to Nullable/std::optional check.
# See https://github.com/llvm/llvm-project/issues/97426
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.changed_files }}
run: |
touch out/changed_files.txt
for file in ${ALL_CHANGED_FILES}; do
Expand Down
5 changes: 5 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,8 @@
path = third_party/re2/src
url = https://github.com/google/re2.git
platforms = linux,darwin
[submodule "third_party/libdatachannel/repo"]
path = third_party/libdatachannel/repo
url = https://github.com/paullouisageneau/libdatachannel.git
platforms = linux
recursive = true
4 changes: 4 additions & 0 deletions examples/platform/bouffalolab/common/plat/plat.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

#define EXT_DISCOVERY_TIMEOUT_SECS 20

#ifndef CONFIG_APP_ADVERTISE_COMMISSIONABLE_ON_LAST_FABRIC_REMOVAL
#define CONFIG_APP_ADVERTISE_COMMISSIONABLE_ON_LAST_FABRIC_REMOVAL 0
#endif

typedef void (*app_pds_gpio_irq_handler_t)(void * arg);

#ifdef __cplusplus
Expand Down
4 changes: 4 additions & 0 deletions examples/platform/bouffalolab/common/plat/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ void UnlockOpenThreadTask(void)
}
#endif

#if CONFIG_APP_ADVERTISE_COMMISSIONABLE_ON_LAST_FABRIC_REMOVAL
class AppFabricTableDelegate : public FabricTable::Delegate
{
void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex)
Expand Down Expand Up @@ -206,6 +207,7 @@ class AppFabricTableDelegate : public FabricTable::Delegate
}
}
};
#endif

CHIP_ERROR PlatformManagerImpl::PlatformInit(void)
{
Expand Down Expand Up @@ -295,8 +297,10 @@ CHIP_ERROR PlatformManagerImpl::PlatformInit(void)

gExampleDeviceInfoProvider.SetStorageDelegate(&chip::Server::GetInstance().GetPersistentStorage());

#if CONFIG_APP_ADVERTISE_COMMISSIONABLE_ON_LAST_FABRIC_REMOVAL
static AppFabricTableDelegate sAppFabricDelegate;
chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(&sAppFabricDelegate);
#endif

chip::DeviceLayer::PlatformMgr().UnlockChipStack();

Expand Down
9 changes: 9 additions & 0 deletions scripts/build/builders/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,17 @@ def PostBuildCommand(self):
+ ' | xargs -n1 basename | sed "s/\\.profraw//" '
+ f' | xargs -I @ echo -object {shlex.quote(os.path.join(self.output_dir, "tests", "@"))}'
+ f' | xargs -n 10240 llvm-cov export -format=lcov --instr-profile {_indexed_instrumentation} '
# only care about SDK code. third_party is not considered sdk
+ ' --ignore-filename-regex "/third_party/"'
# about 75K lines with almost 0% coverage
+ ' --ignore-filename-regex "/zzz_generated/"'
# generated interface files. about 8K lines with little coverage
+ ' --ignore-filename-regex "/out/.*/Linux/dbus/"'
# 100% coverage for 1K lines, but not relevant (test code)
+ ' --ignore-filename-regex "/out/.*/clang_static_coverage_config/"'
# Tests are likely 100% or close to, want to see only "functionality tested"
+ ' --ignore-filename-regex "/tests/"'
# Ignore system includes
+ ' --ignore-filename-regex "/usr/include/"'
+ ' --ignore-filename-regex "/usr/lib/"'
+ f' | cat >{shlex.quote(_lcov_data)}'
Expand Down
55 changes: 38 additions & 17 deletions src/darwin/Framework/CHIP/MTRDevice_XPC.mm
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,23 @@ - (oneway void)deviceConfigurationChanged:(NSNumber *)nodeID
}];
}

static const auto * requiredInternalStateKeys = @[ kMTRDeviceInternalPropertyDeviceState, kMTRDeviceInternalPropertyLastSubscriptionAttemptWait ];
static const auto * optionalInternalStateKeys = @[ kMTRDeviceInternalPropertyKeyVendorID, kMTRDeviceInternalPropertyKeyProductID, kMTRDeviceInternalPropertyNetworkFeatures, kMTRDeviceInternalPropertyMostRecentReportTime, kMTRDeviceInternalPropertyLastSubscriptionFailureTime ];

- (BOOL)_internalState:(NSDictionary *)dictionary hasValidValuesForKeys:(const NSArray<NSString *> *)keys valueRequired:(BOOL)required
static const auto * requiredInternalStateKeys = @{
kMTRDeviceInternalPropertyDeviceState : NSNumber.class,
kMTRDeviceInternalPropertyLastSubscriptionAttemptWait : NSNumber.class,
};

static const auto * optionalInternalStateKeys = @{
kMTRDeviceInternalPropertyKeyVendorID : NSNumber.class,
kMTRDeviceInternalPropertyKeyProductID : NSNumber.class,
kMTRDeviceInternalPropertyNetworkFeatures : NSNumber.class,
kMTRDeviceInternalPropertyMostRecentReportTime : NSDate.class,
kMTRDeviceInternalPropertyLastSubscriptionFailureTime : NSDate.class,
};

- (BOOL)_ensureValidValuesForKeys:(const NSDictionary<NSString *, Class> *)keys inInternalState:(NSMutableDictionary *)internalState valueRequired:(BOOL)required
{
// At one point, all keys were NSNumber valued; now there are also NSDates.
// TODO: Create a mapping between keys and their expected types and use that in the type check below.
for (NSString * key in keys) {
id value = dictionary[key];
id value = internalState[key];
if (!value) {
if (required) {
MTR_LOG_ERROR("%@ device:internalStateUpdated: handed state with no value for \"%@\": %@", self, key, value);
Expand All @@ -270,9 +278,17 @@ - (BOOL)_internalState:(NSDictionary *)dictionary hasValidValuesForKeys:(const N

continue;
}
if (!MTR_SAFE_CAST(value, NSNumber) && !MTR_SAFE_CAST(value, NSDate)) {
MTR_LOG_ERROR("%@ device:internalStateUpdated: handed state with invalid value for \"%@\": %@", self, key, value);
return NO;
if (![value isKindOfClass:keys[key]]) {
MTR_LOG_ERROR("%@ device:internalStateUpdated: handed state with invalid value of type %@ for \"%@\": %@", self,
NSStringFromClass([value class]), key, value);
if (required) {
return NO;
}

// If an optional value is invalid, just drop it and press on with
// the other parts of the state, so we don't break those pieces
// just because something optional has gone awry.
[internalState removeObjectForKey:key];
}
}

Expand All @@ -292,13 +308,21 @@ - (oneway void)device:(NSNumber *)nodeID internalStateUpdated:(NSDictionary *)di
return;
}

[self _updateInternalState:[dictionary mutableCopy]];
}

- (void)_updateInternalState:(NSMutableDictionary *)newState
{
VerifyOrReturn([self _ensureValidValuesForKeys:requiredInternalStateKeys inInternalState:newState valueRequired:YES]);
VerifyOrReturn([self _ensureValidValuesForKeys:optionalInternalStateKeys inInternalState:newState valueRequired:NO]);

NSNumber * oldStateNumber = MTR_SAFE_CAST(self._internalState[kMTRDeviceInternalPropertyDeviceState], NSNumber);
NSNumber * newStateNumber = MTR_SAFE_CAST(dictionary[kMTRDeviceInternalPropertyDeviceState], NSNumber);
NSNumber * newStateNumber = MTR_SAFE_CAST(newState[kMTRDeviceInternalPropertyDeviceState], NSNumber);

VerifyOrReturn([self _internalState:dictionary hasValidValuesForKeys:requiredInternalStateKeys valueRequired:YES]);
VerifyOrReturn([self _internalState:dictionary hasValidValuesForKeys:optionalInternalStateKeys valueRequired:NO]);
NSNumber * oldPrimedState = MTR_SAFE_CAST(self._internalState[kMTRDeviceInternalPropertyDeviceCachePrimed], NSNumber);
NSNumber * newPrimedState = MTR_SAFE_CAST(newState[kMTRDeviceInternalPropertyDeviceCachePrimed], NSNumber);

[self _setInternalState:dictionary];
[self _setInternalState:newState];

if (!MTREqualObjects(oldStateNumber, newStateNumber)) {
MTRDeviceState state = self.state;
Expand All @@ -307,9 +331,6 @@ - (oneway void)device:(NSNumber *)nodeID internalStateUpdated:(NSDictionary *)di
}];
}

NSNumber * oldPrimedState = MTR_SAFE_CAST(self._internalState[kMTRDeviceInternalPropertyDeviceCachePrimed], NSNumber);
NSNumber * newPrimedState = MTR_SAFE_CAST(dictionary[kMTRDeviceInternalPropertyDeviceCachePrimed], NSNumber);

if (!MTREqualObjects(oldPrimedState, newPrimedState)) {
[self _lockAndCallDelegatesWithBlock:^(id<MTRDeviceDelegate> delegate) {
if ([delegate respondsToSelector:@selector(deviceCachePrimed:)]) {
Expand Down
Loading
Loading