Add ESP32 setPhyMode in WiFi Init and force HT20
This commit is contained in:
parent
5bffce9297
commit
5680069768
@ -190,10 +190,29 @@ int WiFiHelper::getPhyMode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool WiFiHelper::setPhyMode(WiFiPhyMode_t mode) {
|
bool WiFiHelper::setPhyMode(WiFiPhyMode_t mode) {
|
||||||
// 1 = B
|
/*
|
||||||
// 2 = BG
|
mode 1 = B
|
||||||
// 3 = BGN
|
mode 2 = BG
|
||||||
// 4 = BGNAX
|
mode 3 = BGN
|
||||||
|
mode 4 = BGNAX
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
ESPEasy:
|
||||||
|
HT20 = 20 MHz channel width.
|
||||||
|
HT40 = 40 MHz channel width.
|
||||||
|
In theory, HT40 can offer upto 150 Mbps connection speed.
|
||||||
|
However since HT40 is using nearly all channels on 2.4 GHz WiFi,
|
||||||
|
Thus you are more likely to experience disturbances.
|
||||||
|
The response speed and stability is better at HT20 for ESP units.
|
||||||
|
*/
|
||||||
|
esp_wifi_set_bandwidth(WIFI_IF_STA, WIFI_BW_HT20);
|
||||||
|
/*
|
||||||
|
ESPEasy:
|
||||||
|
Set to use "Long GI" making it more resilliant to reflections
|
||||||
|
See: https://www.tp-link.com/us/configuration-guides/q_a_basic_wireless_concepts/?configurationId=2958#_idTextAnchor038
|
||||||
|
*/
|
||||||
|
esp_wifi_config_80211_tx_rate(WIFI_IF_STA, WIFI_PHY_RATE_MCS3_LGI);
|
||||||
|
|
||||||
uint8_t protocol_bitmap = WIFI_PROTOCOL_11B; // 1
|
uint8_t protocol_bitmap = WIFI_PROTOCOL_11B; // 1
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 4: protocol_bitmap |= WIFI_PROTOCOL_11AX; // 16
|
case 4: protocol_bitmap |= WIFI_PROTOCOL_11AX; // 16
|
||||||
|
|||||||
@ -329,13 +329,9 @@ void WifiBegin(uint8_t flag, uint8_t channel) {
|
|||||||
|
|
||||||
WiFiSetSleepMode();
|
WiFiSetSleepMode();
|
||||||
WifiSetOutputPower();
|
WifiSetOutputPower();
|
||||||
// if (WiFiHelper::getPhyMode() != WIFI_PHY_MODE_11N) { WiFiHelper::setPhyMode(WIFI_PHY_MODE_11N); } // B/G/N
|
|
||||||
// if (WiFiHelper::getPhyMode() != WIFI_PHY_MODE_11G) { WiFiHelper::setPhyMode(WIFI_PHY_MODE_11G); } // B/G
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
if (Wifi.phy_mode) {
|
WiFiHelper::setPhyMode(WiFiPhyMode_t((Wifi.phy_mode > 0) ? Wifi.phy_mode : 4)); // 1-B/2-BG/3-BGN/4-BGNAX
|
||||||
WiFiHelper::setPhyMode(WiFiPhyMode_t(Wifi.phy_mode)); // 1-B/2-BG/3-BGN/4-BGNAX
|
#endif // ESP32
|
||||||
}
|
|
||||||
#endif
|
|
||||||
WiFi.setAutoReconnect(true);
|
WiFi.setAutoReconnect(true);
|
||||||
switch (flag) {
|
switch (flag) {
|
||||||
case 0: // AP1
|
case 0: // AP1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user