WiFi Events¶
-
group
wifi_ev
Event callback interface for WiFi events.
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
-
typedef Delegate<void(const String &ssid, MacAddress bssid, uint8_t channel)>
StationConnectDelegate
¶ 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.
- Parameters
ssid
:bssid
:channel
:
-
typedef Delegate<void(const String &ssid, MacAddress bssid, WifiDisconnectReason reason)>
StationDisconnectDelegate
¶ 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.
- When the station is already connected to the AP, and a manual disconnect or re-configuration is taking place. e.g.
- Parameters
ssid
: SSID from which we’ve disconnectedbssid
:reason
: Why the connection was dropped
-
typedef Delegate<void(WifiAuthMode oldMode, WifiAuthMode newMode)>
StationAuthModeChangeDelegate
¶ 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.
- Parameters
oldMode
:newMode
:
-
typedef Delegate<void(IpAddress ip, IpAddress netmask, IpAddress gateway)>
StationGotIPDelegate
¶ 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.
- Parameters
ip
:netmask
:gateway
:
-
typedef Delegate<void(MacAddress mac, uint16_t aid)>
AccessPointConnectDelegate
¶ Delegate type for ‘Access Point Connect’ event.
- Note
- This event occurs every time a station is connected to our Access Point.
- Parameters
mac
: MAC address of the stationaid
: Association ID representing the connected station
-
typedef Delegate<void(MacAddress mac, uint16_t aid)>
AccessPointDisconnectDelegate
¶ Delegate type for ‘Access Point Disconnect’ event.
- Note
- This event occurs every time a station is disconnected from our Access Point.
- Parameters
mac
: MAC address of the stationaid
: Association ID assigned to the station
-
typedef Delegate<void(int rssi, MacAddress mac)>
AccessPointProbeReqRecvedDelegate
¶ Delegate type for ‘Access Point Probe Request Received’ event.
- Note
- Probe Requests are a low-level management frame which are used to determine informaton about our Access Point, such as which authentication modes are supported.
- Parameters
rssi
: Signal strengthmac
:
Enums
-
enum
WifiDisconnectReason
¶ Reason codes for WiFi station disconnection.
Values:
Variables
-
WifiEventsClass &
WifiEvents
¶ Global reference to architecture-specific implementation.
-
class
WifiEventsClass
¶ - #include <WifiEvents.h>
WiFi events class.
Public Functions
-
void
onStationConnect
(StationConnectDelegate delegateFunction)¶ Set callback for ‘station connected’ event.
-
void
onStationDisconnect
(StationDisconnectDelegate delegateFunction)¶ Set callback for ‘station disconnected’ event.
-
void
onStationAuthModeChange
(StationAuthModeChangeDelegate delegateFunction)¶ Set callback for ‘station authorisation mode change’ event.
-
void
onStationGotIP
(StationGotIPDelegate delegateFunction)¶ Set callback for ‘station connected with IP address’ event.
-
void
onAccessPointConnect
(AccessPointConnectDelegate delegateFunction)¶ Set callback for ‘access point client connected’ event.
-
void
onAccessPointDisconnect
(AccessPointDisconnectDelegate delegateFunction)¶ Set callback for ‘access point client disconnected’ event.
-
void
onAccessPointProbeReqRecved
(AccessPointProbeReqRecvedDelegate delegateFunction)¶ Set callback for ‘access point probe request received’ event.
-
void
-