pkg/openthread: Add tests

This commit is contained in:
José Ignacio Alamos 2017-06-01 11:48:23 -04:00
parent 017280db13
commit fc4fd6222f
3 changed files with 123 additions and 0 deletions

tests/openthread/Makefile Normal file
View File

@ -0,0 +1,53 @@
APPLICATION = openthread
# If no BOARD is found in the environment, use this default:
BOARD ?= samr21-xpro
BOARD_WHITELIST := samr21-xpro iotlab-m3 fox iotlab-a8-m3
# This has to be the absolute path to the RIOT base directory:
# Comment this out to disable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
# Change this to 0 show compiler invocation lines by default:
QUIET ?= 1
USEPKG += openthread
USEMODULE += openthread_contrib
USEMODULE += libmbedcrypto
USEMODULE += libopenthread
USEMODULE += libopenthread-cli
USEMODULE += xtimer
ifneq (,$(filter samr21-xpro,$(BOARD)))
DRIVER := at86rf233
ifneq (,$(filter iotlab-m3 fox iotlab-a8-m3,$(BOARD)))
DRIVER := at86rf231
ifneq (,$(filter at86rf2%,$(DRIVER)))
USEMODULE += random
USEMODULE += shell
USEMODULE += shell_commands
USEMODULE += ipv6_addr
#required for C++ compiling
CXXEXFLAGS += -fno-rtti
USEMODULE += cpp11-compat
#Define PANID and CHANNEL used by default
include $(RIOTBASE)/Makefile.include

View File

@ -0,0 +1,36 @@
## OpenThread on RIOT
This test demonstrates the [OpenThread]( stack running on RIOT. When flashed,
it will initialize the OpenThread Command Line Interface for interacting with the stack.
## Quick usage
To test OpenThread on RIOT, you can do the following:
1. Flash nodes with `make BOARD=<target> clean all flash`
2. Write `panid 0x1234`, `ifconfig up` then `thread start` on one node.
3. Check the state of the node with `state`. In the beggining should be `detached`, but after some seconds it should
become `leader`
4. Write `panid 0x1234`, `ifconfig up` then `thread start` on another node.
The second node should become `child` or `router` if there's a leader.
5. Get the mesh IP address of a node with `ipaddr`.
Addresses starting with `fd` are mesh-local, and addresses starting with `fe80` are link-local.
Mesh-local address types that contain `ff:fe00` are classified as Router Locator (RLOC). Mesh-local address types
that don't contain `ff:fe00` are Endpoint Identifies (EID).
6. Ping from another node to a mesh-local address with `ping fdde:ad00:beef:0:946a:c722:a5d9:8481`.
7. You can try IEEE802.15.4 scan with `scan` command
8. You can also check other commands with `help`
9. Enjoy!
## Note
See the [OpenThread CLI Reference]( for more information about OpenThread CLI commands

tests/openthread/main.c Normal file
View File

@ -0,0 +1,34 @@
* Copyright (C) 2017 Baptiste CLENET
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
* @file
* @brief OpenThread test application
* @author Baptiste Clenet <>
#include <stdio.h>
#include "net/ipv6/addr.h"
#include "openthread/ip6.h"
#include "openthread/thread.h"
#include "openthread/udp.h"
#include "ot.h"
#include "shell.h"
#include "shell_commands.h"
int main(void)
printf("Get PANID\n");
uint16_t panid = 0;
uint8_t res = ot_call_command("panid", NULL, (void*)&panid);
printf("Current panid: 0x%x (res:%x)\n", panid, res);
return 0;