RIOT-OS and IEEE 802.15.4 / 6LoWPAN

From Embedded Lab Vienna for IoT & Security
Jump to navigation Jump to search

Summary

Information on how to use/configure RIOT-OS with IEEE 802.15.4 and 6LoWPAN.

Requirements

In order to complete these steps, you must have followed RIOT-OS Setup before.

  • Default 802.15.4 PAN ID of RIOT-OS/SAMR21-xpro: 0x23
  • Default 802.15.4 channel ID of RIOT-OS/SAMR21-xpro: 26

Configure IEEE 802.15.4 PAN/Channel ID in RIOT

Via RIOT Shell:

  • Use ifconfig to determine the 802.15.4/6LoWPAN interface ID of SAMR21-xpro (7 in this case):
ifconfig
# Iface  7  HWaddr: 57:98  Channel: 26  Page: 0  NID: 0x23  PHY: O-QPSK
[...]
#           Long HWaddr: E2:F9:02:0F:36:26:A2:68
[...]
#           inet6 addr: fe80::e0f9:20f:3626:a268  scope: link  VAL
  • Note: All ifconfig config options can be shown with ifconfig <interface id> set.
  • Configure Channeld/PAN ID:
ifconfig 7 set pan_id 0xbeef
ifconfig 7 set channel 23

Set Channel/PAN ID via Makefile of your application, e.g.:

CFLAGS += -DCONFIG_IEEE802154_DEFAULT_CHANNEL=16
CFLAGS += -DCONFIG_IEEE802154_DEFAULT_PANID=0xcafe

Or for RIOT in general:

vim /Path/to/RIOT/makefiles/default-radio-settings.inc.mk

cf. https://github.com/RIOT-OS/RIOT/blob/master/makefiles/default-radio-settings.inc.mk

  • Default 802.15.4 PAN ID of RIOT-OS/SAMR21-xpro: 0x23
  • Default 802.15.4 channel ID of RIOT-OS/SAMR21-xpro: 26

OPTIONAL: change HW address via RIOT Shell during runtime:

ifconfig 6 set addr_long 02:0:0:0:0:0:0:2

Test 802.15.4/6LoWPAN with RIOT gcoap example

RIOT's gcoap example can be found here: https://github.com/RIOT-OS/RIOT/tree/master/examples/gcoap

README: https://github.com/RIOT-OS/RIOT/blob/master/examples/gcoap/README.md

Flash it on e.g. two SAMR21-xpro devices.

It may be necessary to specify the sending / outgoing interface. This can be done by appending the number of the network interface to the (link-local) IPv6 address (e.g. %6"):

coap get [fe80::d8b8:65ff:feee:121b%6]:5683 /.well-known/core

=> fe80::d8b8:65ff:feee:121b%6 => fe80::[..] is the remote link-local address, but "%6" specifies the local interface ID of node where this command is submitted.

The interface ID is stated when you perform ifconfig on your local node. Normally this interface ID is 6 or 7.

Used Hardware

Courses

  • IT-Security master's programme: Mobile and Embedded Security ILV

References