Skip to content

Commit

Permalink
[EFR32][Groups] Add group commands support to light-switch example (#…
Browse files Browse the repository at this point in the history
…15727)

* Refactor commands structure for light-switch

* Add group command support to light-switch

* generated files

* PR review comments

* read me update

* regen

* fix mispelled work
  • Loading branch information
mkardous-silabs authored Mar 7, 2022
1 parent dde4a8f commit d2f5008
Show file tree
Hide file tree
Showing 17 changed files with 1,007 additions and 128 deletions.
16 changes: 16 additions & 0 deletions .github/.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1373,3 +1373,19 @@ zephyrproject
Zigbee
zigbeealliance
zigbeethread
libshell
TestGroupDemoConfig
ACLs
AddNOC
CHIPConfig
CHIPProjectAppConfig
CaseAdminNode
DataVersion
ProxyView
ReadAttribute
WriteAttribute
kAdminister
kManage
kOperate
kView
xFFFFFFFD
34 changes: 28 additions & 6 deletions examples/light-switch-app/efr32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,21 @@ combination with JLinkRTTClient as follows:

**Matter shell**

- 'switch on' : Sends On command to bound device
**_OnOff Cluster_**

- 'switch off' : Sends Off command to bound device
- 'switch onoff on' : Sends unicast On command to bound device
- 'switch onoff off' : Sends unicast Off command to bound device
- 'switch onoff toggle' : Sends unicast Toggle command to bound device

- 'switch toggle : Sends Toggle command to bound device
- 'switch groups onoff on' : Sends On group command to bound group
- 'switch groups onoff off' : Sends On group command to bound group
- 'switch groups onoff toggle' : Sends On group command to bound group

* You can provision and control the Chip device using the python controller,
Chip tool standalone, Android or iOS app

[CHIPTool](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md)
standalone, Android or iOS app

Here is an example with the CHIPTool:
Here is an example with the CHIPTool for unicast commands only:

```
chip-tool pairing ble-thread 1 hex:<operationalDataset> 20202021 3840
Expand All @@ -280,6 +283,25 @@ combination with JLinkRTTClient as follows:
chip-tool binding write binding '[{"fabricIndex": 1, "node": <lighting-node-id>, "endpoint": 1, "cluster":6}]' 1 1
```
Here is an example with the CHIPTool for groups commands only:
```
chip-tool pairing ble-thread 1 hex:<operationalDataset> 20202021 3840
chip-tool tests TestGroupDemoConfig --nodeId 1
chip-tool tests TestGroupDemoConfig --nodeId <lighting-node-id>
chip-tool binding write binding '[{"fabricIndex": 1, "group": 257}]' 1 1
```
To run the example with unicast and groups commands, run the group
configuration commands and replace the last one with binding this command
```
chip-tool binding write binding '[{"fabricIndex": 1, "group": 257},{"fabricIndex": 1, "node": <lighting-node-id>, "endpoint": 1, "cluster":6} ]' 1 1
```
### Notes
- Depending on your network settings your router might not provide native ipv6
Expand Down
6 changes: 3 additions & 3 deletions examples/light-switch-app/efr32/include/binding-handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
#include "lib/core/CHIPError.h"

CHIP_ERROR InitBindingHandler();
void SwitchToggleOnOff(intptr_t context);
void SwitchOnOffOn(intptr_t context);
void SwitchOnOffOff(intptr_t context);
void SwitchWorkerFunction(intptr_t context);

struct BindingCommandData
{
chip::EndpointId localEndpointId = 1;
chip::CommandId commandId;
chip::ClusterId clusterId;
bool isGroup = false;
};
6 changes: 5 additions & 1 deletion examples/light-switch-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@ void AppTask::SwitchActionEventHandler(AppEvent * aEvent)
{
if (aEvent->Type == AppEvent::kEventType_Button)
{
chip::DeviceLayer::PlatformMgr().ScheduleWork(SwitchToggleOnOff, 0);
BindingCommandData * data = Platform::New<BindingCommandData>();
data->commandId = chip::app::Clusters::OnOff::Commands::Toggle::Id;
data->clusterId = chip::app::Clusters::OnOff::Id;

DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast<intptr_t>(data));
}
}

Expand Down
Loading

0 comments on commit d2f5008

Please sign in to comment.