Merge pull request #651 from android606/log-tx-failure

Set critical error and reboot when radio fails to generate Tx IRQ - fixes #138
1.2-legacy
Kevin Hester 2021-01-27 18:05:56 +08:00 zatwierdzone przez GitHub
commit 2b4ddc07f5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 21 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,20 @@ 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);
#ifndef NO_ESP32
if (busyTx && (millis() - lastTxStart > 65000)) // After 5s more, reboot
ESP.restart();
#endif
}
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 {