Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mckk/Pervasion
base: 6b60877eb9
...
head fork: mckk/Pervasion
compare: 38aad629bf
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
View
13 DataMsg.h
@@ -1,13 +1,14 @@
-//#ifndef DATAMSG_H
+#ifndef DATAMSG_H
#define DATAMSG_H
enum {
- AM_DATAMSG = 95,
- DATAMSG_HEADER = 0x99,
+ AM_DATAMSG = 95,
+ DATAMSG_HEADER = 0x99,
};
typedef nx_struct DataMsg {
- nx_uint8_t srcid;
- nx_uint16_t temp;
- nx_uint16_t lux;
+ nx_uint8_t srcid;
+ nx_uint16_t temp;
+ nx_uint16_t lux;
} DataMsg;
+#endif
View
9 FireMsg.h
@@ -1,11 +1,12 @@
-//#ifndef FIREMSG_H
+#ifndef FIREMSG_H
#define FIREMSG_H
enum {
- AM_FIREMSG = 231,
- FIREMSG_HEADER = 0x99,
+ AM_FIREMSG = 231,
+ FIREMSG_HEADER = 0x99,
};
typedef nx_struct FireMsg {
- nx_uint8_t srcid;
+ nx_uint8_t srcid;
} FireMsg;
+#endif
View
31 Receiver/ReceiverAppC.nc
@@ -7,25 +7,36 @@ implementation
{
components MainC, ReceiverC, LedsC;
+
+ //Timer for sync messsages
+ components new TimerMilliC() as SyncTimer;
+
+ //AM controller
components ActiveMessageC;
+ //Receiver for data messages
components new AMReceiverC(AM_DATAMSG) as DataReceiver;
+ //Receiver for fire messages
+ components new AMReceiverC(AM_FIREMSG) as FireMsgReceiver;
+ //Sender for sync messages
+ components new AMSenderC(AM_TIMERRESTARTMSG) as TimerMsgSender;
+ //Serial controller
components SerialActiveMessageC;
+ //Sender for data messages
components new SerialAMSenderC(AM_SERIALMSG) as SerialSender;
- components new AMReceiverC(AM_FIREMSG) as FireMsgReceiver;
-
ReceiverC -> MainC.Boot;
-
ReceiverC.Leds -> LedsC;
-
- ReceiverC.AMControl -> ActiveMessageC;
- ReceiverC.DataReceive -> DataReceiver;
+ ReceiverC.SyncTimer -> SyncTimer;
+
+ ReceiverC.AMControl -> ActiveMessageC;
+ ReceiverC.DataReceive -> DataReceiver;
+ ReceiverC.FireMsgReceive -> FireMsgReceiver;
+ ReceiverC.TimerPacket -> TimerMsgSender;
+ ReceiverC.TimerSend -> TimerMsgSender;
ReceiverC.SerialAMControl -> SerialActiveMessageC;
- ReceiverC.SerialPacket -> SerialSender;
- ReceiverC.SerialSend -> SerialSender;
-
- ReceiverC.FireMsgReceive -> FireMsgReceiver;
+ ReceiverC.SerialPacket -> SerialSender;
+ ReceiverC.SerialSend -> SerialSender;
}
View
193 Receiver/ReceiverC.nc
@@ -2,118 +2,157 @@
#include "../DataMsg.h"
#include "SerialMsg.h"
#include "../FireMsg.h"
+#include "../TimerRestartMsg.h"
module ReceiverC
{
uses interface Leds;
uses interface Boot;
+ //Timer for sync messages
+ uses interface Timer<TMilli> as SyncTimer;
+
+ //Radio controls
uses interface SplitControl as AMControl;
uses interface Receive as DataReceive;
+ uses interface Receive as FireMsgReceive;
+ uses interface Packet as TimerPacket;
+ uses interface AMSend as TimerSend;
+
+ //Serial controls
uses interface SplitControl as SerialAMControl;
uses interface Packet as SerialPacket;
uses interface AMSend as SerialSend;
-
- uses interface Receive as FireMsgReceive;
}
implementation
{
-
- uint16_t temperature_value;
- uint16_t lux_value;
-
- message_t datapkt;
+ enum {
+ SYNC_PERIOD = 10000, // Set sync period to 10 seconds
+ };
+
bool AMBusy;
+ // Datapkt for sync message
+ message_t datapkt;
- message_t serialpkt;
bool SerialAMBusy;
+ // Datapkt for serial data message
+ message_t serialpkt;
event void Boot.booted()
{
- temperature_value = 0;
- lux_value = 0;
-
call AMControl.start();
-
call SerialAMControl.start();
+
+ // Fire sync timer every SYNC_PERIOD seconds
+ call SyncTimer.startPeriodic(SYNC_PERIOD);
+ }
+
+//-----------------TIMER EVENTS------------------------------------//
+ event void SyncTimer.fired()
+ {
+ // On fired broadcast sync message
+ TimerRestartMsg *pkt = NULL;
+ pkt = (TimerRestartMsg *)(call TimerPacket.getPayload(&datapkt, sizeof(TimerRestartMsg)));
+ pkt -> srcid = TOS_NODE_ID;
+ if (!AMBusy && call TimerSend.send(AM_BROADCAST_ADDR, &datapkt, sizeof(TimerRestartMsg)) == SUCCESS){
+ AMBusy = TRUE;
+ }
}
- event void AMControl.stopDone(error_t err) {
- if(err == SUCCESS){
- AMBusy = TRUE;
- }
+//-----------------RADIO EVENTS------------------------------------//
+ event void AMControl.startDone(error_t err)
+ {
+ if (err == SUCCESS) {
+ AMBusy = FALSE;
+ }
+ }
+
+ event void AMControl.stopDone(error_t err)
+ {
+ if(err == SUCCESS) {
+ AMBusy = TRUE;
+ }
+ }
+
+ event void TimerSend.sendDone(message_t *msg, error_t error)
+ {
+ AMBusy = FALSE;
+ }
+
+ event message_t * FireMsgReceive.receive(message_t * msg, void * payload, uint8_t len)
+ {
+ FireMsg * fire_pkt = NULL;
+ SerialMsg * s_pkt = NULL;
+
+ if (len != sizeof(FireMsg)) {
+ return msg;
}
- event void AMControl.startDone(error_t err) {
- if (err == SUCCESS) {
- AMBusy = FALSE;
- }
- }
+ fire_pkt = (FireMsg *) payload;
+ s_pkt = (SerialMsg *)(call SerialPacket.getPayload(&serialpkt, sizeof(SerialMsg)));
+
+ s_pkt->header = SERIALMSG_HEADER;
+ s_pkt->srcid = fire_pkt->srcid;
+ s_pkt->fire = TRUE;
+ s_pkt->temperature = 0;
+ s_pkt->lux = 0;
+
+ if (!SerialAMBusy && (call SerialSend.send(AM_BROADCAST_ADDR, &serialpkt, sizeof(SerialMsg)) == SUCCESS)) {
+ SerialAMBusy = TRUE;
+ }
- event message_t * DataReceive.receive(message_t * msg, void * payload, uint8_t len) {
- SerialMsg * s_pkt = NULL;
- DataMsg * d_pkt = NULL;
-
- if(len == sizeof(DataMsg)) {
- d_pkt = (DataMsg *) payload;
- }
-
- s_pkt = (SerialMsg *)(call SerialPacket.getPayload(&serialpkt, sizeof(SerialMsg)));
-
- s_pkt->header = SERIALMSG_HEADER;
- s_pkt->srcid = d_pkt->srcid;
- s_pkt->temperature = d_pkt->temp;
- s_pkt->lux = d_pkt->lux;
- s_pkt->fire = FALSE;
-
- if (!SerialAMBusy && (call SerialSend.send(AM_BROADCAST_ADDR, &serialpkt, sizeof(SerialMsg)) == SUCCESS)) {
- SerialAMBusy = TRUE;
- }
+ call Leds.led1Toggle();
+ return msg;
+ }
- call Leds.led0Toggle();
-
+ event message_t * DataReceive.receive(message_t * msg, void * payload, uint8_t len)
+ {
+ SerialMsg * s_pkt = NULL;
+ DataMsg * d_pkt = NULL;
+
+ if(len != sizeof(DataMsg)) {
return msg;
}
+
+ d_pkt = (DataMsg *) payload;
+
+ s_pkt = (SerialMsg *)(call SerialPacket.getPayload(&serialpkt, sizeof(SerialMsg)));
+
+ s_pkt->header = SERIALMSG_HEADER;
+ s_pkt->srcid = d_pkt->srcid;
+ s_pkt->temperature = d_pkt->temp;
+ s_pkt->lux = d_pkt->lux;
+ s_pkt->fire = FALSE;
+
+ if (!SerialAMBusy && (call SerialSend.send(AM_BROADCAST_ADDR, &serialpkt, sizeof(SerialMsg)) == SUCCESS)) {
+ SerialAMBusy = TRUE;
+ }
- event message_t * FireMsgReceive.receive(message_t * msg, void * payload, uint8_t len) {
- FireMsg * fire_pkt = NULL;
- SerialMsg * s_pkt = NULL;
-
- if (len == sizeof(FireMsg)) {
- fire_pkt = (FireMsg *) payload;
- }
-
- s_pkt = (SerialMsg *)(call SerialPacket.getPayload(&serialpkt, sizeof(SerialMsg)));
+ call Leds.led0Toggle();
- s_pkt->header = SERIALMSG_HEADER;
- s_pkt->srcid = fire_pkt->srcid;
- s_pkt->fire = TRUE;
- s_pkt->temperature = 0;
- s_pkt->lux = 0;
-
- if (!SerialAMBusy && (call SerialSend.send(AM_BROADCAST_ADDR, &serialpkt, sizeof(SerialMsg)) == SUCCESS)) {
- SerialAMBusy = TRUE;
- }
-
- call Leds.led1Toggle();
-
- return msg;
- }
-
+ return msg;
+ }
- event void SerialAMControl.stopDone(error_t err) {
- if(err == SUCCESS){
- }
+//-----------------SERIAL EVENTS------------------------------------//
+ event void SerialAMControl.stopDone(error_t err)
+ {
+ if(err == SUCCESS) {
+ SerialAMBusy = TRUE;
}
-
- event void SerialAMControl.startDone(error_t err) {
- if (err == SUCCESS) {
- SerialAMBusy = FALSE;
- }
- }
- event void SerialSend.sendDone(message_t *msg, error_t error) {
- SerialAMBusy = FALSE;
+ }
+
+ event void SerialAMControl.startDone(error_t err)
+ {
+ if (err == SUCCESS) {
+ SerialAMBusy = FALSE;
}
+ }
+
+ event void SerialSend.sendDone(message_t *msg, error_t error)
+ {
+ SerialAMBusy = FALSE;
+ }
+
}
View
16 Receiver/SerialMsg.h
@@ -2,17 +2,17 @@
#define SERIALMSG_H
enum {
- AM_SERIAL = 11,
- AM_SERIALMSG = 11,
- SERIALMSG_HEADER = 0x9F,
+ AM_SERIAL = 11,
+ AM_SERIALMSG = 11,
+ SERIALMSG_HEADER = 0x9F,
};
typedef nx_struct SerialMsg {
- nx_uint8_t header;
- nx_uint16_t srcid;
- nx_int16_t temperature;
- nx_int16_t lux;
- nx_bool fire;
+ nx_uint8_t header;
+ nx_uint16_t srcid;
+ nx_int16_t temperature;
+ nx_int16_t lux;
+ nx_bool fire;
} SerialMsg;
#endif
View
8 Sender/SenderAppC.nc
@@ -18,6 +18,8 @@ implementation
components new AMSenderC(AM_FIREMSG) as FireMsgSender;
components new AMReceiverC(AM_DATAMSG) as DataReceiver;
+ components new AMReceiverC(AM_TIMERRESTARTMSG) as TimerMsgReceiver;
+
SenderC -> MainC.Boot;
SenderC.SensorTimer -> SensorTimer;
@@ -28,9 +30,13 @@ implementation
SenderC.Lux_Sensor -> Lux_Sensor;
SenderC.AMControl -> ActiveMessageC;
+
SenderC.DataPacket -> DataSender;
+ SenderC.DataReceive -> DataReceiver;
SenderC.DataSend -> DataSender;
+
SenderC.FireMsgSend -> FireMsgSender;
- SenderC.DataReceive -> DataReceiver;
+
+ SenderC.TimerMsgReceive -> TimerMsgReceiver;
}
View
358 Sender/SenderC.nc
@@ -1,6 +1,7 @@
#include "Timer.h"
#include "../DataMsg.h"
#include "../FireMsg.h"
+#include "../TimerRestartMsg.h"
module SenderC
{
@@ -13,34 +14,38 @@ module SenderC
uses interface Read<uint16_t> as Lux_Sensor;
uses interface SplitControl as AMControl;
+
uses interface Packet as DataPacket;
uses interface AMSend as DataSend;
- uses interface AMSend as FireMsgSend;
uses interface Receive as DataReceive;
+
+ uses interface AMSend as FireMsgSend;
+
+ uses interface Receive as TimerMsgReceive;
}
implementation
{
enum {
- SAMPLE_PERIOD = 1000,
- NEIGHBOURS_NUMBER = 2, // the number of neighbour nodes
- LOG_SIZE = 30, // log size should be even
- BASE_ADDR = 0x22, // the address of base station
+ SAMPLE_PERIOD = 1000,
+ NEIGHBOURS_NUMBER = 2, // the number of neighbour nodes
+ LOG_SIZE = 30, // log size should be even
+ BASE_ADDR = 0x22, // the address of base station
};
// used to store sensor's readings
uint16_t temperature;
uint16_t lux;
- // used for messaging
- message_t datapkt;
- bool AMBusy;
-
// Used to check when both checks are done
bool temperatureRead;
bool luxRead;
-
+
+ // used for messaging
+ message_t datapkt;
+ bool AMBusy;
+
// Used to store the last temperature readings
uint16_t tempLog[LOG_SIZE];
uint16_t curLogIndex;
@@ -53,12 +58,11 @@ implementation
// stores the id of the last neighbour who was communicating wih us;
uint8_t lastNeighbourId;
-
event void Boot.booted()
{
- int i;
+ int i;
- // initialize all variables
+ // initialize all variables
temperature = 0;
lux = 0;
curLogIndex = 0;
@@ -69,199 +73,203 @@ implementation
bufferFull = FALSE;
// initialize the values of all arrays
- for (i = 0 ; i < LOG_SIZE ; i++) {
- tempLog[i] = 0;
- }
+ for (i = 0 ; i < LOG_SIZE ; i++) {
+ tempLog[i] = 0;
+ }
+
for (i = 0 ; i < NEIGHBOURS_NUMBER ; i++) {
- neighboursLux[i] = FALSE;
- }
-
- call SensorTimer.startPeriodic(SAMPLE_PERIOD);
+ neighboursLux[i] = FALSE;
+ }
+
call AMControl.start();
}
event void SensorTimer.fired()
{
call Temp_Sensor.read();
- call Lux_Sensor.read();
+ call Lux_Sensor.read();
}
- event void GreenLedTimer.fired(){
- call Leds.led1Toggle();
+ event void GreenLedTimer.fired()
+ {
+ call Leds.led1Toggle();
}
- event void AMControl.stopDone(error_t err) {
- if(err == SUCCESS){
- }
+ event void AMControl.stopDone(error_t err)
+ {
+ if(err == SUCCESS){
+ AMBusy = TRUE;
}
+ }
- event void AMControl.startDone(error_t err) {
- if (err == SUCCESS) {
- AMBusy = FALSE;
- }
- }
-
- event void DataSend.sendDone(message_t * msg, error_t error) {
- if (&datapkt == msg) {
- AMBusy = FALSE;
- temperatureRead = FALSE;
- luxRead = FALSE;
- }
+ event void AMControl.startDone(error_t err)
+ {
+ if (err == SUCCESS) {
+ AMBusy = FALSE;
+ }
+ }
- call Leds.led2Off();
+ event void DataSend.sendDone(message_t * msg, error_t error)
+ {
+ if (&datapkt == msg) {
+ AMBusy = FALSE;
+ temperatureRead = FALSE;
+ luxRead = FALSE;
}
+ call Leds.led2Off();
+ }
- event void FireMsgSend.sendDone(message_t * msg, error_t error) {
- if (&datapkt == msg) {
- AMBusy = FALSE;
- }
- }
-
- // for receiving messages from other nodes
- event message_t * DataReceive.receive(message_t * msg, void * payload, uint8_t len) {
- DataMsg * d_pkt = NULL;
-
- if(len == sizeof(DataMsg)) {
- d_pkt = (DataMsg *) payload;
- if(d_pkt->lux < 100){
- call Leds.led1Toggle();
- call GreenLedTimer.startOneShot(20);
- }
-
- // write the received lux reading to the buffer
- if (lastNeighbourId != d_pkt->srcid) {
- lastNeighbourId = d_pkt->srcid;
- luxIndex = 1 - luxIndex;
- }
-
- // falg whether any neighbour indicates dark
- neighboursLux[luxIndex] = d_pkt->lux < 100;
- }
-
- return msg;
+ event void FireMsgSend.sendDone(message_t * msg, error_t error)
+ {
+ if (&datapkt == msg) {
+ AMBusy = FALSE;
}
+ }
+ // for receiving messages from other nodes
+ event message_t * DataReceive.receive(message_t * msg, void * payload, uint8_t len)
+ {
+ DataMsg * d_pkt = NULL;
+ if(len == sizeof(DataMsg)) {
+ d_pkt = (DataMsg *) payload;
+ if(d_pkt->lux < 100) {
+ call Leds.led1Toggle();
+ call GreenLedTimer.startOneShot(20);
+ }
+ // write the received lux reading to the buffer
+ if (lastNeighbourId != d_pkt->srcid) {
+ lastNeighbourId = d_pkt->srcid;
+ luxIndex = 1 - luxIndex;
+ }
+ // flag whether any neighbour indicates dark
+ neighboursLux[luxIndex] = d_pkt->lux < 100;
+ }
+ return msg;
+ }
+ // for receiving syncMessages
+ event message_t * TimerMsgReceive.receive(message_t * msg, void * payload, uint8_t len)
+ {
+ if(len == sizeof(TimerRestartMsg)) {
+ call SensorTimer.startPeriodic(SAMPLE_PERIOD);
+ }
+ return msg;
+ }
+
// If both temperature and light readings occured, send the data
- task void sendData(){
- if(temperatureRead && luxRead){
- DataMsg *pkt = NULL;
- call Leds.led2On();
-
- pkt = (DataMsg *)(call DataPacket.getPayload(&datapkt, sizeof(DataMsg)));
- pkt->srcid = TOS_NODE_ID;
- pkt->temp = temperature;
- pkt->lux = lux;
-
- if(!AMBusy){
- if(call DataSend.send(AM_BROADCAST_ADDR, &datapkt, sizeof(DataMsg)) == SUCCESS){
- AMBusy = TRUE;
- }
- }
- }
+ task void sendData()
+ {
+ if(temperatureRead && luxRead) {
+ DataMsg *pkt = NULL;
+ call Leds.led2On();
+
+ pkt = (DataMsg *)(call DataPacket.getPayload(&datapkt, sizeof(DataMsg)));
+ pkt->srcid = TOS_NODE_ID;
+ pkt->temp = temperature;
+ pkt->lux = lux;
+
+ if(!AMBusy && call DataSend.send(AM_BROADCAST_ADDR, &datapkt, sizeof(DataMsg)) == SUCCESS) {
+ AMBusy = TRUE;
+ }
+ }
}
// Checks for fire condition, if the fire is detected, flashes red
// light and sends alert message to the remote mote
- task void checkForFire() {
-
- // Declare all vars
- int index = 0;
- int sumOne = 0;
- int sumTwo = 0;
- int avgOne = 0;
- int avgTwo = 0;
- int splitIndex;
- bool areNeighboursDark = TRUE;
- FireMsg *pkt = NULL;
-
+ task void checkForFire()
+ {
+ // Declare all vars
+ int index = 0;
+ int sumOne = 0;
+ int sumTwo = 0;
+ int avgOne = 0;
+ int avgTwo = 0;
+ int splitIndex;
+ bool areNeighboursDark = TRUE;
+ FireMsg *pkt = NULL;
+
// The first condition is that all nodes detect that it is currently dark
- // Check that all neighbours are dark
- for ( ; index < NEIGHBOURS_NUMBER; index++) {
- // if the reading actually occured
- areNeighboursDark = areNeighboursDark && neighboursLux[index];
- }
-
- if (areNeighboursDark && lux < 100) {
- // all nodes are in the dark
- // The second condition is to check whether there is an increase in temperature
-
- // Split the buffer into two arrays
- splitIndex = (curLogIndex + LOG_SIZE/2) % LOG_SIZE;
-
- // Compute average of each array
- index = curLogIndex;
-
- sumOne = 0;
- for ( ; index != splitIndex ; ) {
- sumOne = sumOne + tempLog[index];
- index = (index + 1) % LOG_SIZE;
- }
-
- sumTwo = 0;
- for ( ; index != curLogIndex ; ) {
- sumTwo = sumTwo + tempLog[index];
- index = (index + 1) % LOG_SIZE;
- }
-
- avgOne = sumOne/(LOG_SIZE/2);
- avgTwo = sumTwo/(LOG_SIZE/2);
-
- if (avgOne + 20 < avgTwo) {
- // we have fire
- // turn on red led
- call Leds.led0On();
-
- // send the fire message
- pkt = (FireMsg *)(call DataPacket.getPayload(&datapkt, sizeof(FireMsg)));
- pkt->srcid = TOS_NODE_ID;
-
- if(!AMBusy){
- if(call FireMsgSend.send(BASE_ADDR, &datapkt, sizeof(FireMsg)) == SUCCESS){
- AMBusy = TRUE;
- }
- }
- }
- }
-
- else {
- // fire may be over, ensure that the red ligh is turned off
- call Leds.led0Off();
- }
+ // Check that all neighbours are dark
+ for ( ; index < NEIGHBOURS_NUMBER; index++) {
+ // if the reading actually occured
+ areNeighboursDark = areNeighboursDark && neighboursLux[index];
+ }
+
+ if (areNeighboursDark && lux < 100) {
+ // all nodes are in the dark
+ // The second condition is to check whether there is an increase in temperature
+
+ // Split the buffer into two arrays
+ splitIndex = (curLogIndex + LOG_SIZE/2) % LOG_SIZE;
+
+ // Compute average of each array
+ index = curLogIndex;
+
+ sumOne = 0;
+ for ( ; index != splitIndex ; ) {
+ sumOne = sumOne + tempLog[index];
+ index = (index + 1) % LOG_SIZE;
+ }
+
+ sumTwo = 0;
+ for ( ; index != curLogIndex ; ) {
+ sumTwo = sumTwo + tempLog[index];
+ index = (index + 1) % LOG_SIZE;
+ }
+
+ avgOne = sumOne/(LOG_SIZE/2);
+ avgTwo = sumTwo/(LOG_SIZE/2);
+
+ if (avgOne + 20 < avgTwo) {
+ // we have fire
+ // turn on red led
+ call Leds.led0On();
+
+ // send the fire message
+ pkt = (FireMsg *)(call DataPacket.getPayload(&datapkt, sizeof(FireMsg)));
+ pkt->srcid = TOS_NODE_ID;
+
+ if(!AMBusy && call FireMsgSend.send(BASE_ADDR, &datapkt, sizeof(FireMsg)) == SUCCESS){
+ AMBusy = TRUE;
+ }
+ }
+ } else {
+ // fire may be over, ensure that the red ligh is turned off
+ call Leds.led0Off();
+ }
}
- event void Temp_Sensor.readDone(error_t result, uint16_t data) {
+ event void Temp_Sensor.readDone(error_t result, uint16_t data)
+ {
if(result == SUCCESS){
- temperature = data;
- temperatureRead = TRUE;
- post sendData();
-
- // write the temperature to the log
- tempLog[curLogIndex] = temperature;
-
- // check if we already had LOG_SIZE readings of temperature
- // if not, we do not want to check for fire
- if (curLogIndex == LOG_SIZE - 1) {
- bufferFull = TRUE;
- }
- curLogIndex = (curLogIndex + 1) % LOG_SIZE;
-
- // post task to check for fire
- if (bufferFull) {
- post checkForFire();
- }
+ temperature = data;
+ temperatureRead = TRUE;
+ post sendData();
+
+ // write the temperature to the log
+ tempLog[curLogIndex] = temperature;
+
+ // check if we already had LOG_SIZE readings of temperature
+ // if not, we do not want to check for fire
+ if (curLogIndex == LOG_SIZE - 1) {
+ bufferFull = TRUE;
+ }
+ curLogIndex = (curLogIndex + 1) % LOG_SIZE;
+
+ // post task to check for fire
+ if (bufferFull) {
+ post checkForFire();
+ }
}
}
- event void Lux_Sensor.readDone(error_t result, uint16_t data){
- if(result == SUCCESS){
- lux = data;
- luxRead = TRUE;
- post sendData();
- }
+ event void Lux_Sensor.readDone(error_t result, uint16_t data)
+ {
+ if(result == SUCCESS){
+ lux = data;
+ luxRead = TRUE;
+ post sendData();
+ }
}
-
-
-
}
View
12 TimerRestartMsg.h
@@ -0,0 +1,12 @@
+#ifndef TIMERRESTARTMSG_H
+#define TIMERRESTARTMSG_H
+
+enum {
+ AM_TIMERRESTARTMSG = 189,
+ TIMERRESTARTMSG_HEADER = 0x99,
+};
+
+typedef nx_struct TimerRestartMsg {
+ nx_uint8_t srcid;
+} TimerRestartMsg;
+#endif

No commit comments for this range

Something went wrong with that request. Please try again.