Chat freely about anything...

User avatar
By pvvx
#9123
EadF wrote:I've found one important (for me at least) api change in 0.9.5:

user_interface.h:
Code: Select all#define NULL_MODE       0x00
#define STATION_MODE    0x01
#define SOFTAP_MODE     0x02
#define STATIONAP_MODE  0x03

In 0.9.4 the call "wifi_set_opmode(NULL_MODE);" had the practical effect of turning off the WiFi
In 0.9.5 it means "let's crashs the whole system after a second or so" :cry:

Since this seems to be a persistent setting, it carried over from my "console only" test program to the blinky example i had problem with above. (blinky does not set wifi opmode)

No.
wifi_set_opmode(a2) SDK 0.9.5:
Code: Select all<wifi_set_opmode>:
            addi   a1, a1, -16
            s32i.n   a12, a1, 8
            s32i.n   a0, a1, 4
         mov.n   a12, a2
         bltui   a2, 4, _wifi_set_opmode5
           movi.n   a2, 0
           j   _wifi_set_opmode5

_wifi_set_opmode1:
            l32r   a0, 40240fcc <0x3fff08a0>
            l32r   a3, 4024104c <0x3ffe9c58>
            l8ui   a2, a0, 128
            l8ui   a3, a3, 0
            beq   a2, a12, 40241085
           s32i.n   a0, a1, 0
            bnei   a3, 1, _wifi_set_opmode2
           mov.n   a2, a12
            call0   40240fe4 <wifi_set_opmode_local>

_wifi_set_opmode2:
           l32i.n   a4, a1, 0
            l32r   a2, 40240938 <0x3fff0918>
           s8i   a12, a4, 128
            call0   402410ac <wifi_param_save_protect>

_wifi_set_opmode3:
           movi.n   a2, 1

_wifi_set_opmode4:
           l32i.n   a12, a1, 8
           l32i.n   a0, a1, 4
            addi   a1, a1, 16
           ret.n

_wifi_set_opmode5:
           movi.n   a2, 5
            call0   40240624 <(pm_is_open(), ets_timer_setfn(), pm_is_waked())>
            bnei   a2, -1, _wifi_set_opmode1
            l32r   a5, 402407ec <0x3ffe9c80>   
            s8i   a12, a5, 130
            j   _wifi_set_opmode4
User avatar
By EadF
#9132 no?

here is a 0.9.5 example:
Code: Select all#include "driver/uart.h"
#include "user_interface.h"
void ICACHE_FLASH_ATTR user_init()
{
  uart_init(BIT_RATE_115200, BIT_RATE_115200);
  wifi_set_opmode(NULL_MODE);
}

result:
Code: Select all{...gibberish removed..MEM CHECK FAIL!!!
{,mode:
Fatal exception (28):
epc1=0x40240551, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000


wifi_set_opmode( NULL_MODE) commented out:

Code: Select all#include "driver/uart.h"
#include "user_interface.h"
void ICACHE_FLASH_ATTR user_init()
{
  uart_init(BIT_RATE_115200, BIT_RATE_115200);
  //wifi_set_opmode( NULL_MODE); //NULL_MODE is still in there, persistent
}

result:
Code: Select all{...gibberish removed..MEM CHECK FAIL!!!
{,mode:
Fatal exception (28):
epc1=0x40240551, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000


Using something else than NULL_MODE:

Code: Select all#include "driver/uart.h"
#include "user_interface.h"
void ICACHE_FLASH_ATTR user_init()
{
  uart_init(BIT_RATE_115200, BIT_RATE_115200);
  wifi_set_opmode( STATION_MODE );
}

result:
Code: Select all...gibberish removed..MEM HECK FAIL!!!
{,mode: sta(xxxxxxxx)
add if0
scandone
add 0
aid 1
pm open phy_2,type:2 0 0
cnt

connected with MYWIFI, channel 10
dhcp client start...
ip:192.168.0.216,mask:255.255.255.0,gw:192.168.0.1


With 0.9.4 there is no problem using NULL_MODE.
User avatar
By pvvx
#9140 In user_init WiFi is not initialized.
Code: Select all#include "driver/uart.h"
#include "user_interface.h"

void init_done_cb(void)
{
   wifi_set_opmode(NULL_MODE);
}

void user_init(void)
{
   // Configure the UART
   uart_init(BIT_RATE_115200, BIT_RATE_115200);
   system_init_done_cb(init_done_cb);
}

"2C-SDK-Espressif IoT SDK Programming Guide_v0.9.5.pdf":
3.4.2. wifi_set_opmode
Function: set wifi working mode as STATION, SOFTAP or STATION+SOFTAP
Note:
Versions before esp_iot_sdk_v0.9.2, need to call system_restart() after this api;
after esp_iot_sdk_v0.9.2, need not to restart.
Function definition:
bool wifi_set_opmode (uint8 opmode)
Input parameters:
uint8 opmode——Wifi working modes: 0x01 means STATION_MODE,
0x02 means SOFTAP_MODE, 0x03 means STATIONAP_MODE.
Return:
True - succeed;
False - fail.

Use deep_sleep for off WiFi:
Code: Select all#include <c_types.h>
#include <osapi.h>
#include <user_interface.h>
#include "driver/uart.h"

// old value deep_sleep_set_option (if no rtc_vcc  = ?)
uint16 deep_sleep_get_option(void)
{
   return ((*((volatile uint32_t *)0x60001060))>>16);
}

// start: =1 pin reset, =0 pin ch_pd
uint16 sys_start_pin_reset(void)
{
   return (*((volatile uint32_t *)0x60001060));
}

void init_done_cb(void)
{
   os_printf("\nInit done. WiFi get mode = %u\n", wifi_get_opmode());
}

void user_init(void)
{
   // Configure the UART
   uart_init(BIT_RATE_115200, BIT_RATE_115200);
   os_printf("\n\nWiFi mode = %u, DeepSleep old mode = %u\n", wifi_get_opmode(), deep_sleep_get_option());
   if(deep_sleep_get_option() != 4) {
      system_deep_sleep_set_option(4);
      system_deep_sleep(1);
   }
   system_init_done_cb(init_done_cb);
}

WiFi mode = 3, DeepSleep old mode = 4
mode : sta(18:fe:34:9f:c0:bf) + softAP(1a:fe:34:9f:c0:bf)
add if0
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
add if1
pm close 0 0 0/51960
bcn 100

Init done. WiFi get mode = 3
User avatar
By Athena
#9301
pvvx wrote:system restart() and software reset() non stop LwIP -> eternal crash, not reset, not deep_sleep, .... :lol:


Hi, pvvx, could you offer more information about this problem you mentioned ?

:oops: I can't understand what you mean ..

Thanks for your interest in ESP8266 !