Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change network key of all end devices of a network? (TZ-1026) #390

Closed
Alfff opened this issue Jul 26, 2024 · 7 comments
Closed

How to change network key of all end devices of a network? (TZ-1026) #390

Alfff opened this issue Jul 26, 2024 · 7 comments
Labels

Comments

@Alfff
Copy link

Alfff commented Jul 26, 2024

Question

I am developing a system which requires my device, acting as a coordinator, to periodically rotate the network key. How can I achieve this with the ESP32H2?

Specifically, I am looking for the equivalents of the following two functions:

I have tried using esp_zb_secur_network_key_set, but it seems to only change the key locally and does not broadcast the change order to the end devices, because the end devices stop responding after the change.

I would appreciate any guidance or examples on how to effectively rotate the network key on the ESP32H2.

Thank you in advance.

Additional context.

No response

@Alfff Alfff added the Question label Jul 26, 2024
@github-actions github-actions bot changed the title How to change network key of all end devices of a network? How to change network key of all end devices of a network? (TZ-1026) Jul 26, 2024
@xieqinan
Copy link
Contributor

@Alfff ,

The esp_zb_secur_network_key_set() only supports setting the local network key. The APSME-SWITCH-KEY request is supported in the latest v1.4.1 version. We will include this feature in the next release. Thank you for your patience.

@Alfff
Copy link
Author

Alfff commented Jul 29, 2024

@xieqinan Will this feature be included in the NCP protocol?

@xieqinan
Copy link
Contributor

@Alfff ,

The esp-zigbee-ncp is implemented based on the esp-zigbee-sdk, allowing developers to use the APIs provided by the esp-zigbee-sdk for development. As a result, if the esp-zigbee-sdk supports a particular feature, the NCP protocol will also support it.

@Alfff
Copy link
Author

Alfff commented Aug 2, 2024

Thanks @xieqinan

@Alfff Alfff closed this as completed Aug 2, 2024
@Alfff
Copy link
Author

Alfff commented Aug 28, 2024

@xieqinan,

Is there anything new? I don't see any changes in this regard in the release notes for version 1.5.0

@Alfff Alfff reopened this Aug 28, 2024
@xieqinan
Copy link
Contributor

@Alfff ,

Please use the following code instead:

#include "zboss_api.h"

extern void zb_secur_send_nwk_key_switch(uint8_t param);

typedef struct zb_apsme_switch_key_req_s {
    esp_zb_ieee_addr_t dest_address; /*!< Destination address  */
    uint8_t key_seq_number;          /*!< Sequence Number */
} zb_apsme_switch_key_req_t;

static uint8_t s_dest_addr[] = {0x01, 0x02, 0x03, 0x04, 0x01, 0x02, 0x03, 0x04}; // Unicast to destination address of network

static esp_err_t esp_zb_secur_apsme_switch_key_req(bool broadcasted)
{
    esp_err_t ret = ESP_OK;
    uint8_t param = zb_buf_get_out();
    if (broadcasted) {
        uint16_t *ptr = (uint16_t *)ZB_BUF_GET_PARAM(param, uint16_t);
        *ptr = broadcasted;
    } else {
        zb_apsme_switch_key_req_t *ptr = (zb_apsme_switch_key_req_t *)ZB_BUF_GET_PARAM(param, zb_apsme_switch_key_req_t);
        memcpy(ptr->dest_address, s_dest_addr, sizeof(esp_zb_ieee_addr_t));
        ptr->key_seq_number = 0;
    }
    zb_secur_send_nwk_key_switch(param);
    return ret;
}

@Alfff
Copy link
Author

Alfff commented Aug 28, 2024

Thank you so much @xieqinan 🥇

@Alfff Alfff closed this as completed Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants