class documentation
Class to manage WiFi functionality on a MicroPython device.
| Method | __del__ |
Destructor to clean up resources. |
| Method | __init__ |
Initialize the WiFi class. |
| Method | callback |
Set the connection callback function. |
| Method | connect |
Connect to a Wi-Fi network. |
| Method | connect |
Connect to a Wi-Fi network asynchronously. |
| Method | disconnect |
Disconnect from the Wi-Fi network. |
| Method | is |
Check if the device is connected to a Wi-Fi network. |
| Method | reset |
Reset the Wi-Fi configuration. |
| Method | scan |
Scan for available Wi-Fi networks. |
| Method | status |
Get the current Wi-Fi connection status. |
| Method | timeout |
Set the connection timeout in seconds. |
| Instance Variable | connection |
The timestamp when the connection attempt started. |
| Instance Variable | connection |
The timeout duration for WiFi connections in seconds. |
| Instance Variable | error |
The last error message encountered during WiFi operations. |
| Instance Variable | mode |
The WiFi mode (STA_IF or AP_IF). |
| Instance Variable | password |
The password for the WiFi network. |
| Instance Variable | ssid |
The SSID of the WiFi network. |
| Instance Variable | wlan |
The WLAN object for managing WiFi connections. |
| Property | callback |
Get the connection callback function. |
| Property | device |
Get the current device IP address. |
| Property | last |
Get the last connection error message. |
| Property | mac |
Get the MAC address of the Wi-Fi interface. |
| Property | state |
Get the current Wi-Fi state. |
| Property | timeout |
Get the connection timeout in seconds. |
| Method | __close |
Internal method to close the background thread. |
| Method | _should |
Check if the operation should continue running. |
| Instance Variable | _callback |
Undocumented |
| Instance Variable | _current |
Undocumented |
| Instance Variable | _state |
Undocumented |
| Instance Variable | _thread |
Undocumented |
| Instance Variable | _thread |
Undocumented |
| Instance Variable | _thread |
Undocumented |
| Instance Variable | _thread |
Undocumented |
Initialize the WiFi class.
| Parameters | |
threadThreadManager | Optional ThreadManager instance for managed threading. Defaults to None. |
timeout:int | Connection timeout in seconds. Defaults to 10. |
Set the connection callback function.
The callback receives the Wi-Fi state and an error message (if any).
| Parameters | |
func:callable | The callback function to set. |
Connect to a Wi-Fi network.
| Parameters | |
ssid:str | SSID of the Wi-Fi network. |
password:str | Password for the Wi-Fi network. Defaults to "". |
stabool | True for station mode (STA_IF), False for access point mode (AP_IF). Defaults to True. |
| Returns | |
bool | True if the connection succeeded, False otherwise. |
Connect to a Wi-Fi network asynchronously.
| Parameters | |
ssid:str | SSID of the Wi-Fi network. |
password:str | Password for the Wi-Fi network. Defaults to "". |
stabool | True for station mode (STA_IF), False for access point mode (AP_IF). Defaults to True. |
| Returns | |
bool | True if the connection was started. |