Browse Source

Add init calls to sensors; update TODOs.

master
flabbergast 7 years ago
parent
commit
d546d39f23
3 changed files with 14 additions and 2 deletions
  1. +0
    -1
      TODO.md
  2. +7
    -0
      modules/sensors/TM.js
  3. +7
    -1
      modules/socket_server.js

+ 0
- 1
TODO.md View File

@@ -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
- 0
modules/sensors/TM.js View File

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


+ 7
- 1
modules/socket_server.js View File

@@ -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…
Cancel
Save