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
|
*.png
|
||||||
*.stl
|
*.stl
|
||||||
config.custom.h
|
config.custom.h
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue