Skip to content

Commit

Permalink
Let's report crashes as part of the init message after all
Browse files Browse the repository at this point in the history
  • Loading branch information
lptr committed Dec 13, 2024
1 parent f301ad8 commit 3c5a571
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions main/devices/Device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,11 @@ class Device {
json["state"] = static_cast<int>(initState);
json["peripherals"].to<JsonArray>().set(peripheralsInitJson);
json["sleepWhenIdle"] = kernel.powerManager.sleepWhenIdle;

reportPreviousCrashIfAny(json);
},
Retention::NoRetain, QoS::AtLeastOnce, 5s);

reportPreviousCrashIfAny();

Task::loop("telemetry", 8192, [this](Task& task) {
publishTelemetry();
// TODO Configure these telemetry intervals
Expand Down Expand Up @@ -545,7 +545,7 @@ class Device {
}
}

void reportPreviousCrashIfAny() {
void reportPreviousCrashIfAny(JsonObject& json) {
esp_err_t errCheck = esp_core_dump_image_check();
if (errCheck == ESP_ERR_NOT_FOUND) {
LOGV("No core dump found");
Expand All @@ -561,12 +561,8 @@ class Device {
if (err != ESP_OK) {
LOGE("Failed to get core dump summary: %s", esp_err_to_name(err));
} else {
mqttDeviceRoot->publish(
"crash",
[&](JsonObject& json) {
reportPreviousCrash(json, summary);
},
Retention::Retain, QoS::AtLeastOnce, 5s);
auto crashJson = json["crash"].to<JsonObject>();
reportPreviousCrash(crashJson, summary);
}

ESP_ERROR_CHECK_WITHOUT_ABORT(esp_core_dump_image_erase());
Expand Down

0 comments on commit 3c5a571

Please sign in to comment.