]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/lib/tosthreads/chips/rf230/ActiveMessageLayerC.nc
Merge TinyOS 2.1.1 into master.
[tinyos-2.x.git] / tos / lib / tosthreads / chips / rf230 / ActiveMessageLayerC.nc
index d7af862259cf92d043c70e0cc3f9478a26e8ed63..b16884a59f249ca452e6c8ef7c8eaca81f44efcc 100644 (file)
@@ -1,17 +1,17 @@
 /*
- * Copyright (c) 2007, Vanderbilt University
+ * Copyright (c) 2009, Vanderbilt University
  * All rights reserved.
  *
  * Permission to use, copy, modify, and distribute this software and its
  * documentation for any purpose, without fee, and without written agreement is
  * hereby granted, provided that the above copyright notice, the following
  * two paragraphs and the author appear in all copies of this software.
- *
+ * 
  * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
  * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ * 
  * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  * Author: Miklos Maroti
  */
 
-module ActiveMessageLayerC
+/*
+ * Make active message TOSThreads-compatible by exposing default interfaces
+ *
+ * Author: Chieh-Jan Mike Liang
+ */
+
+configuration ActiveMessageLayerC
 {
        provides
        {
+               interface AMPacket;
+               interface Packet;
                interface AMSend[am_id_t id];
-    interface Receive[am_id_t id];
+               interface Receive[am_id_t id];
     interface Receive as ReceiveDefault[am_id_t id];
     interface Receive as Snoop[am_id_t id];
     interface Receive as SnoopDefault[am_id_t id];
+               interface SendNotifier[am_id_t id];
        }
+
        uses
        {
-               interface Send as SubSend;
-               interface Receive as SubReceive;
-               interface AMPacket;
+               interface RadioPacket as SubPacket;
+               interface BareSend as SubSend;
+               interface BareReceive as SubReceive;
                interface ActiveMessageConfig as Config;
        }
 }
 
 implementation
 {
-/*----------------- Send -----------------*/
-
-       command error_t AMSend.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len)
-       {
-               error_t error;
-
-               error = call Config.checkPacket(msg);
-               if( error != SUCCESS )
-                       return error;
-
-               call AMPacket.setSource(msg, call AMPacket.address());
-               call AMPacket.setGroup(msg, call AMPacket.localGroup());
-               call AMPacket.setType(msg, id);
-               call AMPacket.setDestination(msg, addr);
-
-               return call SubSend.send(msg, len);
-       }
-
-       inline event void SubSend.sendDone(message_t* msg, error_t error)
-       {
-               signal AMSend.sendDone[call AMPacket.type(msg)](msg, error);
-       }
-
-       inline command error_t AMSend.cancel[am_id_t id](message_t* msg)
-       {
-               return call SubSend.cancel(msg);
-       }
-
-       default event void AMSend.sendDone[am_id_t id](message_t* msg, error_t error)
-       {
-       }
-
-       inline command uint8_t AMSend.maxPayloadLength[am_id_t id]()
-       {
-               return call SubSend.maxPayloadLength();
-       }
-
-       inline command void* AMSend.getPayload[am_id_t id](message_t* msg, uint8_t len)
-       {
-               return call SubSend.getPayload(msg, len);
-       }
-
-/*----------------- Receive -----------------*/
-
-       event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len)
-       {
-               am_id_t type = call AMPacket.type(msg);
-
-               msg = call AMPacket.isForMe(msg)
-                       ? signal Receive.receive[type](msg, payload, len)
-                       : signal Snoop.receive[type](msg, payload, len);
-
-               return msg;
-       }
-
-  default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
-    return signal ReceiveDefault.receive[id](msg, payload, len);
-  }
-
-  default event message_t* ReceiveDefault.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
-    return msg;
-  }
-
-  default event message_t* Snoop.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
-    return signal SnoopDefault.receive[id](msg, payload, len);
-  }
-
-  default event message_t* SnoopDefault.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
-    return msg;
-  }
+       components ActiveMessageLayerP, ActiveMessageAddressC;
+       ActiveMessageLayerP.ActiveMessageAddress -> ActiveMessageAddressC;
+
+       AMPacket = ActiveMessageLayerP;
+       Packet = ActiveMessageLayerP;
+       AMSend = ActiveMessageLayerP;
+       Receive = ActiveMessageLayerP.Receive;
+       ReceiveDefault = ActiveMessageLayerP.ReceiveDefault;
+       Snoop = ActiveMessageLayerP.Snoop;
+       SnoopDefault = ActiveMessageLayerP.SnoopDefault;
+       SendNotifier = ActiveMessageLayerP;
+       
+       SubPacket = ActiveMessageLayerP;
+       SubSend = ActiveMessageLayerP;
+       SubReceive = ActiveMessageLayerP;
+       Config = ActiveMessageLayerP;
 }