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

Zigbee Coordinator (Client) - IAS Zone Implementation

SDK: nRF5_SDK_for_Thread_and_Zigbee_v4.1.0
Hardware: 2x nRF52840 (PCA10059) + 1x generic overflow sensor.

This is an attempt to gather complete information regarding IAS Zone enrollment process implementation using ZBOSS Stack.

  • The primary reference, as mentioned in previous post is Official Zigbee ZCL specification (chapter 8.2).
  • Another interesting reference worth mentioning is HA API -> HA Devices -> IAS Zone sample, however, it is more related to IAS Zone server and incompatible with current SDK version.
  • Another bit of information could be found in this post. It is based on relevant SDK version, but again, it is related to IAS Zone server and incomplete.

That's all I have found for now. The rest, like IAS Zone cluster API is just pile of declarations wrapped into html, which does not help at all.

Let's consider one mandatory enrollment method: 'Trip-to-Pair'.

Below is the guiding algorithm from ZCL specification, as I understood it:
(1) Perform service discovery.
I assume, this could be achieved by a CLI command, or related function call
TX < zdo simple_desc_req 0x9CC5 1
RX > src_addr=0x9CC5 ep=1 profile_id=0x0104 app_dev_id=0x402 app_dev_ver=0x1 in_clusters=0x0000,0x000A,0x0500,0x0001 out_clusters=0x0019
It is relatively easy to find how to use function zb_zdo_simple_desc_req() called from zigbee_cli_cmd_zdo.c
Ok, now we see that sensor has 0x0500 (IAS Zone cluster), so the rest makes sense.
(2) Send a Write Attribute command on the IAS Zone server’s IAS_CIE_Address attribute (0x0010) with its IEEE address.
TX < zcl attr write 0x9CC5 1 0x0500 0x0104 0x0010 0xF0 0xF4CE36089BA25E4A
RX > Done
 
NOTE1: According to Wireshark, we received even more than expected:
0x0000 > 0xf230 | ZCL: Write Attributes, Seq: 4, Cmd: Write Attributes (0x02)
0xf230 > 0x0000 | ZCL: Write Attributes Response, Seq: 4, Cmd: Write Attributes Response (0x04), Status: Success (0x00)
...
0xf230 > 0x0000 | ZCL IAS Zone: Zone Status Change Notification, Seq: 81, Cmd: Zone Status Change Notification (0x00), Extended Status: 0x00
0x0000 > 0xf230 | ZCL: Default Response, Seq: 81, Cmd: Default Response (0x0b), Status: Unsupported Cluster (0xc3)
...
0xf230 > 0x0000 | ZCL IAS Zone: Zone Enroll Request, Seq: 82, Cmd: Zone Enroll Request (0x01), ZoneType: Water sensor (0x002a)
0x0000 > 0xf230 | ZCL: Default Response, Seq: 82, Cmd: Default Response (0x0b), Status: Unsupported Cluster (0xc3)
NOTE2: reading/writing attributes is already quite tricky and not trivial to figure out how to use directly without CLI. Still not sure how, when and where to call it.
(3) Receive confirmation from 'IAS Zone server' (sensor) (?) and start waiting for a 'Zone Status Change Notification' with ZoneState attribute equal to 0x00.
Again, accoring to Wireshark the system did receive this packet, and even responded, but neither debug log, nor CLI interface reflected that.
(4) Upon receipt of the above specified packet, send a 'Zone Enroll Response' command which assigns the IAS Zone server’s ZoneID attribute.
I assume this is where we should respond with the following
TX < zcl cmd 0xF230 1 0x0500 -p 0x0104 0x00 -l 0x0001
RX > Done
NOTE1: Wireshark log:
0x0000 > 0xf230 | ZCL IAS Zone: Zone Enroll Response, Seq: 9, Cmd: Zone Enroll Resp(0x00), Enroll resp code: Success (0x00), Zone ID: 0x01
0xf230 > 0x0000 | APS: Ack, Dst Endpt: 1, Src Endpt: 1
NOTE2: Again, how to use it without CLI???
(5) Receive(?) confirmation from IAS Zone server (sensor).
I guess, this might be either 'APS: Ack' mentioned above, or we might have to read related attribute manually
TX < zcl attr read 0xF230 1 0x0500 0x0104 0x0000
RX > ID: 0x0000 Type: 0x30 Value: 1
The next step isn't mentioned, but I think it might be necessary to conduct at this stage in order to recevie (parse?) incoming async reports.
(?)  Bind. This might be achieved by the following command of related function call
TX < zdo bind on 0x5C0272FFFEB9F593 1 0xF4CE36089BA25E4A1 0x0500 0x9CC5
RX > Done

