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.

Manual Control of WiFi connection

I'm working on a battery powered IoT device, which periodically wakes to take a measurement and reports to AWS if change is significant.
Deep Sleep works fine, but when the ESP wakes up it automatically connects to WiFi, can I configure to not connect automatically and only when I want to report?

Alternatively I could use the ULP, but I'm going to avoid that if possible
Thanks,

Comments

  • Hi @borner . What device are you using? Do you mind sharing the deep sleep code? I'm struggling with it now.

  • We were able to turn the Wifi on and off under program control on an ESP32. Can't help with the deep sleep, though.

    We configured the WIFI to be off in the conf*.json files, then we had code like this:

    static struct mgos_config_wifi my_wifi = { 0 };
    
      LOG(LL_INFO, ("Getting WIFI config"));
      my_wifi = *mgos_sys_config_get_wifi();
    
    // set it up (we also set the SSID and password here)
      my_wifi.sta.enable = true;
      LOG(LL_INFO, ("Turning the WIFI on..."));
      mgos_wifi_setup(&my_wifi);
    
    // toggle status
        int wifi_status = mgos_wifi_get_status();
        char * wifi_status_str = mgos_wifi_get_status_str();
        LOG(LL_INFO, ("WIFI status = %d %s", wifi_status, wifi_status_str));
        free (wifi_status_str);
    
        my_wifi.sta.enable = ! my_wifi.sta.enable;
    
        if (! my_wifi.sta.enable) {
          LOG(LL_INFO, ("calling mgos_wifi_disconnect"));
          mgos_wifi_disconnect();
        }
    
        LOG(LL_INFO, ("Setting up with wifi with sta.enable=%s...", my_wifi.sta.enable ? "true" : "false"));
        mgos_wifi_setup(&my_wifi);
    
Sign In or Register to comment.