espressif / esp-zigbee-sdk

Espressif Zigbee SDK
Apache License 2.0
154 stars 26 forks source link

Can't connect after setting MAC address with manufacturing tool (TZ-248) #82

Closed nomis closed 8 months ago

nomis commented 1 year ago

Using 0.9.1:

tools/mfg_tool/esp_zb_mfg_tool.py -c 0x7FFFFFFF -m 404CCAFFFE430BD0
cd examples/esp_zigbee_HA_sample/HA_on_off_light
idf.py set-target esp32c6
idf.py build
idf.py erase-flash
esptool.py -p $ESPPORT write_flash 0xb7000 ../../../tools/mfg_tool/bin/404CCAFFFE423078.bin
idf.py flash

I only get as far as "Starting Interview" trying to add the device. The right MAC address is displayed by the co-ordinator but the end device won't connect:

I (442) ESP_ZB_ON_OFF_LIGHT: ZDO signal: ZDO Config Ready (0x17), status: ESP_OK
I (442) ESP_ZB_ON_OFF_LIGHT: Zigbee stack initialized
I (442) ESP_ZB_ON_OFF_LIGHT: Start network steering
I (9222) ESP_ZB_ON_OFF_LIGHT: ZDO signal: ZDO Leave (0x3), status: ESP_OK
I (9222) ESP_ZB_ON_OFF_LIGHT: Network steering was not successful (status: ESP_FAIL)
I (27172) ESP_ZB_ON_OFF_LIGHT: ZDO signal: ZDO Leave (0x3), status: ESP_OK
I (27172) ESP_ZB_ON_OFF_LIGHT: Network steering was not successful (status: ESP_FAIL)
I (36962) ESP_ZB_ON_OFF_LIGHT: ZDO signal: ZDO Leave (0x3), status: ESP_OK
I (36962) ESP_ZB_ON_OFF_LIGHT: Network steering was not successful (status: ESP_FAIL)
I (79322) ESP_ZB_ON_OFF_LIGHT: ZDO signal: ZDO Leave (0x3), status: ESP_OK
I (79322) ESP_ZB_ON_OFF_LIGHT: Network steering was not successful (status: ESP_FAIL)

It works if I erase the zb_fct partition:

I (442) ESP_ZB_ON_OFF_LIGHT: ZDO signal: ZDO Config Ready (0x17), status: ESP_FAIL
I (442) ESP_ZB_ON_OFF_LIGHT: Zigbee stack initialized
I (442) ESP_ZB_ON_OFF_LIGHT: Start network steering
I (42242) ESP_ZB_ON_OFF_LIGHT: Joined network successfully (Extended PAN ID: *, PAN ID: *, Channel:26)
I (60572) ESP_ZB_ON_OFF_LIGHT: Received message: endpoint(0x64), cluster(0x6), attribute(0x0), data size(1)
I (60572) ESP_ZB_ON_OFF_LIGHT: Light sets to On
I (65722) ESP_ZB_ON_OFF_LIGHT: Received message: endpoint(0x64), cluster(0x6), attribute(0x0), data size(1)
I (65722) ESP_ZB_ON_OFF_LIGHT: Light sets to Off
xieqinan commented 1 year ago

Hello, The esp_zb_mfg_tool.py provides a method for generating and programming the install code, MAC address, and manufacturer code for Zigbee devices. When the device's zb_fct (functionality) has been configured, it will activate the install code mode to facilitate network joining.

Based on your explanation, the light example only programs the channel and MAC address, omitting the install code, which would still trigger the install code mode. In such a scenario, the coordinator must also activate the install code option. Furthermore, the coordinator needs to utilize the esp_zb_secur_ic_str_add() function to incorporate the joining device's install code after the network has been established. Failing to do so might result in the coordinator excluding the device from its network.

To enhance user-friendliness, modifications will be made to the esp_zb_mfg_tool.py to offer a more user-oriented API.

The correct sequence of steps is as follows:

// add the following code after the network formation to esp_on_off_switch.c uint8_t address[] = {0xed, 0xff, 0xc0, 0x50, 0xef, 0xbe, 0xfe, 0xca}; char ic_code[] = "83FED3407A939723A5C639B26916D505C3B5"; esp_zb_secur_ic_str_add(address, ic_code);

nomis commented 1 year ago

To enhance user-friendliness, modifications will be made to the esp_zb_mfg_tool.py to offer a more user-oriented API.

The install code needs to be optional on the end device.

That's not the only parameter that has an undesirable default. The channel mask defaults to only allowing one channel when it should default to all channels.

xieqinan commented 1 year ago

Thank you for your suggestion.

nomis commented 1 year ago

@mallaprashant please create your own issue instead of hijacking this one