From 6de30126a9013e69e3cc759a5c4e9ed531a69217 Mon Sep 17 00:00:00 2001 From: aaronk6 Date: Sat, 16 Mar 2024 17:40:59 +0100 Subject: [PATCH] MQTT: Add is_active and is _playing --- mqtt.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mqtt.c b/mqtt.c index f662009d..fd172161 100644 --- a/mqtt.c +++ b/mqtt.c @@ -21,6 +21,10 @@ struct mosquitto *global_mosq = NULL; char *topic = NULL; int connected = 0; +// track active/playing state +int is_active = 0; +int is_playing = 0; + // mosquitto logging void _cb_log(__attribute__((unused)) struct mosquitto *mosq, __attribute__((unused)) void *userdata, int level, const char *str) { @@ -167,12 +171,16 @@ void mqtt_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t le } else if (type == 'ssnc') { switch (code) { case 'abeg': + is_active = 1; + mqtt_publish("is_active", "1", 1); mqtt_publish("active_start", data, length); break; case 'acre': mqtt_publish("active_remote_id", data, length); break; case 'aend': + is_active = 0; + mqtt_publish("is_active", "0", 1); mqtt_publish("active_end", data, length); break; case 'asal': @@ -210,9 +218,13 @@ void mqtt_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t le mqtt_publish("output_frame_rate", data, length); break; case 'pbeg': + is_playing = 1; + mqtt_publish("is_playing", "1", 1); mqtt_publish("play_start", data, length); break; case 'pend': + is_playing = 0; + mqtt_publish("is_playing", "0", 1); mqtt_publish("play_end", data, length); break; case 'pfls': @@ -224,6 +236,8 @@ void mqtt_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t le } break; case 'prsm': + is_playing = 1; + mqtt_publish("is_playing", "1", 1); mqtt_publish("play_resume", data, length); break; case 'pvol': -- 2.47.3