Sfoglia il codice sorgente

Add init calls to sensors; update TODOs.

master
flabbergast 8 anni fa
parent
commit
d546d39f23
  1. 1
      TODO.md
  2. 7
      modules/sensors/TM.js
  3. 8
      modules/socket_server.js

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 ##

7
modules/sensors/TM.js

@ -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){

8
modules/socket_server.js

@ -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);

Caricamento…
Annulla
Salva