[Documentation] chip-tool - Subscribe interaction
Documentation issues
-
chip-tool documentation on github needs some update regarding
temperaturemeasurementcluster. from version 1.0 it has commands:
sigis:src$ chip-tool temperaturemeasurement
[1666782438.446900][4190997:4190997] CHIP:TOO: Missing command name
Usage:
chip-tool temperaturemeasurement command_name [param1 param2 ...]
+-------------------------------------------------------------------------------------+
| Commands: |
+-------------------------------------------------------------------------------------+
| * command-by-id |
| * read-by-id |
| * read |
| * write-by-id |
| * subscribe-by-id |
| * subscribe |
| * read-event-by-id |
| * subscribe-event-by-id |
+-------------------------------------------------------------------------------------+
- It needs clarification for
subscribecommand fortemperaturemeasurementcluster, i.e
chip-tool temperaturemeasurement subscribe measured-value <min-interval> <max-interval> <destination-id> <endpoint-ids>
- It needs clarification for
subscribecommand forbindingcluster, i.e.
chip-tool binding subscribe binding <min-interval> <max-interval> <destination-id> <endpoint-ids>
According Matter specification: "8.5 Subscribe Interaction" subscriber creates a subscription with a publisher If this interaction are between two nodes, then it is not clear from (2) and (3) where these two nodes are provided as parameters.
My initial guess is that this relationship is provided in binding table, by executing:
chip-tool binding write binding '[{"fabricIndex": 1, "node": <id-of-subscriber>, "endpoint": 1, "cluster": 1026}]' <id-of-publisher> 1
Can you correct me?
Platform
No response
Anything else?
No response
Just to make sure I understand what you are trying to archive, are you trying to subscribe from chip-tool to measured-value on a device that has temperaturemeasurement implemented? In that case I would argue that you are not required to setup a binding, since chip-tool already knows the nodeID of the device?
Binding would be used for informing one device (which does not have any knowledge of an other devices on the network) ex. a switch where it can find another device, ex. a light.
One thing is is setup the binding, but also keep in mind that ACL also needs to be configured to allow for communication between the two devices. Again, in this case, if you want to setup the subscription from chip-tool, then it should already have an ACL entry to allow this.
Hi @ReneJosefsen,
I have node that implements temperaturemeasurement server cluster and Linux node/application that is interested in displaying those measurements. Linux node should receive those temperature measurements at regular intervals, i.e. every 10 sec. It is not an option to use chip-tool to pull those measurements, i.e:
chip-tool temperaturemeasurement read measured-value 52 1
then parse response and send those values to Linux matter application, which will display that value.
I guess subscription should help for direct communication: node to node. In principal I can have more than one node with temperaturemesurement server cluster and more then one node for displaying those measurements. So I need example how to create relationship between concrete nodes (subscriber and publisher)
ACL is another issue.
BTW more detailed question regarding subscription on devzone
Great, then binding is indeed needed to let the Linux node/application know which temperaturemeasurement node to set up its subscription to.
So in your specific example you add the Linux node id to the temperaturemeasurement node's ACL with the appropriate rights and then you setup the binding on the Linux node by adding the temperaturemeasurement node's id to the binding table. You will need to have some logic on the Linux node to then setup the subscription to the temperaturemeasurement node when it gets the binding.
You can not, at the moment, setup a subscription on the Linux node from your chip-tool. Meaning that when you do chip-tool subscribe command it creates a subscription between your chip-tool and the temperaturemeasurement node which does not sound like what you are trying to do. Also, if you want to test subscriptions with chip-tool, you have to run it in interactive mode.
Just as a note to clarify, you properly do not want to do a subscription to the binding attribute on the binding cluster, what you want is most likely to subscribe to measured-value on the temperaturemeasurement cluster using chip-tool temperaturemeasurement subscribe measured-value <min-interval> <max-interval> <destination-id> <endpoint-ids>, but again this does not help you get the subscription on the Linux node.
The light-switch examples might be a good resource: https://github.com/project-chip/connectedhomeip/tree/master/examples/light-switch-app
Thanks @ReneJosefsen,
I've implemented functionality of light-switch on my nrf52840dk development board and I have used chip-tool for binding, i.e in my case:
chip-tool binding write binding '[{"fabricIndex": 1, "node": 32, "endpoint": 1, "cluster": 6}]' 52 1
where 6 is OnOff cluster, 32 - linux matter app, 52 - nrf52840dk lighting-app with temperaturemeasurement and OnOff clusters. After binding and enabling ACL, I can press switch button - I get immediate response (On Off) on Linux app. So far so good.
But...
OnOff cluster has Commands like On, Off, Toggle, and all logic is based on those commands in BindingHandler class
Controller::InvokeCommandRequest(....)
Temperaturemeasurement cluster do not provide any commands, so I can not use Controller::InvokeCommandRequest, so maybe such binding approach do not work.
Problem description became too technical... :-) Can you provide link to forum, where I can ask specific technical questions regarding Matter?
InvokeCommandRequest is as you have noticed, used to invoke a command. There are similar commands to read/write or subscribe to attributes. Have a look at Controller::SubscribeAttribute and/or Controller::ReadAttribute.
I do not think there is a public "forum" for topics/discussions like this unfortunately.
Hi @ReneJosefsen ,
bwt, I was able to build Linux Matter application and use Controller::ReadAttribute for fetching temperature measurements. Right now I have hardcoded peer node ID (with server temperaturemeasurement cluster), but in principal it should be provided at runtime, let say by chip-tool. Does binding table will fit best for this purpose?
chip-tool binding write binding '[{"fabricIndex": 1, "node": 52, "endpoint": 1, "cluster": 1026}]' 32 1
where 52 is a peer node ID, 32 Linux matter application
Sorry for not getting back, it got lost I my mail box. But yes that looks about right. 👍🏻