//tos/interfaces/Packet.nc:
#include
interface Packet {
command void clear(message_t* msg); //清空数据包,将msg的数据清空重新使用
command uint8_t payloadLength(message_t* msg); //返回信息负载的长度
command void setPayloadLength(message_t* msg, uint8_t len); //设置负载长度
command uint8_t maxPayloadLength(); //返回最大负载
command void* getPayload(message_t* msg, uint8_t len); //获取负载,len为需要的负载长度
}
//tos/interfaces/Send.nc:
#include
#include
interface Send {
command error_t send(message_t* msg, uint8_t len); //设置发送数据包的负载长度
command error_t cancel(message_t* msg); //取消数据的传输
event void sendDone(message_t* msg, error_t error); //发送数据完成
command uint8_t maxPayloadLength(); //返回通讯层允许的最大负载长度
command void* getPayload(message_t* msg, uint8_t len); //获取负载
}
//tos/interfaces/Receive.nc:
#include
#include
interface Receive {
event message_t* receive(message_t* msg, void* payload, uint8_t len);
}
//tos/interfaces/PacketAcknowledgements.nc:
interface PacketAcknowledgements {
async command error_t requestAck( message_t* msg ); //告诉协议,当要发送数据包时,使用同步的ACK
async command error_t noAck( message_t* msg ); //告诉协议,当要发送数据包时,不使用同步的ACK
async command bool wasAcked(message_t* msg); //判断传输的数据包是否为ACK
}
//tos/interfaces/RadioTimeStamping.nc:
interface RadioTimeStamping
{
async event void transmittedSFD( uint16_t time, message_t* p_msg );
async event void receivedSFD( uint16_t time ); //开始接收帧的时间
}
//tos/interfaces/AMPacket.nc:
#include
#include
interface AMPacket {
command am_addr_t address();//返回AM栈中节点的AM地址
command am_addr_t destination(message_t* amsg);//返回AM数据包的目的地址的AM地址
command am_addr_t source(message_t* amsg);//返回AM数据包的源地址的AM地址
command void setDestination(message_t* amsg, am_addr_t addr);//设置AM数据包的目的地址的AM地址
command void setSource(message_t* amsg, am_addr_t addr);//设置AM数据包的源地址的AM地址
command bool isForMe(message_t* amsg);
command am_id_t type(message_t* amsg);//返回AM数据包的AM类型,也就是说数据包的类型
command void setType(message_t* amsg, am_id_t t);//设置包的类型
command am_group_t group(message_t* amsg);//获得AM数据包的AM组
command void setGroup(message_t* amsg, am_group_t grp);//设置AM数据包的AM组
command am_group_t localGroup();//返回本节点的AM组
}
//tos/interfaces/AMSend.nc:
#include
#include
#include
interface AMSend {
command error_t send(am_addr_t addr, message_t* msg, uint8_t len);//发送负载长度为len的数据,addr为发送地址
command error_t cancel(message_t* msg);//取消发送数据
event void sendDone(message_t* msg, error_t error);
command uint8_t maxPayloadLength();//返回通信层提供的最大负载长度
command void* getPayload(message_t* msg, uint8_t len);//获取负载
}
AMReceiverC:提供支持以下的接口:Receive,Packet和AMPacket。
AMSenderC:提供支持以下的接口:AMSend,Packet,AMPacket和Acks(即PacketAckowledgements)
AMSnooperC:提供支持以下的接口:Receive,Packet和AMPacket,进行嗅探的组件功能,和组件AMReceiverC功能相同,用于接收数据。
AMSnoopingReceiverC:提供支持以下的接口:Receive,Packet和AMPacket。与AMSnooperC组件比,多了一个ActiveMessageC.Receive[AMId]。
ActiveMessageAddressC:本模块提供了一些指令可以用来获取和设置节点的AM地址。这个模块不是为一般用户提供的,它容易破坏网络栈,所以如果不清楚操作的情况下要避免使用它。