Difference between revisions of "CoAP -13"

From TinyOS Wiki
Jump to: navigation, search
(Compile libcoap and examples)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= TinyOS CoAP (-08) =
+
= TinyOS CoAP (-13) =
  
 
__TOC__
 
__TOC__
  
This page describes how to setup the TinyOS CoAP (-08) implementation based on [http://sourceforge.net/projects/libcoap/ libcoap] and uses the TinyOS blip-rpl stack for UDP communication.
+
This page describes how to setup the TinyOS CoAP (-13) implementation based on [http://sourceforge.net/projects/libcoap/ libcoap] and uses the TinyOS blip-rpl stack for UDP communication.
  
= Repository =
+
You can find the previous version of this page at: [[CoAP_-03]].
  
The updated code is currently not located in tinyos-main on Google code, but in the git repository:
+
= Installation instructions =
http://www.comnets.uni-bremen.de/~mab/git/tinyos-main.git
+
 
 +
== Compile libcoap and examples ==
  
Branch:
 
libcoap-update-to-08-2012-03-11
 
  
== Compile libcoap and examples ==
 
  
 
<pre>
 
<pre>
cd $TOSROOT/support/sdk/c/coap
+
cd $TOSROOT/tools
autoconf
+
./Bootstrap
 
./configure
 
./configure
 
make
 
make
 +
 +
cd $TOSROOT/tools/tinyos/c/coap
 
./configure --with-tinyos
 
./configure --with-tinyos
 
</pre>
 
</pre>
  
== Installation is similar to -03 ==
+
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:
 +
 
 +
<pre>
 +
cd $TOSROOT/apps/CoapBlip
 +
make telosb blip coap install,3 bsl,/dev/ttyUSB0
 +
</pre>
 +
 
 +
== 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:
 +
 
 +
<pre>
 +
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
 +
</pre>
 +
 
 +
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/tools/tinyos/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:
 +
 
 +
{| border="1"
 +
! scope="col" | &nbsp;Flag&nbsp;
 +
! scope="col" | &nbsp;URI&nbsp;
 +
! scope="col" | &nbsp;GET&nbsp;
 +
! scope="col" | &nbsp;PUT&nbsp;
 +
! scope="col" | &nbsp;POST&nbsp;
 +
! scope="col" | &nbsp;DELETE&nbsp;
 +
! scope="col" | &nbsp;Comments&nbsp;
 +
|-
 +
| scope="row"  | &nbsp;#WITHOUT_WELLKNOWN
 +
| align="center" | .well-known/core
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | Core Link Format of URIs
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_DEFAULT
 +
| align="center" |
 +
| align="center" | X
 +
| align="center" | X
 +
| align="center" | X
 +
| align="center" | X
 +
| align="center" | Resource for POST and DELETE support
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_TEMP
 +
| align="center" | /st
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | Temperature
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_HUM
 +
| align="center" | /sh
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | Humidity
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_VOLT
 +
| align="center" | /sv
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | Voltage
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_ALL
 +
| align="center" | /r
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | Temperature + Humidity + Voltage
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_LED
 +
| align="center" | /l
 +
| align="center" | X
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | LEDs
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_ROUTE
 +
| align="center" | /rt
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | Routing table
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_ETSI_IOT_VALIDATE
 +
| align="center" | /validate
 +
| align="center" | X
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | Resource which varies
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_ETSI_IOT_SEGMENT
 +
| align="center" | /seg1/seg2/seg3
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | Long path resource
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_ETSI_IOT_SEPARATE
 +
| align="center" | /separate
 +
| align="center" | X
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | Resource with separate response
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_ETSI_IOT_LOCATION_QUERY
 +
| align="center" | /location-query
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | Resource accepting location query parameters
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_ETSI_IOT_QUERY
 +
| align="center" | /query
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | Resource accepting query parameters
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_ETSI_IOT_LARGE
 +
| align="center" | /large
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | Large resource
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_ETSI_IOT_OBSERVE
 +
| align="center" | /obs
 +
| align="center" | X
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | Observable resource which changes every 5 seconds
 +
|-
 +
| scope="row"  | &nbsp;COAP_RESOURCE_ETSI_IOT_MULTI_FORMAT
 +
| align="center" | /multi-format
 +
| align="center" | X
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | -
 +
| align="center" | 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 [http://www.etsi.org/plugtests/CoAP/About_CoAP.htm 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
  
= Modifications from -03 to -08 =
+
This should turn on all three Leds on the node.
* Interfaces: Read/WriteResource to CoapResource
 
* All resource components moved to tos/lib/net/coap/resources/
 
* All translate components moved to tos/lib/net/coap/translate/
 
* bind() -> setupContext()
 
* Added ETSI plugtest resources
 
* removed most code out of tinyos_net.c/h
 
* ...
 

Latest revision as of 00:45, 29 July 2014

TinyOS CoAP (-13)

This page describes how to setup the TinyOS CoAP (-13) 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.

Installation instructions

Compile libcoap and examples

cd $TOSROOT/tools
./Bootstrap
./configure
make

cd $TOSROOT/tools/tinyos/c/coap
./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/tools/tinyos/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_LED /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.