Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to allow actuators to report data. #11

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/actuators_iot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
};
}
Expand Down
19 changes: 16 additions & 3 deletions lib/rpc_actuators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<services[id].actuatorEventListeners.length; i++){
if(services[id].actuatorEventListeners[i][3] === "actuator"){
var rpc = rpcH.createRPC(services[id].actuatorEventListeners[i][2], "onEvent", sensorEvent);
rpcH.executeRPC(rpc);
}
}
}
break;
default:
console.log('actuator api listener: unrecognized command');
}
Expand Down
4 changes: 2 additions & 2 deletions node_modules/webinos-driver-fake/lib/drivers/fakeDriver1.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.