diff --git a/lib/actuators_iot.js b/lib/actuators_iot.js index 37cff8a..b8c4009 100644 --- a/lib/actuators_iot.js +++ b/lib/actuators_iot.js @@ -153,8 +153,7 @@ this.objRef = objectRef; this.listenerActive = true; this.actuatorEventListeners.push([successCB, errorCB, objectRef, eventType]); - var evt = this.getEvent(0); - driverInterface.sendCommand('value', this.elementId, evt, errorCB, successCB); + driverInterface.sendCommand('start', this.elementId, null, errorCB, successCB); }; this.removeEventListener = function (arguments) { @@ -168,6 +167,7 @@ if(this.actuatorEventListeners.length == 0){ console.log("Stopping listen to actuator " + this.id); this.listenerActive = false; + driverInterface.sendCommand('stop', this.elementId, null); } }; } diff --git a/lib/rpc_actuators.js b/lib/rpc_actuators.js index 65a98d5..17dfa57 100644 --- a/lib/rpc_actuators.js +++ b/lib/rpc_actuators.js @@ -65,10 +65,9 @@ unregFunc(service); delete services[id]; break; - case 'data': + case 'value': var actuatorEvent = data; - //var actuatorEvent = services[id].getEvent(data); - + //handle callbacks for(var i in services[id].actuatorEventCallbacks){ var rpc = rpcH.createRPC(services[id].actuatorEventCallbacks[i], "onEvent", actuatorEvent); @@ -85,6 +84,20 @@ } } break; + case 'data': + console.log("Data from service with id "+id); + + //console.log("RPC_sensors: sensor�" + id + " has " + serviceList[id].listeners.length + " listeners"); + if(services[id].listenerActive == true) { + var sensorEvent = services[id].getEvent(data); + for(var i=0; i 0) { //Send data value... callbackFunc('data', elementsList[index].id, elementsList[index].value); nextValue(index);