uint8_t count;
message_t fullMsg;
bool transmitter;
+
+ uint8_t lastCount;
/**************** Prototypes ****************/
task void send();
}
event message_t *Receive.receive(message_t *msg, void *payload, uint8_t len) {
+ TestPeriodicMsg *periodicMsg = (TestPeriodicMsg *) payload;
+
if(!transmitter) {
- call Leds.led1Toggle();
+ if(lastCount == periodicMsg->count) {
+ call Leds.led0On();
+ call Leds.led1Off();
+ } else {
+ call Leds.led1On();
+ call Leds.led0Off();
+ }
+
+ lastCount = periodicMsg->count;
+
+ call Leds.led2Toggle();
}
return msg;
}
/**************** Tasks ****************/
task void send() {
- TestPeriodicMsg *periodicMsg = (TestPeriodicMsg *) call Packet.getPayload(&fullMsg, NULL);
+ TestPeriodicMsg *periodicMsg = (TestPeriodicMsg *) call Packet.getPayload(&fullMsg, sizeof(TestPeriodicMsg));
periodicMsg->count = count;
call LowPowerListening.setRxSleepInterval(&fullMsg, 1000);
if(call AMSend.send(AM_BROADCAST_ADDR, &fullMsg, sizeof(TestPeriodicMsg)) != SUCCESS) {