接收事件只会在它接收到它正在侦听的消息类型后运行,并且该类型在应用程序配置文件中指定。
因此,在您的配置文件中,您将拥有:
components ApplicationNameP as App, ActiveMessageC;
components new AMSenderC(HELLOMSG) as HELLOMsgSender;
components new AMSenderC(VIOSINMSG) as VIOSINMsgSender;
App.RadioSendHello -> HELLOMsgSender;
App.RadioReceiveHello -> ActiveMessageC.Receive[HELLOMSG];
App.RadioSendViosin -> VIOSINMsgSender;
App.RadioReceiveViosin -> ActiveMessageC.Receive[VIOSINMSG];
在您的标题中,您将拥有:
enum
{
HELLOMSG = 1,
VIOSINMSG = 2,
} ;
在您的应用程序文件中,您将拥有:
uses interface AMSend as RadioSendHello;
uses interface Receive as RadioReceiveHello;
uses interface AMSend as RadioSendViosin;
uses interface Receive as RadioReceiveViosin;
然后,您可以使用相关的事件处理程序在数据包进入时对其进行处理。