TinyPixelMapper icon indicating copy to clipboard operation
TinyPixelMapper copied to clipboard

Wifi Event handler

Open happytm opened this issue 5 years ago • 1 comments

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.

happytm avatar May 26 '20 09:05 happytm

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);"

Gerfunky avatar Jun 21 '21 22:06 Gerfunky