Skip to content

Commit 6ce438e

Browse files
Merge branch 'master' into TC-FAN-3.1
2 parents 5c5ca26 + 7c1d6f7 commit 6ce438e

File tree

11 files changed

+341
-56
lines changed

11 files changed

+341
-56
lines changed

.devcontainer/Dockerfile

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,24 @@ RUN curl https://raw.githubusercontent.com/restyled-io/restyler/master/bin/resty
5454
&& chmod +x /usr/local/bin/restyle-path \
5555
&& :
5656

57-
RUN mkdir -p /opt/sdk/sdks/ \
57+
RUN mkdir -p /opt/android/sdk \
5858
&& chown -R $USERNAME:$USERNAME \
59-
/opt/sdk/sdks/ `# NXP uses a patch_sdk script to change SDK files` \
59+
/opt/android/sdk `# NXP uses a patch_sdk script to change SDK files` \
6060
$ANDROID_HOME \
6161
$IDF_TOOLS_PATH \
6262
&& find $AMEBA_PATH -name "inc_lp" -print0 | xargs -0 chown -R $USERNAME:$USERNAME \
6363
&& find $AMEBA_PATH -name "inc_hp" -print0 | xargs -0 chown -R $USERNAME:$USERNAME \
6464
&& find $AMEBA_PATH -name "project_lp" -print0 | xargs -0 chown -R $USERNAME:$USERNAME \
6565
&& find $AMEBA_PATH -name "project_hp" -print0 | xargs -0 chown -R $USERNAME:$USERNAME \
6666
&& chmod -R +x \
67-
$ANDROID_HOME/tools/bin `# sdkmanager for accepting licenses`\
67+
$ANDROID_HOME/cmdline-tools/10.0/bin `# sdkmanager for accepting licenses`\
6868
&& chmod -R +w \
6969
$IDF_TOOLS_PATH \
7070
&& find $AMEBA_PATH -name "inc_lp" -print0 | xargs -0 chmod -R +w \
7171
&& find $AMEBA_PATH -name "inc_hp" -print0 | xargs -0 chmod -R +w \
7272
&& find $AMEBA_PATH -name "project_lp" -print0 | xargs -0 chmod -R +w \
7373
&& find $AMEBA_PATH -name "project_hp" -print0 | xargs -0 chmod -R +w \
74-
# Safe directory is preffered over chown.
74+
# Safe directory is preferred over chown.
7575
&& git config --global --add safe.directory "*" \
7676
&& :
7777

.github/dependabot.yml

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ updates:
3838
- dependency-name: "third_party/java_deps/repo"
3939
- dependency-name: "third_party/jlink/repo"
4040
- dependency-name: "third_party/jsoncpp/repo"
41+
- dependency-name: "third_party/libdatachannel/repo"
4142
- dependency-name: "third_party/libwebsockets/repo"
4243
- dependency-name: "third_party/lwip/repo"
4344
- dependency-name: "third_party/mbed-mcu-boot/repo"

.github/workflows/build.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,16 @@ jobs:
211211
- name: Find changed files
212212
id: changed-files
213213
uses: tj-actions/changed-files@v45
214+
with:
215+
# Exclude all files under "third_party/"
216+
files-ignore: |
217+
third_party/
218+
214219
- name: Clang-tidy validation
215220
# NOTE: clang-tidy crashes on CodegenDataModel_Write due to Nullable/std::optional check.
216221
# See https://github.com/llvm/llvm-project/issues/97426
217222
env:
218-
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
223+
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.changed_files }}
219224
run: |
220225
touch out/changed_files.txt
221226
for file in ${ALL_CHANGED_FILES}; do

.gitmodules

+5
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,8 @@
349349
path = third_party/re2/src
350350
url = https://github.com/google/re2.git
351351
platforms = linux,darwin
352+
[submodule "third_party/libdatachannel/repo"]
353+
path = third_party/libdatachannel/repo
354+
url = https://github.com/paullouisageneau/libdatachannel.git
355+
platforms = linux
356+
recursive = true

examples/platform/bouffalolab/common/plat/plat.h

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323

2424
#define EXT_DISCOVERY_TIMEOUT_SECS 20
2525

