Commit bf46c2c2 by Martin Kotula

Hub mqtt fixes:

parent 4595f28b
......@@ -7,12 +7,12 @@
<h3>Example data</h3>
<pre>
{ "object": { "sensorId": "Sensor 1", "isBusy": true}}
{ "object": { "sensorId": "Sensor 2", "isBusy": true}}
{ "object": { "sensorId": "Sensor 1", "isBusy": true}}
{ "object": { "sensorId": "Sensor 2", "isBusy": true}}
{ "object": { "sensorId": "Sensor 1", "isBusy": true}}
{ "object": { "sensorId": "Sensor 1", "isBusy": false}}
{ "object": { "sensorId": "Sensor 3", "isBusy": false}}}
{ "object": { "sensorId": "Sensor 3", "isBusy": true}}
{ "sensorId": "Sensor 1", "isBusy": true}
{ "sensorId": "Sensor 2", "isBusy": true}
{ "sensorId": "Sensor 1", "isBusy": true}
{ "sensorId": "Sensor 2", "isBusy": true}
{ "sensorId": "Sensor 1", "isBusy": true}
{ "sensorId": "Sensor 1", "isBusy": false}
{ "sensorId": "Sensor 3", "isBusy": false}
{ "sensorId": "Sensor 3", "isBusy": true}
</pre>
\ No newline at end of file
......@@ -17,15 +17,14 @@ define(["app/config", "app/events", "mqtt", "lodash", "knockout", "knockout-post
try{
console.debug("Mqtt message received: " + message.toString());
var messageBody = JSON.parse(message.toString());
if(messageBody.object === undefined ||
messageBody.object.sensorId === undefined ||
messageBody.object.isBusy === undefined ){
if(messageBody.sensorId === undefined ||
messageBody.isBusy === undefined ){
throw "InvalidMessageFormat";
}
var model = {
id: messageBody.object.sensorId,
isOccupied: messageBody.object.isBusy,
id: messageBody.sensorId,
isOccupied: messageBody.isBusy,
timestamp: new Date()
};
......
......@@ -4,9 +4,9 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<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>
<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