mirror of
https://github.com/eclipse/mosquitto.git
synced 2025-05-09 01:01:11 +08:00
Add user-property output support to sub/rr.
This commit is contained in:
parent
934ec7355a
commit
1c6666b63a
@ -73,6 +73,8 @@ static int check_format(const char *str)
|
||||
// payload length
|
||||
}else if(str[i+1] == 'm'){
|
||||
// mid
|
||||
}else if(str[i+1] == 'P'){
|
||||
// MQTT v5 property user-property
|
||||
}else if(str[i+1] == 'p'){
|
||||
// payload
|
||||
}else if(str[i+1] == 'q'){
|
||||
|
@ -338,7 +338,8 @@ static void formatted_print(const struct mosq_config *lcfg, const struct mosquit
|
||||
uint8_t i8value;
|
||||
uint16_t i16value;
|
||||
uint32_t i32value;
|
||||
char *binvalue, *strvalue;
|
||||
char *binvalue, *strname, *strvalue;
|
||||
const mosquitto_property *prop;
|
||||
|
||||
len = strlen(lcfg->format);
|
||||
|
||||
@ -433,6 +434,26 @@ static void formatted_print(const struct mosq_config *lcfg, const struct mosquit
|
||||
printf("%d", message->mid);
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
strname = NULL;
|
||||
strvalue = NULL;
|
||||
prop = mosquitto_property_read_string_pair(properties, MQTT_PROP_USER_PROPERTY, &strname, &strvalue, false);
|
||||
while(prop){
|
||||
printf("%s:%s", strname, strvalue);
|
||||
free(strname);
|
||||
free(strvalue);
|
||||
strname = NULL;
|
||||
strvalue = NULL;
|
||||
|
||||
prop = mosquitto_property_read_string_pair(prop, MQTT_PROP_USER_PROPERTY, &strname, &strvalue, true);
|
||||
if(prop){
|
||||
fputc(' ', stdout);
|
||||
}
|
||||
}
|
||||
free(strname);
|
||||
free(strvalue);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
write_payload(message->payload, message->payloadlen, 0);
|
||||
break;
|
||||
|
@ -675,6 +675,9 @@
|
||||
<listitem><para><option>%F</option> the MQTT v5 payload-format-indicator property, if present.</para></listitem>
|
||||
<listitem><para><option>%l</option> the length of the payload in bytes.</para></listitem>
|
||||
<listitem><para><option>%m</option> the message id (only relevant for messages with QoS>0).</para></listitem>
|
||||
<listitem><para><option>%P</option> the MQTT v5 user-property property, if present. This will be printed in the
|
||||
form key:value. It is possible for any number of user properties to be attached to a message, and to
|
||||
have duplicate keys.</para></listitem>
|
||||
<listitem><para><option>%p</option> the payload raw bytes (may produce non-printable characters depending on the payload).</para></listitem>
|
||||
<listitem><para><option>%q</option> the message QoS.</para></listitem>
|
||||
<listitem><para><option>%R</option> the MQTT v5 response-topic property, if present.</para></listitem>
|
||||
|
@ -792,6 +792,9 @@ mosquitto_sub -t 'bbc/#' -T bbc/bbc1 --remove-retained</programlisting>
|
||||
<listitem><para><option>%F</option> the MQTT v5 payload-format-indicator property, if present.</para></listitem>
|
||||
<listitem><para><option>%l</option> the length of the payload in bytes.</para></listitem>
|
||||
<listitem><para><option>%m</option> the message id (only relevant for messages with QoS>0).</para></listitem>
|
||||
<listitem><para><option>%P</option> the MQTT v5 user-property property, if present. This will be printed in the
|
||||
form key:value. It is possible for any number of user properties to be attached to a message, and to
|
||||
have duplicate keys.</para></listitem>
|
||||
<listitem><para><option>%p</option> the payload raw bytes (may produce non-printable characters depending on the payload).</para></listitem>
|
||||
<listitem><para><option>%q</option> the message QoS.</para></listitem>
|
||||
<listitem><para><option>%R</option> the MQTT v5 response-topic property, if present.</para></listitem>
|
||||
|
Loading…
x
Reference in New Issue
Block a user