[realtek-ambz] Fix WiFi AP mode and DNS
This commit is contained in:
@@ -71,6 +71,12 @@ class WiFiClass {
|
||||
static uint8_t calculateSubnetCIDR(IPAddress subnetMask);
|
||||
static String macToString(uint8_t *mac);
|
||||
|
||||
static void resetNetworkInfo(WiFiNetworkInfo &info);
|
||||
|
||||
private: /* WiFiGeneric.cpp */
|
||||
bool restoreSTAConfig(const WiFiNetworkInfo &info);
|
||||
bool restoreAPConfig(const WiFiNetworkInfo &info);
|
||||
|
||||
protected: /* WiFiEvents.cpp */
|
||||
static std::vector<EventHandler> handlers;
|
||||
|
||||
|
||||
@@ -119,3 +119,36 @@ String WiFiClass::macToString(uint8_t *mac) {
|
||||
sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
return macStr;
|
||||
}
|
||||
|
||||
void WiFiClass::resetNetworkInfo(WiFiNetworkInfo &info) {
|
||||
LT_VM(WIFI, "Resetting network info: %s", info.ssid);
|
||||
free(info.ssid);
|
||||
free(info.password);
|
||||
free(info.bssid);
|
||||
// wipe the structure, except IP addresses
|
||||
memset(&info, 0x00, sizeof(WiFiNetworkInfo) - 5 * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
bool WiFiClass::restoreSTAConfig(const WiFiNetworkInfo &info) {
|
||||
LT_DM(WIFI, "Restoring %s config: %s", "STA", info.ssid);
|
||||
if (!info.ssid)
|
||||
return false;
|
||||
if (info.localIP) {
|
||||
LT_DM(WIFI, "Restoring STA IP config");
|
||||
if (!config(info.localIP, info.gateway, info.subnet, info.dns1, info.dns2))
|
||||
return false;
|
||||
}
|
||||
return begin(info.ssid, info.password, info.channel, info.bssid);
|
||||
}
|
||||
|
||||
bool WiFiClass::restoreAPConfig(const WiFiNetworkInfo &info) {
|
||||
LT_DM(WIFI, "Restoring %s config: %s", "AP", info.ssid);
|
||||
if (!info.ssid)
|
||||
return false;
|
||||
if (info.localIP) {
|
||||
LT_DM(WIFI, "Restoring AP IP config");
|
||||
if (!softAPConfig(info.localIP, info.gateway, info.subnet))
|
||||
return false;
|
||||
}
|
||||
return softAP(info.ssid, info.password, info.channel, info.ssidHidden);
|
||||
}
|
||||
|
||||
@@ -128,6 +128,20 @@ typedef enum {
|
||||
WIFI_REASON_ROAMING = 207,
|
||||
} wifi_err_reason_t;
|
||||
|
||||
typedef struct {
|
||||
char *ssid;
|
||||
char *password;
|
||||
uint8_t *bssid;
|
||||
bool ssidHidden;
|
||||
int channel;
|
||||
int auth;
|
||||
uint32_t localIP;
|
||||
uint32_t subnet;
|
||||
uint32_t gateway;
|
||||
uint32_t dns1;
|
||||
uint32_t dns2;
|
||||
} WiFiNetworkInfo;
|
||||
|
||||
typedef struct {
|
||||
char *ssid;
|
||||
WiFiAuthMode auth;
|
||||
|
||||
Reference in New Issue
Block a user