From 95925b563a6f3ad6f173e0c2d0cd58a9056df76d Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Thu, 18 Jun 2026 15:56:30 -0700 Subject: [PATCH] Stop playing if nobody's listening --- src/avclandrv.h | 1 + src/sniffer.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/avclandrv.h b/src/avclandrv.h index 81ca7b8..f7b5869 100644 --- a/src/avclandrv.h +++ b/src/avclandrv.h @@ -218,6 +218,7 @@ AVCLAN_frame_t *AVCLAN_getStatusFrame(); void AVCLAN_generateStatus(AVCLAN_frame_t *status, bool is_unicast, devices to); bool AVCLAN_isPlaying(); +void AVCLAN_stopPlaying(); void AVCLAN_incrementTime(); void AVCLAN_setTime(uint8_t mins, uint8_t secs); void AVCLAN_normalizeState(); diff --git a/src/sniffer.c b/src/sniffer.c index fae3080..a3824ff 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -110,6 +110,7 @@ int main() { uint8_t seqIdx = 0; // current index in data_tmp uint8_t err = 0; + uint8_t failedStatusReports = 0; for (uint8_t i = 0; i < CACHE_SIZE; ++i) { frames[i].control = 0x0f; @@ -169,6 +170,12 @@ int main() { err = AVCLAN_sendframe( out, (log_t){.print = printAllFrames, .binary = printBinary}); if (err || resp->r == r_Handled) { + if (err && out == AVCLAN_getStatusFrame() && + failedStatusReports++ > 1) { + failedStatusReports = 0; + AVCLAN_stopPlaying(); // Disable periodic updates if e.g. no-one's + // listening (car was turned off?) + } return_resp(resp); } else { resp = AVCLAN_statemachine(resp);