Skip to content

Commit 738df18

Browse files
blazonceksofthack007
authored andcommitted
Fix for wled#2922
1 parent 4bbf1ba commit 738df18

File tree

6 files changed

+7
-3
lines changed

6 files changed

+7
-3
lines changed

wled00/cfg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
8383

8484
noWifiSleep = doc[F("wifi")][F("sleep")] | !noWifiSleep; // inverted
8585
noWifiSleep = !noWifiSleep;
86-
//int wifi_phy = doc[F("wifi")][F("phy")]; //force phy mode n?
86+
force802_3g = doc[F("wifi")][F("phy")] | force802_3g; //force phy mode g?
8787

8888
JsonObject hw = doc[F("hw")];
8989

@@ -735,7 +735,7 @@ void serializeConfig() {
735735

736736
JsonObject wifi = doc.createNestedObject("wifi");
737737
wifi[F("sleep")] = !noWifiSleep;
738-
//wifi[F("phy")] = 1;
738+
wifi[F("phy")] = (int)force802_3g;
739739

740740
#ifdef WLED_USE_ETHERNET
741741
JsonObject ethernet = doc.createNestedObject("eth");

wled00/data/settings_wifi.htm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ <h3>Configure Access Point</h3>
178178
<option value="3">Never (not recommended)</option></select><br>
179179
AP IP: <span class="sip"> Not active </span><br>
180180
<h3>Experimental</h3>
181+
Force 802.11g mode (ESP8266 only): <input type="checkbox" name="FG"><br>
181182
Disable WiFi sleep: <input type="checkbox" name="WS"><br>
182183
<i>Can help with connectivity issues.<br>
183184
Do not enable if WiFi is working correctly, increases power consumption.</i>

wled00/set.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
4646
if (passlen == 0 || (passlen > 7 && !isAsterisksOnly(request->arg(F("AP")).c_str(), 65))) strlcpy(apPass, request->arg(F("AP")).c_str(), 65);
4747
int t = request->arg(F("AC")).toInt(); if (t > 0 && t < 14) apChannel = t;
4848

49+
force802_3g = request->hasArg(F("FG"));
4950
noWifiSleep = request->hasArg(F("WS"));
5051

5152
#ifndef WLED_DISABLE_ESPNOW

wled00/wled.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ void WLED::initConnection()
10271027

10281028
WiFi.disconnect(true); // close old connections
10291029
#ifdef ESP8266
1030-
WiFi.setPhyMode(WIFI_PHY_MODE_11N);
1030+
WiFi.setPhyMode(force802_3g ? WIFI_PHY_MODE_11G : WIFI_PHY_MODE_11N);
10311031
#endif
10321032

10331033
if (staticIP[0] != 0 && staticGateway[0] != 0) {

wled00/wled.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ WLED_GLOBAL bool noWifiSleep _INIT(true); // disabling
342342
#else
343343
WLED_GLOBAL bool noWifiSleep _INIT(false);
344344
#endif
345+
WLED_GLOBAL bool force802_3g _INIT(false);
345346

346347
#ifdef WLED_USE_ETHERNET
347348
#ifdef WLED_ETH_DEFAULT // default ethernet board type if specified

wled00/xml.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ void getSettingsJS(AsyncWebServerRequest* request, byte subPage, char* dest) //W
343343
sappends('s',SET_F("AP"),fapass);
344344

345345
sappend('v',SET_F("AC"),apChannel);
346+
sappend('c',SET_F("FG"),force802_3g);
346347
sappend('c',SET_F("WS"),noWifiSleep);
347348

348349
#ifndef WLED_DISABLE_ESPNOW

0 commit comments

Comments
 (0)