Reverted back track_id as hex string
This commit is contained in:
@@ -85,9 +85,9 @@ void on_message(__attribute__((unused)) struct mosquitto *mosq,
|
|||||||
debug(2, "[MQTT]: Disconnect Command: %s\n", commands[it]);
|
debug(2, "[MQTT]: Disconnect Command: %s\n", commands[it]);
|
||||||
stop_play(); // stop any current session and don't replace it
|
stop_play(); // stop any current session and don't replace it
|
||||||
} else if (strcmp(commands[it], "queue_next") == 0) {
|
} else if (strcmp(commands[it], "queue_next") == 0) {
|
||||||
// payload is "queue_next <track_id>", where <track_id> is the decimal track_id
|
// payload is "queue_next <track_id>", where <track_id> is the hex track_id
|
||||||
// string as published by shairport-sync itself (see the "mper"/"track_id" handling
|
// 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]);
|
char *track_id = payload + strlen(commands[it]);
|
||||||
while (*track_id == ' ' || *track_id == '\t')
|
while (*track_id == ' ' || *track_id == '\t')
|
||||||
track_id++;
|
track_id++;
|
||||||
@@ -99,7 +99,7 @@ void on_message(__attribute__((unused)) struct mosquitto *mosq,
|
|||||||
} else {
|
} else {
|
||||||
char dacp_command[256];
|
char dacp_command[256];
|
||||||
snprintf(dacp_command, sizeof(dacp_command),
|
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);
|
debug(2, "[MQTT]: Queue Next Command: %s\n", dacp_command);
|
||||||
send_simple_dacp_command(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 (config.mqtt_publish_parsed) {
|
||||||
if (type == 'core') {
|
if (type == 'core') {
|
||||||
int32_t r;
|
int32_t r;
|
||||||
uint64_t trackid;
|
|
||||||
char trackidstring[32];
|
char trackidstring[32];
|
||||||
|
|
||||||
switch (code) {
|
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);
|
mqtt_publish("title", data, length);
|
||||||
break;
|
break;
|
||||||
case 'mper':
|
case 'mper':
|
||||||
trackid = ntohl(*(uint32_t *)data);
|
// publish the raw persistent-id bytes as hex, in the order received --
|
||||||
trackid = trackid << 32;
|
// no byte-order or integer conversion, so this can't reverse the value.
|
||||||
trackid += ntohl(*(uint32_t *)(data + sizeof(uint32_t)));
|
r = 0;
|
||||||
r = snprintf(trackidstring, sizeof(trackidstring), "%" PRIu64 "", trackid);
|
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);
|
mqtt_publish("track_id", trackidstring, r);
|
||||||
}
|
}
|
||||||
} else if (type == 'ssnc') {
|
} else if (type == 'ssnc') {
|
||||||
|
|||||||
Reference in New Issue
Block a user