aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends/mqtt.c
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2021-02-14 02:12:22 +0100
committercbdev <cb@cbcdn.com>2021-02-14 02:12:22 +0100
commitf483c0e50676d6a3b8eb8258daca1115550dd808 (patch)
tree76ca0756b71fd615d3559d36a6058013bd73eb89 /backends/mqtt.c
parent670f3ff21f30b8aae765d61a38a7269d0eaab19d (diff)
downloadmidimonster-f483c0e50676d6a3b8eb8258daca1115550dd808.tar.gz
midimonster-f483c0e50676d6a3b8eb8258daca1115550dd808.tar.bz2
midimonster-f483c0e50676d6a3b8eb8258daca1115550dd808.zip
MQTT backend documentation
Diffstat (limited to 'backends/mqtt.c')
-rw-r--r--backends/mqtt.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/backends/mqtt.c b/backends/mqtt.c
index 29f0436..41fa772 100644
--- a/backends/mqtt.c
+++ b/backends/mqtt.c
@@ -580,7 +580,7 @@ static int mqtt_maintenance(){
static int mqtt_handle_publish(instance* inst, uint8_t type, uint8_t* variable_header, size_t length){
mqtt_instance_data* data = (mqtt_instance_data*) inst->impl;
- char* topic = NULL, *payload = NULL;
+ char* topic = NULL, *payload = NULL, *conversion_end = NULL;
channel* changed = NULL;
channel_value val;
uint8_t qos = (type & 0x06) >> 1, content_utf8 = 0;
@@ -647,7 +647,11 @@ static int mqtt_handle_publish(instance* inst, uint8_t type, uint8_t* variable_h
//FIXME implement input mappings
changed = mm_channel(inst, u, 0);
if(changed){
- val.normalised = strtod(payload, NULL);
+ val.normalised = clamp(strtod(payload, &conversion_end), 1.0, 0.0);
+ if(payload == conversion_end){
+ LOGPF("Failed to parse incoming data for %s.%s", inst->name, data->channel[u].topic);
+ return 0;
+ }
mm_channel_event(changed, val);
}
}