feat: wifiscan
This commit is contained in:
@@ -7,6 +7,18 @@ public:
|
||||
NetworkManager(NodeContext& ctx);
|
||||
void setupWiFi();
|
||||
void setHostnameFromMac();
|
||||
void startWiFiScan();
|
||||
void updateWiFiScan();
|
||||
bool isWiFiScanning() const;
|
||||
void processScanResults(int networksFound);
|
||||
void initTasks(); // Initialize tasks after TaskManager is ready // Public method to process scan results
|
||||
|
||||
private:
|
||||
NodeContext& ctx;
|
||||
bool wifiScanInProgress;
|
||||
unsigned long wifiScanStartTime;
|
||||
static const unsigned long WIFI_SCAN_TIMEOUT_MS = 10000; // 10 seconds timeout
|
||||
static const char* const WIFI_SCAN_MONITOR_TASK; // Task name for WiFi scan monitoring
|
||||
|
||||
void onWiFiScanComplete(int networksFound); // Keep private for internal use
|
||||
};
|
||||
|
||||
@@ -2,12 +2,33 @@
|
||||
|
||||
#include <WiFiUdp.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "NodeInfo.h"
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <initializer_list>
|
||||
#include "Config.h"
|
||||
|
||||
// Forward declaration
|
||||
class TaskManager;
|
||||
|
||||
// WiFi access point structure
|
||||
struct WiFiAccessPoint {
|
||||
String ssid;
|
||||
int32_t rssi;
|
||||
uint8_t encryption;
|
||||
uint8_t* bssid;
|
||||
int32_t channel;
|
||||
bool isHidden;
|
||||
|
||||
WiFiAccessPoint() : rssi(0), encryption(0), bssid(nullptr), channel(0), isHidden(false) {}
|
||||
~WiFiAccessPoint() {
|
||||
if (bssid) {
|
||||
delete[] bssid;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class NodeContext {
|
||||
public:
|
||||
NodeContext();
|
||||
@@ -19,10 +40,14 @@ public:
|
||||
NodeInfo self;
|
||||
std::map<String, NodeInfo>* memberList;
|
||||
Config config;
|
||||
TaskManager* taskManager;
|
||||
|
||||
using EventCallback = std::function<void(void*)>;
|
||||
std::map<std::string, std::vector<EventCallback>> eventRegistry;
|
||||
|
||||
void on(const std::string& event, EventCallback cb);
|
||||
void fire(const std::string& event, void* data);
|
||||
|
||||
// WiFi access points storage
|
||||
std::vector<WiFiAccessPoint>* wifiAccessPoints;
|
||||
};
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "NodeContext.h"
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
// Forward declaration
|
||||
class NodeContext;
|
||||
|
||||
// Define our own callback type to avoid conflict with TaskScheduler
|
||||
using TaskFunction = std::function<void()>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user