Add init calls to sensors; update TODOs.
This commit is contained in:
parent
e38162bada
commit
d546d39f23
3 changed files with 14 additions and 2 deletions
1
TODO.md
1
TODO.md
|
@ -3,7 +3,6 @@
|
|||
### LLAP sensor message handling ###
|
||||
- remember timestamp (when was the last message received)
|
||||
- allow for "disabling" the display/processing the messages?
|
||||
- refactor variables: make one object for one sensor
|
||||
- do something about STARTED/AWAKE/SLEEPING messages?
|
||||
|
||||
## Eventually ##
|
||||
|
|
|
@ -12,8 +12,14 @@
|
|||
* the serial connection and send the update over the socket
|
||||
*/
|
||||
|
||||
/* TODO:
|
||||
* - remember and display time of last message
|
||||
*/
|
||||
|
||||
var TMtemp = "??";
|
||||
var TMtempTime = "no reading yet";
|
||||
var TMbatt = "??";
|
||||
var TMbattTime = "no reading yet";
|
||||
|
||||
exports.init = function(socket){
|
||||
};
|
||||
|
@ -21,6 +27,7 @@ exports.init = function(socket){
|
|||
exports.onUserConnected = function(socket){
|
||||
socket.emit('received-TM-temp', { content: ("Temp: "+TMtemp+" ºC") });
|
||||
socket.emit('received-TM-batt', { content: ("Batt: "+TMbatt+" V") });
|
||||
// t: set the time of the last reading
|
||||
};
|
||||
|
||||
exports.onDataOverSerial = function(sockets,message){
|
||||
|
|
|
@ -39,6 +39,12 @@ exports.init = function(io){
|
|||
socket.on('send-llap-msg', function(data){
|
||||
serport.sendLLAPmsg(data.content);
|
||||
});
|
||||
// initialise the sensor code (if they want to add some listeners)
|
||||
for(var s in sensors){
|
||||
if(sensors.hasOwnProperty(s) && sensors[s].hasOwnProperty('init')){
|
||||
sensors[s].init(socket);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -68,7 +74,7 @@ exports.onDataOverSerial = function(data){
|
|||
var onUserConnected = function(socket)
|
||||
{
|
||||
serport.writeNumber(socket.user.id);
|
||||
// run initialisation code for all loaded sensors
|
||||
// run userConnected initialisation code for all loaded sensors
|
||||
for(var s in sensors){
|
||||
if(sensors.hasOwnProperty(s) && sensors[s].hasOwnProperty('onUserConnected')){
|
||||
sensors[s].onUserConnected(socket);
|
||||
|
|
Loading…
Reference in a new issue