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
  • Hi Marjeris,

    Thank you for clarification.

    I am not sure if the stack will handle the 'Zone Enroll Request' command or not

    Currently, default response to 'Zone Enroll Requests' is 'Unsopported Command' (when IAS Zone cluster is declared), so yes, it has to be intercepted and handled by the APP layer and answered with either 'Success' + Enrolled ZoneID of 'Fail'. Just wanted to clarify that scheduling response packets right from the callback is the right thing and I don't have to create and manage signals for external thread for that.

    I look forward to hearing from you about possibility of larger Zigbee networks (especially when TC is not on NRF52840) and expected 'IAS ACE Zone Table' size. Also, can application layer store information (like that zone table) inside persistent config sector? Or should it allocate another, different sector in flash memory for that?

    Regards,

    Nikita

  • Hi,

    I am sorry for the late reply. Answer from one of our Zigbee developers:

    "Yes, the Zone Enroll Request needs to be handled by the application (in the endpoint handler), I don't see it being handled in the stack. This is also confirmed by DSR.

    Since this is nRF5 SDK, response packets can be scheduled from the callback. To send packet, first obtain the buffer to put packet into and then schedule it to be sent.
    Macro ZB_ZCL_IAS_ZONE_SEND_ZONE_ENROLL_RES can be used to send a response.

    As for the IAS ACE Zone Table, see zb_zcl_ias_ace_zone_table_t in the zb_zcl_ias_ace.h.

    Declare array of zb_zcl_ias_ace_zone_table_t as variable and additional variable (zb_uint16_t) to store the size of the IAS ACE table. When declaring IAS ACE attribute list using ZB_ZCL_DECLARE_IAS_ACE_ATTRIB_LIST macro, you will pass pointers to both IAS ACE zone table and variable with table size to the macro. When it comes to size of the IAS ACE zone table, maximum size is 255 - each zone has its ID stored in uint8, hence the limit.

    I am not yet sure about storing this table at non-volatile memory. Need to check if the stack stores it or not."

    BR,

    Marjeris

  • Hi,

    When it comes to storing the IAS ACE zone table, the stack doesn't store it in non-volatile memory - it has to be implemented in the application. This can be either implemented using Flash Data Storage (FDS) an used in the Zigbee Door Lock example or using ZBOSS's NVRAM and stored as APP_DATA.

  • Thank you Marjeris.

    I was hoping to get a little more information regarding the max network size, and expected (recommended) size of the IAS ACE Zone Table, but oh well... I assume that's all we can get.

    I think we can close this thread now, since primary objective was achieved - I gathered all necessary information and was able to implement IAS Zone Enrollment + reception and processing of async state change reports, and it seems to be stable for now.

    Best reagards,

    Nikita

Related