From 0e37b5adcf400f338defa2b3d1675b0194d049c5 Mon Sep 17 00:00:00 2001 From: zutroy97 Date: Sun, 5 Jul 2026 17:45:24 -0500 Subject: [PATCH] Reverted back track_id as hex string --- mqtt.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/mqtt.c b/mqtt.c index 9c6c429d..f9936cb9 100644 --- a/mqtt.c +++ b/mqtt.c @@ -85,9 +85,9 @@ void on_message(__attribute__((unused)) struct mosquitto *mosq, debug(2, "[MQTT]: Disconnect Command: %s\n", commands[it]); stop_play(); // stop any current session and don't replace it } else if (strcmp(commands[it], "queue_next") == 0) { - // payload is "queue_next ", where is the decimal track_id + // payload is "queue_next ", where is the hex track_id // string as published by shairport-sync itself (see the "mper"/"track_id" handling - // above), e.g. "queue_next 123456789012345" + // above), e.g. "queue_next 1A2B3C4D5E6F7" char *track_id = payload + strlen(commands[it]); while (*track_id == ' ' || *track_id == '\t') track_id++; @@ -99,7 +99,7 @@ void on_message(__attribute__((unused)) struct mosquitto *mosq, } else { char dacp_command[256]; snprintf(dacp_command, sizeof(dacp_command), - "cue?command=add&query='dmap.persistentid:%s'&mode=3", track_id); + "cue?command=add&query='dmap.persistentid:0x%s'&mode=3", track_id); debug(2, "[MQTT]: Queue Next Command: %s\n", dacp_command); send_simple_dacp_command(dacp_command); } @@ -322,7 +322,6 @@ void mqtt_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t le if (config.mqtt_publish_parsed) { if (type == 'core') { int32_t r; - uint64_t trackid; char trackidstring[32]; switch (code) { @@ -342,10 +341,12 @@ void mqtt_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t le mqtt_publish("title", data, length); break; case 'mper': - trackid = ntohl(*(uint32_t *)data); - trackid = trackid << 32; - trackid += ntohl(*(uint32_t *)(data + sizeof(uint32_t))); - r = snprintf(trackidstring, sizeof(trackidstring), "%" PRIu64 "", trackid); + // publish the raw persistent-id bytes as hex, in the order received -- + // no byte-order or integer conversion, so this can't reverse the value. + r = 0; + for (uint32_t i = 0; i < length && r < (int32_t)sizeof(trackidstring) - 2; i++) + r += snprintf(trackidstring + r, sizeof(trackidstring) - (size_t)r, "%02X", + (unsigned char)data[i]); mqtt_publish("track_id", trackidstring, r); } } else if (type == 'ssnc') {