From 1fbb6312f60f4c9812f2d6ff2dc06508bac54ccd Mon Sep 17 00:00:00 2001 From: Scott Simon Date: Thu, 2 Jul 2026 23:50:23 -0500 Subject: [PATCH] Fix byte order of track_id published over MQTT The 'mper' handler cast the raw big-endian persistent-id bytes directly to a host-native uint64_t, which reverses the value on little-endian hosts (e.g. Raspberry Pi). metadata_hub.c already reconstructs the same field correctly by applying ntohl() to each 32-bit half; mqtt.c now does the same, so the published track_id matches the real dmap.persistentid and can be used directly with the queue_next command. Co-Authored-By: Claude Sonnet 5 --- mqtt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mqtt.c b/mqtt.c index 7c6e861b..6fb1fd36 100644 --- a/mqtt.c +++ b/mqtt.c @@ -347,7 +347,9 @@ void mqtt_process_metadata(uint32_t type, uint32_t code, char *data, uint32_t le mqtt_publish("title", data, length); break; case 'mper': - trackid = *(uint64_t *)(data); + trackid = ntohl(*(uint32_t *)data); + trackid = trackid << 32; + trackid += ntohl(*(uint32_t *)(data + sizeof(uint32_t))); r = snprintf(trackidstring, sizeof(trackidstring), "%" PRIX64 "", trackid); mqtt_publish("track_id", trackidstring, r); }