Auto hotspot implementation

This commit is contained in:
Robin Davies
2024-09-11 00:06:52 -04:00
parent bbfd0a07fd
commit 448979e7fe
61 changed files with 5234 additions and 178 deletions
@@ -21,6 +21,23 @@
#include "json.hpp"
#ifndef NEW_WIFI_CONFIG
// 0-> Old hostapd-based hotspot. Now dead code. Works with buster only.
// 1-> NetworkManager-based hotspot (supported on bookworm or later).
#define NEW_WIFI_CONFIG 1
#endif
// Wifi P2P broken completely on Debian 12 updates on raspberry pi.
//
// Setting it to enable uses current-orphaned dead code as of PiPedal v1.2.49
//
// 0: disable.
// 1: enable.
#ifndef ENABLE_WIFI_P2P
#define ENABLE_WIFI_P2P 0
#endif
namespace pipedal {
@@ -30,6 +47,12 @@ namespace pipedal {
class WifiConfigSettings {
public:
using ssid_t = std::vector<uint8_t>;
WifiConfigSettings();
void Load();
void Save();
bool valid_ = false;
bool wifiWarningGiven_ = false;
bool rebootRequired_ = false;
@@ -37,13 +60,20 @@ namespace pipedal {
std::string countryCode_ = "US"; // iso 3661
std::string hotspotName_ = "pipedal";
std::string mdnsName_ = "pipedal";
std::vector<ssid_t> homeNetworks_;
bool hasPassword_ = false;
std::string password_;
std::string channel_ = "g6";
std::string channel_ = "";
bool alwaysOn_ = false;
void ParseArguments(const std::vector<std::string> &arguments);
static bool ValidateCountryCode(const std::string&value);
static bool ValidateChannel(const std::string&countryCode,const std::string&value);
bool operator==(const WifiConfigSettings&other) const;
bool ConfigurationChanged(const WifiConfigSettings&other) const;
bool WantsHotspot(bool ethernetConnected,const std::vector<ssid_t> &availableNetworks);
public:
DECLARE_JSON_MAP(WifiConfigSettings);
};