Quellcode durchsuchen

Add setting to force wifi into 802.11b mode

Christopher Mullins vor 6 Jahren
Ursprung
Commit
e62e61856b

Datei-Diff unterdrückt, da er zu groß ist
+ 2 - 2
dist/index.html.gz.h


+ 2 - 0
lib/Settings/Settings.cpp

@@ -99,6 +99,7 @@ void Settings::patch(JsonObject parsedSettings) {
   this->setIfPresent(parsedSettings, "wifi_static_ip_netmask", wifiStaticIPNetmask);
   this->setIfPresent(parsedSettings, "packet_repeats_per_loop", packetRepeatsPerLoop);
   this->setIfPresent(parsedSettings, "home_assistant_discovery_prefix", homeAssistantDiscoveryPrefix);
+  this->setIfPresent(parsedSettings, "wifi_force_b_mode", wifiForceBMode);
 
   if (parsedSettings.containsKey("rf24_channels")) {
     JsonArray arr = parsedSettings["rf24_channels"];
@@ -283,6 +284,7 @@ void Settings::serialize(Print& stream, const bool prettyPrint) {
   root["wifi_static_ip_netmask"] = this->wifiStaticIPNetmask;
   root["packet_repeats_per_loop"] = this->packetRepeatsPerLoop;
   root["home_assistant_discovery_prefix"] = this->homeAssistantDiscoveryPrefix;
+  root["wifi_force_b_mode"] = this->wifiForceBMode;
 
   JsonArray channelArr = root.createNestedArray("rf24_channels");
   JsonHelpers::vectorToJsonArr<RF24Channel, String>(channelArr, rf24Channels, RF24ChannelHelpers::nameFromValue);

+ 2 - 0
lib/Settings/Settings.h

@@ -113,6 +113,7 @@ public:
     groupStateFields(DEFAULT_GROUP_STATE_FIELDS),
     rf24ListenChannel(RF24Channel::RF24_LOW),
     packetRepeatsPerLoop(10),
+    wifiForceBMode(false),
     _autoRestartPeriod(0)
   { }
 
@@ -185,6 +186,7 @@ public:
   std::map<String, BulbId> groupIdAliases;
   std::map<uint32_t, BulbId> deletedGroupIdAliases;
   String homeAssistantDiscoveryPrefix;
+  bool wifiForceBMode;
 
 protected:
   size_t _autoRestartPeriod;

+ 6 - 0
src/main.cpp

@@ -271,6 +271,12 @@ void applySettings() {
   }
 
   WiFi.hostname(settings.hostname);
+
+  if (settings.wifiForceBMode) {
+    WiFi.setPhyMode(WIFI_PHY_MODE_11B);
+  } else {
+    WiFi.setPhyMode(WIFI_PHY_MODE_11G);
+  }
 }
 
 /**

+ 2 - 1
test/remote/spec/settings_spec.rb

@@ -28,7 +28,8 @@ RSpec.describe 'Settings' do
       {
         'simple_mqtt_client_status' => [true, false],
         'packet_repeats_per_loop' => [10],
-        'home_assistant_discovery_prefix' => ['', 'abc', 'a/b/c']
+        'home_assistant_discovery_prefix' => ['', 'abc', 'a/b/c'],
+        'wifi_force_b_mode' => [true, false]
       }.each do |key, values|
         values.each do |v|
           @client.patch_settings({key => v})

+ 10 - 0
web/src/js/script.js

@@ -79,6 +79,16 @@ var UI_FIELDS = [ {
     type: "string",
     tab: "tab-wifi"
   }, {
+    tag: "wifi_force_b_mode",
+    friendly: "Force 802.11b Mode",
+    help: "If true, force the ESP8266 into 802.11b mode.  Try this if you're having wifi stability problems.",
+    type: "option_buttons",
+    options: {
+      'true': 'True',
+      'false': 'False'
+    },
+    tab: "tab-wifi"
+  }, {
     tag: "ce_pin",
     friendly: "CE / PKT pin",
     help: "Pin on ESP8266 used for 'CE' (for NRF24L01 interface) or 'PKT' (for 'PL1167/LT8900' interface)",