]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/lib/net/DisseminatorP.nc
Added a StdControl interface, and a top-level DisseminationC component. Added a set...
[tinyos-2.x.git] / tos / lib / net / DisseminatorP.nc
index 9b3031758849eaaecc4a0911bc2d5edea0a20fa5..1a6280448d4673d3ecc46cbe1d5caaa41ea9eb76 100644 (file)
  */
 
 generic module DisseminatorP(typedef t) {
+  provides interface StdControl;
+
   provides interface DisseminationValue<t>;
   provides interface DisseminationUpdate<t>;
   provides interface DisseminationCache;
 
-  uses interface Boot;
   uses interface Leds;
 }
 implementation {
   t valueCache;
+  bool m_running;
 
   // A sequence number is 32 bits. The top 16 bits are an incrementing
   // counter, while the bottom 16 bits are a unique node identifier.
   uint32_t seqno = DISSEMINATION_SEQNO_UNKNOWN;
 
-  event void Boot.booted() {
-    signal DisseminationCache.init();
+  command error_t StdControl.start() {
+    error_t result = signal DisseminationCache.start();
+    if ( result == SUCCESS ) { m_running = TRUE; }
+    return result;
+  }
+
+  command error_t StdControl.stop() {
+    if ( !m_running ) { return EOFF; }
+    m_running = FALSE;
+    return signal DisseminationCache.stop();
   }
 
   command const t* DisseminationValue.get() {
     return &valueCache;
   }
 
+  command void DisseminationValue.set( const t* val ) {
+    valueCache = *val;
+  }
+
   command void DisseminationUpdate.change( t* newVal ) {
+    if ( !m_running ) { return; }
     memcpy( &valueCache, newVal, sizeof(t) );
     /* Increment the counter and append the local node ID. */
     seqno = seqno >> 16;