Presentation is loading. Please wait.

Presentation is loading. Please wait.

WSN Training: XMesh Enabled Sensor App

Similar presentations


Presentation on theme: "WSN Training: XMesh Enabled Sensor App"— Presentation transcript:

1 WSN Training: XMesh Enabled Sensor App
Feb 2007 Lab 5 Objectives Use XMesh multi-hop networking service to send sensing data to a base station Using XServe to display the sensor data message on a PC WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

2 Required Hardware and PC Setup
WSN Training: XMesh Enabled Sensor App Feb 2007 Required Hardware and PC Setup Two MICA Motes: MICA2 (MPR4x0) or MICAz (MPR2600) One sensor or data acquisition board: MTS300 or MTS310, MDA100 is OK too One gateway board: MIB510, MIB520, or MIB600 and the associated hardware (cables, power supply) for each A Windows PC with MoteWorks installed WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

3 WSN Training: XMesh Enabled Sensor App
Feb 2007 About MyApp Source code Under directory /MoteWorks/apps/tutorials/lesson_4 What does MyApp do? In terms of sensing it is exactly the same as MyApp in Lab 4 But how it sends the data back to the base station is different Uses the XMesh multi-hop networking service What am I expected to learn? Learn multihop routing service in MoteWorks WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

4 WSN Training: XMesh Enabled Sensor App
Feb 2007 Review: MyApp Steps Review the Makefile Review the Makefile.component Review the Top-level application configuration Review the Top-level module Compile app and flash Motes View data via XServe WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

5 WSN Training: XMesh Enabled Sensor App
Feb 2007 MyApp – Makefile include Makefile.component include $(TOSROOT)/apps/MakeXbowlocal GOALS += basic freq route include $(MAKERULES) The GOALS statement lists three services -- basic, freq, and route RF channel and the routing power mode not specified. Default values in Makexbowlocal will be used. Of course, the freq and route power can be set later during compile time The basic service Will provide the standard Crossbow routing services Common practice to have basic in all XMesh applications Unlike freq and route, there are no additional parameters with basic service. WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

6 MyApp – Makefile.component
WSN Training: XMesh Enabled Sensor App Feb 2007 MyApp – Makefile.component COMPONENT=MyApp SENSORBOARD=mts310 Same as in Lab 4 Note: we’ll need to use SENSORBOARD=mda100cb WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

7 WSN Training: XMesh Enabled Sensor App
Feb 2007 Review: MyApp Steps Makefile Makefile.component Top-level application configuration Top-level module Compile app and flash Motes View data via XServe WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

8 Top-level Configuration
WSN Training: XMesh Enabled Sensor App Feb 2007 Top-level Configuration /* * MyApp.nc */ #include "appFeatures.h" includes sensorboardApp; /** * This configuration shows how to use the Timer, LED, ADC and XMesh components. * Sensor messages are sent multi-hop over the RF radio * Crossbow Technology Inc. **/ configuration MyApp { } implementation { components Main, GenericCommPromiscuous as Comm, MULTIHOPROUTER, MyAppM, TimerC, LedsC, Photo; Main.StdControl -> TimerC.StdControl; Main.StdControl -> MyAppM.StdControl; Main.StdControl -> Comm.Control; Main.StdControl -> MULTIHOPROUTER.StdControl; MyAppM.Timer -> TimerC.Timer[unique("Timer")]; MyAppM.Leds -> LedsC.Leds; MyAppM.PhotoControl -> Photo.PhotoStdControl; MyAppM.Light -> Photo.ExternalPhotoADC; MyAppM.RouteControl -> MULTIHOPROUTER; MyAppM.Send -> MULTIHOPROUTER.MhopSend[AM_XMULTIHOP_MSG]; MULTIHOPROUTER.ReceiveMsg[AM_XMULTIHOP_MSG] ->Comm.ReceiveMsg[AM_XMULTIHOP_MSG]; WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

9 Comparing Configurations in Lab 4 & Lab 5
WSN Training: XMesh Enabled Sensor App Feb 2007 Comparing Configurations in Lab 4 & Lab 5 Lab 4 New! Lab 5 WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