However, the fist problem, is that Responces to 'IAS Zone Report' and 'IAS Zone Enrollment Request' are 'unsupported cluster', so obvously someting else has to be done on the ZC side to instruct ZBOSS stack to to handle 'IAS Zone'-related packets. And the second problem is that system does receive 'Zone Status Change' reports, but never reflects that in log or CLI.

Note that above communication resulted in after calling zb_zcl_ias_zone_init_client(), after calling zboss_start_no_autostart().

I find references to non-existent files/foldes with essential information, like "The complete set of IAS Zone samples can be found in /application/ias_zone_sensor" in the "documentation" at infocenter.nordicsemi.com and in source files/header and wonder why is it removed/hidden? It is among necessary algorithms, required by multiple types of standard sensors, yet unavailable wouthout any options.

Finally, the general question is: how do you (Nordic Developers) expect us (users / 3d party developers) to figure out the sequence of variable decalarations, function calls and callbacks registrations without detaild documentation and examples? Trial-Error? I'm afraid reading headers with minimal comments like "This functions is for that." does not really help, since we still don't undestand what are the prerequisites for that function, what are the inputs/outputs, limitations, etc.

Most probably, I am missing something, but I have already spent significant amount of time digging though all available sources of information, so I would really appreciate if you could direct me.

Regards,
- Nikita
Parents
  • Hi,

    To start with the first problem, if you see the Wireshark messages you are receiving after writing to the IAS_CIE_address attribute of the IAS zone server:

    0xf230 > 0x0000 | ZCL IAS Zone: Zone Status Change Notification, Seq: 81, Cmd: Zone Status Change Notification (0x00), Extended Status: 0x00
    0x0000 > 0xf230 | ZCL: Default Response, Seq: 81, Cmd: Default Response (0x0b), Status: Unsupported Cluster (0xc3)
    ...
    0xf230 > 0x0000 | ZCL IAS Zone: Zone Enroll Request, Seq: 82, Cmd: Zone Enroll Request (0x01), ZoneType: Water sensor (0x002a)
    0x0000 > 0xf230 | ZCL: Default Response, Seq: 82, Cmd: Default Response (0x0b), Status: Unsupported Cluster (0xc3)

    You see the coordinator (CLI example) responds with 'Unsupported Cluster' to the IAS zone server commands 'Zone Status Change Notification' and 'Zone Enroll Request'. I think as for all other ZCL clusters the first think you need to do is to declared the IAS zone client cluster on the coordinator side as an output cluster (see figure 8-1 in the ZCL specification 'Typical Use of the IAS clusters', server IAS zone needs to be paired with a client IAS zone, as normal cluster behaviour in Zigbee, for example light switch - light bulb example shows an example of server-client interaction). If you send a match desc request to the CLI coordinator example you will see that the only output clusters declared on endpoint 64 are 0x0000 (basic), 0x0003(identify) and 0x0004(groups), so IAS zone client need to be added here.

    And the second problem is that system does receive 'Zone Status Change' reports, but never reflects that in log or CLI

    Just so you are aware of it, the CLI example doesn't magically print logs from attribute reporting either. If you see in the Multisensor example you need to enable displaying the reports in CLI, using the command 'log enable info zigbee.report' to print the reports. You can see how printing of attribute logs on CLI example is handled in nrf_log_frontend.c and zigbee_cli_cmd_attr_report.c.

    But back to your question, the 'Zone Status Change Notification' is actually a ZCL command generated by the IAS zone server, so it's not the same as configuring attribute reports either. I think you should treat these notifications like a normal ZCL command, for example see how the ON/OFF command is handled by the light bulb example, which intercept the command in the ZCL device callback function to power the LED light ON or OFF, see the light_bulb example zcl_device_cb() callback function. But before intercepting the command on the code it's better to be sure that the coordinator is acknowledging these commands sucessfully (since right now the coordinator is just responding with 'Unsupported Cluster') using Wireshark.

    I find references to non-existent files/foldes with essential information, like "The complete set of IAS Zone samples can be found in /application/ias_zone_sensor" in the "documentation" at infocenter.nordicsemi.com and in source files/header and wonder why is it removed/hidden?

    This is sadly a known and reported bug in the documentation. The release of the Zigbee stack from DSR to Nordic may have contained a IAS zone server example long time ago, and the comments from the documentation have slipped into our API docs. There is an internal ticket to see if this line in the documentation should be remove or modified. There is currently no IAS zone sensor example available on our nRF5 SDK for Zigbee & Thread.

    Finally, the general question is: how do you (Nordic Developers) expect us (users / 3d party developers) to figure out the sequence of variable decalarations, function calls and callbacks registrations without detaild documentation and examples? Trial-Error? I'm afraid reading headers with minimal comments like "This functions is for that." does not really help, since we still don't undestand what are the prerequisites for that function, what are the inputs/outputs, limitations, etc.

    I will forward this feedback to our developers. For declaring attributes, clusters, cluster list and endpoints I think the more detailed documentation we have at the moment is this section from our Zigbee API stack overview at the infocenter: 'Implementing a Zigbee end product with ZCL'. This section of the documentation have been getting bigger and better for each release but we may have parts that should be better covered/explained. Reading the ZCL specification is also obligatory for implementing other Zigbee clusters than the ones available in our examples.

    Best regards,

    Marjeris

  • Hi Marjeris,

    Thank you for detailed explanation. I believe that should help with implementation, I will post my results.

    The release of the Zigbee stack from DSR to Nordic may have contained a IAS zone server example long time ago, and the comments from the documentation have slipped into our API docs.

    Ah, I see. DSR might have not provided the examples in the first place and/or source code of those examples became completely obsolete as SDK evolves and there was not enough resources to keep those up to date, so it was removed to avoid confusion. That's totally understandable. However, if those example do exist (and if not, how about requesting those from DSR?), and taking into consideration that documentation is not finished and needs quite a bit of work to be done at this point, I think it is still worth posting a link even to heavily obsolete and non-functional example code (with related disclaimer, of course), since reading through it still help restore / understand the logic of declarations and function calls.

    For example, it is sill not clear where+when to call zb_zcl_ias_zone_init_client() and if it is necessary to call it at all, I just found it accidentally, while reading the header file. Is it enough to call it once in the main() function? Does it has to be called before or after zboss_start() or zboss_start_no_autostart() or any other function, or it doesn't matter, or, maybe, it should be called inside zboss_signal_handler(), similar to bdb_start_top_level_commissioning(), and if so, at which signal, at which status of that signal? These are the essential answers that developer needs to know for each function in order to use it properly. And it gets much, much worse when a function has arguments.So far, my absolute favorites are zboss_signal_handler(zb_bufid_t bufid) and zcl_device_cb(zb_bufid_t bufid), where bufid just gets re-casted to multiple different structure types through zb_buf_get_tail_func(), but there is almost no error detection/handling implemented explicitly, while pointer cast is one of the most dangerous operations in C/C++.

    Another example is zboss_start(). I actually do like how it is documented, brief exaplanation has everything necessary to work with this function: it states what it does, what are the prerequsites and consiquences of calling that function and even briefly mentioned the next step (i.e. calling zboss_main_loop()). Unfortunately, documentation makes impression that there is no alternative except polling zboss_main_loop()at max speed, draining the power source, even if nothig is happening, but that is a minor issue.

    Fortunately, most of the time examples do allow us to extract all the necessary answers, but when there is no example, no details in documentation and no source code of the function, this is just impossible, so I hope you understand my frustration. And I hope my feedback will help Nordic Developers improve SDK documentation and examples in the future.

    Best regards,

    Nikita

  • Hi again,

    Regarding zb_zcl_ias_zone_init_client(), this function should not be called by the application. Try instead of getting started with the cluster implementation like in other Zigbee applications. Perhaps it's easier to start out with the light coordinator cluster, as it is a much strip down example with basic coordinator functionality and then add the IAS zone client cluster to it.

    Nik said:
    I think it is still worth posting a link even to heavily obsolete and non-functional example code (with related disclaimer, of course), since reading through it still help restore / understand the logic of declarations and function calls.

    I am afraid those examples are obsolete, as said there is an internal ticket for reviewing this part of the documentation and I think the references to these examples will ended being removed from the documentation. Also just so you are aware of it it's not possible for us to disclose ZBOSS source code as our licence with DSR does not allow us too share any source code.

    Regarding you feedback about zboss_main_loop() current comsumption, have you seen our Sleepy End Device samples?

    Did you have any other questions to help you get started with the IAS zone client on coordinator side?

    Best regards,

    Marjeris

Reply
  • Hi again,

    Regarding zb_zcl_ias_zone_init_client(), this function should not be called by the application. Try instead of getting started with the cluster implementation like in other Zigbee applications. Perhaps it's easier to start out with the light coordinator cluster, as it is a much strip down example with basic coordinator functionality and then add the IAS zone client cluster to it.

    Nik said:
    I think it is still worth posting a link even to heavily obsolete and non-functional example code (with related disclaimer, of course), since reading through it still help restore / understand the logic of declarations and function calls.

    I am afraid those examples are obsolete, as said there is an internal ticket for reviewing this part of the documentation and I think the references to these examples will ended being removed from the documentation. Also just so you are aware of it it's not possible for us to disclose ZBOSS source code as our licence with DSR does not allow us too share any source code.

    Regarding you feedback about zboss_main_loop() current comsumption, have you seen our Sleepy End Device samples?

    Did you have any other questions to help you get started with the IAS zone client on coordinator side?

    Best regards,

    Marjeris

Children
No Data
Related