Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By is0lated
#33415 I've updated the loop code to be
Code: Select all//Main code function
static void ICACHE_FLASH_ATTR
loop(os_event_t *events)
{
    //os_printf("Hello\n\r");
    //Keep track of whether we're connected
    static bool connected = false;
    //Debug message to print out whether we're connected or not
    os_printf("The connected state is %s\n", connected ? "true" : "false");
    //If we're not connected, connect, otherwise to nothing
    if(!connected)
    {
            os_printf("Now going to connect to AP\n");
            wifi_station_connect();
            connected = true;
    }
    os_delay_us(10000); system_os_post(user_procTaskPrio, 0, 0 );
}

The output then becomes
Code: Select alladd if0
The connected state is false
Now going to connect to AP
scandone
The connected state is true
The connected state is true
...
The connected state is true
scandone
no shhh... found, reconnect after 1s
The connected state is true

etc. It still seems to be printing out the wrong event call back messages.
User avatar
By kolban
#33467 Another potential thought is that you are registering your wifi event callback in the function called "user_init". Have a study and search on the function called "system_init_done_cb()". It seems that when an ESP8266 starts it goes through a two stage bootup with respect to user code. First "user_init()" is called and you can do "stuff" there ... however, it appears that the environment is NOT yet fully setup. In your user_init() you have the option to register a callback through "system_init_done_cb()". When THAT callback is invoked, we are then in a state where the ESP8266 is "more" ready. It could be that when you set your wifi event handler in "user_init" it is being changed during the second stage bootup and what you might have to do is register your wifi event handler in the system_init_done_cb.

It is certainly worth a test.
User avatar
By is0lated
#33506 I set up a system init finished function and set up the system_init_done_cb(), the init finished function sets up the wifi event handler. Unfortunately, the init done handler runs, but I'm still getting the strange output from the wifi event handler. In fact, I'm getting output from the wifi event handler BEFORE I get the debug messages I've set up in the init done handler. It seems I can set up call back handlers, but something's going on with the wifi event handler. I'm at a bit of a loss here, I'll try re-installing the SDK after updating my computer.
User avatar
By is0lated
#33534 After re-installing the tool-chain the same thing occurs. I also get some strange serial output using sample code from the Espressif forums, I think it's garbled because the serial speed is never set in the example code.

At this point I'm really at a bit of a loss, I'll update this thread if I ever figure out what's going on.