26+
#ifndef CONFIG_APP_ADVERTISE_COMMISSIONABLE_ON_LAST_FABRIC_REMOVAL
27+
#define CONFIG_APP_ADVERTISE_COMMISSIONABLE_ON_LAST_FABRIC_REMOVAL 0
28+
#endif
29+
2630
typedef void (*app_pds_gpio_irq_handler_t)(void * arg);
2731

2832
#ifdef __cplusplus

examples/platform/bouffalolab/common/plat/platform.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ void UnlockOpenThreadTask(void)
178178
}
179179
#endif
180180

181+
#if CONFIG_APP_ADVERTISE_COMMISSIONABLE_ON_LAST_FABRIC_REMOVAL
181182
class AppFabricTableDelegate : public FabricTable::Delegate
182183
{
183184
void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex)
@@ -206,6 +207,7 @@ class AppFabricTableDelegate : public FabricTable::Delegate
206207
}
207208
}
208209
};
210+
#endif
209211

210212
CHIP_ERROR PlatformManagerImpl::PlatformInit(void)
211213
{
@@ -295,8 +297,10 @@ CHIP_ERROR PlatformManagerImpl::PlatformInit(void)
295297

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

300+
#if CONFIG_APP_ADVERTISE_COMMISSIONABLE_ON_LAST_FABRIC_REMOVAL
298301
static AppFabricTableDelegate sAppFabricDelegate;
299302
chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(&sAppFabricDelegate);
303+
#endif
300304

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

scripts/build/builders/host.py

+9
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,17 @@ def PostBuildCommand(self):
653653
+ ' | xargs -n1 basename | sed "s/\\.profraw//" '
654654
+ f' | xargs -I @ echo -object {shlex.quote(os.path.join(self.output_dir, "tests", "@"))}'
655655
+ f' | xargs -n 10240 llvm-cov export -format=lcov --instr-profile {_indexed_instrumentation} '
656+
# only care about SDK code. third_party is not considered sdk
656657
+ ' --ignore-filename-regex "/third_party/"'
658+
# about 75K lines with almost 0% coverage
659+
+ ' --ignore-filename-regex "/zzz_generated/"'
660+
# generated interface files. about 8K lines with little coverage
661+
+ ' --ignore-filename-regex "/out/.*/Linux/dbus/"'
662+
# 100% coverage for 1K lines, but not relevant (test code)
663+
+ ' --ignore-filename-regex "/out/.*/clang_static_coverage_config/"'
664+
# Tests are likely 100% or close to, want to see only "functionality tested"
657665
+ ' --ignore-filename-regex "/tests/"'
666+
# Ignore system includes
658667
+ ' --ignore-filename-regex "/usr/include/"'
659668
+ ' --ignore-filename-regex "/usr/lib/"'
660669
+ f' | cat >{shlex.quote(_lcov_data)}'

src/darwin/Framework/CHIP/MTRDevice_XPC.mm

+38-17
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,23 @@ - (oneway void)deviceConfigurationChanged:(NSNumber *)nodeID
253253
}];
254254
}
255255

