|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Public Member Functions | |
| WifiController ()=default | |
| bool | init () override |
| Initializes controller resources and event group. | |
| bool | start () override |
| Starts Wi-Fi controller service state. | |
| void | stop () override |
| Stops Wi-Fi controller and disables active Wi-Fi stack. | |
| core::ServiceState | getState () const override |
| const char * | getName () const override |
| bool | enable (WifiMode mode=WifiMode::STA) override |
| Enables Wi-Fi in requested mode and starts driver. | |
| void | disable () override |
| Disables Wi-Fi driver and resets runtime state. | |
| bool | isEnabled () const override |
| WifiMode | getMode () const override |
| WifiState | getWifiState () const override |
| bool | connect (const char *ssid, const char *password, uint32_t timeoutMs=10000) override |
| Connects STA interface to an access point. | |
| void | disconnect () override |
| Disconnects from current access point and clears connection state. | |
| bool | isConnected () const override |
| const char * | getCurrentSsid () const override |
| bool | getIpAddress (char *ip, size_t len) const override |
| Returns current STA IPv4 address as text. | |
| bool | getMacAddress (uint8_t *mac) const override |
| Reads MAC address of active Wi-Fi interface. | |
| int8_t | getRssi () const override |
| Returns RSSI of current STA connection. | |
| bool | startScan () override |
| Starts asynchronous AP scan. | |
| bool | isScanComplete () const override |
| Returns whether the last scan has completed. | |
| uint8_t | getScanResults (WifiScanResult *results, uint8_t maxResults) override |
| Copies scan results into caller buffer. | |
| bool | startAp (const char *ssid, const char *password=nullptr, uint8_t channel=1) override |
| Configures and starts soft-AP parameters. | |
| uint8_t | getConnectedStations () const override |
| Returns number of stations connected to soft-AP. | |
| void | onWifiEvent (int32_t eventId, void *eventData) |
| Handles Wi-Fi events from ESP-IDF event loop. | |
| void | onIpEvent (int32_t eventId, void *eventData) |
| Handles IP-related events from ESP-IDF event loop. | |
| Public Member Functions inherited from cdc::hal::IWifiController | |
| virtual | ~IWifiController ()=default |
| Public Member Functions inherited from cdc::core::IService | |
| virtual | ~IService ()=default |
Static Public Attributes | |
| static WifiController * | instance_ = nullptr |
| Static Public Attributes inherited from cdc::hal::IWifiController | |
| static constexpr uint8_t | MAX_SCAN_RESULTS = 32 |
ESP32 WiFi Controller Implementation
Definition at line 33 of file WifiController.cpp.
|
default |
|
overridevirtual |
Connects STA interface to an access point.
| ssid | Target SSID. |
| password | Optional passphrase. |
| timeoutMs | Timeout for waiting on connection result. |
Implements cdc::hal::IWifiController.
Definition at line 386 of file WifiController.cpp.
References cdc::hal::CONNECTING, cdc::hal::CONNECTION_FAILED, LOG_E, LOG_I, LOG_W, cdc::hal::STA, cdc::hal::STA_AP, TAG, WIFI_CONNECTED_BIT, WIFI_FAIL_BIT, and WIFI_GOT_IP_BIT.
|
overridevirtual |
Disables Wi-Fi driver and resets runtime state.
Implements cdc::hal::IWifiController.
Definition at line 347 of file WifiController.cpp.
References cdc::hal::DISCONNECTED, LOG_I, cdc::hal::OFF, and TAG.
|
overridevirtual |
Disconnects from current access point and clears connection state.
Implements cdc::hal::IWifiController.
Definition at line 446 of file WifiController.cpp.
References cdc::hal::CONNECTED, cdc::hal::DISCONNECTED, and cdc::hal::GOT_IP.
|
overridevirtual |
Enables Wi-Fi in requested mode and starts driver.
| mode | Requested Wi-Fi mode. |
Implements cdc::hal::IWifiController.
Definition at line 235 of file WifiController.cpp.
References cdc::hal::AP, console_flush(), disable(), cdc::hal::DISCONNECTED, cdc::hal::ipEventHandler(), LOG_E, LOG_I, cdc::hal::OFF, cdc::hal::STA, cdc::hal::STA_AP, cdc::core::STARTED, TAG, and cdc::hal::wifiEventHandler().
|
overridevirtual |
Returns number of stations connected to soft-AP.
Implements cdc::hal::IWifiController.
Definition at line 637 of file WifiController.cpp.
References cdc::hal::AP, and cdc::hal::STA_AP.
|
inlineoverridevirtual |
Get current SSID (when connected)
Implements cdc::hal::IWifiController.
Definition at line 55 of file WifiController.cpp.
|
overridevirtual |
Returns current STA IPv4 address as text.
| ip | Output text buffer. |
| len | Output buffer size. |
Implements cdc::hal::IWifiController.
Definition at line 461 of file WifiController.cpp.
|
overridevirtual |
Reads MAC address of active Wi-Fi interface.
| mac | Output 6-byte MAC buffer. |
Implements cdc::hal::IWifiController.
Definition at line 475 of file WifiController.cpp.
|
inlineoverridevirtual |
Get current operating mode
Implements cdc::hal::IWifiController.
Definition at line 48 of file WifiController.cpp.
|
inlineoverridevirtual |
Get service name (for logging/debugging)
Implements cdc::core::IService.
Definition at line 42 of file WifiController.cpp.
|
overridevirtual |
Returns RSSI of current STA connection.
Implements cdc::hal::IWifiController.
Definition at line 489 of file WifiController.cpp.
References cdc::hal::GOT_IP.
|
overridevirtual |
Copies scan results into caller buffer.
| results | Output result array. |
| maxResults | Maximum writable entries. |
Implements cdc::hal::IWifiController.
Definition at line 547 of file WifiController.cpp.
References cdc::hal::WifiScanResult::channel, LOG_E, cdc::hal::OPEN, cdc::hal::WifiScanResult::rssi, cdc::hal::WifiScanResult::security, cdc::hal::WifiScanResult::ssid, TAG, cdc::hal::WEP, cdc::hal::WPA2_ENTERPRISE, cdc::hal::WPA2_PSK, cdc::hal::WPA3_PSK, and cdc::hal::WPA_PSK.
|
inlineoverridevirtual |
Get current service state
Implements cdc::core::IService.
Definition at line 41 of file WifiController.cpp.
|
inlineoverridevirtual |
Get current connection state
Implements cdc::hal::IWifiController.
Definition at line 49 of file WifiController.cpp.
|
overridevirtual |
Initializes controller resources and event group.
Implements cdc::core::IService.
Definition at line 143 of file WifiController.cpp.
References cdc::core::ERROR, cdc::core::INITIALIZED, instance_, LOG_E, LOG_I, cdc::core::STARTED, TAG, and cdc::core::UNINITIALIZED.
|
inlineoverridevirtual |
Check if connected to a network
Implements cdc::hal::IWifiController.
Definition at line 54 of file WifiController.cpp.
References cdc::hal::GOT_IP.
|
inlineoverridevirtual |
Check if WiFi is currently enabled
Implements cdc::hal::IWifiController.
Definition at line 47 of file WifiController.cpp.
|
overridevirtual |
Returns whether the last scan has completed.
Implements cdc::hal::IWifiController.
Definition at line 537 of file WifiController.cpp.
| void cdc::hal::WifiController::onIpEvent | ( | int32_t | eventId, |
| void * | eventData ) |
Handles IP-related events from ESP-IDF event loop.
| eventId | Event identifier. |
| eventData | Event payload. |
Definition at line 711 of file WifiController.cpp.
References cdc::hal::CONNECTED, cdc::hal::GOT_IP, LOG_I, LOG_W, TAG, and WIFI_GOT_IP_BIT.
| void cdc::hal::WifiController::onWifiEvent | ( | int32_t | eventId, |
| void * | eventData ) |
Handles Wi-Fi events from ESP-IDF event loop.
| eventId | Event identifier. |
| eventData | Event payload. |
Definition at line 654 of file WifiController.cpp.
References cdc::hal::CONNECTED, cdc::hal::CONNECTION_FAILED, console_flush(), cdc::hal::DISCONNECTED, LOG_I, TAG, WIFI_CONNECTED_BIT, WIFI_FAIL_BIT, and WIFI_SCAN_DONE_BIT.
|
overridevirtual |
Starts Wi-Fi controller service state.
Implements cdc::core::IService.
Definition at line 168 of file WifiController.cpp.
References cdc::core::INITIALIZED, cdc::core::STARTED, and cdc::core::STOPPED.
|
overridevirtual |
Configures and starts soft-AP parameters.
| ssid | AP SSID. |
| password | Optional AP password. |
| channel | AP channel. |
Implements cdc::hal::IWifiController.
Definition at line 601 of file WifiController.cpp.
References cdc::hal::AP, LOG_E, LOG_I, cdc::hal::STA_AP, and TAG.
|
overridevirtual |
Starts asynchronous AP scan.
Implements cdc::hal::IWifiController.
Definition at line 505 of file WifiController.cpp.
References LOG_E, LOG_I, LOG_W, cdc::hal::STA, cdc::hal::STA_AP, TAG, and WIFI_SCAN_DONE_BIT.
|
overridevirtual |
Stops Wi-Fi controller and disables active Wi-Fi stack.
Implements cdc::core::IService.
Definition at line 180 of file WifiController.cpp.
References disable(), cdc::core::STARTED, and cdc::core::STOPPED.
|
static |
Definition at line 102 of file WifiController.cpp.
Referenced by init(), cdc::hal::ipEventHandler(), and cdc::hal::wifiEventHandler().