Arduino icon indicating copy to clipboard operation
Arduino copied to clipboard

WiFi.printDiag doesn't support softAP

Open TimeTravelingOwls opened this issue 11 years ago • 9 comments

This may be outside of the scope of WiFi.printDiag, but it doesn't seem to support softAP. The Mode gets displayed as AP, but status stays set at 255 regardless of the AP's state:

Mode: AP PHY mode: N Channel: 1 AP id: 0 Status: 255 Auto connect: 1 SSID (0): Passphrase (0): BSSID set: 0

I know that some details of the softAP connection are available, because I can see the client's MAC, join, leave, etc., when I have Serial.setDebugOutput(true); set, but I'm not sure where that's coming from - is it somewhere in the lwip code? Is there a direct way to query softAP status within a sketch?

I'm trying to flip a token based on whether a client has disconnected from the softAP - any suggestions for a reliable way to track join/leave?

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

TimeTravelingOwls avatar Jun 25 '15 23:06 TimeTravelingOwls

yeah, I have a fix for that. Will be in the next pull.

me-no-dev avatar Jun 25 '15 23:06 me-no-dev

Thanks @me-no-dev - I'll test when it lands.

In the meanwhile, any suggestion for how to determine when a client has connected/disconnected? Seems like it ought to be easy, but I'm just not seeing it.

TimeTravelingOwls avatar Jun 26 '15 05:06 TimeTravelingOwls

extern "C" {
  #include "user_interface.h"
  #include "ip_addr.h"
  #include "mem.h"

  void _onWiFiEvent(System_Event_t *event){
    if(event->event == EVENT_SOFTAPMODE_STACONNECTED){
      Event_SoftAPMode_StaConnected_t *data = (Event_SoftAPMode_StaConnected_t *)(&event->event_info.sta_connected);
      Serial.printf("Station Connected: id: %d, mac: " MACSTR "\n", data->aid, MAC2STR(data->mac));
    } else if(event->event == EVENT_SOFTAPMODE_STADISCONNECTED){
      Event_SoftAPMode_StaDisconnected_t *data = (Event_SoftAPMode_StaDisconnected_t *)(&event->event_info.sta_disconnected);
      Serial.printf("Station Disconnected: id: %d, mac: " MACSTR "\n", data->aid, MAC2STR(data->mac));
    }
  }
}

void setup(){
  Serial.begin(115200);
  wifi_set_event_handler_cb(_onWiFiEvent);
}

me-no-dev avatar Jun 26 '15 09:06 me-no-dev

Note that this will disable the event handler present in ESP8266Wifi library.

igrr avatar Jun 26 '15 14:06 igrr

We should add it there then

me-no-dev avatar Jun 26 '15 14:06 me-no-dev

@me-no-dev: perfect - thanks!

Should I close this issue or wait until it's been pulled through?

TimeTravelingOwls avatar Jun 26 '15 17:06 TimeTravelingOwls

Better leave it open so I don't forget to add this.

igrr avatar Jun 26 '15 17:06 igrr

@igrr I think the current wifi event system supersedes this. Is there anything left to do?

devyte avatar Oct 21 '17 22:10 devyte

Yes, onStationModeConnected and onStationModeDisconnected functions in WiFi class provide this functionality.

igrr avatar Oct 22 '17 05:10 igrr