]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/system/ActiveMessageAddressC.nc
Remove bogus 'tab:4' and 'tab:2' markers.
[tinyos-2.x.git] / tos / system / ActiveMessageAddressC.nc
index a6fa6dd64cb3a3b6419f5e7019169e69d6253403..b7cb3ea1915a0a90b09415bcd5bd13191519357d 100644 (file)
@@ -1,5 +1,5 @@
 // $Id$
-/*                                                                     tab:4
+/*
  * "Copyright (c) 2004-2005 The Regents of the University  of California.  
  * All rights reserved.
  *
  */
 
 /**
- * Component that stores the node's active message address.
+ * Component that stores the node's active message address and group ID.
  *
  * @author Philip Levis
- * @date June 19 2005
+ * @author David Moss
  */
 
 module ActiveMessageAddressC  {
-  provides async command am_addr_t amAddress();
-  provides async command void setAmAddress(am_addr_t a);
+  provides {
+    interface ActiveMessageAddress;
+    async command am_addr_t amAddress();
+    async command void setAmAddress(am_addr_t a);
+  }
 }
 implementation {
+
+  /** Node address */
   am_addr_t addr = TOS_AM_ADDRESS;
 
+  /** Group address */
+  am_group_t group = TOS_AM_GROUP;
+  
+  /***************** ActiveMessageAddress Commands ****************/
+  /**
+   * @return the active message address of this node
+   */
+  async command am_addr_t ActiveMessageAddress.amAddress() {
+    return call amAddress();
+  }
+  
+  /**
+   * Set the active message address of this node
+   * @param group The node's group ID
+   * @param addr The node's active message address
+   */
+  async command void ActiveMessageAddress.setAddress(am_group_t myGroup, am_addr_t myAddr) {
+    atomic {
+      addr = myAddr;
+      group = myGroup;
+    }
+    signal ActiveMessageAddress.changed();
+  }
+  
+    
+  /**
+   * @return the group address of this node
+   */
+  async command am_group_t ActiveMessageAddress.amGroup() {
+    am_group_t myGroup;
+    atomic myGroup = group;
+    return myGroup;
+  }
+  
+
+  /***************** Deprecated Commands ****************/
   /**
    * Get the node's default AM address.
    * @return address
+   * @deprecated Use ActiveMessageAddress.amAddress() instead
    */
   async command am_addr_t amAddress() {
-    return addr;
+    am_addr_t myAddr;
+    atomic myAddr = addr;
+    return myAddr;
   }
   
   /**
    * Set the node's default AM address.
    *
    * @param a - the address.
+   * @deprecated Use ActiveMessageAddress.setAddress() instead
    */
   async command void setAmAddress(am_addr_t a) {
-    addr = a;
+    atomic addr = a;
+    signal ActiveMessageAddress.changed();
   }
+  
+  
+  /***************** Defaults ****************/
+  /**
+   * Notification that the address of this node changed.
+   */
+  default async event void ActiveMessageAddress.changed() {
+  }
+  
 }