-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add and Enable IM subscription support (#9510)
* [testsuite] Refactor test suite simulated cluster command * Add initial IM subscriber server change --Extend IM ReadHandler with subscribe capability, and update the corresponding reporting engine, which can process multiple subscriber, process subscribe request and generate subscribe response. --Hook setDirty API to ember so that ember can generate the change set and send it out via IM report. * Add initial IM subscription client change --Extends IM read client with subscribe capability and it can send subscribe request and process subscribe process and further maintain subscription with livess check. --Disable path filter for IM read/subscribe request. --Update templates to use interaction model APIs for sending subscribe requests. --Update DeviceControllerInteractionModelDelegate to handle report messages from subscription. --Update ChipCallback Mgr to bridge subscribe responses to existing callbacks, and handle TLV message just as read responses. --Update TestSuite for basic Subscription protocol tests, test routing looks like follows: Send subscribe request, wait for response. Wait for a few seconds, and execute "kick" commands. The test is expected to receive the same number of Reports as the number of kick commands. The test will fail when not receiving enough report data from server in global timeout. --Update python script test to (in cirque) include a similar test routine as test suite. --Add unit test for positive and negative subscribe test --Add integrated cirque test for subscribe * Update test cases, add darwin test * run codegen Co-authored-by: Song Guo <[email protected]>
- Loading branch information
1 parent
7c00fa2
commit ec5f5dc
Showing
78 changed files
with
3,460 additions
and
2,678 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
examples/chip-tool/templates/partials/process_response_value.zapt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{{#chip_tests_item_response_parameters}} | ||
{{#if hasExpectedValue}} | ||
{{#if isList}} | ||
if (count != {{expectedValue.length}}) | ||
{ | ||
ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "{{expectedValue}}"); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{else}} | ||
{{#if (isString type)}} | ||
{{chipType}} {{asLowerCamelCase name}}Argument = chip::ByteSpan(chip::Uint8::from_const_char("{{expectedValue}}"), strlen("{{expectedValue}}")); | ||
if (!{{asLowerCamelCase name}}.data_equal({{asLowerCamelCase name}}Argument)) | ||
{{else}} | ||
if ({{asLowerCamelCase name}} != {{expectedValue}}{{asTypeLiteralSuffix chipType}}) | ||
{{/if}} | ||
{ | ||
ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "{{expectedValue}}"); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{/if}} | ||
{{/if}} | ||
{{#if hasExpectedConstraints}} | ||
{{#if expectedConstraints.type}} | ||
ChipLogError(chipTool, "Warning: {{asLowerCamelCase name}} type checking is not implemented yet. Expected type: '%s'", "{{expectedConstraints.type}}"); | ||
{{/if}} | ||
|
||
{{#if expectedConstraints.format}} | ||
ChipLogError(chipTool, "Warning: {{asLowerCamelCase name}} format checking is not implemented yet. Expected format: '%s'", "{{expectedConstraints.format}}"); | ||
{{/if}} | ||
|
||
{{#if expectedConstraints.minLength}} | ||
if ({{asLowerCamelCase name}}.size() < {{expectedConstraints.minLength}}) | ||
{ | ||
ChipLogError(chipTool, "Error: {{asLowerCamelCase name}} is too short. Min size is {{expectedConstraints.minLength}} but got '%zu'", {{asLowerCamelCase name}}.size()); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{/if}} | ||
|
||
{{#if expectedConstraints.maxLength}} | ||
if ({{asLowerCamelCase name}}.size() > {{expectedConstraints.maxLength}}) | ||
{ | ||
ChipLogError(chipTool, "Error: {{asLowerCamelCase name}} is too long. Max size is {{expectedConstraints.maxLength}} but got '%zu'", {{asLowerCamelCase name}}.size()); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{/if}} | ||
|
||
{{#if expectedConstraints.minValue}} | ||
if ({{asLowerCamelCase name}} < {{expectedConstraints.minValue}}) | ||
{ | ||
ChipLogError(chipTool, "Error: {{asLowerCamelCase name}} is lower than expected. Min value is {{expectedConstraints.minValue}} but got '%d'", {{asLowerCamelCase name}}); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{/if}} | ||
|
||
{{#if expectedConstraints.maxValue}} | ||
if ({{asLowerCamelCase name}} > {{expectedConstraints.maxValue}}) | ||
{ | ||
ChipLogError(chipTool, "Error: {{asLowerCamelCase name}} is higher than expected. Max value is {{expectedConstraints.maxValue}} but got '%d'", {{asLowerCamelCase name}}); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{/if}} | ||
|
||
{{#if expectedConstraints.notValue}} | ||
if ({{asLowerCamelCase name}} == {{expectedConstraints.notValue}}) | ||
{ | ||
ChipLogError(chipTool, "Error: {{asLowerCamelCase name}} was not expected to be '{{expectedConstraints.notValue}}' due to notValue constraint"); | ||
runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); | ||
return; | ||
} | ||
{{/if}} | ||
{{/if}} | ||
{{/chip_tests_item_response_parameters}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
examples/chip-tool/templates/partials/testsuite/WaitForAttributeReport.zapt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// The callback should be called atleast once | ||
{{#chip_tests_WaitForAttributeReport_attribute_info}} | ||
using OnReportCallback_{{parent.index}} = void (*)(void * context{{#chip_tests_item_response_parameters}}, {{#if isList}}uint16_t count, {{/if}}{{chipType}} {{#if isList}}* {{/if}}{{asLowerCamelCase name}}{{/chip_tests_item_response_parameters}}); | ||
chip::Callback::Callback<OnReportCallback_{{ parent.index }}> mOnReportCallback_{{parent.index}} { SubscribeAttribute_{{ parent.index }}_OnReportCallback, this }; | ||
{{/chip_tests_WaitForAttributeReport_attribute_info}} | ||
|
||
bool mReceivedReport_{{index}} = false; | ||
|
||
CHIP_ERROR TestSendCluster{{asUpperCamelCase cluster}}Command{{asUpperCamelCase command}}_{{index}}() | ||
{ | ||
ChipLogProgress(chipTool, "{{cluster}} - {{asUpperCamelCase command}} - {{label}}"); | ||
{{#chip_tests_WaitForAttributeReport_attribute_info}} | ||
chip::Controller::{{asUpperCamelCase cluster}}Cluster cluster; | ||
cluster.Associate(mDevice, {{endpoint}}); | ||
return cluster.ReportAttribute{{asUpperCamelCase attribute}}(mOnReportCallback_{{parent.index}}.Cancel()); | ||
{{/chip_tests_WaitForAttributeReport_attribute_info}} | ||
} | ||
|
||
{{#chip_tests_WaitForAttributeReport_attribute_info}} | ||
static void SubscribeAttribute_{{ parent.index }}_OnReportCallback(void * context{{#chip_tests_item_response_parameters}}, {{#if isList}}uint16_t count, {{/if}}{{chipType}} {{#if isList}}* {{/if}}{{asLowerCamelCase name}}{{/chip_tests_item_response_parameters}}) | ||
{ | ||
ChipLogProgress(chipTool, "On/Off - Subscribe {{asUpperCamelCase attribute}} Attribute: Report Data"); | ||
{{parent.parent.filename}} * runner = reinterpret_cast<{{parent.parent.filename}} *>(context); | ||
|
||
if (runner->mReceivedReport_{{parent.index}}) | ||
{ | ||
// Receiving attribute more than once is not an issue, since the following handler will override previous handlers. | ||
return; | ||
} | ||
|
||
{{> process_response_value}} | ||
|
||
runner->mReceivedReport_{{parent.index}} = true; | ||
ChipLogProgress(chipTool, "On/Off - report received."); | ||
runner->NextTest(); | ||
} | ||
|
||
{{/chip_tests_WaitForAttributeReport_attribute_info}} |
6 changes: 6 additions & 0 deletions
6
examples/chip-tool/templates/partials/testsuite/WaitForMs.zapt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CHIP_ERROR TestSendCluster{{asUpperCamelCase cluster}}Command{{asUpperCamelCase command}}_{{index}}() | ||
{ | ||
ChipLogProgress(chipTool, "{{cluster}} - {{asUpperCamelCase command}} - {{label}}"); | ||
|
||
return {{command}}({{#chip_tests_item_parameters}}{{#not_first}}, {{/not_first}}{{definedValue}}{{/chip_tests_item_parameters}}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.