Sense To Rfm configuration Sense To Rfm this

  • Slides: 12
Download presentation
Sense. To. Rfm configuration Sense. To. Rfm { // this module does not provide

Sense. To. Rfm configuration Sense. To. Rfm { // this module does not provide any interface } implementation { components Main, Sense. To. Int, Int. To. Rfm, Timer. C, Photo as Sensor; Main. Std. Control -> Sense. To. Int; Main. Std. Control -> Int. To. Rfm; Main Std. Control Sense. To. Int. Timer -> Timer. C. Timer[unique("Timer")]; Sense. To. Int. Timer -> Timer. C; Sense. To. Int. ADC -> Sensor; Timer. Control Timer ADCControl Int. Output Sense. To. Int. ADCControl -> Sensor; Sense. To. Int. Output -> Int. To. Rfm; Timer. C Photo Int. To. Rfm }

Nested Configuration includes Int. Msg; configuration Int. To. Rfm { provides { Std. Control

Nested Configuration includes Int. Msg; configuration Int. To. Rfm { provides { Std. Control Int. To. Rfm. M interface Int. Output; interface Std. Control; } Sub. Control } Send. Msg[AM_INTMSG]; Generic. Comm implementation { components Int. To. Rfm. M, Generic. Comm as Comm; Int. Output = Int. To. Rfm. M; Std. Control = Int. To. Rfm. M; Int. To. Rfm. M. Send -> Comm. Send. Msg[AM_INTMSG]; Int. To. Rfm. M. Sub. Control -> Comm; } Int. Output

Int. To. Rfm Module includes Int. Msg; command result_t Std. Control. start() { return

Int. To. Rfm Module includes Int. Msg; command result_t Std. Control. start() { return call Sub. Control. start(); } module Int. To. Rfm. M { uses { interface Std. Control as Sub. Control; interface Send. Msg as Send; } provides { interface Int. Output; interface Std. Control; } } implementation { bool pending; struct TOS_Msg data; command result_t Std. Control. init() { pending = FALSE; return call Sub. Control. init(); } command result_t Std. Control. stop() { return call Sub. Control. stop(); } command result_t Int. Output. output(uint 16_t value) {. . . if (call Send. send(TOS_BCAST_ADDR , sizeof(Int. Msg), &data) return SUCCESS; . . . } event result_t Send. send. Done(TOS_Msg. Ptr msg, result_t success) {. . . } }

The Complete Application Sense. To. Rfm generic comm Int. To. Rfm AMStandard packet Radio.

The Complete Application Sense. To. Rfm generic comm Int. To. Rfm AMStandard packet Radio. CRCPacket UARTno. CRCPacket CRCfilter no. CRCPacket Timer photo byte Mica. High. Speed. Radio. M Sec. Ded. Encode Channel. Mon bit SPIByte. FIFO Slave. Pin phototemp Radio. Timing Random. LFSR SW UART Clock. C ADC HW

Sending a Message bool pending; struct TOS_Msg data; command result_t Int. Output. output(uint 16_t

Sending a Message bool pending; struct TOS_Msg data; command result_t Int. Output. output(uint 16_t value) { Int. Msg *message = (Int. Msg *)data; if (!pending) { pending = TRUE; message->val = value; message->src = TOS_LOCAL_ADDRESS; if (call Send. send(TOS_BCAST_ADDR, sizeof(Int. Msg), &data)) return SUCCESS; pending = FALSE; } return FAIL; destination length } • Refuses to accept command if buffer is still full or network refuses to accept send command • User component provide structured msg storage

Send done Event event result_t Int. Output. send. Done(TOS_Msg. Ptr msg, result_t success) {

Send done Event event result_t Int. Output. send. Done(TOS_Msg. Ptr msg, result_t success) { if (pending && msg == &data) { pending = FALSE; signal Int. Output. output. Complete(success); } return SUCCESS; } } • Send done event fans out to all potential senders • Use the event to schedule pending communication

Rfm. To. Leds configuration Rfm. To. Leds { } implementation { components Main, Rfm.

Rfm. To. Leds configuration Rfm. To. Leds { } implementation { components Main, Rfm. To. Int, Int. To. Leds; Main. Std. Control -> Int. To. Leds. Std. Control; Main. Std. Control -> Rfm. To. Int. Std. Control; Rfm. To. Int. Output -> Int. To. Leds. Int. Output; } Main Std. Control Int. To. Leds Std. Control Rfm. To. Int. Output

Rfmto. Int configuration Rfm. To. Int { provides interface Std. Control; uses interface Int.

Rfmto. Int configuration Rfm. To. Int { provides interface Std. Control; uses interface Int. Output; } implementation { components Rfm. To. Int. M, Generic. Comm; Int. Output = Rfm. To. Int. M; Std. Control = Rfm. To. Int. M; Rfm. To. Int. M. Receive. Int. Msg -> Generic. Comm. Receive. Msg[AM_INTMSG]; Rfm. To. Int. M. Comm. Control -> Generic. Comm; } Std. Control Int. Output Rfm. To. Int. M Receive. Msg Comm. Control Generic. Comm

Rfm. To. Int. M command result_t Std. Control. stop() { module Rfm. To. Int.

Rfm. To. Int. M command result_t Std. Control. stop() { module Rfm. To. Int. M { return call Comm. Control. stop(); provides interface Std. Control; } uses { interface Receive. Msg as Receive. Int. Msg; event TOS_Msg. Ptr interface Int. Output; Receive. Int. Msg. receive(TOS_Msg. Ptr m) { interface Std. Control as Comm. Control; Int. Msg *message = (Int. Msg *)m->data; } call Int. Output. output(message->val); } implementation { return m; } command result_t Std. Control. init() { return call Comm. Control. init(); event result_t } Int. Output. output. Complete(result_t success) { command result_t Std. Control. start() { return call Comm. Control. start(); } return SUCCESS; } }

Int. To. Leds configuration Int. To. Leds { provides interface Int. Output; provides interface

Int. To. Leds configuration Int. To. Leds { provides interface Int. Output; provides interface Std. Control; } implementation { components Int. To. Leds. M, Leds. C; Int. Output = Int. To. Leds. M. Int. Output; Std. Control = Int. To. Leds. M. Std. Control; Int. To. Leds. M. Leds -> Leds. C. Leds; }

Receive Event event TOS_Msg. Ptr Receive. Int. Msg. receive(TOS_Msg. Ptr m) { Int. Msg

Receive Event event TOS_Msg. Ptr Receive. Int. Msg. receive(TOS_Msg. Ptr m) { Int. Msg *message = (Int. Msg *)m->data; call Int. Output. output(message->val); return m; } • Active message automatically dispatched to associated handler – knows format, no run-time parsing – performs action on message event • Must return free buffer to the system – typically the incoming buffer if processing complete

Exercise • • Distributed version of Blink Timer and Blink. M on one mote

Exercise • • Distributed version of Blink Timer and Blink. M on one mote Leds. C on another mote When timeout occurs, the first mote should send a command to the other mote to make the LED blink.