examples/openthread: move test to examples
This commit is contained in:
parent
74ec336d03
commit
b75ffb98da
53
examples/openthread/Makefile
Normal file
53
examples/openthread/Makefile
Normal file
@ -0,0 +1,53 @@
|
||||
APPLICATION = openthread
|
||||
|
||||
# If no BOARD is found in the environment, use this default:
|
||||
BOARD ?= samr21-xpro
|
||||
|
||||
# These are the boards that OpenThread stack has been tested on
|
||||
BOARD_WHITELIST := samr21-xpro iotlab-m3 fox iotlab-a8-m3
|
||||
|
||||
# This has to be the absolute path to the RIOT base directory:
|
||||
RIOTBASE ?= $(CURDIR)/../..
|
||||
|
||||
# Change this to 0 show compiler invocation lines by default:
|
||||
QUIET ?= 1
|
||||
|
||||
USEPKG += openthread
|
||||
OPENTHREAD_TYPE ?= ftd
|
||||
ifeq ($(OPENTHREAD_TYPE),mtd)
|
||||
# MTD: A Minimal Thread Device does not have router functionality
|
||||
# compiled in. As a result, it is not necessary to configure the
|
||||
# routerrole on an MTD. At the same time, an MTD may or may not be sleepy.
|
||||
USEMODULE += openthread-mtd
|
||||
USEMODULE += openthread-cli-mtd
|
||||
else
|
||||
# ftd: A Full Thread Device has router functionality compiled in
|
||||
USEMODULE += openthread-ftd
|
||||
USEMODULE += openthread-cli-ftd
|
||||
endif
|
||||
|
||||
#Define PANID, CHANNEL and UART_BAUDRATE used by default
|
||||
OPENTHREAD_PANID ?= 0xbeef
|
||||
OPENTHREAD_CHANNEL ?= 26
|
||||
|
||||
CFLAGS += -DOPENTHREAD_PANID=$(OPENTHREAD_PANID)
|
||||
CFLAGS += -DOPENTHREAD_CHANNEL=$(OPENTHREAD_CHANNEL)
|
||||
|
||||
ifneq (,$(filter samr21-xpro,$(BOARD)))
|
||||
DRIVER := at86rf233
|
||||
endif
|
||||
ifneq (,$(filter iotlab-m3 fox iotlab-a8-m3,$(BOARD)))
|
||||
DRIVER := at86rf231
|
||||
endif
|
||||
|
||||
USEMODULE += $(DRIVER)
|
||||
|
||||
USEMODULE += xtimer
|
||||
USEMODULE += random
|
||||
USEMODULE += ps
|
||||
|
||||
#required for C++ compiling
|
||||
CXXEXFLAGS += -fno-rtti
|
||||
USEMODULE += cpp11-compat
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
70
examples/openthread/README.md
Normal file
70
examples/openthread/README.md
Normal file
@ -0,0 +1,70 @@
|
||||
## OpenThread on RIOT
|
||||
|
||||
This example demonstrates how to use the [OpenThread](https://github.com/openthread/openthread)
|
||||
open source implementation of [Thread](https://threadgroup.org/) on RIOT.
|
||||
|
||||
The [Command Line Interface](https://github.com/openthread/openthread/blob/master/examples/apps/cli/README.md) of
|
||||
OpenThread was ported. Please check the
|
||||
[full documentation](https://github.com/openthread/openthread/blob/master/src/cli/README.md)
|
||||
of the CLI for usage information.
|
||||
|
||||
You can either build a FTD or MTD firmware:
|
||||
- MTD: A Minimal Thread Device does not have router functionality compiled in.
|
||||
An MTD may or may not be sleepy.
|
||||
- FTD: A Full Thread Device has router functionality compiled in.
|
||||
|
||||
## Quick usage
|
||||
|
||||
With RIOT port, a node is auto-setup and ready to communicate with
|
||||
this configuration:
|
||||
```
|
||||
OPENTHREAD_PANID=0xbeef
|
||||
OPENTHREAD_CHANNEL=26
|
||||
```
|
||||
|
||||
You can pass the panid/channel independently when building the firmware:
|
||||
```
|
||||
make BOARD=<target> OPENTHREAD_PANID=0xaaaa OPENTHREAD_TYPE=ftd flash term
|
||||
```
|
||||
```
|
||||
make BOARD=<target> OPENTHREAD_CHANNEL=20 OPENTHREAD_TYPE=ftd flash term
|
||||
```
|
||||
|
||||
To try OpenThread in RIOT, you can do the following:
|
||||
|
||||
1. Flash nodes with MTD or FTD functionality:
|
||||
```
|
||||
make BOARD=<target> clean all flash OPENTHREAD_TYPE=mtd
|
||||
```
|
||||
```
|
||||
make BOARD=<target> clean all flash OPENTHREAD_TYPE=ftd
|
||||
```
|
||||
|
||||
2. Check the state of the node with `state`. In the beginning, it should be
|
||||
`detached`, but after some seconds it should become `leader`
|
||||
|
||||
3. Start another node and check that it becomes `router`. There is only one
|
||||
leader in a Thread network.
|
||||
|
||||
4. 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
|
||||
```
|
||||
5. Ping from another node with
|
||||
```
|
||||
ping fdde:ad00:beef:0:946a:c722:a5d9:848
|
||||
```
|
||||
|
||||
6. You can try IEEE802.15.4 scan with `scan` command
|
||||
|
||||
7. You can also check other commands with `help`
|
||||
|
||||
|
||||
## OpenThread port on RIOT status
|
||||
|
||||
OpenThread port on RIOT is stable. In case of any bug, please report via
|
||||
[GitHub issue](https://github.com/RIOT-OS/RIOT/issues/new?template=bug_report.md&title=Bug).
|
||||
@ -10,25 +10,21 @@
|
||||
* @file
|
||||
* @brief OpenThread test application
|
||||
*
|
||||
* @author Baptiste Clenet <baptiste.clenet@xsoen.com>
|
||||
* @author Baptiste Clenet <bapclenet@gmail.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");
|
||||
puts("This a test for OpenThread");
|
||||
/* Example of how to call OpenThread stack functions */
|
||||
puts("Get PANID ");
|
||||
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;
|
||||
}
|
||||
@ -1,43 +0,0 @@
|
||||
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)/../..
|
||||
|
||||
# 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
|
||||
|
||||
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
|
||||
@ -1,36 +0,0 @@
|
||||
## 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
|
||||
Loading…
x
Reference in New Issue
Block a user