10 Communication in Lab 4 and Lab 5
WSN Training: XMesh Enabled Sensor App Feb 2007 Communication in Lab 4 and Lab 5 MyApp (Lab 4) GenericComm component Function: Sends a message either directly through the UART port or over the radio If by radio: broadcast or to a specific node address. MyApp (Lab 5) GenericComm replaced by GenericCommPromiscuous Function: Adds special radio “snooping” capabilities required by XMesh. MULTIHOPROUTER component (appears as XMeshBinaryRouter) Function: XMesh networking service for multi-hopping GenericComm service is eventually used, but special routing information is added, which is hidden from the application WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

11 WSN Training: XMesh Enabled Sensor App
Feb 2007 Review: MyApp Steps Makefile Makefile.component Top-level application configuration Top-level module Compile app and flash Motes View data via XServe WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

12 WSN Training: XMesh Enabled Sensor App
Feb 2007 Top Level Module The application’s module is MoteWorks/apps/tutorials/lesson_4/MyAppM.nc How does it differ from MyAppM.nc in Lab 4? Uses the MhopSend interface instead of the SendMsg interface. XMesh implements the MhopSend interface WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

13 nesC Interface – MhopSend Usage Summary
WSN Training: XMesh Enabled Sensor App Feb 2007 nesC Interface – MhopSend Usage Summary interface MhopSend { command result_t send(uint16_t dest, uint8_t mode, TOS_MsgPtr msg, uint16_t length); command void* getBuffer(TOS_MsgPtr msg, uint16_t* length); event result_t sendDone(TOS_MsgPtr msg, result_t success); } The MhopSend interface specifies two command Send Send a message buffer with a data payload of a specific length. getBuffer Given a TinyOS message buffer, provide a pointer to the data buffer within it that an application can use as well as its length. and one event sendDone Signaled when a packet sent with send() completes. WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

14 MoteWorks/apps/tutorials/lesson_4/MyApp.nc – Specification
WSN Training: XMesh Enabled Sensor App Feb 2007 MoteWorks/apps/tutorials/lesson_4/MyApp.nc – Specification #include "appFeatures.h" includes MultiHop; includes sensorboard; /** * This module shows how to use the Timer, LED, ADC and XMesh components. * Sensor messages are sent multi-hop over the RF radio * Crossbow Technology Inc. **/ module MyAppM { provides { interface StdControl; } uses { interface Timer; interface Leds; interface StdControl as PhotoControl; interface ADC as Light; interface MhopSend as Send; interface RouteControl; WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

