Set critical error and reboot when radio fails to generate tx IRQ

1.2-legacy
Andrew Mark 2021-01-19 18:21:54 -08:00
rodzic 39d14fedc2
commit 79dad8ec8c
3 zmienionych plików z 19 dodań i 1 usunięć

Wyświetl plik

@ -7,6 +7,7 @@
#include "CryptoEngine.h"
#include "FSCommon.h"
#include "GPS.h"
#include "main.h"
#include "MeshRadio.h"
#include "NodeDB.h"
#include "PacketHistory.h"
@ -583,8 +584,14 @@ NodeInfo *NodeDB::getOrCreateNode(NodeNum n)
/// Record an error that should be reported via analytics
void recordCriticalError(CriticalErrorCode code, uint32_t address)
{
// Print error to screen and serial port
String lcd = String("Critical error ") + code + "!\n";
screen->print(lcd.c_str());
DEBUG_MSG("NOTE! Recording critical error %d, address=%x\n", code, address);
// Record error to DB
myNodeInfo.error_code = code;
myNodeInfo.error_address = address;
myNodeInfo.error_count++;
}

Wyświetl plik

@ -3,6 +3,7 @@
#include "NodeDB.h"
#include "SPILock.h"
#include "mesh-pb-constants.h"
#include "error.h"
#include <configuration.h>
#include <pb_decode.h>
#include <pb_encode.h>
@ -67,9 +68,18 @@ bool RadioLibInterface::canSendImmediately()
bool busyTx = sendingPacket != NULL;
bool busyRx = isReceiving && isActivelyReceiving();
if (busyTx || busyRx) {
if (busyTx)
DEBUG_MSG("Can not send yet, busyTx\n");
// If we've been trying to send the same packet more than one minute and we haven't gotten a
// TX IRQ from the radio, the radio is probably broken.
if (busyTx && (millis() - lastTxStart > 60000)){
DEBUG_MSG("Hardware Failure! busyTx for more than 60s\n");
recordCriticalError(CriticalErrorCode_TransmitFailed);
if (busyTx && (millis() - lastTxStart > 65000)) // After 5s more, reboot
ESP.restart();
}
if (busyRx)
DEBUG_MSG("Can not send yet, busyRx\n");
return false;

Wyświetl plik

@ -76,7 +76,8 @@ typedef enum _CriticalErrorCode {
CriticalErrorCode_Unspecified = 4,
CriticalErrorCode_UBloxInitFailed = 5,
CriticalErrorCode_NoAXP192 = 6,
CriticalErrorCode_InvalidRadioSetting = 7
CriticalErrorCode_InvalidRadioSetting = 7,
CriticalErrorCode_TransmitFailed = 8
} CriticalErrorCode;
typedef enum _ChannelSettings_ModemConfig {