Beruflich Dokumente
Kultur Dokumente
TinyOS Architecture
Main (scheduler)
Application
Sensing
Comms
Other Libraries
Compilation
ncc
gcc
Outline
l
l
l
l
Basic example
Outline
l
l
l
l
Basic example
Components
l
Components
l
PowerupAppC
module PowerupC {
use interface Boot;
use interface Leds;
}
implementation{
event void Boot.booted(){
call Leds.led0On();
}
}
===============================
configuration PowerupAppC {}
implementation{
components MainC, LedsC,PowerupC;
PowerupC.Boot->MainC.Boot;
PowerupC.Leds->LedsC.Leds;
}
Interfaces
l
l
l
Commands
l Implemented by provider
l Called by user
Events
l Called (signaled) by provider
l Implemented (captured) by user
PowerupC
MainC
Interface Boot
l
l
l
Component MainC
l
Interfaces
l
Outline
l
l
l
l
Basic example
Basic example
l
l
Reporting theft
l
Quick review
l
l
l
l
l
l
Outline
l
l
l
l
Basic example
Tasks
l
The interrupt handler (function) will be invoked immediately after the interrupt
Race conditions
High-level component
command
event
Low-level component
command
event
H/w drivers, etc
h/w interrupts
Task 1
Task 0
call SomeInterface.someCmd();
configuration SomeComponent {
provides interface SomeInterface;
}
implementation {}
Task Scheduler
l
ComponentA
ComponentB
call Interface.doSomething();
return SUCCESS;
post doSomething();
Outline
l
l
l
l
Basic example
Radio Stacks
Your Application
AMSend
SplitControl
Receive
Message Queue
ActiveMessage
CSMA / Acknowledgements
Transmit / Receive / Init
Radio Hardware
SplitControl
l
AMSend
l
Provided by ActiveMessageC
Provided by AMSenderC
Receive
l
Provided by AMReceiverC
SplitControl
l
AMSend
l
Provided by SerialActiveMessageC
Provided by SerialAMSenderC
Receive
l
Provided by SerialAMReceiverC
Send Messages
message_t myMsg;
task void sendMsg() {
if(call AMSend.send(AM_BROADCAST_ADDR,
&myMsg, 0) != SUCCESS) {
post sendMsg();
}
}
event void AMSend.sendDone(message_t *msg,
error_t error) {
post sendMsg();
}
Receive a Message
event message_t *Receive.receive(message_t *msg, void
*payload, uint8_t length) {
call Leds.led0Toggle();
return msg;
}
Payloads
l
Header
Payload
Optional Footer
message_t
typedef nx_struct message_t {
nx_uint8_t header[sizeof(message_header_t)];
nx_uint8_t data[TOSH_DATA_LENGTH];
nx_uint8_t footer[sizeof(message_footer_t)];
nx_uint8_t metadata[sizeof(message_metadata_t)];
} message_t;
#ifndef MYPAYLOAD_H
#define MYPAYLOAD_H
typedef nx_struct MyPayload {
nx_uint8_t count;
} MyPayload;
enum {
AM_MYPAYLOAD = 0x50,
};
#endif
CFLAGS += -DCC2420_DEF_CHANNEL=12
CC2420Control.SetRFPower(power)
CC2420Packet.getLqi(msg);
Common Gotchas
l
Timer Interface
l
Timer
l
l
CC2420
l
l
l
l
l
Loading the security RAM buffers on the CC2420 with the information to be
encrypted (payload without header)
Microcontroller reads out of the security RAM buffer and concatenates the data
with the unencrypted packet header.
This full packet would be uploaded again to the CC2420 TXFIFO buffer and
transmitted.
The key is built with the binary or transfered using serial port
http://cis.sjtu.edu.cn/index.php/The_Standalone_AES_Encryption_of_CC2420_(Ti
nyOS_2.10_and_MICAz)
Takes advantage of the fact that the Key is loaded into the CC2420 chip, using a
well know pin
l
http://travisgoodspeed.blogspot.com/2009/03/breaking-802154-aes128-by-syringe.html
l
l
http://tos-ide.ethz.ch/wiki/pmwiki.php?n=Site.Setup
TOSSIM
Using actual hardware (Suggested)
l
l
Testbeds
l
l
KanseiGenie
Peoplenet
Installation
Download VMPlayer
https://my.vmware.com/web/vmware/free#desktop_end_user_computing/
vmware_player/5_0|PLAYER-500|product_downloads
http://docs.tinyos.net/tinywiki/index.php/Running_a_XubunTOS_Virtual_Machine_I
mage_in_VMware_Player
Checking installation
$ cd $TOSROOT
$ cd apps/Blink
$ make telosb
$ cd build/telosb
$ ls
main.exe main.ihex tos_image.xml
$ export
$MAKERULES, $TOSROOT, $TOSDIR
Compiling TOSSIM
l
$ cd $TOSROOT
$ cd apps/Blink
$ make micaz sim
Running simulations
l
l
python
Details in
http://docs.tinyos.net/tinywiki/index.php/TOSSIM
Sample Exercise-1
LinkQuality Measurement simulation
l Use TOSSIM to inject radio channel model and simulate the following
application on 5 nodes
l Application specifications
l
l
Each node sends a periodic (once every 15 sec) broadcast Msg, with a sequence
number.
Whenever it receives a message on radio, print the following using debug
statements
l
l
l
l
Turn On Blue LED when you send the message and turn it off after you get the
sendDone
Toggle Green LED whenever you receive a msg
You will need components
l
l
l
l
l
AMSenderC
AMReceiverC
CC2420Packet
Timer
Leds
Sample Exercise-2
Periodically display a number from 0 to 7 by the three LEDs.
l Application Specification
l
l
l
l
l
TimerMilliC
LedsC
References
l
To learn more
l
http://docs.tinyos.net
Hardware vendors
l
l
l
l
l
Crossbow.com
Moteiv.com
Centila.com
Sunspots
Imote2
Acknowledgment
l
Thank You!
l
Questions ?
Contact information
l
l