Skip to content

Commit a93bf56

Browse files
committed
Fix for ESP-Now one to many fail bug
See: espressif/esp-idf#8992 The bug may be fixed in v2.0.4.
1 parent 5f6b007 commit a93bf56

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Firmware/RTK_Surveyor/ESPNOW.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void espnowOnDataReceived(const uint8_t *mac, const uint8_t *incomingData, int l
6363

6464
//Pass RTCM bytes (presumably) from ESP NOW out ESP32-UART2 to ZED-UART1
6565
serialGNSS.write(incomingData, len);
66-
if(!inMainMenu) log_d("ESPNOW received %d RTCM bytes, pushed to ZED, RSSI: %d", len, espnowRSSI);
66+
if (!inMainMenu) log_d("ESPNOW received %d RTCM bytes, pushed to ZED, RSSI: %d", len, espnowRSSI);
6767

6868
espnowIncomingRTCM = true;
6969
lastEspnowRssiUpdate = millis();
@@ -93,7 +93,9 @@ void espnowStart()
9393
if (wifiState == WIFI_OFF && espnowState == ESPNOW_OFF)
9494
{
9595
//Radio is off, turn it on
96+
WiFi.useStaticBuffers(true); //Fix for one to many ESP-Now bug, prior to ESP32 core v2.0.4: https://github.com/espressif/esp-idf/issues/8992
9697
WiFi.mode(WIFI_STA);
98+
9799
esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_LR);
98100
Serial.println("WiFi off, ESP-Now added to protocols");
99101
}
@@ -230,7 +232,7 @@ bool espnowIsPaired()
230232

231233
//Enable radio. User may have arrived here from the setup menu rather than serial menu.
232234
settings.radioType = RADIO_ESPNOW;
233-
235+
234236
recordSystemSettings(); //Record radioType and espnowPeerCount to NVM
235237

236238
espnowSetState(ESPNOW_PAIRED);
@@ -350,7 +352,7 @@ void espnowProcessRTCM(byte incoming)
350352
espnowOutgoingSpot = 0; //Wrap
351353
esp_now_send(0, (uint8_t *) &espnowOutgoing, sizeof(espnowOutgoing)); //Send packet to all peers
352354
delay(10); //We need a small delay between sending multiple packets
353-
355+
354356
espnowBytesSent += sizeof(espnowOutgoing);
355357

356358
espnowOutgoingRTCM = true;

Firmware/RTK_Surveyor/WiFi.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ void wifiStart(char* ssid, char* pw)
209209
#ifdef COMPILE_WIFI
210210
if ((wifiState == WIFI_OFF) || (wifiState == WIFI_ON))
211211
{
212+
WiFi.useStaticBuffers(true); //Fix for one to many ESP-Now bug, prior to ESP32 core v2.0.4: https://github.com/espressif/esp-idf/issues/8992
212213
WiFi.mode(WIFI_STA);
213214

214215
#ifdef COMPILE_ESPNOW
@@ -256,6 +257,7 @@ void wifiStop()
256257
//If ESP-Now is active, change protocol to only Long Range
257258
else if (espnowState > ESPNOW_OFF)
258259
{
260+
WiFi.useStaticBuffers(true); //Fix for one to many ESP-Now bug, prior to ESP32 core v2.0.4: https://github.com/espressif/esp-idf/issues/8992
259261
WiFi.mode(WIFI_STA);
260262

261263
// Enable long range, PHY rate of ESP32 will be 512Kbps or 256Kbps

0 commit comments

Comments
 (0)