X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=apps%2FAntiTheft%2FNodes%2FAntiTheftC.nc;h=3d502a929713062d388d1dd524f5501483391feb;hb=e9bfab607e051bae6afb47b44892ce37541d1b44;hp=8696be00e094e332c7102c47b7b619bf02578151;hpb=2f4074d1cdeebc129285f8c568f83a83eec98d71;p=tinyos-2.x.git diff --git a/apps/AntiTheft/Nodes/AntiTheftC.nc b/apps/AntiTheft/Nodes/AntiTheftC.nc index 8696be00..3d502a92 100644 --- a/apps/AntiTheft/Nodes/AntiTheftC.nc +++ b/apps/AntiTheft/Nodes/AntiTheftC.nc @@ -13,6 +13,8 @@ * * @author David Gay */ +#include "antitheft.h" + module AntiTheftC { uses { @@ -36,7 +38,7 @@ implementation { enum { /* Threshold for considering mote in a dark place */ - DARK_THRESHOLD = 200, + DARK_THRESHOLD = 600, /* Amount of time warning leds should stay on (in checkInterval counts) */ WARNING_TIME = 3, @@ -103,11 +105,12 @@ implementation /* Report the identity of this node, using the collection protocol */ /* Get the payload part of alertMsg and fill in our data */ - alert_t *newAlert = call AlertRoot.getPayload(&alertMsg); - newAlert->stolenId = TOS_NODE_ID; - - /* and send it... */ - check(call AlertRoot.send(&alertMsg, sizeof *newAlert)); + alert_t *newAlert = call AlertRoot.getPayload(&alertMsg, sizeof(alert_t)); + if (newAlert != NULL) { + newAlert->stolenId = TOS_NODE_ID; + /* and send it... */ + check(call AlertRoot.send(&alertMsg, sizeof *newAlert)); + } } } @@ -135,13 +138,13 @@ implementation } /* Radio started. Now start the collection protocol and set the - radio to a 2% low-power-listening duty cycle */ + wakeup interval for low-power-listening wakeup to half a second. */ event void RadioControl.startDone(error_t ok) { if (ok == SUCCESS) { call DisseminationControl.start(); call CollectionControl.start(); - call LowPowerListening.setLocalDutyCycle(200); + call LowPowerListening.setLocalWakeupInterval(512); } else errorLed();