Skip to content

Commit

Permalink
Merge branch 'master' into default_enable_dm_provider
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Oct 12, 2024
2 parents 10ecddb + 1988399 commit dc46aa8
Show file tree
Hide file tree
Showing 254 changed files with 15,747 additions and 466 deletions.
45 changes: 7 additions & 38 deletions .github/workflows/examples-efr32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ jobs:
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--enable-flashbundle \
--target efr32-brd4187c-thermostat-openthread-mtd \
--target efr32-brd4187c-air-quality-sensor-app-openthread-mtd \
--target efr32-brd4187c-thermostat-use-ot-lib \
--target efr32-brd4187c-switch-shell-use-ot-coap-lib \
--target efr32-brd4187c-unit-test \
build \
Expand All @@ -82,42 +81,30 @@ jobs:
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--enable-flashbundle \
--target efr32-brd4187c-light-use-ot-lib \
--target efr32-brd4187c-pump \
--target efr32-brd4187c-lock-shell-heap-monitoring \
build \
--copy-artifacts-to out/artifacts \
"
- name: Clean out build output
run: rm -rf ./out
- name: Build BRD4187C variants (3)
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--enable-flashbundle \
--target efr32-brd4187c-lock-rpc \
--target efr32-brd4187c-air-quality-sensor-app-shell-heap-monitoring \
--target efr32-brd4187c-window-covering-additional-data-advertising \
--target efr32-brd4187c-light-rpc \
build \
--copy-artifacts-to out/artifacts \
"
- name: Prepare some bloat report from the previous builds
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
efr32 BRD4187C lighting-app \
out/efr32-brd4187c-light-rpc/matter-silabs-lighting-example.out \
efr32 BRD4187C lock-app \
out/efr32-brd4187c-lock-rpc/matter-silabs-lock-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
efr32 BRD4187C window-app \
out/efr32-brd4187c-window-covering-additional-data-advertising/matter-silabs-window-example.out \
/tmp/bloat_reports/
- name: Clean out build output
run: rm -rf ./out
- name: Build BRD4338A WiFi Soc variants
- name: Build some WiFi Soc variants
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--enable-flashbundle \
--target efr32-brd4338a-light-skip-rps-generation \
--target efr32-brd2605a-light-skip-rps-generation \
--target efr32-brd4338a-lock-skip-rps-generation \
build \
--copy-artifacts-to out/artifacts \
Expand All @@ -130,24 +117,6 @@ jobs:
/tmp/bloat_reports/
- name: Clean out build output
run: rm -rf ./out
- name: Build BRD2605A WiFi Soc variants
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--enable-flashbundle \
--target efr32-brd2605a-light-skip-rps-generation \
--target efr32-brd2605a-lock-skip-rps-generation \
build \
--copy-artifacts-to out/artifacts \
"
- name: Prepare bloat report for brd2605a lock app
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
efr32 BRD2605a lock-app \
out/efr32-brd2605a-lock-skip-rps-generation/matter-silabs-lock-example.out \
/tmp/bloat_reports/
- name: Clean out build output
run: rm -rf ./out
- name: Build EFR32 with WiFi NCP
run: |
./scripts/run_in_build_env.sh \
Expand Down
10 changes: 5 additions & 5 deletions docs/testing/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Python tests located in src/python_testing
section should include various parameters and their respective values,
which will guide the test runner on how to execute the tests.
- All test classes inherit from `MatterBaseTest` in
[matter_testing_support.py](https://github.com/project-chip/connectedhomeip/blob/master/src/python_testing/matter_testing_support.py)
[matter_testing.py](https://github.com/project-chip/connectedhomeip/blob/master/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py)
- Support for commissioning using the python controller
- Default controller (`self.default_controller`) of type `ChipDeviceCtrl`
- `MatterBaseTest` inherits from the Mobly BaseTestClass
Expand All @@ -38,7 +38,7 @@ Python tests located in src/python_testing
decorated with the @async_test_body decorator
- Use `ChipDeviceCtrl` to interact with the DUT
- Controller API is in `ChipDeviceCtrl.py` (see API doc in file)
- Some support methods in `matter_testing_support.py`
- Some support methods in `matter_testing.py`
- Use Mobly assertions for failing tests
- `self.step()` along with a `steps_*` method to mark test plan steps for cert
tests
Expand Down Expand Up @@ -379,7 +379,7 @@ pai = await dev_ctrl.SendCommand(nodeid, 0, Clusters.OperationalCredentials.Comm
## Mobly helpers

The test system is based on Mobly, and the
[matter_testing_support.py](https://github.com/project-chip/connectedhomeip/blob/master/src/python_testing/matter_testing_support.py)
[matter_testing.py](https://github.com/project-chip/connectedhomeip/blob/master/src/python_testing/matter_testing_infrastructure/chip/testing/matter_testing.py)
class provides some helpers for Mobly integration.

- `default_matter_test_main`
Expand Down Expand Up @@ -561,11 +561,11 @@ these steps to set this up:

## Other support utilities

- `basic_composition_support`
- `basic_composition`
- wildcard read, whole device analysis
- `CommissioningFlowBlocks`
- various commissioning support for core tests
- `spec_parsing_support`
- `spec_parsing`
- parsing data model XML into python readable format

# Running tests locally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class Converter():
def __init__(self, specifications):
self.__specs = specifications
self.__converters = [
DarwinAnyFormatConverter(),
StructFieldsNameConverter(),
FloatConverter(),
OctetStringConverter()
Expand Down Expand Up @@ -252,6 +253,43 @@ def maybe_convert(self, typename: str, value):
return value


class DarwinAnyFormatConverter(BaseConverter):
"""
Darwin payloads format for *ById commands is different from the base
format used for other commands.
"""

def run(self, specs, value, cluster_name: str, typename: str, array: bool):
if isinstance(value, list) and len(value) >= 1 and isinstance(value[0], dict) and value[0].get('data') is not None:
value = [self.__convert(item_value) for item_value in value]
return value

def __convert(self, value):
if not isinstance(value, dict):
return value

data = value.get('data')
if not isinstance(data, dict):
return value

value = data.get('value')
if not isinstance(value, list):
return value

value_type = data.get('type')

if value_type == 'Structure':
struct = {}
for field in value:
context_tag = field.get('contextTag')
struct[str(context_tag)] = self.__convert(field)
value = struct
elif value_type == 'Array':
value = [self.__convert(item_value) for item_value in value]

return value


class FloatConverter(BaseConverter):
"""
Jsoncpp stores floats as double.
Expand Down Expand Up @@ -348,7 +386,7 @@ def run(self, specs, value, cluster_name: str, typename: str, array: bool):
del value[key_name]

elif isinstance(value, list) and array:
value = [self.run(specs, v, cluster_name, typename, False)
value = [self.run(specs, v, cluster_name, typename, isinstance(v, list))
for v in value]

return value
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,16 @@ def __get_alias(self, cluster_name: str, command_name: str = None, argument_name
if aliases is None or aliases.get(argument_name) is None:
return None

return aliases.get(argument_name)
value = aliases.get(argument_name)

if cluster_name == '*' and self.__is_darwin_framework_tool:
if argument_name == 'AttributeId':
return 'attribute-id'
elif argument_name == 'ClusterId':
return 'cluster-id'
elif argument_name == 'Value':
return 'attribute-value'
return value

def _supports_endpoint(self, request):
return self._has_support(request, 'has_endpoint')
Expand Down
5 changes: 5 additions & 0 deletions examples/darwin-framework-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ executable("darwin-framework-tool") {
"commands/discover/Commands.h",
"commands/discover/DiscoverCommissionablesCommand.h",
"commands/discover/DiscoverCommissionablesCommand.mm",
"commands/memory/Commands.h",
"commands/memory/DumpMemoryGraphCommand.h",
"commands/memory/DumpMemoryGraphCommand.mm",
"commands/memory/LeaksTool.h",
"commands/memory/LeaksTool.mm",
"commands/pairing/Commands.h",
"commands/pairing/DeviceControllerDelegateBridge.mm",
"commands/pairing/GetCommissionerNodeIdCommand.h",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ class ClusterCommand : public ModelCommand {
uint16_t __block responsesNeeded = repeatCount;
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);

__auto_type * endpoint = @(endpointId);
__auto_type * cluster = @(clusterId);
__auto_type * command = @(commandId);
while (repeatCount--) {
[device invokeCommandWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]
clusterID:[NSNumber numberWithUnsignedInteger:clusterId]
commandID:[NSNumber numberWithUnsignedInteger:commandId]
[device invokeCommandWithEndpointID:endpoint
clusterID:cluster
commandID:command
commandFields:commandFields
timedInvokeTimeout:mTimedInteractionTimeoutMs.HasValue()
? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()]
Expand All @@ -88,6 +91,9 @@ class ClusterCommand : public ModelCommand {
if (error != nil) {
mError = error;
LogNSError("Error", error);
RemoteDataModelLogger::LogCommandErrorAsJSON(endpoint, cluster, command, error);
} else {
RemoteDataModelLogger::LogCommandAsJSON(endpoint, cluster, command, values);
}
if (responsesNeeded == 0) {
SetCommandExitStatus(mError);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,26 @@ class ReadAttribute : public ModelCommand {
if (mFabricFiltered.HasValue()) {
params.filterByFabric = mFabricFiltered.Value();
}

__auto_type * endpoint = @(endpointId);
__auto_type * cluster = @(mClusterId);
__auto_type * attribute = @(mAttributeId);
[device
readAttributesWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]
clusterID:[NSNumber numberWithUnsignedInteger:mClusterId]
attributeID:[NSNumber numberWithUnsignedInteger:mAttributeId]
readAttributesWithEndpointID:endpoint
clusterID:cluster
attributeID:attribute
params:params
queue:callbackQueue
completion:^(NSArray<NSDictionary<NSString *, id> *> * _Nullable values, NSError * _Nullable error) {
if (error != nil) {
LogNSError("Error reading attribute", error);
RemoteDataModelLogger::LogAttributeErrorAsJSON(endpoint, cluster, attribute, error);
}
if (values) {
for (id item in values) {
NSLog(@"Response Item: %@", [item description]);
}
RemoteDataModelLogger::LogAttributeAsJSON(endpoint, cluster, attribute, values);
}
SetCommandExitStatus(error);
}];
Expand Down Expand Up @@ -137,16 +143,23 @@ class SubscribeAttribute : public ModelCommand {
params.resubscribeAutomatically = mAutoResubscribe.Value();
}

[device subscribeToAttributesWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]
clusterID:[NSNumber numberWithUnsignedInteger:mClusterId]
attributeID:[NSNumber numberWithUnsignedInteger:mAttributeId]
__auto_type * endpoint = @(endpointId);
__auto_type * cluster = @(mClusterId);
__auto_type * attribute = @(mAttributeId);
[device subscribeToAttributesWithEndpointID:endpoint
clusterID:cluster
attributeID:attribute
params:params
queue:callbackQueue
reportHandler:^(NSArray<NSDictionary<NSString *, id> *> * _Nullable values, NSError * _Nullable error) {
if (error != nil) {
RemoteDataModelLogger::LogAttributeErrorAsJSON(endpoint, cluster, attribute, error);
}
if (values) {
for (id item in values) {
NSLog(@"Response Item: %@", [item description]);
}
RemoteDataModelLogger::LogAttributeAsJSON(endpoint, cluster, attribute, values);
}
SetCommandExitStatus(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ class WriteAttribute : public ModelCommand {
{
dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);

__auto_type * endpoint = @(endpointId);
__auto_type * cluster = @(mClusterId);
__auto_type * attribute = @(mAttributeId);
[device
writeAttributeWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId]
clusterID:[NSNumber numberWithUnsignedInteger:clusterId]
attributeID:[NSNumber numberWithUnsignedInteger:attributeId]
writeAttributeWithEndpointID:endpoint
clusterID:cluster
attributeID:attribute
value:value
timedWriteTimeout:mTimedInteractionTimeoutMs.HasValue()
? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()]
Expand All @@ -86,11 +89,13 @@ class WriteAttribute : public ModelCommand {
completion:^(NSArray<NSDictionary<NSString *, id> *> * _Nullable values, NSError * _Nullable error) {
if (error != nil) {
LogNSError("Error writing attribute", error);
RemoteDataModelLogger::LogAttributeErrorAsJSON(endpoint, cluster, attribute, error);
}
if (values) {
for (id item in values) {
NSLog(@"Response Item: %@", [item description]);
}
RemoteDataModelLogger::LogAttributeAsJSON(endpoint, cluster, attribute, values);
}
SetCommandExitStatus(error);
}];
Expand Down
45 changes: 27 additions & 18 deletions examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,40 @@

CHIP_ERROR CHIPCommandBridge::Run()
{
ChipLogProgress(chipTool, "Running Command");
ReturnErrorOnFailure(MaybeSetUpStack());
SetIdentity(mCommissionerName.HasValue() ? mCommissionerName.Value() : kIdentityAlpha);
// In interactive mode, we want to avoid memory accumulating in the main autorelease pool,
// so we clear it after each command.
@autoreleasepool {
ChipLogProgress(chipTool, "Running Command");
// Although the body of `Run` is within its own autorelease pool, this code block is further wrapped
// in an additional autorelease pool. This ensures that when the memory dump graph command is used directly,
// we can verify there’s no additional noise from the autorelease pools—a kind of sanity check.
@autoreleasepool {
ReturnErrorOnFailure(MaybeSetUpStack());
}
SetIdentity(mCommissionerName.HasValue() ? mCommissionerName.Value() : kIdentityAlpha);

{
std::lock_guard<std::mutex> lk(cvWaitingForResponseMutex);
mWaitingForResponse = YES;
}
{
std::lock_guard<std::mutex> lk(cvWaitingForResponseMutex);
mWaitingForResponse = YES;
}

ReturnLogErrorOnFailure(RunCommand());
ReturnLogErrorOnFailure(RunCommand());

auto err = StartWaiting(GetWaitDuration());
auto err = StartWaiting(GetWaitDuration());

bool deferCleanup = (IsInteractive() && DeferInteractiveCleanup());
bool deferCleanup = (IsInteractive() && DeferInteractiveCleanup());

Shutdown();
Shutdown();

if (deferCleanup) {
sDeferredCleanups.insert(this);
} else {
Cleanup();
}
MaybeTearDownStack();
if (deferCleanup) {
sDeferredCleanups.insert(this);
} else {
Cleanup();
}
MaybeTearDownStack();

return err;
return err;
}
}

CHIP_ERROR CHIPCommandBridge::GetPAACertsFromFolder(NSArray<NSData *> * __autoreleasing * paaCertsResult)
Expand Down
Loading

0 comments on commit dc46aa8

Please sign in to comment.