Decode incoming messages as JSON

This commit is contained in:
Starbeamrainbowlabs 2019-07-09 11:46:35 +01:00
parent 5aa990b421
commit 321b154105
2 changed files with 11 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.pcapng
*.png *.png
*.stl *.stl
config.custom.h config.custom.h

View File

@ -56,7 +56,16 @@ class TTNAppServer {
} }
async handle_message(topic, message_buffer) { async handle_message(topic, message_buffer) {
console.log(arguments); let message = message_buffer.toString("utf8"),
message_object = null;
try {
message_object = JSON.parse(message);
} catch(error) {
this.log.log(error);
return false;
}
this.log.log(`[mqtt/handler] ${topic}: `, message_object);
// await this.message_handler.handle(payload); // await this.message_handler.handle(payload);
} }
} }