diff --git a/Firmware/RTK_Surveyor/Base.ino b/Firmware/RTK_Surveyor/Base.ino index c39615874..41e68589c 100644 --- a/Firmware/RTK_Surveyor/Base.ino +++ b/Firmware/RTK_Surveyor/Base.ino @@ -229,7 +229,5 @@ void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming) { ntripServerProcessRTCM(incoming); -#ifdef COMPILE_ESPNOW espnowProcessRTCM(incoming); -#endif } diff --git a/Firmware/RTK_Surveyor/Display.ino b/Firmware/RTK_Surveyor/Display.ino index 12245a901..53683b2bb 100644 --- a/Firmware/RTK_Surveyor/Display.ino +++ b/Firmware/RTK_Surveyor/Display.ino @@ -331,8 +331,11 @@ void updateDisplay() //Do nothing. Quick, fall through state. break; - case (STATE_ESPNOW_PAIR): - paintEspNowPair(); + case (STATE_ESPNOW_PAIRING_NOT_STARTED): + paintEspNowPairing(); + break; + case (STATE_ESPNOW_PAIRING): + paintEspNowPairing(); break; case (STATE_SHUTDOWN): @@ -2151,12 +2154,12 @@ void paintDisplaySetup() printTextCenter("Bubble", 12 * 2, QW_FONT_8X16, 1, false); printTextCenter("Config", 12 * 3, QW_FONT_8X16, 1, true); } - else if (setupState == STATE_ESPNOW_PAIR) + else if (setupState == STATE_ESPNOW_PAIRING_NOT_STARTED) { printTextCenter("Base", 12 * 0, QW_FONT_8X16, 1, false); printTextCenter("Bubble", 12 * 1, QW_FONT_8X16, 1, false); printTextCenter("Config", 12 * 2, QW_FONT_8X16, 1, false); - printTextCenter("Pair", 12 * 3, QW_FONT_8X16, 1, true); + printTextCenter("E-Pair", 12 * 3, QW_FONT_8X16, 1, true); } else if (setupState == STATE_PROFILE) paintDisplaySetupProfile("Base"); @@ -2191,12 +2194,12 @@ void paintDisplaySetup() printTextCenter("Bubble", 12 * 2, QW_FONT_8X16, 1, false); printTextCenter("Config", 12 * 3, QW_FONT_8X16, 1, true); } - else if (setupState == STATE_ESPNOW_PAIR) + else if (setupState == STATE_ESPNOW_PAIRING_NOT_STARTED) { printTextCenter("Rover", 12 * 0, QW_FONT_8X16, 1, false); printTextCenter("Bubble", 12 * 1, QW_FONT_8X16, 1, false); printTextCenter("Config", 12 * 2, QW_FONT_8X16, 1, false); - printTextCenter("Pair", 12 * 3, QW_FONT_8X16, 1, true); + printTextCenter("E-Pair", 12 * 3, QW_FONT_8X16, 1, true); } else if (setupState == STATE_PROFILE) paintDisplaySetupProfile("Rover"); @@ -2521,7 +2524,11 @@ void paintKeyProvisionFail(uint16_t displayTime) } //Show screen while ESP-Now is pairing -void paintEspNowPair() +void paintEspNowPairing() { displayMessage("ESP-Now Pairing", 0); } +void paintEspNowPaired() +{ + displayMessage("ESP-Now Paired", 2000); +} diff --git a/Firmware/RTK_Surveyor/ESPNOW.ino b/Firmware/RTK_Surveyor/ESPNOW.ino index e0a6b20d9..3029229fc 100644 --- a/Firmware/RTK_Surveyor/ESPNOW.ino +++ b/Firmware/RTK_Surveyor/ESPNOW.ino @@ -12,7 +12,6 @@ We don't care if the ESP NOW packet is corrupt or not. RTCM has its own CRC. RTK needs valid RTCM once every few seconds so a single dropped frame is not critical. */ -#ifdef COMPILE_ESPNOW //Create a struct for ESP NOW pairing typedef struct PairMessage { @@ -23,6 +22,7 @@ typedef struct PairMessage { } PairMessage; // Callback when data is sent +#ifdef COMPILE_ESPNOW void espnowOnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) { // Serial.print("Last Packet Send Status: "); @@ -31,10 +31,12 @@ void espnowOnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) // else // Serial.println("Delivery Fail"); } +#endif // Callback when data is received void espnowOnDataRecieved(const uint8_t *mac, const uint8_t *incomingData, int len) { +#ifdef COMPILE_ESPNOW if (espnowState == ESPNOW_PAIRING) { if (len == sizeof(PairMessage)) //First error check @@ -66,10 +68,12 @@ void espnowOnDataRecieved(const uint8_t *mac, const uint8_t *incomingData, int l espnowIncomingRTCM = true; lastEspnowRssiUpdate = millis(); } +#endif } // Callback for all RX Packets // Get RSSI of all incoming management packets: https://esp32.com/viewtopic.php?t=13889 +#ifdef COMPILE_ESPNOW void promiscuous_rx_cb(void *buf, wifi_promiscuous_pkt_type_t type) { // All espnow traffic uses action frames which are a subtype of the mgmnt frames so filter out everything else. @@ -79,11 +83,13 @@ void promiscuous_rx_cb(void *buf, wifi_promiscuous_pkt_type_t type) const wifi_promiscuous_pkt_t *ppkt = (wifi_promiscuous_pkt_t *)buf; packetRSSI = ppkt->rx_ctrl.rssi; } +#endif //If WiFi is already enabled, simply add the LR protocol //If the radio is off entirely, start the radio, turn on only the LR protocol void espnowStart() { +#ifdef COMPILE_ESPNOW if (wifiState == WIFI_OFF && espnowState == ESPNOW_OFF) { //Radio is off, turn it on @@ -97,21 +103,19 @@ void espnowStart() //Enable WiFi + ESP-Now // Enable long range, PHY rate of ESP32 will be 512Kbps or 256Kbps esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_LR); - Serial.println("Wi-Fi on, ESP-Now added to protocols"); + Serial.println("WiFi on, ESP-Now added to protocols"); } //If ESP-Now is active, WiFi is active, do nothing else { - Serial.println("Wi-Fi already on, ESP-Now already on"); + Serial.println("WiFi already on, ESP-Now already on"); } // Init ESP-NOW if (esp_now_init() != ESP_OK) { - Serial.println("Error initializing ESP-NOW"); + Serial.println("Error starting ESP-Now"); return; } - else - Serial.println("ESP-NOW Initialized"); // Use promiscuous callback to capture RSSI of packet esp_wifi_set_promiscuous(true); @@ -143,13 +147,17 @@ void espnowStart() } } } + + Serial.println("ESP-Now Started"); +#endif } //If WiFi is already enabled, simply remove the LR protocol //If WiFi is off, stop the radio entirely void espnowStop() { - if(espnowState == ESPNOW_OFF) return; +#ifdef COMPILE_ESPNOW + if (espnowState == ESPNOW_OFF) return; if (wifiState == WIFI_OFF) { @@ -178,13 +186,11 @@ void espnowStop() Serial.println("Error deinitializing ESP-NOW"); return; } - +#endif espnowSetState(ESPNOW_OFF); - - Serial.println("ESP NOW Off"); } -//Begin broadcasting our MAC and wait for remote unit to respond +//Start ESP-Now if needed, put ESP-Now into broadcast state void espnowBeginPairing() { espnowStart(); @@ -194,60 +200,45 @@ void espnowBeginPairing() espnowAddPeer(broadcastMac, false); // Encryption is not supported for multicast addresses espnowSetState(ESPNOW_PAIRING); +} - //Begin sending our MAC every 250ms until a remote device sends us there info - randomSeed(millis()); - - Serial.println("Begin pairing. Place other unit in pairing mode. Press any key to exit."); - while (Serial.available()) Serial.read(); - - while (1) +//Regularly call during pairing to see if we've received a Pairing message +bool espnowIsPaired() +{ +#ifdef COMPILE_ESPNOW + if (espnowState == ESPNOW_MAC_RECEIVED) { - if (Serial.available()) break; + //Remove broadcast peer + uint8_t broadcastMac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + espnowRemovePeer(broadcastMac); - int timeout = 1000 + random(0, 100); //Delay 1000 to 1100ms - for (int x = 0 ; x < timeout ; x++) + if (esp_now_is_peer_exist(receivedMAC) == true) + log_d("Peer already exists"); + else { - delay(1); + //Add new peer to system + espnowAddPeer(receivedMAC); - if (espnowState == ESPNOW_MAC_RECEIVED) - { - //Remove broadcast peer - espnowRemovePeer(broadcastMac); - - if (esp_now_is_peer_exist(receivedMAC) == true) - log_d("Peer already exists"); - else - { - //Add new peer to system - espnowAddPeer(receivedMAC); - - //Record this MAC to peer list - memcpy(settings.espnowPeers[settings.espnowPeerCount], receivedMAC, 6); - settings.espnowPeerCount++; - settings.espnowPeerCount %= ESPNOW_MAX_PEERS; - } - - //Send message directly to the received MAC (not unicast), then exit - espnowSendPairMessage(receivedMAC); - - espnowSetState(ESPNOW_PAIRED); - Serial.println("Pairing compete"); - return; - } + //Record this MAC to peer list + memcpy(settings.espnowPeers[settings.espnowPeerCount], receivedMAC, 6); + settings.espnowPeerCount++; + settings.espnowPeerCount %= ESPNOW_MAX_PEERS; } - espnowSendPairMessage(broadcastMac); //Send unit's MAC address over broadcast, no ack, no encryption + //Send message directly to the received MAC (not unicast), then exit + espnowSendPairMessage(receivedMAC); - Serial.println("Scanning for other radio..."); + espnowSetState(ESPNOW_PAIRED); + return (true); } - - Serial.println("User pressed button. Pairing canceled."); +#endif + return (false); } //Create special pair packet to a given MAC esp_err_t espnowSendPairMessage(uint8_t *sendToMac) { +#ifdef COMPILE_ESPNOW // Assemble message to send PairMessage pairMessage; @@ -263,6 +254,9 @@ esp_err_t espnowSendPairMessage(uint8_t *sendToMac) pairMessage.crc += unitMACAddress[x]; return (esp_now_send(sendToMac, (uint8_t *) &pairMessage, sizeof(pairMessage))); //Send packet to given MAC +#else + return (ESP_OK); +#endif } //Add a given MAC address to the peer list @@ -273,6 +267,7 @@ esp_err_t espnowAddPeer(uint8_t *peerMac) esp_err_t espnowAddPeer(uint8_t *peerMac, bool encrypt) { +#ifdef COMPILE_ESPNOW esp_now_peer_info_t peerInfo; memcpy(peerInfo.peer_addr, peerMac, 6); @@ -286,15 +281,23 @@ esp_err_t espnowAddPeer(uint8_t *peerMac, bool encrypt) if (result != ESP_OK) log_d("Failed to add peer"); return (result); +#else + return (ESP_OK); +#endif } //Remove a given MAC address from the peer list esp_err_t espnowRemovePeer(uint8_t *peerMac) { +#ifdef COMPILE_ESPNOW esp_err_t result = esp_now_del_peer(peerMac); if (result != ESP_OK) log_d("Failed to remove peer"); return (result); +#else + return (ESP_OK); +#endif + } //Update the state of the ESP Now state machine @@ -303,6 +306,8 @@ void espnowSetState(ESPNOWState newState) if (espnowState == newState) Serial.print("*"); espnowState = newState; + + Serial.print("espnowState: "); switch (newState) { case ESPNOW_OFF: @@ -328,6 +333,7 @@ void espnowSetState(ESPNOWState newState) void espnowProcessRTCM(byte incoming) { +#ifdef COMPILE_ESPNOW if (espnowState == ESPNOW_PAIRED) { //Move this byte into ESP NOW to send buffer @@ -344,6 +350,5 @@ void espnowProcessRTCM(byte incoming) espnowOutgoingRTCM = true; } } +#endif } - -#endif //ifdef COMPILE_ESPNOW diff --git a/Firmware/RTK_Surveyor/Form.ino b/Firmware/RTK_Surveyor/Form.ino index bffdd2ec0..d4036c292 100644 --- a/Firmware/RTK_Surveyor/Form.ino +++ b/Firmware/RTK_Surveyor/Form.ino @@ -387,8 +387,10 @@ void createSettingsString(char* settingsCSV) char apDaysRemaining[20]; if (strlen(settings.pointPerfectCurrentKey) > 0) { +#ifdef COMPILE_L_BAND uint8_t daysRemaining = daysFromEpoch(settings.pointPerfectNextKeyStart + settings.pointPerfectNextKeyDuration + 1); sprintf(apDaysRemaining, "%d", daysRemaining); +#endif } else sprintf(apDaysRemaining, "No Keys"); diff --git a/Firmware/RTK_Surveyor/RTK_Surveyor.ino b/Firmware/RTK_Surveyor/RTK_Surveyor.ino index 5b7b7f38f..865878b2c 100644 --- a/Firmware/RTK_Surveyor/RTK_Surveyor.ino +++ b/Firmware/RTK_Surveyor/RTK_Surveyor.ino @@ -26,10 +26,10 @@ const int FIRMWARE_VERSION_MAJOR = 2; const int FIRMWARE_VERSION_MINOR = 4; #define COMPILE_WIFI //Comment out to remove WiFi functionality +//#define COMPILE_AP //Requires WiFi. Comment out to remove Access Point functionality +#define COMPILE_ESPNOW //Requires WiFi. Comment out to remove ESP-Now functionality. #define COMPILE_BT //Comment out to remove Bluetooth functionality -#define COMPILE_AP //Comment out to remove Access Point functionality #define COMPILE_L_BAND //Comment out to remove L-Band functionality -#define COMPILE_ESPNOW //Comment out to remove ESP-Now functionality #define COMPILE_IDLE_TASKS //Comment out to remove idle tasks #define ENABLE_DEVELOPER //Uncomment this line to enable special developer modes (don't check power button at startup) @@ -468,7 +468,7 @@ bool espnowOutgoingRTCM = false; | RTCM |--->|-->| |--------->| |-->|----->|TXD, MISO | | | | | | Bluetooth | | UART 2 | | | UART1 | | | NMEA + RTCM |<---|<--| |<-------+-| |<--|<-----|RXD, MOSI |<----' - +-------------+ | '-----------' | '--------' |28 42| | + +-------------+ | '-----------' | '--------' |28 43| | | | | | | .---------+ | | | | | / uSD Card | | | | | | diff --git a/Firmware/RTK_Surveyor/States.ino b/Firmware/RTK_Surveyor/States.ino index 480ca78c8..417d1b2c6 100644 --- a/Firmware/RTK_Surveyor/States.ino +++ b/Firmware/RTK_Surveyor/States.ino @@ -240,7 +240,7 @@ void updateSystemState() bluetoothStop(); bluetoothStart(); //Restart Bluetooth with 'Base' identifier - + startUART2Tasks(); //Start monitoring the UART1 from ZED for NMEA and UBX data (enables logging) if (configureUbloxModuleBase() == true) @@ -596,9 +596,8 @@ void updateSystemState() displayWiFiConfigNotStarted(); //Display immediately during SD cluster pause bluetoothStop(); -#ifdef COMPILE_ESPNOW espnowStop(); -#endif + stopUART2Tasks(); //Delete F9 serial tasks if running startWebServer(); //Start in AP mode and show config html page @@ -900,14 +899,35 @@ void updateSystemState() break; #endif //COMPILE_L_BAND - case (STATE_ESPNOW_PAIR): + case (STATE_ESPNOW_PAIRING_NOT_STARTED): { - if(espnowState == ESPNOW_OFF) +#ifdef COMPILE_ESPNOW + paintEspNowPairing(); + + //Start ESP-Now if needed, put ESP-Now into broadcast state + espnowBeginPairing(); + + changeState(STATE_ESPNOW_PAIRING); +#else + changeState(STATE_ROVER_NOT_STARTED); +#endif + } + break; + + case (STATE_ESPNOW_PAIRING): + { +#ifdef COMPILE_ESPNOW + if (espnowIsPaired() == true) { - espnowBeginPairing(); + paintEspNowPaired(); + changeState(STATE_ROVER_NOT_STARTED); } - - //Display 'ESP-Now Pairing' while we wait + else + { + uint8_t broadcastMac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + espnowSendPairMessage(broadcastMac); //Send unit's MAC address over broadcast, no ack, no encryption + } +#endif } break; @@ -1053,8 +1073,11 @@ void changeState(SystemState newState) break; #endif //COMPILE_L_BAND - case (STATE_ESPNOW_PAIR): - Serial.print("State: ESP-Now Pair"); + case (STATE_ESPNOW_PAIRING_NOT_STARTED): + Serial.print("State: ESP-Now Pairing Not Started"); + break; + case (STATE_ESPNOW_PAIRING): + Serial.print("State: ESP-Now Pairing"); break; case (STATE_SHUTDOWN): diff --git a/Firmware/RTK_Surveyor/Tasks.ino b/Firmware/RTK_Surveyor/Tasks.ino index b2381b451..cf338a67f 100644 --- a/Firmware/RTK_Surveyor/Tasks.ino +++ b/Firmware/RTK_Surveyor/Tasks.ino @@ -412,7 +412,8 @@ void ButtonCheckTask(void *e) case STATE_BUBBLE_LEVEL: case STATE_WIFI_CONFIG_NOT_STARTED: case STATE_WIFI_CONFIG: - case STATE_ESPNOW_PAIR: + case STATE_ESPNOW_PAIRING_NOT_STARTED: + case STATE_ESPNOW_PAIRING: lastSystemState = systemState; //Remember this state to return after we mark an event requestChangeState(STATE_DISPLAY_SETUP); setupState = STATE_MARK_EVENT; @@ -464,9 +465,9 @@ void ButtonCheckTask(void *e) setupState = STATE_WIFI_CONFIG_NOT_STARTED; break; case STATE_WIFI_CONFIG_NOT_STARTED: - setupState = STATE_ESPNOW_PAIR; + setupState = STATE_ESPNOW_PAIRING_NOT_STARTED; break; - case STATE_ESPNOW_PAIR: + case STATE_ESPNOW_PAIRING_NOT_STARTED: //If only one active profile do not show any profiles index = getProfileNumberFromUnit(0); displayProfile = getProfileNumberFromUnit(1); @@ -531,7 +532,8 @@ void ButtonCheckTask(void *e) case STATE_BUBBLE_LEVEL: case STATE_WIFI_CONFIG_NOT_STARTED: case STATE_WIFI_CONFIG: - case STATE_ESPNOW_PAIR: + case STATE_ESPNOW_PAIRING_NOT_STARTED: + case STATE_ESPNOW_PAIRING: lastSystemState = systemState; //Remember this state to return after we mark an event requestChangeState(STATE_DISPLAY_SETUP); setupState = STATE_MARK_EVENT; @@ -583,9 +585,9 @@ void ButtonCheckTask(void *e) setupState = STATE_WIFI_CONFIG_NOT_STARTED; break; case STATE_WIFI_CONFIG_NOT_STARTED: - setupState = STATE_ESPNOW_PAIR; + setupState = STATE_ESPNOW_PAIRING_NOT_STARTED; break; - case STATE_ESPNOW_PAIR: + case STATE_ESPNOW_PAIRING_NOT_STARTED: //If only one active profile do not show any profiles index = getProfileNumberFromUnit(0); displayProfile = getProfileNumberFromUnit(1); diff --git a/Firmware/RTK_Surveyor/WiFi.ino b/Firmware/RTK_Surveyor/WiFi.ino index a4895f6f6..96c882669 100644 --- a/Firmware/RTK_Surveyor/WiFi.ino +++ b/Firmware/RTK_Surveyor/WiFi.ino @@ -153,13 +153,13 @@ void wifiStartAP() #endif WiFi.begin(WIFI_SSID, WIFI_PASSWORD); - Serial.print("Wi-Fi connecting to"); + Serial.print("WiFi connecting to"); while (wifiGetStatus() != WL_CONNECTED) { Serial.print("."); delay(500); } - Serial.print("Wi-Fi connected with IP: "); + Serial.print("WiFi connected with IP: "); Serial.println(WiFi.localIP()); #else //LOCAL_WIFI_TESTING //Start in AP mode @@ -177,10 +177,10 @@ void wifiStartAP() WiFi.softAPConfig(local_IP, gateway, subnet); if (WiFi.softAP("RTK Config") == false) //Must be short enough to fit OLED Width { - Serial.println("Wi-Fi AP failed to start"); + Serial.println("WiFi AP failed to start"); return; } - Serial.print("Wi-Fi AP Started with IP: "); + Serial.print("WiFi AP Started with IP: "); Serial.println(WiFi.softAPIP()); #endif //LOCAL_WIFI_TESTING } @@ -197,7 +197,7 @@ bool wifiConnectionTimeout() #ifdef COMPILE_WIFI if ((millis() - wifiTimer) <= WIFI_CONNECTION_TIMEOUT) return false; - Serial.println("Wi-Fi connection timeout!"); + Serial.println("WiFi connection timeout!"); #endif //COMPILE_WIFI return true; } @@ -221,7 +221,7 @@ void wifiStart(char* ssid, char* pw) esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N); #endif - Serial.printf("Wi-Fi connecting to %s\r\n", ssid); + Serial.printf("WiFi connecting to %s\r\n", ssid); WiFi.begin(ssid, pw); wifiTimer = millis(); wifiSetState(WIFI_NOTCONNECTED); @@ -251,7 +251,7 @@ void wifiStop() { WiFi.mode(WIFI_OFF); wifiSetState(WIFI_OFF); - Serial.println("Wi-Fi Stopped"); + Serial.println("WiFi Stopped"); } //If ESP-Now is active, change protocol to only Long Range else if (espnowState > ESPNOW_OFF) @@ -263,13 +263,13 @@ void wifiStop() wifiSetState(WIFI_OFF); - Serial.println("Wi-Fi disabled, ESP-Now left in place"); + Serial.println("WiFi disabled, ESP-Now left in place"); } #else //Turn off radio WiFi.mode(WIFI_OFF); wifiSetState(WIFI_OFF); - Serial.println("Wi-Fi Stopped"); + Serial.println("WiFi Stopped"); #endif //Display the heap state diff --git a/Firmware/RTK_Surveyor/menuMain.ino b/Firmware/RTK_Surveyor/menuMain.ino index 9d8b83bbb..480255596 100644 --- a/Firmware/RTK_Surveyor/menuMain.ino +++ b/Firmware/RTK_Surveyor/menuMain.ino @@ -334,7 +334,7 @@ void menuRadio() } else Serial.println(" No Paired Radios"); - + Serial.println("2) Pair radios"); Serial.println("3) Forget all radios"); @@ -352,7 +352,44 @@ void menuRadio() else if (settings.radioType == RADIO_ESPNOW && incoming == 2) { Serial.println("Begin ESP NOW Pairing"); + + //Start ESP-Now if needed, put ESP-Now into broadcast state espnowBeginPairing(); + + //Begin sending our MAC every 250ms until a remote device sends us there info + randomSeed(millis()); + + Serial.println("Begin pairing. Place other unit in pairing mode. Press any key to exit."); + while (Serial.available()) Serial.read(); + + uint8_t broadcastMac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; + + bool exitPair = false; + while (exitPair == false) + { + if (Serial.available()) + { + Serial.println("User pressed button. Pairing canceled."); + break; + } + + int timeout = 1000 + random(0, 100); //Delay 1000 to 1100ms + for (int x = 0 ; x < timeout ; x++) + { + delay(1); + + if (espnowIsPaired() == true) //Check if we've received a pairing message + { + Serial.println("Pairing compete"); + exitPair = true; + break; + } + } + + espnowSendPairMessage(broadcastMac); //Send unit's MAC address over broadcast, no ack, no encryption + + Serial.println("Scanning for other radio..."); + } } else if (settings.radioType == RADIO_ESPNOW && incoming == 3) { @@ -360,8 +397,11 @@ void menuRadio() byte bContinue = getByteChoice(menuTimeout); if (bContinue == 'y') { - for (int x = 0 ; x < settings.espnowPeerCount ; x++) - espnowRemovePeer(settings.espnowPeers[x]); + if (espnowState > ESPNOW_OFF) + { + for (int x = 0 ; x < settings.espnowPeerCount ; x++) + espnowRemovePeer(settings.espnowPeers[x]); + } settings.espnowPeerCount = 0; Serial.println("Radios forgotten"); } diff --git a/Firmware/RTK_Surveyor/settings.h b/Firmware/RTK_Surveyor/settings.h index 6da21e836..893ca13be 100644 --- a/Firmware/RTK_Surveyor/settings.h +++ b/Firmware/RTK_Surveyor/settings.h @@ -33,7 +33,8 @@ typedef enum STATE_KEYS_PROVISION_WIFI_STARTED, STATE_KEYS_PROVISION_WIFI_CONNECTED, STATE_KEYS_PROVISION_WIFI_TIMEOUT, - STATE_ESPNOW_PAIR, + STATE_ESPNOW_PAIRING_NOT_STARTED, + STATE_ESPNOW_PAIRING, STATE_SHUTDOWN, } SystemState; volatile SystemState systemState = STATE_ROVER_NOT_STARTED; @@ -487,6 +488,7 @@ struct struct_online { } online; #ifdef COMPILE_WIFI +#ifdef COMPILE_L_BAND //AWS certificate for PointPerfect API static const char *AWS_PUBLIC_CERT = R"=====( -----BEGIN CERTIFICATE----- @@ -511,3 +513,4 @@ rqXRfboQnoZsG4q5WTP468SQvvG5 -----END CERTIFICATE----- )====="; #endif +#endif