*
* @author David Gay
*/
+#include "antitheft.h"
+
module AntiTheftC
{
uses {
interface DisseminationValue<settings_t> as SettingsValue;
interface Send as AlertRoot;
interface StdControl as CollectionControl;
+ interface StdControl as DisseminationControl;
interface SplitControl as RadioControl;
interface LowPowerListening;
interface AMSend as TheftSend;
{
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,
/* 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));
+ }
}
}
}
/* 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();