firmware: debug/test build profiles with real behavioural differences

This commit is contained in:
Lars Nolden
2026-09-01 11:23:28 +02:00
parent 31c7aa7d02
commit c835c62172
9 changed files with 133 additions and 13 deletions
+26 -6
View File
@@ -22,7 +22,11 @@ repeater_cfg_t g_cfg = {
.repeat_delay_ms = 50,
.tx_power_dbm = -9,
.repeat_enabled = true,
#ifdef CONFIG_WMBUS_VERBOSE_DEFAULT
.verbose = true,
#else
.verbose = false,
#endif
.whitelist = {0},
.whitelist_len = 0,
};
@@ -219,10 +223,18 @@ static const char *do_tx(const uint8_t *payload, int payload_len,
*tx_done_us = notify_seen ? s_irq_ts : esp_timer_get_time();
fem_set_tx(false);
sx126x_clear_irq(SX126X_IRQ_ALL);
LOGJ("\"event\":\"tx_diag\",\"irq\":%u,\"notify\":%s,\"dio1_high_seen\":%s,"
"\"max_chip_mode\":%u,\"device_errors\":%u",
irq, notify_seen ? "true" : "false", dio1_seen ? "true" : "false",
max_mode, sx126x_get_device_errors());
#ifdef CONFIG_WMBUS_TX_DIAG_ALWAYS
const bool want_diag = true;
#else
// otherwise only when something went wrong, so timing stays clean
const bool want_diag = g_cfg.verbose || !(irq & SX126X_IRQ_TX_DONE);
#endif
if (want_diag) {
LOGJ("\"event\":\"tx_diag\",\"irq\":%u,\"notify\":%s,"
"\"dio1_high_seen\":%s,\"max_chip_mode\":%u,\"device_errors\":%u",
irq, notify_seen ? "true" : "false", dio1_seen ? "true" : "false",
max_mode, sx126x_get_device_errors());
}
if (irq & SX126X_IRQ_TX_DONE) {
g_stats.tx_success++;
return notify_seen ? "ok" : "ok_polled";
@@ -247,11 +259,15 @@ static void log_tx(const char *result, uint32_t hash, int len,
(long long)(tx_start - rx_ts), len, hash,
(int)g_cfg.tx_power_dbm,
(long long)(tx_done > tx_start ? tx_done - tx_start : 0), result);
#ifdef CONFIG_WMBUS_LOG_RAW_FRAMES
if (payload && payload_len > 0) {
printf(",\"tx_payload\":\"");
print_hex(payload, payload_len);
printf("\"");
}
#else
(void)payload; (void)payload_len;
#endif
printf("}\n");
fflush(stdout);
}
@@ -421,12 +437,16 @@ static void handle_rx(int64_t rxdone_ts)
printf("{\"seq\":%" PRIu32 ",\"event\":\"wmbus_rx\",\"timestamp_us\":%lld,"
"\"rxdone_us\":%lld,\"frequency_hz\":868950000,\"format\":\"%c\","
"\"length\":%d,\"rssi_dbm\":%d,\"crc_ok\":%s,"
"\"hash\":\"%08" PRIx32 "\",\"raw\":\"",
"\"hash\":\"%08" PRIx32 "\"",
s_seq++, (long long)frame_end_ts, (long long)rxdone_ts,
fmt == WMBUS_FRAME_A ? 'A' : 'B', total, rssi,
crc_ok ? "true" : "false", hash);
#ifdef CONFIG_WMBUS_LOG_RAW_FRAMES
printf(",\"raw\":\"");
print_hex(frame, total);
printf("\"}\n");
printf("\"");
#endif
printf("}\n");
fflush(stdout);
if (!g_cfg.repeat_enabled || !crc_ok) return;