diff options
| author | Michal Hanus <mikehanus@protonmail.com> | 2025-05-26 22:51:43 +0200 |
|---|---|---|
| committer | Michal Hanus <mikehanus@protonmail.com> | 2025-05-26 22:51:43 +0200 |
| commit | f4b199f60188733cb3bafeb199bdf6fe3758616e (patch) | |
| tree | 72f1c8bfb349f6a8ccb0723dbd98644c7a8dbef6 /nrfdemo/src/mqtt_connection.c | |
| parent | a407db2d45286f37eff10710c9a8e43755cedfc6 (diff) | |
only LTE
Diffstat (limited to 'nrfdemo/src/mqtt_connection.c')
| -rw-r--r-- | nrfdemo/src/mqtt_connection.c | 9 |
1 files changed, 8 insertions, 1 deletions
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)); } |
