Chat freely about anything...

User avatar
By elektronika_ba
#1838 Hi,

What do I need to do so that wifi_station_connect() function doesn't reset the chip after being called?

This is part of code that produces this error:
Code: Select all//...stationConf is loaded with setup above this line...
      wifi_station_set_config(&stationConf);

      uart0_sendStr("Connecting to WIFI...");
      os_sprintf(temp, "SSID: %s, PWD: %s\r\n", stationConf.ssid, stationConf.password);
      uart0_sendStr(temp);

      wifi_station_connect();


The result on UART:
Code: Select allConnecting to WIFI...SSID: linksys7, PWD: nobodyknowsit

 ets Jan  8 2013,rst cause:4, boot mode:(3,7)

wdt reset
load 0x40100000, len 23760, room 16
tail 0
chksum 0xd0
load 0x3ffe8000, len 2692, room 8
tail 12
chksum 0x24
ho 0 tail 12 room 4
load 0x3ffe8a90, len 3672, room 12
tail 12
chksum 0xf0
csum 0xf0


I also found out that if I comment the line wifi_station_connect() the module somehow connects to my AP (it probably saves my AP information in flash somewhere because even when I re-flash it with new firmware it somehow connects on it's own). Also, if I call wifi_station_disconnect() at the beginning of my code I also get a restart.

Any clues?

Oh, and I previously did a wifi_set_opmode(1); // STATION_MODE
Last edited by elektronika_ba on Wed Oct 22, 2014 12:16 pm, edited 1 time in total.
User avatar
By igrr
#1839 You don't need to call wifi_set_opmode each time the firmware starts, as the mode is saved in a settings region of the flash. Btw if you do call wifi_set_opmode, you have to do a reset afterwards.
The same applies for the AP settings, they are saved in flash. Set them once and the module will connect automatically. No need to call wifi_station_connect from your user_init.
User avatar
By elektronika_ba
#1840 Ok thanks for the info. I edited my post and removed that comment because I saw that ESP does the same thing I do, on startup they set the opmode and continue without restarting the chip...

Well, setting opmode only once is hard to implement in code. When I for example build a standalone device how will the code for setting the opmode be executed just once? The device can lose power many times in its life and code would start from the beginning... I would need to use the load_user_param & save_user_param to keep track if I have the settings in the flash.

Anyway even when I comment out the set_opmode() the chip still restarts :-(
Last edited by elektronika_ba on Wed Oct 22, 2014 12:41 pm, edited 1 time in total.
User avatar
By elektronika_ba
#1841 I posted my code to github. Care to check it out? Thanks :)
https://github.com/elektronika-ba/ctrl-esp8266-test/

edit, again: hmmm, it all works when I call wifi_station_connect() a bit later in code. This is some strange stuff. I will try putting the wifi_station_connect() in timer. Now I do it like this: (and it works)

Code: Select allvoid ICACHE_FLASH_ATTR debug_thingy(void)
{
  uint8_t temp;

  temp = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF;

  if(temp=='c')
  {
     uart0_sendStr("CONNECTING\r\n");
     wifi_station_connect();
  }
  else if(temp=='d')
  {
     uart0_sendStr("DISCONNECTING\r\n");
     wifi_station_disconnect();
  }
}


and the debug_thingy() function is called on UART.c receive interrupt, so I command the wifi_connect and disconnect from terminal.