WiFi Events
- group wifi_ev
Event callback interface for WiFi events.
See also
See also
Defines
-
WIFI_DISCONNECT_REASON_CODES_MAP(XX)
Common set of reason codes to IEEE 802.11-2007.
Some acronymns used here - see the full standard for more precise definitions.
SSID: Service Set Identifier (the visible name given to an Access Point)
BSSID: Basic Service Set Identifier (a MAC address physically identifying the AP)
IE: Information Element (standard piece of information carried within WiFi packets)
STA: Station (any device which supports WiFi, including APs though the term commonly refers to a client)
AP: Access Point (device to which other stations may be associated)
RSN: Robust Security Network
AUTH: Authentication (how a station proves its identity to another)
Note
Codes at 200+ are non-standard, defined by Espressif.
Typedefs
-
using StationConnectDelegate = Delegate<void(const String &ssid, MacAddress bssid, uint8_t channel)>
Delegate type for ‘station connected’ event.
Note
This event occurs when the station successfully connects to the target AP. Upon receiving this event, the DHCP client begins the process of getting an IP address.
- Param ssid:
- Param bssid:
- Param channel:
-
using StationDisconnectDelegate = Delegate<void(const String &ssid, MacAddress bssid, WifiDisconnectReason reason)>
Delegate type for ‘station disconnected’ event.
Note
This event can be generated in the following scenarios:
When the station is already connected to the AP, and a manual disconnect or re-configuration is taking place. e.g.
WifiStation.disconnect()
When
WifiStation.connect()
is called, but the Wi-Fi driver fails to set up a connection with the AP due to certain reasons, e.g. the scan fails to find the target AP, authentication times out, etc. If there are more than one AP with the same SSID, the disconnected event is raised after the station fails to connect all of the found APs.When the Wi-Fi connection is disrupted because of specific reasons, e.g., the station continuously loses N beacons, the AP kicks off the station, the AP’s authentication mode is changed, etc.
- Param ssid:
SSID from which we’ve disconnected
- Param bssid:
- Param reason:
Why the connection was dropped
-
using StationAuthModeChangeDelegate = Delegate<void(WifiAuthMode oldMode, WifiAuthMode newMode)>
Delegate type for ‘station authorisation mode changed’ event.
Note
This event arises when the AP to which the station is connected changes its authentication mode, e.g., from ‘no auth’ to WPA. Generally, the application event callback does not need to handle this.
- Param oldMode:
- Param newMode:
-
using StationGotIPDelegate = Delegate<void(IpAddress ip, IpAddress netmask, IpAddress gateway)>
Delegate type for ‘station got IP address’ event.
Note
This event arises when the DHCP client successfully gets the IPV4 address from the DHCP server, or when the IPV4 address is changed. The IPV4 may be changed because of the following reasons:
The DHCP client fails to renew/rebind the IPV4 address, and the station’s IPV4 is reset to 0.
The DHCP client rebinds to a different address.
The static-configured IPV4 address is changed.
- Param ip:
- Param netmask:
- Param gateway:
-
using AccessPointConnectDelegate = Delegate<void(MacAddress mac, uint16_t aid)>
Delegate type for ‘Access Point Connect’ event.
Note
This event occurs every time a station is connected to our Access Point.
- Param mac:
MAC address of the station
- Param aid:
Association ID representing the connected station
-
using AccessPointDisconnectDelegate = Delegate<void(MacAddress mac, uint16_t aid)>
Delegate type for ‘Access Point Disconnect’ event.
Note
This event occurs every time a station is disconnected from our Access Point.
- Param mac:
MAC address of the station
- Param aid:
Association ID assigned to the station
-
using AccessPointProbeReqRecvedDelegate = Delegate<void(int rssi, MacAddress mac)>
Delegate type for ‘Access Point Probe Request Received’ event.
Note
Probe Requests are a low-level management frame which are used to determine information about our Access Point, such as which authentication modes are supported.
- Param rssi:
Signal strength
- Param mac:
Enums
-
enum WifiDisconnectReason
Reason codes for WiFi station disconnection.
See also
Values:
Variables
-
WifiEventsClass &WifiEvents
Global reference to architecture-specific implementation.
-
class WifiEventsClass
- #include <WifiEvents.h>
WiFi events class.
Public Functions
-
inline void onStationConnect(StationConnectDelegate delegateFunction)
Set callback for ‘station connected’ event.
-
inline void onStationDisconnect(StationDisconnectDelegate delegateFunction)
Set callback for ‘station disconnected’ event.
-
inline void onStationAuthModeChange(StationAuthModeChangeDelegate delegateFunction)
Set callback for ‘station authorisation mode change’ event.
-
inline void onStationGotIP(StationGotIPDelegate delegateFunction)
Set callback for ‘station connected with IP address’ event.
-
inline void onAccessPointConnect(AccessPointConnectDelegate delegateFunction)
Set callback for ‘access point client connected’ event.
-
inline void onAccessPointDisconnect(AccessPointDisconnectDelegate delegateFunction)
Set callback for ‘access point client disconnected’ event.
-
inline void onAccessPointProbeReqRecved(AccessPointProbeReqRecvedDelegate delegateFunction)
Set callback for ‘access point probe request received’ event.
Public Static Functions
-
static String getDisconnectReasonName(WifiDisconnectReason reason)
Get short name for disconnection reason.
-
static String getDisconnectReasonDesc(WifiDisconnectReason reason)
Get descriptive explanation for disconnect reason.
-
inline void onStationConnect(StationConnectDelegate delegateFunction)
-
WIFI_DISCONNECT_REASON_CODES_MAP(XX)