Decode incoming messages as JSON
This commit is contained in:
parent
5aa990b421
commit
321b154105
2 changed files with 11 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
*.pcapng
|
||||
*.png
|
||||
*.stl
|
||||
config.custom.h
|
||||
|
|
|
@ -56,7 +56,16 @@ class TTNAppServer {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue