Skip to content

Zigbee end device "randomly" factory resets; seems due to handling of ESP_ZB_ZDO_SIGNAL_LEAVE #11381

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

Open
1 task done
tofurky opened this issue May 21, 2025 · 3 comments · May be fixed by #11385
Open
1 task done

Zigbee end device "randomly" factory resets; seems due to handling of ESP_ZB_ZDO_SIGNAL_LEAVE #11381

tofurky opened this issue May 21, 2025 · 3 comments · May be fixed by #11385
Assignees
Labels
Area: Zigbee Issues and Feature Request about Zigbee Status: In Progress ⚠️ Issue is in progress
Milestone

Comments

@tofurky
Copy link

tofurky commented May 21, 2025

Board

dfrobot_beetle_esp32c6

Device Description

Small esp32c6 board powered via USB-C

Hardware Configuration

I2C pins are wired up to DF Robot O2 sensor; powered via USB-C port

Version

v3.2.0

IDE Name

arduino-cli

Operating System

Linux

Flash frequency

40MHz

PSRAM enabled

no

Upload speed

460800

Description

The device is on a fairly busy Zigbee network with tens of bulbs from different vendors including Ikea, Cree, Sylvania/OSRAM. Using Homeassistant 2025.4 with ZHA on a SkyConnect / ZBT-1 dongle (silabs stack).

Somewhat randomly, it seems another device on the network (Ikea bulbs, I believe - I actually had a capture of them doing the same to some Lutron remotes) won't like something the ESP32C6 does and tells it to "leave" the network - generating a ESP_ZB_ZDO_SIGNAL_LEAVE signal. It seems it happens when the device sends a reading; some other device didn't like it. Last set of logs attached below shows it was in the middle of updating the clusters.

The result due to the default handler of this in ZigbeeCore.cpp is that the device will factory reset itself and need to be manually rejoined to the network.

Relevant code:

case ESP_ZB_ZDO_SIGNAL_LEAVE: // End Device + Router
// Device was removed from the network, factory reset the device
if ((zigbee_role_t)Zigbee.getRole() != ZIGBEE_COORDINATOR) {
Zigbee.factoryReset(true);
}
break;
default: log_v("ZDO signal: %s (0x%x), status: %s", esp_zb_zdo_signal_to_string(sig_type), sig_type, esp_err_to_name(err_status)); break;

Per docs, there is an enum that can be checked to determine which type of reset this is. I have a feeling that the proper handling of these messages coming from other nodes on the network (i.e. not the coordinator) should just be to reset the zigbee stack or reset the device, without fully wiping the stored config and requiring it to be manually re-joined to the network.

Sketch

Basically, Zigbee_Temperature_Sensor.ino. Can post full sketch if needed, but I believe this issue is due to the catch-all handling of ESP_ZB_ZDO_SIGNAL_LEAVE signals in ZigbeeCore.cpp

Debug Message

