CoAP -17

From TinyOS Wiki
Jump to: navigation, search

TinyOS CoAP (-17)

This page describes how to setup the TinyOS CoAP (-17) implementation based on libcoap and uses the TinyOS blip-rpl stack for UDP communication.

You can find the previous version of this page at: CoAP_-03 and CoAP_-13.

Installation instructions

Compile libcoap and examples

cd $TOSROOT/support/sdk/c/coap
autoconf
./configure
make
./configure --with-tinyos

The code has been tested on TelosB nodes only, yet. The sample implementation depends on TelosB sensors.


Compile and install CoapBlip application

To install CoapBlip on a mote, attach the mote via USB and run the following set of commands:

cd $TOSROOT/apps/CoapBlip
make telosb blip coap install,3 bsl,/dev/ttyUSB0

Setting up PppRouter and ppp connection

To install the PppRouter application for IPv6 support on the second attached mote, execute

cd $TOSROOT/apps/PppRouter

and install the PppRouter:

make telosb blip install bsl,/dev/ttyUSB1

Next, start the ppp connection by executing

sudo pppd debug passive noauth nodetach 115200 /dev/ttyUSB1 nocrtscts nocdtrcts lcp-echo-interval 0 noccp noip ipv6 ::23,::24

After entering the sudo password, a similar output should be printed on your screen:

using channel 1
Using interface ppp0
Connect: ppp0 <--> /dev/ttyUSB1
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xc33c412b> <pcomp> <accomp>]
rcvd [LCP ConfRej id=0x1 <magic 0xc33c412b> <pcomp>]
sent [LCP ConfReq id=0x2 <asyncmap 0x0> <accomp>]
rcvd [LCP ConfAck id=0x2 <asyncmap 0x0> <accomp>]
rcvd [LCP ConfReq id=0x3 <mru 1280> <asyncmap 0x0> <accomp>]
sent [LCP ConfAck id=0x3 <mru 1280> <asyncmap 0x0> <accomp>]
sent [IPV6CP ConfReq id=0x1 <addr fe80::0000:0000:0000:0023>]
rcvd [IPV6CP ConfReq id=0x1 <addr fe80::0000:0000:0000:0000>]
sent [IPV6CP ConfNak id=0x1 <addr fe80::0000:0000:0000:0024>]
rcvd [IPV6CP ConfReq id=0x2 <addr fe80::0000:0000:0000:0000>]
sent [IPV6CP ConfNak id=0x2 <addr fe80::757d:cee8:dcad:b877>]
rcvd [IPV6CP ConfReq id=0x3 <addr fe80::0000:0000:0000:0024>]
sent [IPV6CP ConfAck id=0x3 <addr fe80::0000:0000:0000:0024>]
sent [IPV6CP ConfReq id=0x1 <addr fe80::0000:0000:0000:0023>]
rcvd [IPV6CP ConfAck id=0x1 <addr fe80::0000:0000:0000:0023>]
local  LL address fe80::0000:0000:0000:0023
remote LL address fe80::0000:0000:0000:0024
Script /etc/ppp/ipv6-up started (pid 23284)
Script /etc/ppp/ipv6-up finished (pid 23284), status = 0x0

Open a new terminal and run

sudo ifconfig ppp0 add fec0::100/64

The ppp connection is now established.

Run CoAP example client

To run the CoAP example client and request a resource from the server execute the following commands:

cd $TOSROOT/support/sdk/c/coap/examples
./coap-client coap://[fec0::3]/<URI>

whereas <URI> specifies the resource you want to access.

For TelosB motes, currently the following resources are supported and can be enabled/disabled in the Makefile of the CoAP application:

 Flag   URI   GET   PUT   POST   DELETE   Comments 
 #WITHOUT_WELLKNOWN .well-known/core X - - - Core Link Format of URIs
 COAP_RESOURCE_DEFAULT X X X X Resource for POST and DELETE support
 COAP_RESOURCE_TEMP /st X - - - Temperature
 COAP_RESOURCE_HUM /sh X - - - Humidity
 COAP_RESOURCE_VOLT /sv X - - - Voltage
 COAP_RESOURCE_ALL /r X - - - Temperature + Humidity + Voltage
 COAP_RESOURCE_KEY /l X X - - LEDs
 COAP_RESOURCE_ROUTE /rt X - - - Routing table
 COAP_RESOURCE_ETSI_IOT_VALIDATE /validate X X - - Resource which varies
 COAP_RESOURCE_ETSI_IOT_SEGMENT /seg1/seg2/seg3 X - - - Long path resource
 COAP_RESOURCE_ETSI_IOT_SEPARATE /separate X X - - Resource with separate response
 COAP_RESOURCE_ETSI_IOT_LOCATION_QUERY /location-query X - X - Resource accepting location query parameters
 COAP_RESOURCE_ETSI_IOT_QUERY /query X - - - Resource accepting query parameters
 COAP_RESOURCE_ETSI_IOT_LARGE /large X - - - Large resource
 COAP_RESOURCE_ETSI_IOT_OBSERVE /obs X X - - Observable resource which changes every 5 seconds
 COAP_RESOURCE_ETSI_IOT_MULTI_FORMAT /multi-format X - - - Resource that exist in different content-formats

Note: Due to restricted memory capacities on TelosB motes, you may not be able to enable all resources at the same time!

All ETSI_IOT resources were tested during the 2nd CoAP Plugtest. Further information can be found in the test description


As an example for accessing the LED resource, the following commands can be used:

GET request:

 ./coap-client coap://[fec0::3]/l


PUT request:

./coap-client -m put coap://[fec0::3]/l -e 7

This should turn on all three Leds on the node.