mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-13 23:45:25 +00:00
Add option to disable 802.11b data rates
This commit is contained in:
parent
84fe477783
commit
7c5a1b1fb8
@ -47,7 +47,7 @@ struct WiFiConfig {
|
||||
bool mdns;
|
||||
uint8_t power;
|
||||
uint8_t sleep;
|
||||
uint8_t mode;
|
||||
uint8_t use11b;
|
||||
bool autoreboot;
|
||||
}; // 213
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ bool AmsConfiguration::setWiFiConfig(WiFiConfig& config) {
|
||||
wifiChanged |= strcmp(config.hostname, existing.hostname) != 0;
|
||||
wifiChanged |= config.power != existing.power;
|
||||
wifiChanged |= config.sleep != existing.sleep;
|
||||
wifiChanged |= config.mode != existing.mode;
|
||||
wifiChanged |= config.use11b != existing.use11b;
|
||||
wifiChanged |= config.autoreboot != existing.autoreboot;
|
||||
} else {
|
||||
wifiChanged = true;
|
||||
@ -94,6 +94,7 @@ void AmsConfiguration::clearWifi(WiFiConfig& config) {
|
||||
strcpy(config.hostname, (String("ams-") + String(chipId, HEX)).c_str());
|
||||
config.mdns = true;
|
||||
config.sleep = 0xFF;
|
||||
config.use11b = 1;
|
||||
}
|
||||
|
||||
void AmsConfiguration::clearWifiIp(WiFiConfig& config) {
|
||||
@ -1002,7 +1003,7 @@ bool AmsConfiguration::relocateConfig96() {
|
||||
|
||||
WiFiConfig wifi;
|
||||
EEPROM.get(CONFIG_WIFI_START, wifi);
|
||||
wifi.mode = 1; // WIFI_STA
|
||||
wifi.use11b = 1;
|
||||
wifi.autoreboot = true;
|
||||
EEPROM.put(CONFIG_WIFI_START, wifi);
|
||||
|
||||
|
||||
2
lib/SvelteUi/app/dist/index.css
vendored
2
lib/SvelteUi/app/dist/index.css
vendored
File diff suppressed because one or more lines are too long
18
lib/SvelteUi/app/dist/index.js
vendored
18
lib/SvelteUi/app/dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -60,7 +60,7 @@
|
||||
e: { e: false, k: '', a: '' },
|
||||
m: { e: false, w: false, v: false, a: false, c: false }
|
||||
},
|
||||
w: { s: '', p: '', w: 0.0, z: 255, a: true },
|
||||
w: { s: '', p: '', w: 0.0, z: 255, a: true, b: true },
|
||||
n: {
|
||||
m: '', i: '', s: '', g: '', d1: '', d2: '', d: false, n1: '', n2: '', h: false
|
||||
},
|
||||
@ -404,6 +404,9 @@
|
||||
<div class="my-3">
|
||||
<label><input type="checkbox" name="wa" value="true" bind:checked={configuration.w.a} class="rounded mb-1"/> Auto reboot on connection problem</label>
|
||||
</div>
|
||||
<div class="my-3">
|
||||
<label><input type="checkbox" name="wb" value="true" bind:checked={configuration.w.b} class="rounded mb-1"/> Allow 802.11b legacy rates</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cnt">
|
||||
<strong class="text-sm">Network</strong>
|
||||
|
||||
@ -3,5 +3,6 @@
|
||||
"p": "%s",
|
||||
"w": %.1f,
|
||||
"z": %d,
|
||||
"a": %s
|
||||
"a": %s,
|
||||
"b": %s
|
||||
},
|
||||
|
||||
@ -877,7 +877,8 @@ void AmsWebServer::configurationJson() {
|
||||
strlen(wifiConfig.psk) > 0 ? "***" : "",
|
||||
wifiConfig.power / 10.0,
|
||||
wifiConfig.sleep,
|
||||
wifiConfig.autoreboot ? "true" : "false"
|
||||
wifiConfig.autoreboot ? "true" : "false",
|
||||
wifiConfig.use11b ? "true" : "false"
|
||||
);
|
||||
server.sendContent(buf);
|
||||
snprintf_P(buf, BufferSize, CONF_NET_JSON,
|
||||
@ -1131,7 +1132,6 @@ void AmsWebServer::handleSave() {
|
||||
if(!psk.equals("***")) {
|
||||
strcpy(wifi.psk, psk.c_str());
|
||||
}
|
||||
wifi.mode = 1; // WIFI_STA
|
||||
|
||||
if(server.hasArg(F("sm")) && server.arg(F("sm")) == "static") {
|
||||
strcpy(wifi.ip, server.arg(F("si")).c_str());
|
||||
@ -1157,7 +1157,6 @@ void AmsWebServer::handleSave() {
|
||||
meterConfig->baud = 2400;
|
||||
meterConfig->parity = 3; // 8N1
|
||||
case 2: // spenceme
|
||||
case 8: // dbeinder: HAN mosquito
|
||||
case 50: // Generic ESP32-S2
|
||||
case 51: // Wemos S2 mini
|
||||
case 70: // Generic ESP32-C3
|
||||
@ -1168,6 +1167,10 @@ void AmsWebServer::handleSave() {
|
||||
case 7: // Pow-U+
|
||||
wifi.sleep = 2; // Light sleep
|
||||
break;
|
||||
case 8: // dbeinder: HAN mosquito
|
||||
wifi.sleep = 1; // Modem sleep
|
||||
wifi.use11b = 0;
|
||||
break;
|
||||
}
|
||||
config->setWiFiConfig(wifi);
|
||||
config->setMeterConfig(*meterConfig);
|
||||
@ -1236,6 +1239,7 @@ void AmsWebServer::handleSave() {
|
||||
wifi.power = server.arg(F("ww")).toFloat() * 10;
|
||||
wifi.sleep = server.arg(F("wz")).toInt();
|
||||
wifi.autoreboot = server.hasArg(F("wa")) && server.arg(F("wa")) == F("true");
|
||||
wifi.use11b = server.hasArg(F("wb")) && server.arg(F("wb")) == F("true");
|
||||
config->setWiFiConfig(wifi);
|
||||
|
||||
if(server.hasArg(F("nm"))) {
|
||||
@ -1915,6 +1919,7 @@ void AmsWebServer::configFileDownload() {
|
||||
if(strlen(wifi.dns2) > 0) server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("dns2 %s\n"), wifi.dns2));
|
||||
}
|
||||
server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("mdns %d\n"), wifi.mdns ? 1 : 0));
|
||||
server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("use11b %d\n"), wifi.use11b ? 1 : 0));
|
||||
}
|
||||
|
||||
if(includeMqtt) {
|
||||
|
||||
@ -30,6 +30,7 @@ ADC_MODE(ADC_VCC);
|
||||
#endif
|
||||
|
||||
#if defined(ESP32)
|
||||
#include <esp_wifi.h>
|
||||
#include <esp_task_wdt.h>
|
||||
#include <lwip/dns.h>
|
||||
#endif
|
||||
@ -125,6 +126,7 @@ AmsDataStorage ds(&Debug);
|
||||
EnergyAccounting ea(&Debug);
|
||||
|
||||
uint8_t wifiReconnectCount = 0;
|
||||
bool wifiDisable11b = false;
|
||||
|
||||
HDLCParser *hdlcParser = NULL;
|
||||
MBUSParser *mbusParser = NULL;
|
||||
@ -167,6 +169,14 @@ uint8_t dnsState = 0;
|
||||
ip_addr_t dns0;
|
||||
void WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||
switch(event) {
|
||||
#if defined(ESP32)
|
||||
case ARDUINO_EVENT_WIFI_READY:
|
||||
if (wifiDisable11b) {
|
||||
esp_wifi_config_11b_rate(WIFI_IF_AP, true);
|
||||
esp_wifi_config_11b_rate(WIFI_IF_STA, true);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP: {
|
||||
const ip_addr_t* dns = dns_getserver(0);
|
||||
memcpy(&dns0, dns, sizeof(dns0));
|
||||
@ -315,6 +325,12 @@ void setup() {
|
||||
WiFi.softAPdisconnect(true);
|
||||
WiFi.mode(WIFI_OFF);
|
||||
|
||||
WiFiConfig wifiConf;
|
||||
if(config.getWiFiConfig(wifiConf)) {
|
||||
wifiDisable11b = !wifiConf.use11b;
|
||||
}
|
||||
WiFi.onEvent(WiFiEvent);
|
||||
|
||||
bool hasFs = false;
|
||||
#if defined(ESP32)
|
||||
debugD_P(PSTR("ESP32 LittleFS"));
|
||||
@ -1381,8 +1397,7 @@ void WiFi_connect() {
|
||||
#if defined(ESP32)
|
||||
if(strlen(wifi.hostname) > 0) {
|
||||
WiFi.setHostname(wifi.hostname);
|
||||
}
|
||||
WiFi.onEvent(WiFiEvent);
|
||||
}
|
||||
#endif
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
@ -1899,6 +1914,9 @@ void configFileParse() {
|
||||
} else if(strncmp_P(buf, PSTR("hostname "), 9) == 0) {
|
||||
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
||||
strcpy(wifi.hostname, buf+9);
|
||||
} else if(strncmp_P(buf, PSTR("use11b "), 7) == 0) {
|
||||
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
||||
wifi.use11b = String(buf+7).toInt() == 1;
|
||||
} else if(strncmp_P(buf, PSTR("mdns "), 5) == 0) {
|
||||
if(!lWiFi) { config.getWiFiConfig(wifi); lWiFi = true; };
|
||||
wifi.mdns = String(buf+5).toInt() == 1;;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user