introduction to tinyos 2.x and nesc. anatomy of telosb mote limited computational and communication...
Post on 19-Dec-2015
221 views
TRANSCRIPT
![Page 1: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/1.jpg)
INTRODUCTION TO TINYOS 2.X AND NESC
![Page 2: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/2.jpg)
Anatomy of TelosB Mote
Limited computational and communication resources
MSP430 16-bit microcontroller 10kB RAM 250 kbps, high data rate radio Sensors (temperature, humidity, light) Data collection and programming via USB
interface 48kB of flash program memory IEEE 802.15.4 compliant A pair of AA batteries (4 days)
http://www.willow.co.uk/TelosB_Datasheet.pdf
![Page 3: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/3.jpg)
Typical WSN Application
Periodic Data Collection Network
Maintenance Triggered Events
Detection/Notification
Infrequently occurs
Long Lifetime Months to Years
without changing batteries
Power management is the key to WSN success
sleepw
ake
up
processingdata acquisitioncommunication
Pow
er
Time
![Page 4: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/4.jpg)
TinyOS
TinyOS is designed for the small, low-power microcontrollers motes have.
MAIN AIM: saving power! 2nd AIM: easy development of
applications! TinyOS applications and systems, as well
as the OS itself is written in nesC a dialect of C.
![Page 5: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/5.jpg)
TinyOS
Component-based architecture Event-driven operating system Developed for resource constrained wireless
sensor networks Ultimately not limited by WSN’s.
TinyOS, libraries, applications written in nesC NesC language
A dialect of C Language with extensions for components
Features a task scheduler Automatically puts the microcontroller to sleep
when there is no code to execute Allows for concurrency Lets execution be split-phase
![Page 6: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/6.jpg)
Software Challenges
Power efficient Put microcontroller and radio to sleep
Small memory footprint Non-preemptable FIFO task scheduling
Efficient modularity Function call (event and command) interface
between commands Application specific Concurrency-intensive operation
Event-driven architecture No user/kernel boundary
![Page 7: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/7.jpg)
TinyOS
Component based architecture allows frequent changes while still keeping the size of code minimum.
Event based execution model means no user/kernel boundary and hence supports high concurrency.
It is power efficient as it makes the sensors sleep as soon as possible.
Has small footprint as it uses a non-preemtable FIFO task scheduling.
![Page 8: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/8.jpg)
What TinyOS provides
Things to make writing applications easier: A component model which allows you to
write small, reusable pieces of code and compose them into larger abstractions;
application programming interfaces (APIs), services, component libraries and an overall component structure that simplify writing new applications and services.
![Page 9: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/9.jpg)
COMPONENT BASED ARCHITECTURE
![Page 10: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/10.jpg)
Component-Oriented Programming
A nesC application consists of components Components can be reused Components can be replaced Components can be hardware or software
![Page 11: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/11.jpg)
Component-Oriented Programming Object-Oriented Programming:
Focuses on the relationships between classes that are combined into one large binary executable
Component-Oriented Programming: Focuses on interchangeable code modules
that work independently and don't require you to be familiar with their inner workings to use them.
![Page 12: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/12.jpg)
nesC vs C and C++
Each non-abstract subclass of GraphicObject, such as Circle and Rectangle, must provide implementations for the methods of the abstract class GraphicObject.
Components have only private variables.
No inheritance.
![Page 13: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/13.jpg)
Component-Oriented Programming File name and types in TinyOS:
Module (suffixed with P.nc) Configuration (suffixed with AppC.nc) – At
TOP level Configuration (suffixed with C.nc) – At
Lower level Interface (suffixed with .nc)
Collectively, a Configuration and a Module are combined to create a Component.
![Page 14: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/14.jpg)
Modules 1/3
Define functionality that make your application run.
Provide interfaces to other modules. Use interfaces from other modules. Don’t care what’s behind the interface. Implement interface definitions
Modules are like the IC’s on a circuit board that actually do something.
![Page 15: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/15.jpg)
Modules 2/3
Each component is specified by an interface.
A Component has:– Frame (internal states) e.g. variables,
functions, etc.– Tasks (data processing)– Interface(s) (commands/events)
Commands and Events are function calls
![Page 16: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/16.jpg)
Modules 3/3 - Implementation Implementation of a
module defines how the component works
Application code All commands and
events declared as provided in the interface MUST be implemented
![Page 17: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/17.jpg)
Configurations
Wire interfaces from several modules together.
Wrap modules. Are implemented by connecting
interfaces of existing components.
Configurations are like a Printed Circuit Board, laying out wiring that connects modules together.
![Page 18: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/18.jpg)
Interface: Commands/Events Define the interactions between modules
Commands Implemented by the module providing the interface Called by the module using the interface
Events Signaled by the module providing the interface Captured by the module using the interface
Components either provide or use an interface Provide - All interface commands MUST be implemented for
users to call Use - All interface events MUST be implemented for providers to
signal
![Page 19: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/19.jpg)
Interface Example
The Provider (implementor) of this interface must implement the start and stop commands.
The User of this interface, i.e., a components that invokes commands, must implement the event fired.
Timer.nc * filename for a bidirectional interface
interface Timer {
command result_t start (char type uint32_t interval);command result_t stop();event result_t fired();
}
![Page 20: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/20.jpg)
A HELLO-WORLD EXAMPLE
![Page 21: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/21.jpg)
Component Diagram
HelloCCONFIGURATION
![Page 22: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/22.jpg)
HelloC Configuration
configuration HelloC {}
implementation {}
![Page 23: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/23.jpg)
Component Diagram
HelloCMODULE
HelloP
![Page 24: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/24.jpg)
HelloC Configuration
configuration HelloC {}
implementation { components HelloP;}
![Page 25: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/25.jpg)
HelloP Module
module HelloP {}
implementation {}
![Page 26: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/26.jpg)
Component Diagram
HelloCFUNCTIONALITY
HelloP
void myFunctions() {…}
![Page 27: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/27.jpg)
HelloP Module
module HelloP { uses { interface Boot; interface Leds; }}
implementation {}
![Page 28: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/28.jpg)
Boot Interface
interface Boot { event void booted();}
Boot sequence provides one interface: Boot for signaling that the system has
successfully booted
TinyOS 2.x Boot Sequencehttp://www.tinyos.net/tinyos-2.x/doc/html/tep107.html
![Page 29: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/29.jpg)
HelloP Module
module HelloP { uses { interface Boot; interface Leds; }}
implementation { event void Boot.booted() { }}
USE an interface,
CAPTURE all of its events!
The HelloP module MUST implement the booted() event that is provided by the Boot Interface (see slide Interface: Commands/Events)
![Page 30: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/30.jpg)
Leds Interface
interface Leds { command void led0On(); command void led0Off(); command void led0Toggle();
…
command void set(uint8_t val);}
![Page 31: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/31.jpg)
HelloP Module
module HelloP { uses { interface Boot; interface Leds as MyLeds; interface Leds as MySecondLeds; }}
implementation { event void Boot.booted() { call Leds.led0On(); }}
Keyword “as” is used when multiple usages of an interface is required (similar to the “new” keyword of Java/c++)
![Page 32: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/32.jpg)
Component Diagram
HelloCINTERFACES
HelloP
Ledsvoid myFunctions() {…}
Boot
![Page 33: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/33.jpg)
Component Diagram
HelloC
HelloP
Leds
LedsC
void myFunctions() {…}
Boot
MainC
CONFIGURATIONS
![Page 34: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/34.jpg)
HelloC Configuration
configuration HelloC {}
implementation { components HelloP, MainC, LedsC, SecondLedsC;
// USES -> PROVIDES HelloP.Boot -> MainC.Boot; HelloP.MyLeds -> LedsC; HelloP.MySecondLeds -> SecondLedsC;}
![Page 35: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/35.jpg)
Component Diagram
HelloC
HelloP
Leds
LedsC
void myFunctions() {…}
MainC
BootUSES
PROVIDES
![Page 36: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/36.jpg)
RADIO COMMUNICATION
![Page 37: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/37.jpg)
Split-Control 1/4
Because sensor nodes have a broad range of hardware capabilities, one of the goals of TinyOS is to have a flexible hardware/software boundary.
In a split-phase operation the request that initiates an operation completes immediately.
Actual completion of the operation is signaled by a separate callback.
![Page 38: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/38.jpg)
Split-Control 2/4: Example 1
For example, to acquire a sensor reading with an analog-to-digital converter (ADC), software writes to a few configuration registers to start a sample.
When the ADC sample completes, the hardware issues an interrupt, and the software reads the value out of a data register.
![Page 39: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/39.jpg)
Split-Control 3/4: Example 2
Packet send method in Active Messages component.
This is a long operation, involving converting the packets to bytes, then to bits and ultimately driving the RF circuits to send the bits, one by one.
A call to a split-phase operation returns immediately
![Page 40: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/40.jpg)
Split-Control 4/4
ComponentA ComponentB
call Interface.doSomething();return SUCCESS;
signal Interface.done();
![Page 41: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/41.jpg)
Radio Stacks
Radio Hardware
Transmit / Receive / Init
CSMA / Acknowledgements
ActiveMessage
Message Queue
Your Application
ReceiveSplitControlAMSend
![Page 42: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/42.jpg)
Main Radio Interfaces
SplitControl Provided by ActiveMessageC
AMSend Provided by AMSenderC
Receive Provided by AMReceiverC
![Page 43: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/43.jpg)
Setting up the Radio: Configurationconfiguration MyAppC {}
implementation { components MyAppP, MainC, ActiveMessageC, new AMSenderC(0), // send an AM type 0
message new AMReceiverC(0); // receive an AM type
0 message MyAppP.Boot -> MainC; MyAppP.SplitControl -> ActiveMessageC; MyAppP.AMSend -> AMSenderC; MyAppP.Receiver -> AMReceiverC;}
![Page 44: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/44.jpg)
Setting up the Radio: Modulemodule MyAppP { uses { interface Boot; interface SplitControl; interface AMSend; interface Receive; }}
implementation { …}
![Page 45: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/45.jpg)
Turn on the Radio
event void Boot.booted() { call SplitControl.start(); }
message_t sendbuf;
event void SplitControl.startDone(error_t error) { call AMSend.send(AM_BROADCAST_ADDR,& sendbuf,
sizeof(sendbuf));}
event void SplitControl.stopDone(error_t error) { }
MyAppP.SplitControl -> ActiveMessageC;
The SplitControl is connected to the ActiveMessageC (radio component of the mote)
Destination address
Pointer to send buffer
Size of msg
![Page 46: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/46.jpg)
Send Messages
event void AMSend.sendDone(message_t *msg, error_t error) {
// Successful transmission}
![Page 47: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/47.jpg)
Receive a Message
event message_t *Receive.receive(message_t *msg, void
*payload, uint8_t length) {
call Leds.led0Toggle();
return msg;
}
![Page 48: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/48.jpg)
Payloads
A message consists of: Header Payload Optional Footer
![Page 49: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/49.jpg)
TinyOS 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;
![Page 50: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/50.jpg)
Payloads : Use Network Types(MyPayload.h)
#ifndef MYPAYLOAD_H#define MYPAYLOAD_H
typedef nx_struct MyPayload { nx_uint8_t count;} MyPayload;
enum { AM_MYPAYLOAD = 0x50,};
#endif
![Page 51: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/51.jpg)
Example: Filling out a Payload
message_t sendbuf;
void createMsg() {
MyPayload *payload = (MyPayload *) call AMSend.getPayload(&sendbuf);
payload->count = (myCount++); call AMSend.send(AM_BROADCAST_ADDR,& sendbuf,
sizeof(sendbuf));
}
![Page 52: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/52.jpg)
Example: Receiving a Payload
event void Receive.receive(message_t *msg, void *payload, uint8_t len) {
MyPayload *payload = (MyPayload *) payload;
call Leds.set(payload->count);
return msg;
}
![Page 53: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/53.jpg)
Tutorial Mote-mote radio communication
Consider two nodes running the same application.
Each node increments a counter and sends a message with the counter value over the radio.
The receiver of the message displays the counter's three least significant bits on the three LEDs.
http://docs.tinyos.net/index.php/Mote-mote_radio_communication
![Page 54: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/54.jpg)
TINYOS 2.X INSTALLATION
![Page 55: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/55.jpg)
Installing TinyOS 2.x
2 easy choices1. On Ubuntu: http://docs.tinyos.net/index.php/Installing_TinyOS_2.1#Two-
step_install_on_your_host_OS_with_Debian_packages
2. Running a XubunTOS Virtual Machine Image in VMware Player:
a) On Ubuntuhttp://docs.tinyos.net/index.php/Running_a_XubunTOS_Virtual_Machine_Image_in_VMware_Player#Debian_Linux_VMware_Player_Installation
b) On Windowshttp://docs.tinyos.net/index.php/Running_a_XubunTOS_Virtual_Machine_Image_in_VMware_Player#Windows_VMware_Player_Installation
![Page 56: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/56.jpg)
PROGRAM A TELOSB MOTE
![Page 57: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/57.jpg)
Blink Application
It simply causes the LED0 to to turn on and off at 4Hz, LED1 to turn on and off at 2Hz, and LED2 to turn on and off at 1Hz.
The effect is as if the three LEDs were displaying a binary count of zero to seven every two seconds.
http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Blink:_An_Example_Application
![Page 58: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/58.jpg)
motelist
![Page 59: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/59.jpg)
Program a specific mote
To compile a program for telosb platform:
make telosb To flash/upload the program to a telosb
mote:make telosb install, <NODE ID>
bsl,<Serial Port>e.g.
http://docs.tinyos.net/index.php/Getting_Started_with_TinyOS#Installing_on_telos-family_mote_.28telosa.2C_telosb.29
![Page 60: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/60.jpg)
Successful programming!
![Page 61: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/61.jpg)
SenseWALL
Protocol/algorithm implementation Experimental comparison, validation and
evaluation Actuation etc …
![Page 62: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/62.jpg)
Example Application 1/2
Consider a basic data-collection application.
Nodes running this application periodically wake up, sample some sensors, and send the data through an ad hoc collection tree to a data sink.
![Page 63: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/63.jpg)
Example Application 2/2
The four TinyOS APIs the application uses: low power settings for the radio, a timer, sensors, and a data collection routing layer.
![Page 64: INTRODUCTION TO TINYOS 2.X AND NESC. Anatomy of TelosB Mote Limited computational and communication resources MSP430 16-bit microcontroller 10kB RAM](https://reader030.vdocuments.mx/reader030/viewer/2022032800/56649d2d5503460f94a03a92/html5/thumbnails/64.jpg)
References
Για απορίες flip a coin (for load balancing, see LEACH): [email protected] (HEAD) [email protected] (TAIL)
References TinyOS Wiki http://docs.tinyos.net/index.php/Main_Page TinyOS installation http://docs.tinyos.net/index.php/Installing_TinyOS_2.1.1 TinyOS reference
http://www.tinyos.net/tinyos-2.x/doc/pdf/tinyos-programming.pdf NesC reference http://nescc.sourceforge.net/papers/nesc-ref.pdf TinyOS Tutorials http://docs.tinyos.net/index.php/TinyOS_Tutorials Documentation and TEPs http://www.tinyos.net/tinyos-2.1.0/doc/ TinyOS API http://www.tinyos.net/tinyos-2.1.0/doc/nesdoc/telosa/index.html