ESP8266 Developer Zone The Official ESP8266 Forum 2018-11-02T16:04:01+08:00 https://bbs.espressif.com:443/feed.php?f=66&t=24183 2018-11-02T16:04:01+08:00 2018-11-02T16:04:01+08:00 https://bbs.espressif.com:443/viewtopic.php?t=24183&p=35264#p35264 <![CDATA[Re: Enter Light Sleep Mode cause reset]]>

Code:

   struct rst_info *rst_info = system_get_rst_info();
   os_printf("reset reason: %x\n", rst_info->reason);
   if(rst_info->reason == REASON_WDT_RST || rst_info->reason == REASON_EXCEPTION_RST || rst_info->reason == REASON_SOFT_WDT_RST)
   {
         if (rst_info->reason == REASON_EXCEPTION_RST)
         {
            os_printf("Fatal exception (%d):\n", rst_info->exccause);
         }
         os_printf("epc1=0x%08x, epc2=0x%08x, epc3=0x%08x, excvaddr=0x%08x, depc=0x%08x\n",rst_info->epc1, rst_info->epc2, rst_info->epc3, rst_info->excvaddr, rst_info->depc);
   }


Code:

reset reason: 3
epc1=0x40232284, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000


Code:

40232284:   ffff06           j   40232284 <fpm_do_sleep+0x20>

Statistics: Posted by JacksonLv — Fri Nov 02, 2018 4:04 pm


]]>
2018-11-02T14:08:42+08:00 2018-11-02T14:08:42+08:00 https://bbs.espressif.com:443/viewtopic.php?t=24183&p=35242#p35242 <![CDATA[Enter Light Sleep Mode cause reset]]>

Code:

sleep_time_cnt: 60

enter sleep mode

wifi disconnected

pm close 7
fpm open,type:1 0
fpm 758

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x40100000, len 2408, room 16
tail 8
chksum 0xe5
load 0x3ffe8000, len 776, room 0
tail 8
chksum 0x84
load 0x3ffe8310, len 632, room 0
tail 8
chksum 0xd8
csum 0xd8


Code:

   void ICACHE_FLASH_ATTR user_init(){
   PIN_FUNC_SELECT(RED_LIGHT_IO_MUX, RED_LIGHT_IO_FUNC);

   drv_Switch_Init();
   sleep_init();

   os_printf("Firmware Version: 20181101\n");

   wifi_set_opmode(STATION_MODE);

   wifi_station_get_config_default(&stationConf);

   if (os_strlen(stationConf.ssid) != 0) {
      os_printf("user_scan\n");
      //net_status   = 1;
      os_timer_disarm(&check_ip_timer);
      os_timer_setfn(&check_ip_timer, (os_timer_func_t *) user_check_ip, NULL);
      os_timer_arm(&check_ip_timer, 100, 0);

   } else {
       os_printf("smartcfg\n");

       smartconfig_start(smartconfig_done);
       net_status  = 0;
       WIFI_DISCONNTED_FLAG;

   }

   os_timer_disarm(&light_status_timer);
   os_timer_setfn(&light_status_timer, (os_timer_func_t *)led_status_timer_func , NULL);
   os_timer_arm(&light_status_timer,MAIN_TIMER_PERIOD,1);

   os_timer_disarm(&sleep_timer);
   os_timer_setfn(&sleep_timer, (os_timer_func_t *)sleep_timer_func , NULL);
   os_timer_arm(&sleep_timer,SLEEP_TIMER_PERIOD,1);
   }



Code:

void sleep_init(void){
   wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);     //set force sleep type, clsoe rf&cpu
   wifi_fpm_set_wakeup_cb(fpm_wakup_cb_func1); //Set fpm wakeup callback function

}


Code:

void sleep_start(void )
{
   os_printf("enter sleep mode\n\n");

   if(wifi_station_get_connect_status() == STATION_GOT_IP){
      while(!wifi_station_disconnect()){
         os_delay_us(10);
      }
      os_printf("wifi disconnected\n\n");
   } else {
      smartconfig_stop();
      os_printf("wifi not connected\n\n");
   }
   os_delay_ms(200);
   RED_LIGHT_OFF;
   wifi_set_opmode(NULL_MODE);               //set wifi mode to null mode.
   wifi_fpm_open();                        //enable force sleep fucntion

   int rst =  wifi_fpm_do_sleep(FPM_SLEEP_MAX_TIME);      // do sleep
   os_printf("sleep rst : %d",rst);


}



Code:

void ICACHE_FLASH_ATTR
sleep_timer_func(void )
{
   static uint8_t cnt = 0;
   if(sleep_time_cnt < SLEEP_TIME_CNT){
      sleep_time_cnt++;
      os_printf("sleep_time_cnt: %d\n\n",sleep_time_cnt);
   }else {//2 min
      sleep_time_cnt = 0;
      os_timer_disarm(&check_ip_timer);
      os_timer_disarm(&light_status_timer);
      os_timer_disarm(&KeyScan_timer);
      os_timer_disarm(&sleep_timer);
      sleep_start();
   }

}

Statistics: Posted by JacksonLv — Fri Nov 02, 2018 2:08 pm


]]>