15 MoteWorks/apps/tutorials/lesson_4/MyAppM.nc – Implementation (1 of 4)
WSN Training: XMesh Enabled Sensor App Feb 2007 MoteWorks/apps/tutorials/lesson_4/MyAppM.nc – Implementation (1 of 4) implementation { bool sending_packet = FALSE; TOS_Msg msg_buffer; XDataMsg *pack; /** * Initialize the component. Always returns <code>SUCCESS</code> **/ command result_t StdControl.init() { uint16_t len; call Leds.init(); call PhotoControl.init(); // Initialize the message packet with default values atomic { pack = (XDataMsg*)call Send.getBuffer(&msg_buffer, &len); pack->board_id = SENSOR_BOARD_ID; pack->packet_id = 1; pack->packet_id = pack->packet_id | 0x80; } return SUCCESS; The first change we see is a different message packet being initialized in the StdControl.init function. This module calls the XMesh Send.getBuffer command which returns a pointer to the payload area in the msg_buffer. Initialize the standard MTS310 packet with the default values. WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

16 MoteWorks/apps/tutorials/lesson_4/MyAppM.nc – Implementation (2 of 4)
WSN Training: XMesh Enabled Sensor App Feb 2007 MoteWorks/apps/tutorials/lesson_4/MyAppM.nc – Implementation (2 of 4) /** * Start things up. This just sets the rate for the clock component. Always returns <code>SUCCESS</code> **/ command result_t StdControl.start() { // Start a repeating timer that fires every 1000ms return call Timer.start(TIMER_REPEAT, 1000); } * Halt execution of the application. * This just disables the clock component. command result_t StdControl.stop() { return call Timer.stop(); * Toggle the red LED in response to the <code>Timer.fired</code> event. * Start the light sensor control and sample the data event result_t Timer.fired() { call Leds.redToggle(); call PhotoControl.start(); call Light.getData(); return SUCCESS; This section of the source code was seen before in MyAppM.nc of lesson_3. WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

17 MoteWorks/apps/tutorials/lesson_4/MyAppM.nc – Implementation (3 of 4)
WSN Training: XMesh Enabled Sensor App Feb 2007 MoteWorks/apps/tutorials/lesson_4/MyAppM.nc – Implementation (3 of 4) /** * Stop the Light sensor control, build the message packet and send **/ void task SendData() { call PhotoControl.stop(); if (sending_packet) return; atomic sending_packet = TRUE; // send message to XMesh multi-hop networking layer pack->parent = call RouteControl.getParent(); if (call Send.send(BASE_STATION_ADDRESS,MODE_UPSTREAM,&msg_buffer,sizeof(XDataMsg)) != SUCCESS) sending_packet = FALSE; return; } * Light ADC data ready * Toggle yellow LED to signal Light sensor data sampled Always returns <code>SUCCESS</code> async event result_t Light.dataReady(uint16_t data) { atomic pack->light = data; atomic pack->vref = 417; // a dummy 3V reference voltage, /3000 = 417 call Leds.yellowToggle(); return SUCCESS; The next difference is that the packet must include the current routing parent This is obtained by making a call to the XMesh command RouteControl.getParent Then send the message using the Send.send command specifying the base station as the destination and the transport mode as MODE_UPSTREAM. WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

18 MoteWorks/apps/tutorials/lesson_4/MyAppM.nc – Implementation (4 of 4)
WSN Training: XMesh Enabled Sensor App Feb 2007 MoteWorks/apps/tutorials/lesson_4/MyAppM.nc – Implementation (4 of 4) /** * Sensor data has been sucessfully sent through XMesh * Toggle green LED to signal message sent * Always returns <code>SUCCESS</code> **/ event result_t Send.sendDone(TOS_MsgPtr msg, result_t success) { call Leds.greenToggle(); atomic sending_packet = FALSE; return SUCCESS; } As with the MyApp application of lesson 3 we receive the Send.sendDone event that signifies the message has been sent. LED color Indication Red 1 second timer event fired Yellow Light sensor has been sampled Green Sensor message has been sent back to base station WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

19 WSN Training: XMesh Enabled Sensor App
Feb 2007 Review: MyApp Steps Makefile Makefile.component Top-level application configuration Top-level module Compile app and flash Motes View data via XServe WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

20 MyApp – Compile and Install Program
WSN Training: XMesh Enabled Sensor App Feb 2007 MyApp – Compile and Install Program Plug the Mote that will function as the sensor node into the programming board. Click on the lesson_4/MyApp.nc file in Programmer’s Notepad 2 Select Tools > shell. The make commands will be one of the following MIB510: make <platform> install,<N> mib510,com<#> where <#> is the COM port your MIB510 is attached MIB520: make <platform> install,<N> mib520,com<#> where <#> is the first COM port your assigned by your PC to the USB port MIB600: make <platform> install,<N> erpb,<IP_address> Note: <N> = 1, 2, 3, etc. WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

21 MyApp – Compile and Install Program
WSN Training: XMesh Enabled Sensor App Feb 2007 MyApp – Compile and Install Program LED color Indication Red 1 second timer event fired Yellow Light sensor has been sampled Green Sensor message has been sent back to base station Next, plug the Mote that will function as the base station into the programming board. This Mote will be programmed with a special application named XMeshBase located in the /MoteWorks/apps/xmesh/XMeshBase folder. Select the XMeshBase.nc file in Programmer’s Notepad Select Tools > shell When prompted for parameters, type in the appropriate compile and install command WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

22 Viewing Sensor Data in XServe
WSN Training: XMesh Enabled Sensor App Feb 2007 Viewing Sensor Data in XServe The next step is to verify that messages are being received at the base station by running the XServe application on your PC to display the packets. Open a Cygwin command prompt by double clicking on the icon located on your desktop. At the command prompt type MIB510 xserve –s=com<#> where <#> is the serial port to which your MIB510 MIB520 users: xserve –s=com<#+1> where <#> is the first COM port assigned to the MIB520 MIB600 users: xserve –i=<IP_Address> where <IP_Address> is the IP address of the MIB600 You should see output similar to the following screen shot WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

23 WSN Training: XMesh Enabled Sensor App
Feb 2007 Sample XServe output WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary

24 WSN Training: XMesh Enabled Sensor App
Feb 2007 What you need to do Finish Lab 5 report (posted on website) WSN Training: XMesh Enabled Sensor App Feb 2007 Crossbow Technology, Inc. Proprietary


Download ppt "WSN Training: XMesh Enabled Sensor App"

Similar presentations


Ads by Google