【代码解释】 module MyC { uses interface Boot; // 使用Boot接口 uses interface Leds; // 使用Leds接口 // 至于接口是哪个组件提供的, 只能在configuration中指明 } implementation { event void Boot.booted() { call Leds.led2Toggle(); } }
configuration MyAppC { } implementation { components MyC, MainC, LedsC; // 该模块使用的组件。注意配置MyAppC不是组件,所以要引用对应的MyC组件
MyC.Boot -> MainC.Boot; // Boot接口是MainC组件提供的 MyC.Leds -> LedsC.Leds; // Leds接口是LedsC组件提供的 }
|