Copyright © https://mongoose-os.com

Mongoose OS Forum

frame
ATTENTION! This forum has moved to:

https://community.mongoose-os.com

Do not post any new messages.

Can't put esp8266 sleep with timer

edited February 5 in Mongoose OS

Hi,
I have this code:

static void measure_distance(int ev, void *ev_data, void *userdata) 
{
  // ... nothing important
  mgos_shadow_update(0, strBuffer);
  mgos_set_timer(10000, 0, sleep_later, NULL);
  // ... nothing important
}
static void sleep_later(void *arg)
{
  system_deep_sleep(30 * 1000000);
  (void)arg;
}

enum mgos_app_init_result mgos_app_init(void)
{
    mgos_event_add_handler(MGOS_EVENT_CLOUD_CONNECTED, measure_distance, NULL);
    return MGOS_APP_INIT_SUCCESS;
}

Exception 28 @ 0x4000df2f, vaddr 0x00000033 instead of sleep

Without timer it's working, but dosn't have enought time to send data to mdash.

With timer it sending data, but can't go sleep.
Am I missing something?

Comments

  • Problem solved:

    static void sleep_later(void *arg)
    {
      wifi_station_disconnect();
      wifi_set_opmode_current(NULL_MODE);
      system_deep_sleep(30 * 1000000);
      (void)arg;
    }
    
Sign In or Register to comment.