firmware: LED heartbeat on GPIO35 (boot/alive/rx/tx/fault patterns), non-blocking

This commit is contained in:
Lars Nolden
2026-09-01 14:53:23 +02:00
parent b221738d2a
commit 61d52503ab
6 changed files with 106 additions and 1 deletions
+5
View File
@@ -2,6 +2,7 @@
#include "sx126x.h"
#include "wmbus.h"
#include "board.h"
#include "led.h"
#include <stdio.h>
#include <string.h>
@@ -142,6 +143,7 @@ static bool radio_full_init(void)
static bool recover(const char *reason, int level)
{
g_stats.recoveries++;
led_notify_fault();
bool ok = false;
switch (level) {
case 1:
@@ -282,6 +284,7 @@ static const char *do_tx(const uint8_t *payload, int payload_len,
}
if (irq & SX126X_IRQ_TX_DONE) {
g_stats.tx_success++;
led_notify_tx();
if (*tx_done_us > *tx_start_us) {
g_stats.tx_airtime_us += (uint64_t)(*tx_done_us - *tx_start_us);
}
@@ -477,6 +480,7 @@ static void handle_rx(int64_t rxdone_ts)
bool crc_ok = wmbus_check_crc(fmt, frame, total);
if (crc_ok) g_stats.rx_valid++; else g_stats.rx_crc_fail++;
if (crc_ok) led_notify_rx();
uint32_t hash = wmbus_hash(frame, total);
// RxDone fires after the fixed 255-byte capture; the frame actually
// ended earlier. Reconstruct the real end-of-frame time.
@@ -563,6 +567,7 @@ static void repeater_task(void *arg)
recover_ladder("boot_init_failed");
}
if (!sx126x_set_rx()) recover_ladder("boot_rx_failed");
led_boot_done();
int64_t last_heartbeat = 0;
for (;;) {