Here are older logs I left in a comment a while ago (https://github.com/espressif/arduino-esp32/pull/10676#issuecomment-2564487117)

It's happening as well on 3.2.0, I just didn't have the device running with verbose logs this time.


[26523678][V][ZigbeeTempSensor.cpp:112] setHumidity(): Updating humidity sensor value...
[26523678][D][ZigbeeTempSensor.cpp:114] setHumidity(): Setting humidity to 2090
[26523679][V][ZigbeeTempSensor.cpp:71] setTemperature(): Updating temperature sensor value...
[26523679][D][ZigbeeTempSensor.cpp:73] setTemperature(): Setting temperature to 2430
[26524179][I][o2.ino:140] zigbee_reading_handler(): Sent average of readings of oxygen=20.9%, temperature=24.3 C (60 total readings)
[26524677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.3 C (2518 us)
[26525677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.4 C (2416 us)
[26526677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.3 C (2485 us)
[26526711][I][ZigbeeCore.cpp:225] esp_zb_app_signal_handler(): Device started up in non factory-reset mode
[26526711][I][ZigbeeCore.cpp:238] esp_zb_app_signal_handler(): Device rebooted
[26526712][D][ZigbeeCore.cpp:466] searchBindings(): Requesting binding table for address 0x81e6
[26526713][D][ZigbeeCore.cpp:406] bindingTableCb(): Binding table callback for address 0x81e6 with status 0
[26526714][D][ZigbeeCore.cpp:409] bindingTableCb(): Binding table info: total 2, index 0, count 2
[26526714][D][ZigbeeCore.cpp:419] bindingTableCb(): Binding table record: src_endp 10, dst_endp 1, cluster_id 0x0402, dst_addr_mode 3
[26526715][D][ZigbeeCore.cpp:436] bindingTableCb(): Device bound to EP 10 -> device endpoint: 1, short addr: 0x0000, ieee addr: <censored>
[26526715][D][ZigbeeCore.cpp:419] bindingTableCb(): Binding table record: src_endp 10, dst_endp 1, cluster_id 0x0405, dst_addr_mode 3
[26526716][D][ZigbeeCore.cpp:436] bindingTableCb(): Device bound to EP 10 -> device endpoint: 1, short addr: 0x0000, ieee addr: <censored>
[26526717][D][ZigbeeCore.cpp:457] bindingTableCb(): Filling bounded devices finished
[26527677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.4 C (2539 us)
[26528677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.4 C (2408 us)
[26529677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.3 C (2336 us)
[26530677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.2 C (2474 us)
[26531677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.4 C (2433 us)
[26532677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.3 C (2415 us)
[26533677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.3 C (2457 us)
[26534677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.4 C (2414 us)
[26535677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.3 C (2399 us)
[26536677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.3 C (2451 us)
[26537677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.4 C (2413 us)
[26538677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.5 C (2408 us)
[26539677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.3 C (2449 us)
[26540677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.3 C (2526 us)
[26541677][D][o2.ino:57] sensor_read(): oxygen=20.9% temperature=24.3 C (2402 us)
[26542032][V][ZigbeeCore.cpp:344] factoryReset(): Factory resetting Zigbee stack, device will reboot
ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0xc (SW_CPU),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x4001975a
SPIWP:0xee
mode:DIO, clock div:2
load:0x40875720,len:0x1228
load:0x4086c110,len:0xd9c
load:0x4086e610,len:0x2f74
entry 0x4086c110


Logs from this time around, for completeness:

[6263503][D][ZigbeeTempSensor.cpp:134] setHumidity(): Setting humidity to 2070
[6263503][D][ZigbeeTempSensor.cpp:81] setTemperature(): Setting temperature to 2240
[6264003][I][o2.ino:133] zigbee_reading_handler(): Sent averaged readings of oxygen=20.7%, temperature=22.4 C (60 total readings)
[6323506][D][ZigbeeTempSensor.cpp:134] setHumidity(): Setting humidity to 2070
[6323507][D][ZigbeeTempSensor.cpp:81] setTemperature(): Setting temperature to 2250
ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0xc (SW_CPU),boot:0xc (SPI_FAST_FLASH_BOOT)
Saved PC:0x4001975a
SPIWP:0xee
mode:DIO, clock div:2
load:0x40875720,len:0x1260
load:0x4086c110,len:0xdc4
load:0x4086e610,len:0x3018
entry 0x4086c110
=========== Before Setup Start ===========
Chip Info:
------------------------------------------
  Model             : ESP32-C6
  Package           : 1
  Revision          : 0.01
  Cores             : 1
  CPU Frequency     : 160 MHz
  XTAL Frequency    : 40 MHz
  Features Bitfield : 0x00000052
  Embedded Flash    : No
  Embedded PSRAM    : No
  2.4GHz WiFi       : Yes
  Classic BT        : No
  BT Low Energy     : Yes
  IEEE 802.15.4     : Yes
------------------------------------------
INTERNAL Memory Info:
------------------------------------------
  Total Size        :   449424 B ( 438.9 KB)
  Free Bytes        :   411748 B ( 402.1 KB)
  Allocated Bytes   :    30692 B (  30.0 KB)
  Minimum Free Bytes:   411748 B ( 402.1 KB)
  Largest Free Block:   385012 B ( 376.0 KB)
------------------------------------------
Flash Info:
------------------------------------------
  Chip Size         :  4194304 B (4 MB)
  Block Size        :    65536 B (  64.0 KB)
  Sector Size       :     4096 B (   4.0 KB)
  Page Size         :      256 B (   0.2 KB)
  Bus Speed         : 40 MHz
  Bus Mode          : QIO
------------------------------------------
Partitions Info:
------------------------------------------
                nvs : addr: 0x00009000, size:    20.0 KB, type: DATA, subtype: NVS
            otadata : addr: 0x0000E000, size:     8.0 KB, type: DATA, subtype: OTA
               app0 : addr: 0x00010000, size:  1280.0 KB, type:  APP, subtype: OTA_0
               app1 : addr: 0x00150000, size:  1280.0 KB, type:  APP, subtype: OTA_1
             spiffs : addr: 0x00290000, size:  1388.0 KB, type: DATA, subtype: SPIFFS
         zb_storage : addr: 0x003EB000, size:    16.0 KB, type: DATA, subtype: FAT
             zb_fct : addr: 0x003EF000, size:     4.0 KB, type: DATA, subtype: FAT
           coredump : addr: 0x003F0000, size:    64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
  Compile Date/Time : Mar 28 2025 20:26:21
  Compile Host OS   : linux
  ESP-IDF Version   : v5.4.1-1-g2f7dcd862a-dirty
  Arduino Version   : 3.2.0
------------------------------------------
Board Info:
------------------------------------------
  Arduino Board     : DFROBOT_BEETLE_ESP32C6
  Arduino Variant   : dfrobot_beetle_esp32c6
  Arduino FQBN      : esp32:esp32:dfrobot_beetle_esp32c6:JTAGAdapter=builtin,CDCOnBoot=cdc,PartitionScheme=zigbee,CPUFreq=160,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=debug,EraseFlash=none,ZigbeeMode=ed
============ Before Setup End ============
[   125][I][esp32-hal-ledc.c:166] ledcAttachChannel(): LEDC attached to pin 15 (channel 0, resolution 12)
[   125][I][o2.ino:201] setup_sensor(): Clearing I2C bus
[   225][I][esp32-hal-i2c-ng.c:105] i2cInit(): Initializing I2C Master: num=0 sda=19 scl=20 freq=100000
[   226][I][o2.ino:221] setup_sensor(): Configuring sensor
[   251][I][o2.ino:228] setup_sensor(): Successfully configured O2 sensor
[   263][I][o2.ino:236] setup_zigbee(): Configuring Zigbee
[   264][D][ZigbeeCore.cpp:97] addEndpoint(): Endpoint: 10, Device ID: 0x0302
[   264][I][o2.ino:251] setup_zigbee(): Initializing Zigbee
[   264][D][ZigbeeCore.cpp:145] zigbeeInit(): Initialize Zigbee stack
[   339][D][ZigbeeCore.cpp:152] zigbeeInit(): Register all Zigbee EPs in list
[   341][I][ZigbeeCore.cpp:160] zigbeeInit(): List of registered Zigbee EPs:
[   341][I][ZigbeeCore.cpp:162] zigbeeInit(): Device type: Temperature Sensor, Endpoint: 10, Device ID: 0x0302
[   345][I][ZigbeeCore.cpp:241] esp_zb_app_signal_handler(): Zigbee stack initialized
[   346][D][ZigbeeCore.cpp:242] esp_zb_app_signal_handler(): Zigbee channel mask: 0x07fff800
[   347][I][ZigbeeCore.cpp:248] esp_zb_app_signal_handler(): Device started up in  factory-reset mode
[   348][I][ZigbeeCore.cpp:255] esp_zb_app_signal_handler(): Start network steering
[   350][I][o2.ino:275] setup_reporting(): Setting reporting intervals
[   353][I][o2.ino:311] setup_clusters(): Setting initial cluster values
[   356][D][ZigbeeTempSensor.cpp:134] setHumidity(): Setting humidity to 2070
[   357][D][ZigbeeTempSensor.cpp:81] setTemperature(): Setting temperature to 2250
[   359][I][o2.ino:339] connect_zigbee(): Waiting for Zigbee to connect...
[  2359][I][o2.ino:339] connect_zigbee(): Waiting for Zigbee to connect...
[  2577][I][ZigbeeCore.cpp:317] esp_zb_app_signal_handler(): Network steering was not successful (status: ESP_FAIL)
[  4360][I][o2.ino:339] connect_zigbee(): Waiting for Zigbee to connect...
[  5811][I][ZigbeeCore.cpp:317] esp_zb_app_signal_handler(): Network steering was not successful (status: ESP_FAIL)
[  6362][I][o2.ino:339] connect_zigbee(): Waiting for Zigbee to connect...
[  8363][I][o2.ino:339] connect_zigbee(): Waiting for Zigbee to connect...
[  9042][I][ZigbeeCore.cpp:317] esp_zb_app_signal_handler(): Network steering was not successful (status: ESP_FAIL)
[ 10363][I][o2.ino:339] connect_zigbee(): Waiting for Zigbee to connect...

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@tofurky tofurky added the Status: Awaiting triage Issue is waiting for triage label May 21, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y added the Area: Zigbee Issues and Feature Request about Zigbee label May 21, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this May 21, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y added Status: In Progress ⚠️ Issue is in progress and removed Status: Awaiting triage Issue is waiting for triage labels May 21, 2025
@P-R-O-C-H-Y
Copy link
Member

Hi @tofurky, Thank you for reporting this issue.
I will open a PR today with a proper leave signal handling, which will depend on a leave type.
Leave without rejoin (will factory reset) or Leave and rejoin (only reboot ESP).

@tofurky
Copy link
Author

tofurky commented May 21, 2025

Hi @tofurky, Thank you for reporting this issue. I will open a PR today with a proper leave signal handling, which will depend on a leave type. Leave without rejoin (will factory reset) or Leave and rejoin (only reboot ESP).

Great, thanks for the quick response. I can test it locally, but I unfortunately don't have a mechanism to trigger the leave; it sometimes takes a week or 2.

@P-R-O-C-H-Y P-R-O-C-H-Y linked a pull request May 21, 2025 that will close this issue
@tofurky
Copy link
Author

tofurky commented May 21, 2025

I've reflashed using the ZigbeeCore.cpp changes from #11385.

It'll be a bit more difficult to tell when it happens now, as it was quite obvious when the device was factory reset, but I'm saving serial output to a .txt file so I can grep it for that other (new) case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Zigbee Issues and Feature Request about Zigbee Status: In Progress ⚠️ Issue is in progress
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

2 participants