]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - apps/tests/rf230/RadioCountToDiag/RadioCountToDiagP.nc
Merge TinyOS 2.1.1 into master.
[tinyos-2.x.git] / apps / tests / rf230 / RadioCountToDiag / RadioCountToDiagP.nc
index ad9de621568c4a86a749a743e13f53aa6a3e7882..0cf4d49c1dc5482a9e01ab37a455567abe5a7c24 100644 (file)
@@ -41,11 +41,18 @@ module RadioCountToDiagP
                interface SplitControl as RadioControl;
 
                interface ActiveMessageAddress;
+               interface LowPowerListening;
+
+               interface Leds;
        }
 }
 
 #ifndef SEND_PERIOD
-#define SEND_PERIOD 10
+#define SEND_PERIOD 20
+#endif
+
+#ifndef SLEEP_INTERVAL
+#define SLEEP_INTERVAL 50
 #endif
 
 implementation
@@ -62,6 +69,9 @@ implementation
                        post radioPowerUp();
                else
                {
+#ifdef LOW_POWER_LISTENING
+                       call LowPowerListening.setLocalWakeupInterval(SLEEP_INTERVAL);
+#endif         
                        call SendTimer.startPeriodic(SEND_PERIOD);
                        call ReportTimer.startPeriodic(1000);
                }
@@ -99,7 +109,6 @@ implementation
        }
 
        uint32_t sendCount;
-       uint32_t sendError;
        uint32_t sendDoneSuccess;
        uint32_t sendDoneError;
        uint32_t ackedCount;
@@ -109,10 +118,11 @@ implementation
 
        event void ReportTimer.fired()
        {
+               call Leds.led0Toggle();
+
                if( call DiagMsg.record() )
                {
                        call DiagMsg.uint16(sendCount);
-                       call DiagMsg.uint16(sendError);
                        call DiagMsg.uint16(sendDoneSuccess);
                        call DiagMsg.uint16(sendDoneError);
                        call DiagMsg.uint16(ackedCount);
@@ -135,8 +145,13 @@ implementation
        {
                uint16_t addr;
 
+               call Leds.led1Toggle();
+               
                call Packet.clear(&txMsg);
                call PacketAcknowledgements.requestAck(&txMsg);
+#ifdef LOW_POWER_LISTENING
+               call LowPowerListening.setRemoteWakeupInterval(&txMsg, SLEEP_INTERVAL);
+#endif
 
                addr = call ActiveMessageAddress.amAddress();
                if( addr == 2 )
@@ -148,8 +163,6 @@ implementation
 
                if( call AMSend.send(addr, &txMsg, sizeof(ping_t)) == SUCCESS )
                        ++sendCount;
-               else
-                       ++sendError;
        }
 
        event void AMSend.sendDone(message_t* msg, error_t error)