256-
static const auto * requiredInternalStateKeys = @[ kMTRDeviceInternalPropertyDeviceState, kMTRDeviceInternalPropertyLastSubscriptionAttemptWait ];
257-
static const auto * optionalInternalStateKeys = @[ kMTRDeviceInternalPropertyKeyVendorID, kMTRDeviceInternalPropertyKeyProductID, kMTRDeviceInternalPropertyNetworkFeatures, kMTRDeviceInternalPropertyMostRecentReportTime, kMTRDeviceInternalPropertyLastSubscriptionFailureTime ];
258-
259-
- (BOOL)_internalState:(NSDictionary *)dictionary hasValidValuesForKeys:(const NSArray<NSString *> *)keys valueRequired:(BOOL)required
256+
static const auto * requiredInternalStateKeys = @{
257+
kMTRDeviceInternalPropertyDeviceState : NSNumber.class,
258+
kMTRDeviceInternalPropertyLastSubscriptionAttemptWait : NSNumber.class,
259+
};
260+
261+
static const auto * optionalInternalStateKeys = @{
262+
kMTRDeviceInternalPropertyKeyVendorID : NSNumber.class,
263+
kMTRDeviceInternalPropertyKeyProductID : NSNumber.class,
264+
kMTRDeviceInternalPropertyNetworkFeatures : NSNumber.class,
265+
kMTRDeviceInternalPropertyMostRecentReportTime : NSDate.class,
266+
kMTRDeviceInternalPropertyLastSubscriptionFailureTime : NSDate.class,
267+
};
268+
269+
- (BOOL)_ensureValidValuesForKeys:(const NSDictionary<NSString *, Class> *)keys inInternalState:(NSMutableDictionary *)internalState valueRequired:(BOOL)required
260270
{
261-
// At one point, all keys were NSNumber valued; now there are also NSDates.
262-
// TODO: Create a mapping between keys and their expected types and use that in the type check below.
263271
for (NSString * key in keys) {
264-
id value = dictionary[key];
272+
id value = internalState[key];
265273
if (!value) {
266274
if (required) {
267275
MTR_LOG_ERROR("%@ device:internalStateUpdated: handed state with no value for \"%@\": %@", self, key, value);
@@ -270,9 +278,17 @@ - (BOOL)_internalState:(NSDictionary *)dictionary hasValidValuesForKeys:(const N
270278

271279
continue;
272280
}
273-
if (!MTR_SAFE_CAST(value, NSNumber) && !MTR_SAFE_CAST(value, NSDate)) {
274-
MTR_LOG_ERROR("%@ device:internalStateUpdated: handed state with invalid value for \"%@\": %@", self, key, value);
275-
return NO;
281+
if (![value isKindOfClass:keys[key]]) {
282+
MTR_LOG_ERROR("%@ device:internalStateUpdated: handed state with invalid value of type %@ for \"%@\": %@", self,
283+
NSStringFromClass([value class]), key, value);
284+
if (required) {
285+
return NO;
286+
}
287+
288+
// If an optional value is invalid, just drop it and press on with
289+
// the other parts of the state, so we don't break those pieces
290+
// just because something optional has gone awry.
291+
[internalState removeObjectForKey:key];
276292
}
277293
}
278294

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

311+
[self _updateInternalState:[dictionary mutableCopy]];
312+
}
313+
314+
- (void)_updateInternalState:(NSMutableDictionary *)newState
315+
{
316+
VerifyOrReturn([self _ensureValidValuesForKeys:requiredInternalStateKeys inInternalState:newState valueRequired:YES]);
317+
VerifyOrReturn([self _ensureValidValuesForKeys:optionalInternalStateKeys inInternalState:newState valueRequired:NO]);
318+
295319
NSNumber * oldStateNumber = MTR_SAFE_CAST(self._internalState[kMTRDeviceInternalPropertyDeviceState], NSNumber);
296-
NSNumber * newStateNumber = MTR_SAFE_CAST(dictionary[kMTRDeviceInternalPropertyDeviceState], NSNumber);
320+
NSNumber * newStateNumber = MTR_SAFE_CAST(newState[kMTRDeviceInternalPropertyDeviceState], NSNumber);
297321

298-
VerifyOrReturn([self _internalState:dictionary hasValidValuesForKeys:requiredInternalStateKeys valueRequired:YES]);
299-
VerifyOrReturn([self _internalState:dictionary hasValidValuesForKeys:optionalInternalStateKeys valueRequired:NO]);
322+
NSNumber * oldPrimedState = MTR_SAFE_CAST(self._internalState[kMTRDeviceInternalPropertyDeviceCachePrimed], NSNumber);
323+
NSNumber * newPrimedState = MTR_SAFE_CAST(newState[kMTRDeviceInternalPropertyDeviceCachePrimed], NSNumber);
300324

301-
[self _setInternalState:dictionary];
325+
[self _setInternalState:newState];
302326

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

310-
NSNumber * oldPrimedState = MTR_SAFE_CAST(self._internalState[kMTRDeviceInternalPropertyDeviceCachePrimed], NSNumber);
311-
NSNumber * newPrimedState = MTR_SAFE_CAST(dictionary[kMTRDeviceInternalPropertyDeviceCachePrimed], NSNumber);
312-
313334
if (!MTREqualObjects(oldPrimedState, newPrimedState)) {
314335
[self _lockAndCallDelegatesWithBlock:^(id<MTRDeviceDelegate> delegate) {
315336
if ([delegate respondsToSelector:@selector(deviceCachePrimed:)]) {

0 commit comments

Comments
 (0)