Skip to content

Commit

Permalink
fixed packet parser to not get messed up by downlink
Browse files Browse the repository at this point in the history
  • Loading branch information
adkinsjd committed Apr 2, 2018
1 parent 17dd1d5 commit f13b32e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/lab11/packet-parser/packet-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,12 @@ mqtt_client.on('connect', function () {

// Callback for each packet
mqtt_external.on('message', function (topic, message) {
var json = JSON.parse(message.toString());
console.log("Received from " + topic);
try {
var json = JSON.parse(message.toString());
console.log("Received from " + topic);
} catch(e) {
//this must have been a downlink message not in json format
}
try {
if(json.data && json.receiver && json.geohash) {
buf = Buffer.from(json.data);
Expand Down

0 comments on commit f13b32e

Please sign in to comment.