]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Updated TestDissemination and TestNetwork to start the dissemination service manually...
authorgtolle <gtolle>
Sat, 14 Apr 2007 00:34:20 +0000 (00:34 +0000)
committergtolle <gtolle>
Sat, 14 Apr 2007 00:34:20 +0000 (00:34 +0000)
apps/tests/TestDissemination/TestDisseminationAppC.nc
apps/tests/TestDissemination/TestDisseminationC.nc
apps/tests/TestNetwork/TestNetworkAppC.nc
apps/tests/TestNetwork/TestNetworkC.nc

index 0d5c6132db151a4b459f0d0a066387097f5cae05..ce1e121cf44d30b79c418eb61f0bc0c8b2c3031d 100644 (file)
@@ -52,6 +52,16 @@ implementation {
   components MainC;
   TestDisseminationC.Boot -> MainC;
 
+  components ActiveMessageC;
+  TestDisseminationC.RadioControl -> ActiveMessageC;
+
+  components DisseminationC;
+  TestDisseminationC.DisseminationControl -> DisseminationC;
+
+  components UserButtonC;
+  TestDisseminationC.Get -> UserButtonC;
+  TestDisseminationC.Notify -> UserButtonC;
+
   components new DisseminatorC(uint32_t, 0x1234) as Object32C;
   TestDisseminationC.Value32 -> Object32C;
   TestDisseminationC.Update32 -> Object32C;
index 270f61ac2b3db0837069563dbc6e6ecf974c3f4f..df388ed79eb5dde3bb8a81cc877f577e569fd7f8 100644 (file)
@@ -1,4 +1,5 @@
 #include <Timer.h>
+#include <UserButton.h>
 
 /*
  * Copyright (c) 2006 Arched Rock Corporation
 module TestDisseminationC {
   uses interface Boot;
 
+  uses interface SplitControl as RadioControl;
+
+  uses interface StdControl as DisseminationControl;
+
+  uses interface Get<button_state_t>;
+  uses interface Notify<button_state_t>;
+
   uses interface DisseminationValue<uint32_t> as Value32;
   uses interface DisseminationUpdate<uint32_t> as Update32;
 
@@ -62,19 +70,51 @@ module TestDisseminationC {
 }
 implementation {
   event void Boot.booted() {
-    if ( TOS_NODE_ID % 4 == 1 ) {
-      call Timer.startPeriodic(20000);
+    uint32_t initialVal32 = 123456;
+    uint16_t initialVal16 = 1234;
+
+    call Value32.set( &initialVal32 ); 
+    call Value16.set( &initialVal16 ); 
+
+    call RadioControl.start();
+  }
+
+  event void RadioControl.startDone( error_t result ) {
+    
+    if ( result != SUCCESS ) {
+
+      call RadioControl.start();
+
+    } else {
+
+      call DisseminationControl.start();
+      
+      if ( TOS_NODE_ID % 4 == 1 ) {
+       call Timer.startPeriodic( 1024 * 20 );
+      } else {
+       call Timer.startPeriodic( 1024 );
+      }
     }
   }
 
+  event void RadioControl.stopDone( error_t result ) { }
+
   event void Timer.fired() {
     uint32_t newVal32 = 0xDEADBEEF;
     uint16_t newVal16 = 0xABCD;
-    call Leds.led0Toggle();
-    call Leds.led1Toggle();
-    call Update32.change( &newVal32 );
-    call Update16.change( &newVal16 );
-    dbg("TestDisseminationC", "TestDisseminationC: Timer fired.\n");
+
+    if ( TOS_NODE_ID % 4 == 1 ) {
+      call Leds.led0Toggle();
+      call Leds.led1Toggle();
+      call Update32.change( &newVal32 );
+      call Update16.change( &newVal16 );
+      dbg("TestDisseminationC", "TestDisseminationC: Timer fired.\n");
+    } else {
+      const uint32_t* newVal = call Value32.get();
+      if ( *newVal == 123456 ) {
+       call Leds.led2Toggle();
+      }
+    }
   }
 
   event void Value32.changed() {
index cbe5078b6d71946b05dd21419be069ea19eb7644..a95dab01600768f4da6d944b0d3306509d9e208b 100644 (file)
@@ -16,6 +16,7 @@
 configuration TestNetworkAppC {}
 implementation {
   components TestNetworkC, MainC, LedsC, ActiveMessageC;
+  components DisseminationC;
   components new DisseminatorC(uint16_t, SAMPLE_RATE_KEY) as Object16C;
   components CollectionC as Collector;
   components new CollectionSenderC(CL_TEST);
@@ -35,6 +36,7 @@ implementation {
   TestNetworkC.RadioControl -> ActiveMessageC;
   TestNetworkC.SerialControl -> SerialActiveMessageC;
   TestNetworkC.RoutingControl -> Collector;
+  TestNetworkC.DisseminationControl -> DisseminationC;
   TestNetworkC.Leds -> LedsC;
   TestNetworkC.Timer -> TimerMilliC;
   TestNetworkC.DisseminationPeriod -> Object16C;
index a2ba9e11711dcc6dff9d20da514f2a4171a0f7fb..63dce3ba4d04d48cc2bcb46521e4d16189fa8ac7 100644 (file)
@@ -19,6 +19,7 @@ module TestNetworkC {
   uses interface SplitControl as RadioControl;
   uses interface SplitControl as SerialControl;
   uses interface StdControl as RoutingControl;
+  uses interface StdControl as DisseminationControl;
   uses interface DisseminationValue<uint16_t> as DisseminationPeriod;
   uses interface Send;
   uses interface Leds;
@@ -63,6 +64,7 @@ implementation {
       call RadioControl.start();
     }
     else {
+      call DisseminationControl.start();
       call RoutingControl.start();
       if (TOS_NODE_ID % 500 == 0) {
        call RootControl.setRoot();