
3 changed files with 123 additions and 0 deletions
@ -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:
|
||||
RIOTBASE ?= $(CURDIR)/../..
|
||||
|
||||
# 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:
|
||||
CFLAGS += -DDEVELHELP -Wall
|
||||
|
||||
# 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
|
||||
endif |
||||
ifneq (,$(filter iotlab-m3 fox iotlab-a8-m3,$(BOARD))) |
||||
DRIVER := at86rf231
|
||||
endif |
||||
|
||||
ifneq (,$(filter at86rf2%,$(DRIVER))) |
||||
FEATURES_REQUIRED = periph_spi
|
||||
FEATURES_REQUIRED = periph_gpio
|
||||
endif |
||||
|
||||
USEMODULE += $(DRIVER)
|
||||
|
||||
USEMODULE += random
|
||||
USEMODULE += shell
|
||||
USEMODULE += shell_commands
|
||||
USEMODULE += ps
|
||||
USEMODULE += ipv6_addr
|
||||
|
||||
#required for C++ compiling
|
||||
CXXEXFLAGS += -fno-rtti
|
||||
USEMODULE += cpp11-compat
|
||||
|
||||
#Define PANID and CHANNEL used by default
|
||||
#CFLAGS += -DOPENTHREAD_PANID=0xbeef -DOPENTHREAD_CHANNEL=11
|
||||
|
||||
include $(RIOTBASE)/Makefile.include |
@ -0,0 +1,36 @@
|
||||
## OpenThread on RIOT |
||||
|
||||
This test demonstrates the [OpenThread](https://github.com/openthread/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`. |
||||
|
||||
``` |
||||
ipaddr |
||||
fdde:ad00:beef::ff:fe00:8000 |
||||
fe80::ff:fe00:8000 |
||||
fdde:ad00:beef:0:946a:c722:a5d9:8481 |
||||
fe80::3984:f4eb:d182:5dae |
||||
``` |
||||
|
||||
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](https://github.com/openthread/openthread/blob/master/src/cli/README.md) for more information about OpenThread CLI commands |
@ -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 <baptiste.clenet@xsoen.com> |
||||
*/ |
||||
|
||||
#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); |
||||
|
||||
openthread_uart_run(); |
||||
return 0; |
||||
} |
Loading…
Reference in new issue