介绍了组件图的层次化分解和无线通信。
CntToLedsAndRfm:读取计数器的数值并输出到LED和无线收发模块的栈中。
RfmToLeds:从无线收发模块中接收数据并显示到LED中。
分别编译到两个节点上,然后进行通信测试。
# 单个接口可以连接到多个实现(implementation),如main.stdcontrol
# 配接箭头的方向可以任意,如:
IntToLeds <- Counter.IntOutput; 等同于 Counter.IntOutput -> IntToLeds
# 在配置(Configuration)中也可以提供接口,而不仅仅是使用和配接已有的接口。
# 模块的重命名,如:
components IntToRfmM, GenericComm as Comm;
# 等于号的使用:
IntOutput = IntToRfmM;
其中IntOutput接口是此配置中提供的接口。这里不能用->,因为那是用来连接一个used interface 到provided implementation的。
//没看明白,为什么说confusing?
This is how we specify that Active Messages received with the AM_INTMSG handler ID should be wired to the RfmToIntM.ReceiveMsg interface. The direction of the arrow might be a little confusing here. The ReceiveMsg interface (found in tos/interfaces/ReceiveMsg.nc)only declares an event: receive(), which is signaled with a pointer to the received message. So RfmToIntM uses the ReceiveMsg interface, although that interface does not have any commands to call -- just an event that can be signaled.
# 给节点确定地址,如:
make mica install.38
# 问题:如何确定发送信息的目的地址?
Send.send(TOS_BCAST_ADDR, sizeof(IntMsg), &data)
其中 TOS_BCAST_ADDR 就是发送信息的目的地址。