From f4b199f60188733cb3bafeb199bdf6fe3758616e Mon Sep 17 00:00:00 2001 From: Michal Hanus Date: Mon, 26 May 2025 22:51:43 +0200 Subject: only LTE --- nrfdemo/src/mqtt_connection.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'nrfdemo/src/mqtt_connection.c') diff --git a/nrfdemo/src/mqtt_connection.c b/nrfdemo/src/mqtt_connection.c index 1d884b7..2410bca 100644 --- a/nrfdemo/src/mqtt_connection.c +++ b/nrfdemo/src/mqtt_connection.c @@ -101,7 +101,14 @@ static void data_print(uint8_t *prefix, uint8_t *data, size_t len) int publish_sensor(struct mqtt_client *c, uint8_t* topic, int32_t val1, int32_t val2) { uint8_t buf[20], sgn = (val1 < 0 && val2 < 0) ? '-' : '+'; - snprintf(buf, 20, "%c%i.%03i", labs(val1), labs(val2)/1000); + snprintf(buf, 20, "%c%i.%03i\0", sgn, labs(val1), labs(val2)/1000); + publish_wrap(c, topic, buf, MIN(20, strlen(buf))); +} + +int publish_int(struct mqtt_client *c, uint8_t* topic, int32_t val) +{ + uint8_t buf[20]; + snprintf(buf, 20, "%d", val); publish_wrap(c, topic, buf, strlen(buf)); } -- cgit v1.2.3