Commit bf46c2c2 by Martin Kotula

Hub mqtt fixes:

parent 4595f28b
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
<h3>Example data</h3> <h3>Example data</h3>
<pre> <pre>
{ "object": { "sensorId": "Sensor 1", "isBusy": true}} { "sensorId": "Sensor 1", "isBusy": true}
{ "object": { "sensorId": "Sensor 2", "isBusy": true}} { "sensorId": "Sensor 2", "isBusy": true}
{ "object": { "sensorId": "Sensor 1", "isBusy": true}} { "sensorId": "Sensor 1", "isBusy": true}
{ "object": { "sensorId": "Sensor 2", "isBusy": true}} { "sensorId": "Sensor 2", "isBusy": true}
{ "object": { "sensorId": "Sensor 1", "isBusy": true}} { "sensorId": "Sensor 1", "isBusy": true}
{ "object": { "sensorId": "Sensor 1", "isBusy": false}} { "sensorId": "Sensor 1", "isBusy": false}
{ "object": { "sensorId": "Sensor 3", "isBusy": false}}} { "sensorId": "Sensor 3", "isBusy": false}
{ "object": { "sensorId": "Sensor 3", "isBusy": true}} { "sensorId": "Sensor 3", "isBusy": true}
</pre> </pre>
\ No newline at end of file
...@@ -17,15 +17,14 @@ define(["app/config", "app/events", "mqtt", "lodash", "knockout", "knockout-post ...@@ -17,15 +17,14 @@ define(["app/config", "app/events", "mqtt", "lodash", "knockout", "knockout-post
try{ try{
console.debug("Mqtt message received: " + message.toString()); console.debug("Mqtt message received: " + message.toString());
var messageBody = JSON.parse(message.toString()); var messageBody = JSON.parse(message.toString());
if(messageBody.object === undefined || if(messageBody.sensorId === undefined ||
messageBody.object.sensorId === undefined || messageBody.isBusy === undefined ){
messageBody.object.isBusy === undefined ){
throw "InvalidMessageFormat"; throw "InvalidMessageFormat";
} }
var model = { var model = {
id: messageBody.object.sensorId, id: messageBody.sensorId,
isOccupied: messageBody.object.isBusy, isOccupied: messageBody.isBusy,
timestamp: new Date() timestamp: new Date()
}; };
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>OccupancySensorDashboard</title> <title>OccupancySensorDashboard</title>
<link rel="stylesheet" href="css.css?1499263535088"> <link rel="stylesheet" href="css.css?1499344294490">
<script src="scripts.js?1499263535088"></script> <script src="scripts.js?1499344294491"></script>
</head> </head>
<body> <body>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment