sforkowany z mirror/meshtastic-firmware
Set critical error and reboot when radio fails to generate tx IRQ
rodzic
39d14fedc2
commit
79dad8ec8c
|
@ -7,6 +7,7 @@
|
||||||
#include "CryptoEngine.h"
|
#include "CryptoEngine.h"
|
||||||
#include "FSCommon.h"
|
#include "FSCommon.h"
|
||||||
#include "GPS.h"
|
#include "GPS.h"
|
||||||
|
#include "main.h"
|
||||||
#include "MeshRadio.h"
|
#include "MeshRadio.h"
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "PacketHistory.h"
|
#include "PacketHistory.h"
|
||||||
|
@ -583,8 +584,14 @@ NodeInfo *NodeDB::getOrCreateNode(NodeNum n)
|
||||||
/// Record an error that should be reported via analytics
|
/// Record an error that should be reported via analytics
|
||||||
void recordCriticalError(CriticalErrorCode code, uint32_t address)
|
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);
|
DEBUG_MSG("NOTE! Recording critical error %d, address=%x\n", code, address);
|
||||||
|
|
||||||
|
// Record error to DB
|
||||||
myNodeInfo.error_code = code;
|
myNodeInfo.error_code = code;
|
||||||
myNodeInfo.error_address = address;
|
myNodeInfo.error_address = address;
|
||||||
myNodeInfo.error_count++;
|
myNodeInfo.error_count++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "SPILock.h"
|
#include "SPILock.h"
|
||||||
#include "mesh-pb-constants.h"
|
#include "mesh-pb-constants.h"
|
||||||
|
#include "error.h"
|
||||||
#include <configuration.h>
|
#include <configuration.h>
|
||||||
#include <pb_decode.h>
|
#include <pb_decode.h>
|
||||||
#include <pb_encode.h>
|
#include <pb_encode.h>
|
||||||
|
@ -67,9 +68,18 @@ bool RadioLibInterface::canSendImmediately()
|
||||||
bool busyTx = sendingPacket != NULL;
|
bool busyTx = sendingPacket != NULL;
|
||||||
bool busyRx = isReceiving && isActivelyReceiving();
|
bool busyRx = isReceiving && isActivelyReceiving();
|
||||||
|
|
||||||
|
|
||||||
if (busyTx || busyRx) {
|
if (busyTx || busyRx) {
|
||||||
if (busyTx)
|
if (busyTx)
|
||||||
DEBUG_MSG("Can not send yet, busyTx\n");
|
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)
|
if (busyRx)
|
||||||
DEBUG_MSG("Can not send yet, busyRx\n");
|
DEBUG_MSG("Can not send yet, busyRx\n");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -76,7 +76,8 @@ typedef enum _CriticalErrorCode {
|
||||||
CriticalErrorCode_Unspecified = 4,
|
CriticalErrorCode_Unspecified = 4,
|
||||||
CriticalErrorCode_UBloxInitFailed = 5,
|
CriticalErrorCode_UBloxInitFailed = 5,
|
||||||
CriticalErrorCode_NoAXP192 = 6,
|
CriticalErrorCode_NoAXP192 = 6,
|
||||||
CriticalErrorCode_InvalidRadioSetting = 7
|
CriticalErrorCode_InvalidRadioSetting = 7,
|
||||||
|
CriticalErrorCode_TransmitFailed = 8
|
||||||
} CriticalErrorCode;
|
} CriticalErrorCode;
|
||||||
|
|
||||||
typedef enum _ChannelSettings_ModemConfig {
|
typedef enum _ChannelSettings_ModemConfig {
|
||||||
|
|
Ładowanie…
Reference in New Issue