This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to know where to send an OnOff request?

I'm working on a switch device using nRF5 SDK for Thread and Zigbee version 4.1.0 on an nRF52840 on a PCA10056.

I can get my device to join a network, and can see that the coordinator discovers all clusters and endpoints, and that it binds to the OnOff cluster as expected. zb_zdo_find_bind_src() returns true as expected. The remaining question is how I can know from code which endpoint to send the request to, in the following snippet:

    zb_uint16_t addr = 0;
    ZB_ZCL_ON_OFF_SEND_REQ(bufid,
                           addr,
                           ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                           1,
                           LIGHT_SWITCH_ENDPOINT,
                           ZB_AF_HA_PROFILE_ID,
                           ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
                           cmd_id,
                           NULL);

In the light_switch example (which this is based on) the destination is found by having the light switch discover the bulb, and then save its address and endpoint, but I'm struggling a bit to see how such solution would scale. It seems more reasonable that binding happens from the coordinator, which presumably can give the user an overview over all devices in the network, and then allow binding the devices that makes sense. However, as far as I can see, for this to work, the switch device must then be able to read the local binding table to know which device it should send its messages to. How can I do this, or in what other way can I get the desired functionality?

Parents
  • Hi Ole,

    Sorry for the late reply. We have an example with ZCL groups you can take a look at under the examples/zigbee/experimental/light_control folder which I think can better give the functionality you want for scalability.

    Instead of sending the add group request from the light switch example you could send this request from the coordinator to the nodes you want to add to the same group.

    BR,

    Marjeris

  • I'm sorry, but I don't see how that answers the question. I've looked at that example, but as far as I can see, it only switches one problem for another: the group ID is hardcoded, so having multiple switches control different groups isn't immediately possible. One way to solve this would be to have way to configure the group used on a given switch from the coordinator, but I don't see any way to do so.

    An alternative way, and what I'd prefer to do, is to bind the switch to a group from the coordinator, for instance as described in zigbee2mqtt's documentation. But to get this working, I still need a way to know the correct destination, be it a group or a single device, to send the request to.

  • Hi Ole,

    I have checked, and you can bind the switch EP to a group address. You can try using the CLI command "bind on", and use the group address in the destination address.

    BR,

    Marjeris

  • I'm sorry, but this still doesn't answer my question. I know I can bind the switch to a group, but how do I know where to send the OnOff request?

    In other words, how can I from the switch's button event handler know to which group to send the OnOff request?

  • Any update? I'm unable to make my device work without a way to solve this, or alternatively a workaround. Another way to phrase the question is which destination address I should use for my requests when binding happens from the coordinator device, and not locally, neither based on groups nor single devices.

  • Hi Ole,

    Sorry for the late reply. I thought I already had cover this in my previous answers. If you have a network that includes a coordinator, a switch and several light bulbs, you can send from the coordinator and 'add_group' command to the light bulbs you want to assign the same group ID to, and then from the coordinator send a 'bind on' command to the switch with the group ID as the destination address. Does this answer your question?

  • Unfortunately, as far as I can see this still doesn't answer the question.

    Creating a group from my coordinator works fine (although I see no way to do so through the Nordic coordinator's CLI interface, but that doesn't matter as my end application won't use that), and binding a switch to the group is also fine.

    The missing piece is how to determine which address and endpoint to send the request to.

    As far as I can see, I receive no callback to my code when a bind happens, and I'm unable to see any way to locally read out the binding table (although I can do it from the coordinator, using 'zdo mgmt_bind'). I hence don't know what to use for addr and endpoint in the following snippet:

        zb_uint16_t addr = ?;
        zb_uint8_t endpoint = ?;
        ZB_ZCL_ON_OFF_SEND_REQ(bufid,
                               addr,
                               ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                               endpoint,
                               LIGHT_SWITCH_ENDPOINT,
                               ZB_AF_HA_PROFILE_ID,
                               ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
                               cmd_id,
                               NULL);

Reply
  • Unfortunately, as far as I can see this still doesn't answer the question.

    Creating a group from my coordinator works fine (although I see no way to do so through the Nordic coordinator's CLI interface, but that doesn't matter as my end application won't use that), and binding a switch to the group is also fine.

    The missing piece is how to determine which address and endpoint to send the request to.

    As far as I can see, I receive no callback to my code when a bind happens, and I'm unable to see any way to locally read out the binding table (although I can do it from the coordinator, using 'zdo mgmt_bind'). I hence don't know what to use for addr and endpoint in the following snippet:

        zb_uint16_t addr = ?;
        zb_uint8_t endpoint = ?;
        ZB_ZCL_ON_OFF_SEND_REQ(bufid,
                               addr,
                               ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                               endpoint,
                               LIGHT_SWITCH_ENDPOINT,
                               ZB_AF_HA_PROFILE_ID,
                               ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
                               cmd_id,
                               NULL);

Children
No Data
Related