Skip to content

Commit e68fb7f

Browse files
committed
ESP-NOW: Replace espnowState with espnowGetState()
1 parent 0cd1e77 commit e68fb7f

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

Firmware/RTK_Everywhere/Display.ino

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ void setRadioIcons(std::vector<iconPropertyBlinking> *iconList)
656656
uint8_t numberOfRadios = 1; // Bluetooth always indicated. TODO don't count if BT radio type is OFF.
657657
if (WIFI_IS_RUNNING())
658658
numberOfRadios++;
659-
if (espnowState > ESPNOW_OFF)
659+
if (espnowGetState() > ESPNOW_OFF)
660660
numberOfRadios++;
661661

662662
// Bluetooth only
@@ -673,7 +673,7 @@ void setRadioIcons(std::vector<iconPropertyBlinking> *iconList)
673673
// Do we have WiFi or ESP
674674
if (WIFI_IS_RUNNING())
675675
setWiFiIcon_TwoRadios(iconList);
676-
else if (espnowState > ESPNOW_OFF)
676+
else if (espnowGetState() > ESPNOW_OFF)
677677
setESPNowIcon_TwoRadios(iconList);
678678

679679
setModeIcon(iconList); // Turn on Rover/Base type icons
@@ -753,7 +753,7 @@ void setRadioIcons(std::vector<iconPropertyBlinking> *iconList)
753753
}
754754
#endif // /COMPILE_CELLULAR
755755

756-
if (espnowState == ESPNOW_PAIRED) // ESPNOW : Columns 64 - 71
756+
if (espnowGetState() == ESPNOW_PAIRED) // ESPNOW : Columns 64 - 71
757757
{
758758
iconPropertyBlinking prop;
759759
prop.duty = 0b11111111;
@@ -792,7 +792,7 @@ void setRadioIcons(std::vector<iconPropertyBlinking> *iconList)
792792
}
793793
}
794794

795-
if (espnowState == ESPNOW_PAIRED)
795+
if (espnowGetState() == ESPNOW_PAIRED)
796796
{
797797
if (espnowIncomingRTCM == true) // Download : Columns 74 - 81
798798
{
@@ -1023,7 +1023,7 @@ void setBluetoothIcon_TwoRadios(std::vector<iconPropertyBlinking> *iconList)
10231023
// This is 64x48-specific
10241024
void setESPNowIcon_TwoRadios(std::vector<iconPropertyBlinking> *iconList)
10251025
{
1026-
if (espnowState == ESPNOW_PAIRED)
1026+
if (espnowGetState() == ESPNOW_PAIRED)
10271027
{
10281028
if (espnowIncomingRTCM == true || espnowOutgoingRTCM == true)
10291029
{

Firmware/RTK_Everywhere/ESPNOW.ino

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ esp_err_t espNowAddPeer(const uint8_t * peerMac)
5353
return result;
5454
}
5555

56+
//*********************************************************************
57+
// Get the current ESP-NOW state
58+
ESPNOWState espnowGetState()
59+
{
60+
return espnowState;
61+
}
62+
5663
//----------------------------------------------------------------------
5764
// ESP-NOW bringup from example 4_9_ESP_NOW
5865
// 1. Set station mode

Firmware/RTK_Everywhere/WiFi.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,7 +2728,7 @@ bool wifiConnect(bool startWiFiStation, bool startWiFiAP, unsigned long timeout)
27282728
systemPrintf("Failed to get protocols: %s\r\n", esp_err_to_name(response));
27292729

27302730
// If ESP-NOW is running, blend in ESP-NOW protocol.
2731-
if (espnowState > ESPNOW_OFF)
2731+
if (espnowGetState() > ESPNOW_OFF)
27322732
{
27332733
if (protocols != (WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_LR))
27342734
{
@@ -3233,7 +3233,7 @@ void wifiStop()
32333233
wifiFailedConnectionAttempts = 0; // Reset the counter
32343234

32353235
// If ESP-Now is active, change protocol to only Long Range
3236-
if (espnowState > ESPNOW_OFF)
3236+
if (espnowGetState() > ESPNOW_OFF)
32373237
{
32383238
if (WiFi.getMode() != WIFI_STA)
32393239
WiFi.mode(WIFI_STA);

Firmware/RTK_Everywhere/menuMain.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ void menuRadio()
619619
byte bContinue = getUserInputCharacterNumber();
620620
if (bContinue == 'y')
621621
{
622-
if (espnowState > ESPNOW_OFF)
622+
if (espnowGetState() > ESPNOW_OFF)
623623
{
624624
for (int x = 0; x < settings.espnowPeerCount; x++)
625625
espnowRemovePeer(settings.espnowPeers[x]);
@@ -643,7 +643,7 @@ void menuRadio()
643643
}
644644
else if (settings.enableEspNow == true && incoming == 5 && settings.debugEspNow == true)
645645
{
646-
if (espnowState == ESPNOW_OFF)
646+
if (espnowGetState() == ESPNOW_OFF)
647647
espnowStart();
648648

649649
uint8_t peer1[] = {0xB8, 0xD6, 0x1A, 0x0D, 0x8F, 0x9C}; // Random MAC
@@ -667,7 +667,7 @@ void menuRadio()
667667
}
668668
else if (settings.enableEspNow == true && incoming == 6 && settings.debugEspNow == true)
669669
{
670-
if (espnowState == ESPNOW_OFF)
670+
if (espnowGetState() == ESPNOW_OFF)
671671
espnowStart();
672672

673673
uint8_t espnowData[] =
@@ -680,7 +680,7 @@ void menuRadio()
680680
}
681681
else if (settings.enableEspNow == true && incoming == 7 && settings.debugEspNow == true)
682682
{
683-
if (espnowState == ESPNOW_OFF)
683+
if (espnowGetState() == ESPNOW_OFF)
684684
espnowStart();
685685

686686
uint8_t espnowData[] =

0 commit comments

Comments
 (0)