Closed mw75 closed 1 month ago
Hi @mw75
I failed to reproduce the issue. esp_zb_set_xxx_network_channel_set
should work correctly. Could you please shared the code where you make the call to set the channel, and a more detailed log would also be helpful.
#define MAX_CHILDREN 10 /* the max amount of connected devices */
#define INSTALLCODE_POLICY_ENABLE false /* enable the install code policy for security */
#define HA_ONOFF_SWITCH_ENDPOINT 1 /* esp light switch device endpoint */
#define ESP_ZB_PRIMARY_CHANNEL_MASK (1l << 11) /* Zigbee primary channel mask use in the example */
#define ESP_ZB_ZC_CONFIG() \
{ \
.esp_zb_role = ESP_ZB_DEVICE_TYPE_COORDINATOR, \
.install_code_policy = INSTALLCODE_POLICY_ENABLE, \
.nwk_cfg.zczr_cfg = { \
.max_children = MAX_CHILDREN, \
}, \
}
#define ESP_ZB_DEFAULT_RADIO_CONFIG() \
{ \
.radio_mode = RADIO_MODE_NATIVE, \
}
#define ESP_ZB_DEFAULT_HOST_CONFIG() \
{ \
.host_connection_mode = HOST_CONNECTION_MODE_NONE, \
}
static void esp_zb_task(void *pvParameters)
{
/* initialize Zigbee stack */
esp_zb_platform_config_t config = {
.radio_config = ESP_ZB_DEFAULT_RADIO_CONFIG(),
.host_config = ESP_ZB_DEFAULT_HOST_CONFIG(),
};
ESP_ERROR_CHECK(esp_zb_platform_config(&config));
esp_zb_cfg_t zb_nwk_cfg = ESP_ZB_ZC_CONFIG();
esp_zb_init(&zb_nwk_cfg);
esp_zb_set_primary_network_channel_set(ESP_ZB_PRIMARY_CHANNEL_MASK);
esp_zb_set_secondary_network_channel_set(ESP_ZB_PRIMARY_CHANNEL_MASK);
ESP_ERROR_CHECK(esp_zb_start(false));
esp_zb_main_loop_iteration();
}
void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
{
uint32_t *p_sg_p = signal_struct->p_app_signal;
esp_err_t err_status = signal_struct->esp_err_status;
esp_zb_app_signal_type_t sig_type = *p_sg_p;
esp_zb_zdo_signal_device_annce_params_t *dev_annce_params = NULL;
switch (sig_type) {
case ESP_ZB_ZDO_SIGNAL_SKIP_STARTUP:
ESP_LOGI(TAG, "Zigbee stack initialized");
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_INITIALIZATION);
break;
case ESP_ZB_BDB_SIGNAL_DEVICE_FIRST_START:
case ESP_ZB_BDB_SIGNAL_DEVICE_REBOOT:
if (err_status == ESP_OK) {
ESP_LOGI(TAG, "Device started up in %s factory-reset mode", esp_zb_bdb_is_factory_new() ? "" : "non");
if (esp_zb_bdb_is_factory_new()) {
ESP_LOGI(TAG, "Start network formation");
esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_FORMATION);
} else {
ESP_LOGI(TAG, "Device rebooted");
esp_zb_secur_link_key_exchange_required_set(false);
ESP_ERROR_CHECK(esp_zb_bdb_open_network(240));
}
} else {
ESP_LOGE(TAG, "Failed to initialize Zigbee stack (status: %s)", esp_err_to_name(err_status));
}
break;
case ESP_ZB_NWK_SIGNAL_PERMIT_JOIN_STATUS:
if (err_status == ESP_OK) {
if (*(uint8_t *)esp_zb_app_signal_get_params(p_sg_p)) {
ESP_LOGI(TAG, "Network(0x%04hx) is open for %d seconds", esp_zb_get_pan_id(), *(uint8_t *)esp_zb_app_signal_get_params(p_sg_p));
esp_zb_ieee_addr_t addr;
esp_zb_get_long_address(addr);
ESP_LOGI(TAG,"Long address %x:%x:%x:%x:%x:%x:%x:%x",addr[7],addr[6],addr[5],addr[4],addr[3],addr[2],addr[1],addr[0]);
ESP_LOGI(TAG,"Short address %x",esp_zb_get_short_address());
esp_zb_get_extended_pan_id(addr);
ESP_LOGI(TAG,"extended PanID %x:%x:%x:%x:%x:%x:%x:%x",addr[7],addr[6],addr[5],addr[4],addr[3],addr[2],addr[1],addr[0]);
ESP_LOGI(TAG,"PanID %x",esp_zb_get_pan_id());
ESP_LOGI(TAG,"Channel %d",esp_zb_get_current_channel());
} else {
ESP_LOGW(TAG, "Network(0x%04hx) closed, devices joining not allowed.", esp_zb_get_pan_id());
}
}
break;
default:
ESP_LOGI(TAG, "unhandled ZDO signal: %s (0x%x), status: %s", esp_zb_zdo_signal_to_string(sig_type), sig_type, esp_err_to_name(err_status));
break;
}
}
void app_main(void)
{
ESP_ERROR_CHECK(nvs_flash_init());
xTaskCreate(esp_zb_task, "Zigbee_main", 4096, NULL, 5, NULL);
}
Could you please share coordinator code that sets the channel and also proofs to use that channel?
How to create a more detailed log?
You can try our HA_on_off_switch example.
Please review "Steps to reproduce." step one!
The binary only distribution of esp-zigbee-lib and esp-zboss-lib makes it quite hard to help yourself. I understand, that zboss is licensed, but why is esp-zigbee-lib binary only? Or do i miss something and the code is published somewhere?
Problem is fixed by erase-flash. Looks like stored settings in flash have priority.
Problem is fixed by erase-flash. Looks like stored settings in flash have priority.
Exactly, some leftover info in the flash may cause some unexpected issues. So the erase-flash
operation is recommended.
The current esp-zigbee-sdk is released in library, we don't have the plan to opensource in short term. Feel free to raise github issues for any particular questions, you can also contact our business team via technical-inquiries to request the source code, but there is some order quantity requirement.
Answers checklist.
IDF version.
ESP-IDF v5.3.1
esp-zigbee-lib version.
1.0.9
esp-zboss-lib version.
1.0.9
Espressif SoC revision.
ESP32-C6
What is the expected behavior?
Coordinator running on Channel 11 when i call
What is the actual behavior?
Coordinator is running on channel 13
Steps to reproduce.
More Information.
The binary only distribution of esp-zigbee-lib and esp-zboss-lib makes it quite hard to help yourself. I understand, that zboss is licensed, but why is esp-zigbee-lib binary only? Or do i miss something and the code is published somewhere?