roo_wifi
API Documentation for roo_wifi
Loading...
Searching...
No Matches
esp32_arduino_interface.h
Go to the documentation of this file.
1#pragma once
2
3#include "WiFi.h"
4#include "roo_collections.h"
5#include "roo_scheduler.h"
9
10namespace roo_wifi {
11
12namespace internal {
13
14/// Linked list node storing a native ESP32 event callback.
16 std::function<void(arduino_event_id_t event, arduino_event_info_t info)>
20
22 std::function<void(arduino_event_id_t event, arduino_event_info_t info)>
24 : notify_fn(notify_fn), next(nullptr), prev(nullptr) {}
25};
26
27} // namespace internal
28
29/// ESP32 Arduino Wi-Fi interface implementation.
31 public:
33
35
36 /// Initializes the underlying Wi-Fi stack and registers callbacks.
37 void begin();
38
39 /// Returns current AP information; false if not connected.
40 bool getApInfo(NetworkDetails* info) const override;
41
42 /// Starts a scan.
43 bool startScan() override;
44
45 /// Returns true if the scan has completed.
46 bool scanCompleted() const override;
47
48 /// Returns scan results, up to max_count entries.
49 bool getScanResults(std::vector<NetworkDetails>* list,
50 int max_count) const override;
51
52 /// Disconnects from the current network.
53 void disconnect() override;
54
55 /// Connects to the specified SSID/password.
56 bool connect(const std::string& ssid, const std::string& passwd) override;
57
58 /// Returns the current connection status.
59 ConnectionStatus getStatus() override;
60
61 /// Registers an interface event listener.
62 void addEventListener(EventListener* listener) override;
63
64 /// Unregisters an interface event listener.
65 void removeEventListener(EventListener* listener) override;
66
67 private:
68 void dispatchEvent(WiFiEvent_t event, WiFiEventInfo_t info);
69
71 roo_collections::FlatSmallHashSet<EventListener*> listeners_;
72
73 bool scanning_;
74};
75
76} // namespace roo_wifi
ESP32 Arduino Wi-Fi interface implementation.
bool startScan() override
Starts a scan.
void addEventListener(EventListener *listener) override
Registers an interface event listener.
bool getScanResults(std::vector< NetworkDetails > *list, int max_count) const override
Returns scan results, up to max_count entries.
bool connect(const std::string &ssid, const std::string &passwd) override
Connects to the specified SSID/password.
void removeEventListener(EventListener *listener) override
Unregisters an interface event listener.
bool getApInfo(NetworkDetails *info) const override
Returns current AP information; false if not connected.
ConnectionStatus getStatus() override
Returns the current connection status.
void disconnect() override
Disconnects from the current network.
bool scanCompleted() const override
Returns true if the scan has completed.
void begin()
Initializes the underlying Wi-Fi stack and registers callbacks.
Listener for interface events.
Definition interface.h:84
Abstraction for interacting with the hardware Wi-Fi interface.
Definition interface.h:70
ConnectionStatus
Wi-Fi connection status.
Definition interface.h:42
Detailed network information reported by the interface.
Definition interface.h:53
Linked list node storing a native ESP32 event callback.
Esp32ListenerListNode(std::function< void(arduino_event_id_t event, arduino_event_info_t info)> notify_fn)
std::function< void(arduino_event_id_t event, arduino_event_info_t info)> notify_fn