thing-it-device-wtec
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -422,3 +422,3 @@ "use strict"; | ||
} else { | ||
this.logDebug('Received update prior to being initialized.') | ||
this.logDebug('Fixture received update prior to being initialized.') | ||
} | ||
@@ -425,0 +425,0 @@ } |
@@ -202,10 +202,13 @@ "use strict"; | ||
this.update() | ||
.then(function () { | ||
this.initialized = true; | ||
var initializationUpdate = setInterval( | ||
function () { | ||
this.update() | ||
.then(function () { | ||
this.initialized = true; | ||
clearInterval(initializationUpdate); | ||
if (this.configuration.subscribeIndividualLocation) { | ||
this.logInfo('Subscribing to individual location update, not expecting updates from device.'); | ||
if (this.configuration.subscribeIndividualLocation) { | ||
this.logInfo('Subscribing to individual location update, not expecting updates from device.'); | ||
var payload = '{ \ | ||
var payload = '{ \ | ||
"protocolVersion" : "1", \ | ||
@@ -223,27 +226,30 @@ "schemaVersion" : "1.4.0", \ | ||
this.device.continuousPost('/uApi', payload, function (error, result) { | ||
if (error) { | ||
this.logError(error); | ||
this.device.continuousPost('/uApi', payload, function (error, result) { | ||
if (error) { | ||
this.logError(error); | ||
} else { | ||
this.logDebug('Received change of value notification.'); | ||
this.readResponse(result.responseData.location[0], result.time); | ||
} | ||
}.bind(this)); | ||
} else { | ||
this.logDebug('Received change of value notification.'); | ||
this.readResponse(result.responseData.location[0], result.time); | ||
this.logInfo('Not subscribing to individual location update, expecting updates from device.'); | ||
} | ||
}.bind(this)); | ||
} else { | ||
this.logInfo('Not subscribing to individual location update, expecting updates from device.'); | ||
} | ||
this.logInfo('Location started.'); | ||
}.bind(this)) | ||
.fail(function (error) { | ||
this.logInfo('Location started with error.'); | ||
this.logError(error); | ||
}) | ||
.done(); | ||
this.logInfo('Location started.'); | ||
}.bind(this)) | ||
.fail(function (error) { | ||
this.logInfo('Location started with error.'); | ||
this.logError(error); | ||
}) | ||
.done(); | ||
}.bind(this), 1000); | ||
} | ||
/*this.interval = setInterval(function () { | ||
this.update(); | ||
}.bind(this), 5000);*/ | ||
} | ||
} catch (e) { | ||
/*this.interval = setInterval(function () { | ||
this.update(); | ||
}.bind(this), 5000);*/ | ||
} | ||
catch | ||
(e) { | ||
this.logError('Error during start.', e); | ||
@@ -253,5 +259,5 @@ this.logInfo('Location started with error.'); | ||
setTimeout(function(){ | ||
setTimeout(function () { | ||
deferred.resolve(); | ||
},100); | ||
}, 100); | ||
@@ -561,5 +567,5 @@ return deferred.promise; | ||
} else { | ||
this.logInfo('Received update prior to being initialized.') | ||
this.logInfo('Location received update prior to being initialized.') | ||
} | ||
} | ||
} |
{ | ||
"name": "thing-it-device-wtec", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "[thing-it-node] Device Plugin for wtec devices.", | ||
@@ -5,0 +5,0 @@ "authors": "Klaus Berberich", |
@@ -415,2 +415,8 @@ module.exports = { | ||
for (var i = 0; i < responseArray.length; i++) { | ||
// need to add the starting { of any splitted element back in | ||
if (i>0) { | ||
responseArray[i] = '{\n' + responseArray[i]; | ||
} | ||
responseJSON = JSON.parse(responseArray[i]); | ||
@@ -425,3 +431,3 @@ | ||
} catch (e) { | ||
this.logDebug(responseJSON); | ||
this.logInfo(responseArray[responseArray.length-1]); | ||
this.logDebug('New lines: ' + newlines.length); | ||
@@ -449,2 +455,4 @@ this.logDebug('Max new lines: ' + max); | ||
this.continuousPost(path, payload, callback); | ||
if (callback) { | ||
@@ -458,3 +466,3 @@ callback(new Error('Received end.')); | ||
if ('Parse Error' === error.message) { | ||
this.logDebug('Ignoreing parse error.'); | ||
this.logDebug('Ignoring parse error.'); | ||
// Unfortunately wtec always generates the node js parse error 'HPE_INVALID_CONSTANT' --> ignore | ||
@@ -461,0 +469,0 @@ } else { |
298836
9931