[ZIGBEE] switch key procedure

SDK: 4.1.0

CHIP: 52840

old question

my sleepy zed lost connection to the coordinator after refreshing key of the coordinator.

1) how can I manipulate refresh key of the coordinator?

2) how can I callback to receive broadcast packet?

3) Is there rejoin request function without security? the coordinator manufacturer says that the plain request of rejoin must be procedured after switching key.

4) how can I callback to receive APS packet?

the zed received "switch key packet" but doesn't procedure anything.


  • Hi,

    I'm not sure what you mean by manipulate refresh key, but for network key switching you can use the function zb_secur_setup_nwk_key(), which can be used to force the network key switch procedure. I would recommend taking a look at the documentation for security in the Zigbee SDK, where you can find more information about the Zigbee network security API.

    You can use the function zb_bdb_set_legacy_device_support(1) to disable the trust center require key exchange.

    As for your questions about callback, you can take a look at the information about it in the page about programming principles in Zigbee. Also, it depends on what the callback is for. For ZCL commands, you can take a look at the function zcl_device_cb, which you will find in several of the Zigbee examples in the SDK, and you can also find several examples of different callbacks in CLI, specifically in the file zigbee_cli_cmd_zdo.c.

    Best regards,


  • Hi, thanks for the reply.

    The switch key doesn't have any key value.

    1) What key pass to the function zb_secur_setup_nwk_key()

    The callback I mentioned is about receiving packet handler.

    2) How can I register callback which handles APS layer packet? I currently handles ZCL packets by the code.


    I wants to watch receiving APS ack. The switch key/transport key also are in APS layer.

    3) Why switch key mechanism doesn't work?

    it is zigbee version problem?Is it up to zigbee developer?



    I used "zb_af_set_data_indication" function which callback when receiving packet is aps data frame type.

    but, I want to callback irrespective of frame type.

    5) Is there packet decryption failed signal?

  • I found the solutions about few my questions.

    2) How can I register callback which handles APS layer packet? I currently handles ZCL packets by the code.

    static bool zcl_check_send_result(zb_uint8_t param)
        zb_zcl_command_send_status_t * p_cmd_status;
        if (param == 0)
            return false;
        uint8_t buf_len = zb_buf_len(param);
        p_cmd_status = ZB_BUF_GET_PARAM(param, zb_zcl_command_send_status_t);
        DEBUG_DATAL("ias_zone_result_cb data", zb_buf_begin(param), buf_len);
        DEBUG_PRINTF("Frame acknowledged. Status: %d\n", p_cmd_status->status);
        if (p_cmd_status->status != RET_OK)
            /* No APS-ACK received. */
            DEBUG_PRINTF("No APS-ACK received.\n");
            return false;
        return true;

    I found the code in benchmark source in sdk.

    I summarizes my questions again.


    Why switch key mechanism doesn't work?

    it is zigbee version problem? Is it up to zigbee developer?


    I wants to send zigbee network layer packet like below picture. Which function should I use?


    How can I get network time? Is there the synchronization of time in zigbee stack?

  • Hi,

    I'm sorry for the late response, I've been discussing this case with my colleague responsible for your other case. Since you asked the same questions in that case and they've been answered there, I'll consider this solved. In the future, please refrain from creating several cases with the same questions. Keeping it in one case makes it easier for other users of the forum to find relevant cases if they're experiencing similar issues. In addition, if there are duplicate cases it might lead to the questions being solved in one case without the knowledge of the person working on the other case, which might affect response time. If you however get a problem or have a question unrelated to the original case, please don't hesitate to open a new case.

    Best regards,


  • Hi, sorry about that. I won’t open it for same case. But, The deadline is very imminent. Could you help about this issue?