cis 798 sensor network implementation. goals learning sensor network programming with crossbow motes...

Post on 03-Jan-2016

227 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

CIS 798

Sensor Network Implementation

Goals

• Learning sensor network programming with Crossbow motes

• Implement reasonable sized sensor applications

• Develop expertise to engage in more realistic sensor applications

Platforms

• Crossbow Motes

• TinyOS

• Student groups (2 students each)

• Lab groups

• Project groups

Topics

• TinyOS programming

• Component based programming model

• System setup

• Tutorials

• Help sessions

• Hardware

commands

events

Components

provides uses

Interface: Bidirectional

Interfaces

provides uses

Component: Provide or use multiple interfaces of the same type or different types

Components

Simple components

Configuration

Blink

This application simply causes the red LED on the mote to turn on and off at 1Hz

BlinkBlink.nc configuration Blink {}implementation {  components Main, BlinkM, SingleTimer, LedsC;

  Main.StdControl -> BlinkM.StdControl;  Main.StdControl -> SingleTimer.StdControl;  BlinkM.Timer -> SingleTimer.Timer;  BlinkM.Leds -> LedsC;}

Interface stdcontrolStdControl.nc interface StdControl {  command result_t init();  command result_t start();  command result_t stop();}

Interface StdcontrolMain.StdControl -> BlinkM.StdControl;

When StdControl.init in Main is called, StdControl.init in BlinkM is automatically invoked

BlinkM.ncmodule BlinkM {  provides {    interface StdControl;  }  uses {    interface Timer;    interface Leds;  }}

interface Timer {  command result_t start(char type, uint32_t interval);  command result_t stop();  event result_t fired();}

• start(): to specify the type of the timer and the interval at which the timer will expire;

• the fired() event is signaled when the specified interval has passed

BlinkM.ncinterface Timer {  command result_t start(char type, uint32_t interval);  command result_t stop();  event result_t fired();}

interface Leds { async command result_t init(); async command result_t redOn(); async command result_t redOff(); async command result_t redToggle(); async command result_t greenOn(); async command result_t greenOff(); async command result_t greenToggle(); async command result_t yellowOn(); : :}

BlinkM.nc

module BlinkM {  provides {    interface StdControl;  }  uses {    interface Timer;    interface Leds;  }}

implementation {

  command result_t StdControl.init() {    call Leds.init();    return SUCCESS;  }

  command result_t StdControl.start() {    return call Timer.start(TIMER_REPEAT, 1000) ;  }

  command result_t StdControl.stop() {    return call Timer.stop();  }

  event result_t Timer.fired()  {    call Leds.redToggle();    return SUCCESS;  }}

Week 1

• Read lesson 1

• Install Tiny OS (or use machines in N22)

• Compile Blink

• Program mote to run Blink

• Modify Blink so that Led blinks for 10 secs and then stops for 5 secs (and this is repeated).

top related