Skip to content

Commit 1133ee8

Browse files
committed
Reduce reliance on ESPNOW compile guards
1 parent 86db8c7 commit 1133ee8

File tree

6 files changed

+7
-18
lines changed

6 files changed

+7
-18
lines changed

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,6 @@ void beginI2C()
762762
//Depending on radio selection, begin hardware
763763
void radioStart()
764764
{
765-
#ifdef COMPILE_ESPNOW
766765
if (settings.radioType == RADIO_EXTERNAL)
767766
{
768767
espnowStop();
@@ -773,7 +772,6 @@ void radioStart()
773772
{
774773
espnowStart();
775774
}
776-
#endif
777775
}
778776

779777
//Start task to determine SD card size

Firmware/RTK_Surveyor/Display.ino

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,6 @@ uint32_t setESPNowIcon_TwoRadios()
796796
{
797797
uint32_t icons = 0;
798798

799-
#ifdef COMPILE_ESPNOW
800-
801799
if (espnowState == ESPNOW_PAIRED)
802800
{
803801
//Limit how often we update this spot
@@ -866,7 +864,6 @@ uint32_t setESPNowIcon_TwoRadios()
866864
else
867865
icons |= ICON_BLANK_LEFT;
868866
}
869-
#endif //ifdef COMPILE_ESPNOW
870867

871868
return icons;
872869
}

Firmware/RTK_Surveyor/NVM.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,6 @@ bool parseLine(char* str, Settings *settings)
10061006
}
10071007

10081008
//Scan for ESPNOW peers
1009-
#ifdef COMPILE_ESPNOW
10101009
if (knownSetting == false)
10111010
{
10121011
for (int x = 0 ; x < ESPNOW_MAX_PEERS ; x++)
@@ -1031,7 +1030,6 @@ bool parseLine(char* str, Settings *settings)
10311030
}
10321031
}
10331032
}
1034-
#endif //ifdef COMPILE_ESPNOW
10351033

10361034
//Last catch
10371035
if (knownSetting == false)

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,14 @@ uint8_t espnowOutgoingSpot = 0; //ESP Now has max of 250 characters
406406
uint16_t espnowBytesSent = 0; //May be more than 255
407407
uint8_t receivedMAC[6]; //Holds the broadcast MAC during pairing
408408

409-
int espnowRSSI = 0;
410409
int packetRSSI = 0;
411410
unsigned long lastEspnowRssiUpdate = 0;
412411

413-
const uint8_t ESPNOW_MAX_PEERS = 5; //Maximum of 5 rovers
414412
#endif
413+
414+
int espnowRSSI = 0;
415+
const uint8_t ESPNOW_MAX_PEERS = 5; //Maximum of 5 rovers
416+
415417
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
416418

417419
//Global variables
@@ -904,7 +906,6 @@ void updateRadio()
904906
//then we've reached the end of the RTCM stream. Send partial buffer.
905907
if (espnowOutgoingSpot > 0 && (millis() - espnowLastAdd) > 50)
906908
{
907-
908909
if (settings.espnowBroadcast == false)
909910
esp_now_send(0, (uint8_t *) &espnowOutgoing, espnowOutgoingSpot); //Send partial packet to all peers
910911
else

Firmware/RTK_Surveyor/States.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,6 @@ void updateSystemState()
889889

890890
case (STATE_ESPNOW_PAIRING):
891891
{
892-
#ifdef COMPILE_ESPNOW
893892
if (espnowIsPaired() == true)
894893
{
895894
paintEspNowPaired();
@@ -902,7 +901,6 @@ void updateSystemState()
902901
uint8_t broadcastMac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
903902
espnowSendPairMessage(broadcastMac); //Send unit's MAC address over broadcast, no ack, no encryption
904903
}
905-
#endif
906904
}
907905
break;
908906

Firmware/RTK_Surveyor/WiFi.ino

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,9 @@ void wifiStartAP()
136136
//Start in AP mode
137137
WiFi.mode(WIFI_AP);
138138

139-
#ifdef COMPILE_ESPNOW
140-
// Return protocol to default settings (no WIFI_PROTOCOL_LR for ESP NOW)
141-
esp_wifi_set_protocol(WIFI_IF_AP, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N); //Stops WiFi AP.
142-
#endif
139+
//Before attempting WiFiMulti connect, be sure we have default WiFi protocols enabled.
140+
//This must come after WiFi.mode
141+
esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N);
143142

144143
IPAddress local_IP(192, 168, 4, 1);
145144
IPAddress gateway(192, 168, 4, 1);
@@ -337,7 +336,6 @@ void wifiStop()
337336
WiFi.mode(WIFI_OFF);
338337
log_d("WiFi Stopped");
339338

340-
#ifdef COMPILE_ESPNOW
341339
//If ESP-Now is active, change protocol to only Long Range and re-start WiFi
342340
if (espnowState > ESPNOW_OFF)
343341
{
@@ -348,7 +346,6 @@ void wifiStop()
348346

349347
log_d("WiFi disabled, ESP-Now left in place");
350348
}
351-
#endif
352349

353350
//Display the heap state
354351
reportHeapNow();

0 commit comments

Comments
 (0)