CoAP Chat Application for RIOT OS

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


This documentation describes the setup and usage of a CoAP-based, chat application for the RIOT operating system.


In order to build and use this application, you need to install the tool chains used by RIOT. Tutorials on how to do that can be found in the official RIOT GitHub repository and the official documentation:


Step 1

Clone the repository from and compile it on the board you are using with:

make BOARD= board name all

alternatively you can compile it in native mode, i.e without using an evaluation board:

make BOARD=native all

If you are using native mode, you will need to setup a Virtual RIOT network with at least two TAP devices, for communication between nodes. This can be achieved with the following script:

RIOT/dist/tools/tapsetup/tapsetup -c 2

Open a two terminals and run two nodes. The first with tap0 and the other with tap1.

make BOARD=native PORT=tap0 term
make BOARD=native PORT=tap1 term

Step 2

After boot-up you can type help to see a list of all available commands:

> help
Command              Description
server               Riot CoAP Server
client               Riot CoAP Client
s                    Riot CoAP Server
c                    Riot CoAP Client
reboot               Reboot the node
ps                   Prints information about running threads.
ping6                Ping via ICMPv6
random_init          initializes the PRNG
random_get           returns 32 bit of pseudo randomness
nib                  Configure neighbor information base
ifconfig             Configure network interfaces

Run client on one board (or terminal for native) and server on another.

Step 3

After starting a client on a node you are greeted with the following options:

Help Screen:
Command            Parameters         Description
/discovery[/d]                        send broadcast to find server
/connect[/c]                          connect to set server
/list[/l]                             list discovered server
/info[/i]                             get server info
/setserver[/ss]    [serverid]         set server to serverid
/setuser[/su]      [username]         set user to username
/options[/o]                          show config
/help[/h]                             this screen
/exit[/e]                             exit RioChat, drop back to Shell
Just type to send messages, when you are connected.

After setting a user with /setuser you need to run /discovery to send a broadcast to find the server. /list shows you a list of discovered servers. Each server has a name a server address (IPv6) and an id. With /setserver you can set the server id to your desired server and with /connect, connect to it. After you are connected you can type messages and send them to all clients that are connected to the server.

Used Hardware

This project was realized with the SAMR21-xpro evaluation board by Atmel. It features the ATSAMR21G18A SoC by Microchip. It contains an ARM® Cortex®-M0+ based 32-bit MCU with a 2.4GHz RF transceiver compliant with IEEE 802.15.4 standard.