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

Deep Sleepy End Device does not reliably update (TZ-1291) #481

Open
travisp opened this issue Nov 14, 2024 · 1 comment
Open

Deep Sleepy End Device does not reliably update (TZ-1291) #481

travisp opened this issue Nov 14, 2024 · 1 comment
Labels

Comments

@travisp
Copy link

travisp commented Nov 14, 2024

Question

https://github.com/espressif/esp-zigbee-sdk/blob/main/examples/esp_zigbee_sleep/deep_sleep/main/esp_zb_sleepy_end_device.c

The deep sleep, sleepy end device example doesn't reliably update because it gives 5 seconds until shutdown, but sometimes it takes more than 5 seconds.

I created my own code based on this example that is intended to report a temperature every 10 minutes, and deep sleep in between. The code uses esp_zb_zcl_set_attribute_val to set the attributes. However, it only actually updates the zigbee network if I increase from 5 seconds (e.g. to 10 seconds). Is there a way instead to detect that the update payload has gone out and that it's safe to enter deep sleep?

Additional context.

No response

@github-actions github-actions bot changed the title Deep Sleepy End Device does not reliably update Deep Sleepy End Device does not reliably update (TZ-1291) Nov 14, 2024
@xieqinan
Copy link
Contributor

Hi,

The deep sleep, sleepy end device example doesn't reliably update because it gives 5 seconds until shutdown, but sometimes it takes more than 5 seconds.

The device wake-up time is measured by the ESP timer, which I believe is reliable. I ran the official example without any modifications, and the wake-up time was accurate. If you encounter unreliable timing on your side, please provide some logs or the code used to reproduce the issue for us to investigate.

Is there a way instead to detect that the update payload has gone out and that it's safe to enter deep sleep?

Have you tested whether the report a temperature feature works correctly on a non-sleep device? Also, please check the interval time for the report. The Zigbee stack operates during the device’s wake-up time. You can perform a simple test to verify this, as shown in the code below.

static void ieee_cb(esp_zb_zdp_status_t zdo_status, esp_zb_zdo_ieee_addr_rsp_t *resp, void *user_ctx)
{
    if (zdo_status == ESP_ZB_ZDP_STATUS_SUCCESS) {
        ESP_LOGI(TAG, "Response IEEE address: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", resp->ieee_addr[7],
                 resp->ieee_addr[6], resp->ieee_addr[5], resp->ieee_addr[4], resp->ieee_addr[3], resp->ieee_addr[2],
                 resp->ieee_addr[1], resp->ieee_addr[0]);
    }
}

static void zb_deep_sleep_start(void)
{
    /* Start the one-shot timer */
    const int before_deep_sleep_time_sec = 5;
    ESP_LOGI(TAG, "Start one-shot timer for %ds to enter the deep sleep", before_deep_sleep_time_sec);
    esp_zb_zdo_ieee_addr_req_param_t ieee_req;
    ieee_req.addr_of_interest = 0x0;
    ieee_req.dst_nwk_addr = 0x0;
    ieee_req.request_type = 0;
    ieee_req.start_index = 0;
    esp_zb_lock_acquire(portMAX_DELAY);
    esp_zb_zdo_ieee_addr_req(&ieee_req, ieee_cb, NULL);
    esp_zb_lock_release();
    ESP_ERROR_CHECK(esp_timer_start_once(s_oneshot_timer, before_deep_sleep_time_sec * 1000000));
}

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