Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wifi Event handler #10

Open
happytm opened this issue May 26, 2020 · 1 comment
Open

Wifi Event handler #10

happytm opened this issue May 26, 2020 · 1 comment

Comments

@happytm
Copy link

happytm commented May 26, 2020

Fantastic code.

I have a question regarding ESP32 wifi events you are using in file here: https://github.com/Gerfunky/TinyPixelMapper/blob/master/wifi-ota.cpp

I am trying to use event SYSTEM_EVENT_AP_PROBEREQRECVED but Ido not have callback working for me. Can you please tell me how you got it working?

Code I am trying to use is below:

#include <WiFi.h>
int wifiChannel = 7;


void probeReceived(WiFiEvent_t event, WiFiEventInfo_t info){
   
  Serial.println("Station connected");
   
  for(int i = 0; i< 6; i++){
     
    Serial.printf("%02X", info.sta_connected.mac[i]);  
    if(i<5)Serial.print(":");
  }

  Serial.println("Received probe request packet:");
  Serial.println("RSSI : " + String(info.ap_probereqrecved.rssi));
  Serial.println("MAC  : " + String(info.ap_probereqrecved.mac[0], HEX) + ":" + String(info.ap_probereqrecved.mac[1], HEX) + ":" + String(info.ap_probereqrecved.mac[2], HEX) + ":" + String(info.ap_probereqrecved.mac[3], HEX) + ":" + String(info.ap_probereqrecved.mac[4], HEX) + ":" + String(info.ap_probereqrecved.mac[5], HEX));

 Serial.println();
}
  
void setup() {
  
    Serial.begin(115200);

    WiFi.softAP("ESP32", "<notused>", wifiChannel, 0, 0);
   
WiFi.onEvent(probeRequest, SYSTEM_EVENT_AP_PROBEREQRECVED);
                             
}
  
void loop() { }

Thanks.
@Gerfunky
Copy link
Owner

Sorry for the VERY LATE reply but somehow i did not get any notification.
If its still relevant your callback is formated wrong.
here is a Simple example from the Olimex POE Board that shows you how its done.
and how a Switch is used to destinguish between the diffrenet callback ID'S
Olimex ethernet example

OR you could just copy out my entire "void WiFi_Event(WiFiEvent_t event, system_event_info_t info)" function in the wifi-ota.cpp
and replace "debugMe" -> "Serial.println"
and then register it with "WiFi.onEvent(WiFi_Event);"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants