mirror of
https://github.com/meshtastic/firmware.git
synced 2025-07-29 18:05:42 +00:00
include file/lineno in critical error logs
This commit is contained in:
parent
c27d479a9f
commit
babc1b3613
@ -4,5 +4,8 @@
|
||||
|
||||
#include "mesh/generated/mesh.pb.h" // For CriticalErrorCode
|
||||
|
||||
/// A macro that include filename and line
|
||||
#define RECORD_CRITICALERROR(code) (code, __LINE__, __FILE__)
|
||||
|
||||
/// Record an error that should be reported via analytics
|
||||
void recordCriticalError(CriticalErrorCode code = CriticalErrorCode_Unspecified, uint32_t address = 0);
|
||||
void recordCriticalError(CriticalErrorCode code = CriticalErrorCode_Unspecified, uint32_t address = 0, const char *filename = NULL);
|
||||
|
@ -43,7 +43,7 @@ bool UBloxGPS::setupGPS()
|
||||
DEBUG_MSG("Connected to UBLOX GPS successfully\n");
|
||||
|
||||
if (!setUBXMode())
|
||||
recordCriticalError(CriticalErrorCode_UBloxInitFailed); // Don't halt the boot if saving the config fails, but do report the bug
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_UBloxInitFailed); // Don't halt the boot if saving the config fails, but do report the bug
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
@ -466,7 +466,7 @@ void setup()
|
||||
// Do this after service.init (because that clears error_code)
|
||||
#ifdef AXP192_SLAVE_ADDRESS
|
||||
if (!axp192_found)
|
||||
recordCriticalError(CriticalErrorCode_NoAXP192); // Record a hardware fault for missing hardware
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_NoAXP192); // Record a hardware fault for missing hardware
|
||||
#endif
|
||||
|
||||
// Don't call screen setup until after nodedb is setup (because we need
|
||||
@ -557,7 +557,7 @@ void setup()
|
||||
airTime = new AirTime();
|
||||
|
||||
if (!rIf)
|
||||
recordCriticalError(CriticalErrorCode_NoRadio);
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_NoRadio);
|
||||
else
|
||||
router->addInterface(rIf);
|
||||
|
||||
|
@ -541,11 +541,14 @@ NodeInfo *NodeDB::getOrCreateNode(NodeNum n)
|
||||
}
|
||||
|
||||
/// Record an error that should be reported via analytics
|
||||
void recordCriticalError(CriticalErrorCode code, uint32_t address)
|
||||
void recordCriticalError(CriticalErrorCode code, uint32_t address, const char *filename)
|
||||
{
|
||||
// Print error to screen and serial port
|
||||
String lcd = String("Critical error ") + code + "!\n";
|
||||
screen->print(lcd.c_str());
|
||||
if(filename)
|
||||
DEBUG_MSG("NOTE! Recording critical error %d at %s:%lx\n", code, filename, address);
|
||||
else
|
||||
DEBUG_MSG("NOTE! Recording critical error %d, address=%lx\n", code, address);
|
||||
|
||||
// Record error to DB
|
||||
|
@ -94,15 +94,15 @@ bool RF95Interface::reconfigure()
|
||||
// configure publicly accessible settings
|
||||
int err = lora->setSpreadingFactor(sf);
|
||||
if (err != ERR_NONE)
|
||||
recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||
|
||||
err = lora->setBandwidth(bw);
|
||||
if (err != ERR_NONE)
|
||||
recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||
|
||||
err = lora->setCodingRate(cr);
|
||||
if (err != ERR_NONE)
|
||||
recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||
|
||||
err = lora->setSyncWord(syncWord);
|
||||
assert(err == ERR_NONE);
|
||||
@ -115,13 +115,13 @@ bool RF95Interface::reconfigure()
|
||||
|
||||
err = lora->setFrequency(freq);
|
||||
if (err != ERR_NONE)
|
||||
recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||
|
||||
if (power > MAX_POWER) // This chip has lower power limits than some
|
||||
power = MAX_POWER;
|
||||
err = lora->setOutputPower(power);
|
||||
if (err != ERR_NONE)
|
||||
recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||
|
||||
startReceive(); // restart receiving
|
||||
|
||||
|
@ -75,7 +75,7 @@ bool RadioLibInterface::canSendImmediately()
|
||||
// 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);
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_TransmitFailed);
|
||||
#ifndef NO_ESP32
|
||||
if (busyTx && (millis() - lastTxStart > 65000)) // After 5s more, reboot
|
||||
ESP.restart();
|
||||
|
@ -46,7 +46,8 @@ typedef enum _CriticalErrorCode {
|
||||
CriticalErrorCode_NoAXP192 = 6,
|
||||
CriticalErrorCode_InvalidRadioSetting = 7,
|
||||
CriticalErrorCode_TransmitFailed = 8,
|
||||
CriticalErrorCode_Brownout = 9
|
||||
CriticalErrorCode_Brownout = 9,
|
||||
CriticalErrorCode_SX1262Failure = 10
|
||||
} CriticalErrorCode;
|
||||
|
||||
typedef enum _Routing_Error {
|
||||
@ -216,8 +217,8 @@ typedef struct _ToRadio {
|
||||
#define _Constants_ARRAYSIZE ((Constants)(Constants_DATA_PAYLOAD_LEN+1))
|
||||
|
||||
#define _CriticalErrorCode_MIN CriticalErrorCode_None
|
||||
#define _CriticalErrorCode_MAX CriticalErrorCode_Brownout
|
||||
#define _CriticalErrorCode_ARRAYSIZE ((CriticalErrorCode)(CriticalErrorCode_Brownout+1))
|
||||
#define _CriticalErrorCode_MAX CriticalErrorCode_SX1262Failure
|
||||
#define _CriticalErrorCode_ARRAYSIZE ((CriticalErrorCode)(CriticalErrorCode_SX1262Failure+1))
|
||||
|
||||
#define _Routing_Error_MIN Routing_Error_NONE
|
||||
#define _Routing_Error_MAX Routing_Error_NOT_AUTHORIZED
|
||||
|
@ -108,7 +108,7 @@ void checkSDEvents()
|
||||
while (NRF_SUCCESS == sd_evt_get(&evt)) {
|
||||
switch (evt) {
|
||||
case NRF_EVT_POWER_FAILURE_WARNING:
|
||||
recordCriticalError(CriticalErrorCode_Brownout);
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_Brownout);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -118,7 +118,7 @@ void checkSDEvents()
|
||||
}
|
||||
} else {
|
||||
if (NRF_POWER->EVENTS_POFWARN)
|
||||
recordCriticalError(CriticalErrorCode_Brownout);
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_Brownout);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ static void waitEnterSleep()
|
||||
delay(100); // Kinda yucky - wait until radio says say we can shutdown (finished in process sends/receives)
|
||||
|
||||
if (millis() - now > 30 * 1000) { // If we wait too long just report an error and go to sleep
|
||||
recordCriticalError(CriticalErrorCode_SleepEnterWait);
|
||||
RECORD_CRITICALERROR(CriticalErrorCode_SleepEnterWait);
|
||||
assert(0); // FIXME - for now we just restart, need to fix bug #167
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user