-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenThread port #5552
OpenThread port #5552
Changes from 16 commits
c85f3d1
fd9888c
1ac5165
991400c
2bb2e19
68b5c74
3b48840
bdc1ba0
0ffbbfb
55159ad
0531e39
0908d84
f80447c
aeddb7e
cbb4264
d763a5a
86d339a
c1acf84
5e2c8cb
686e9c8
96888f7
d72c5e9
0042cca
d71f1c5
2edbc70
66ff178
0d4bb42
aad0226
2cbc50b
f8c1065
b0aac67
499888e
38e347a
0f31057
361e981
803e97c
2869464
86b7884
4d50466
377b59f
25327d4
2e0ce6c
f738b25
99d3c20
ca2ba08
8f139b8
8f37f24
f1a054c
84c7b2b
bc02036
a235cb1
d1962c3
cc6fc73
1b31ccd
66f1126
681d392
8e79654
bb95c4c
2440234
d57176b
120a22c
b0d1b11
8293a99
b58d316
6fa89ec
75db297
170e711
3956a26
17fe180
1cc81a1
ccb9d88
fec9a22
083719f
e9fc6f4
710e6b0
56e6471
0441745
ef55b9f
9483874
08e6d30
515eae6
43d00d0
3137208
840ebfc
7b1543b
8a4c64c
4367fd9
a64efbd
089f6d5
c82c4f1
3cb21c4
4b89640
db5c505
c016092
7b48780
db2c83e
dd80410
012423d
32eefed
269fe83
85280e0
e590a86
6ec062f
6c5ee42
77df0e3
0c944a2
c58bc3d
852112a
d715ffa
17a1851
0d9060c
4e9daf1
c5e537d
c278f35
f6646cb
fddb6a0
b251149
88f905c
6d2acf2
342e26c
69a4cb6
bd0e18c
672e5bb
c2ed9e1
cf1f12c
238ef6b
27b77d4
1d2fa71
a79c7b0
c40aee3
c4b652d
01bbc72
521c743
991795d
3f1ebe7
737d13d
ab0076a
050aeb0
1bd44c2
b69055e
ff37d4d
444bded
c0c84d0
cc15076
2fb1160
7b0d475
42a2714
8199413
1e2155a
d878028
d53d277
a7bae16
9056636
d5d9202
47cae78
ac86e48
24e2564
9eac7ef
2bcd0ed
9074bb1
6422922
0732e31
3bd15be
6b409ad
a3b8bb0
0d003e9
9b89b6c
65fbc89
87e5bd8
43e79e2
b0bcf82
5c2c779
fa21d3d
4fe3c64
ffe979e
a138cc2
35bef27
a02d7da
1f2b4ab
e13ebc9
29fdd21
bdb6876
1d27fde
82445fd
a8405df
3b6537a
2ab9711
2ee1ca1
1a3579e
3448d11
06f3114
46155b6
1b0a571
8440a5f
a823694
2b2d41c
b13475a
0becba8
86c6778
8534441
f8dad6e
396e76f
1705621
139d456
bf6ea72
3295238
7c83551
e84d52b
0eb7844
9e8d304
c34b244
9f80348
3ee1a70
f9b0b2e
ac3cff2
24cecf4
13ae220
c1051d4
b3a0053
5ee079b
8849182
78b0ed2
a05a6ee
a9c9e51
96e756e
fa1ccb4
9381a8b
792d71f
0d185e0
9f5b779
746b510
f537b3c
6013bcd
0ac7846
37392a1
e9bbfc4
584e417
6a8651c
e5512c3
d88e121
d4c0e08
583658b
459eb71
a039dbf
593ce1e
fe02b9a
1b253de
3acc830
a5e2bed
56ef435
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -568,3 +568,29 @@ ifneq (,$(filter random,$(USEMODULE))) | |
USEMODULE += tinymt32 | ||
endif | ||
endif | ||
|
||
ifneq (,$(filter openthread,$(USEMODULE))) | ||
USEMODULE += openthread_core | ||
USEMODULE += openthread_contrib | ||
USEPKG += openthread | ||
USEMODULE+=xtimer | ||
|
||
FEATURES_REQUIRED += cpp | ||
FEATURES_REQUIRED += periph_spi periph_gpio | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be split in 2 lines There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And also, why SPI is mandatory here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or gpio, for that matter |
||
endif | ||
|
||
ifneq (,$(filter openthread_contrib,$(USEMODULE))) | ||
USEMODULE+=openthread_contrib_netdev2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be renamed in |
||
USEMODULE+=openthread_contrib_conn | ||
endif | ||
|
||
ifneq (,$(filter openthread_core,$(USEMODULE))) | ||
USEMODULE+=openthread_core_common | ||
USEMODULE+=openthread_core_coap | ||
USEMODULE+=openthread_core_thread | ||
USEMODULE+=openthread_core_net | ||
USEMODULE+=openthread_core_crypto | ||
USEMODULE+=openthread_core_mac | ||
USEMODULE+=mbedtls | ||
USEMODULE+=mbedtls_lib | ||
endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might need adaptation to #5891. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -324,6 +324,13 @@ void at86rf2xx_set_cca_threshold(at86rf2xx_t *dev, int8_t value) | |
at86rf2xx_reg_write(dev, AT86RF2XX_REG__CCA_THRES, value); | ||
} | ||
|
||
#ifdef MODULE_OPENTHREAD | ||
bool at86rf2xx_receiver_listening(at86rf2xx_t *dev) | ||
{ | ||
return (at86rf2xx_reg_read(dev, AT86RF2XX_REG__RX_SYN) & 0x80) ? false : true; | ||
} | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought adaptations to the driver aren't necessary anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isn't the pkg updated version (I created a separate branch for that). That version has a simplified radio layer that doesn't require the LISTENING option There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be great to sync that branch with this PR soonish, so we can merge it for this release ;-). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but I see it a little bit difficult for this release :(. If I manage to link OT libs generated by their building system, I can disable all heavy features and continue with the development. Anyway, can we try to merge this for this release and then PR again the second branch? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a problem with driver changes that are deemed to be reverted later on anyways :-/. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ping? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return !(at86rf2xx_reg_read(dev, AT86RF2XX_REG__RX_SYN) & 0x80); might be better style here ;-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ping? |
||
|
||
void at86rf2xx_set_option(at86rf2xx_t *dev, uint16_t option, bool state) | ||
{ | ||
uint8_t tmp; | ||
|
@@ -366,6 +373,14 @@ void at86rf2xx_set_option(at86rf2xx_t *dev, uint16_t option, bool state) | |
tmp |= AT86RF2XX_IRQ_STATUS_MASK__RX_START; | ||
at86rf2xx_reg_write(dev, AT86RF2XX_REG__IRQ_MASK, tmp); | ||
break; | ||
#ifdef MODULE_OPENTHREAD | ||
case AT86RF2XX_OPT_RX_LISTENING: | ||
DEBUG("[at86rf2xx] opt: enabling listening of pkt\n"); | ||
tmp = at86rf2xx_reg_read(dev, AT86RF2XX_REG__RX_SYN); | ||
tmp &= ~(0x80); | ||
at86rf2xx_reg_write(dev, AT86RF2XX_REG__RX_SYN, tmp); | ||
break; | ||
#endif | ||
default: | ||
/* do nothing */ | ||
break; | ||
|
@@ -407,6 +422,14 @@ void at86rf2xx_set_option(at86rf2xx_t *dev, uint16_t option, bool state) | |
tmp &= ~AT86RF2XX_IRQ_STATUS_MASK__RX_START; | ||
at86rf2xx_reg_write(dev, AT86RF2XX_REG__IRQ_MASK, tmp); | ||
break; | ||
#ifdef MODULE_OPENTHREAD | ||
case AT86RF2XX_OPT_RX_LISTENING: | ||
DEBUG("[at86rf2xx] opt: disabling listening of pkt\n"); | ||
tmp = at86rf2xx_reg_read(dev, AT86RF2XX_REG__RX_SYN); | ||
tmp |= 0x80; | ||
at86rf2xx_reg_write(dev, AT86RF2XX_REG__RX_SYN, tmp); | ||
break; | ||
#endif | ||
default: | ||
/* do nothing */ | ||
break; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,9 @@ typedef enum { | |
NETDEV2_EVENT_RX_COMPLETE, /**< finished receiving a packet */ | ||
NETDEV2_EVENT_TX_STARTED, /**< started to transfer a packet */ | ||
NETDEV2_EVENT_TX_COMPLETE, /**< finished transferring packet */ | ||
#ifdef MODULE_OPENTHREAD | ||
NETDEV2_EVENT_TX_COMPLETE_DATA_PENDING, /**< finished transferring packet and has data pending flag **/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but in that process you also throw together the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, probably because at that time I didn't see a use case for a separate But there was no other particular reason I can remember. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, then let's make this a new PR independent of OpenThread! But might I suggest a different name and doc? I'm not sure what "finished transferring packet and has data pending flag" from a high-level stand-point means. But how about the following? NETDEV2_EVENT_TX_PENDING, /**< data was partly transmitted successfully, but more data is pending */ |
||
#endif | ||
NETDEV2_EVENT_TX_NOACK, /**< ACK requested but not received */ | ||
NETDEV2_EVENT_TX_MEDIUM_BUSY, /**< couldn't transfer packet */ | ||
NETDEV2_EVENT_LINK_UP, /**< link established */ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
APPLICATION = openthread_posix_example | ||
|
||
# If no BOARD is found in the environment, use this default: | ||
BOARD ?= samr21-xpro | ||
|
||
# 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 | ||
|
||
USEMODULE+=openthread | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spaces around |
||
|
||
ifneq (,$(filter samr21-xpro,$(BOARD))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really required ? I thought There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, only works for GNRC atm. |
||
DRIVER := at86rf233 | ||
endif | ||
ifneq (,$(filter iotlab-m3 fox,$(BOARD))) | ||
DRIVER := at86rf231 | ||
endif | ||
|
||
ifneq (,$(filter at86rf2%,$(DRIVER))) | ||
FEATURES_REQUIRED = periph_spi periph_gpio | ||
endif | ||
|
||
USEMODULE += $(DRIVER) | ||
|
||
USEMODULE+=random | ||
|
||
USEMODULE += shell | ||
USEMODULE += shell_commands | ||
USEMODULE += ps | ||
USEMODULE += ipv6_addr | ||
|
||
#required for C++ compiling | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing space after |
||
CXXEXFLAGS += -fno-rtti | ||
USEMODULE += cpp11-compat | ||
|
||
# Needed by posix_sockets example | ||
USEMODULE += posix_sockets | ||
USEMODULE += conn_udp | ||
|
||
include $(RIOTBASE)/Makefile.include |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# openthread_posix_example | ||
|
||
This example shows the `posix_sockets` example running with OpenThread as network stack. The usage is exactly the same | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer the example to run on top of |
||
as the `posix_sockets` example, but includes 2 extra commands for obtaining node ip address and Thread status. | ||
|
||
|
||
## About Thread stack | ||
You can find more information about Thread networks in | ||
http://threadgroup.org/Portals/0/documents/whitepapers/Thread%20Stack%20Fundamentals_v2_public.pdf | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor but I would use the |
||
|
||
## The shell commands | ||
|
||
* `ot_state` - shows the Thread state of a node (leader, router, child) | ||
* `ot_ipaddr` - shows the IP addresses associated to a node (link local, mesh, etc). | ||
|
||
## Example setup | ||
An example usage of this application could be the following setup (tested in IoT-LAB): | ||
|
||
1. Flash nodes with `make BOARD=<target> clean all flash` | ||
2. Wait some seconds. | ||
3. Write command `ot_state` in each node. If everything went OK, only one node should be `leader` | ||
and the reset should be either `router` or `child` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should it be others instead of reset ? |
||
4. Read the ip address of a single node with `ot_ipaddr`: | ||
`ot_ipaddr` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better use markdown code block syntax with ``` or |
||
`fdde:ad00:beef::ff:fe00:8000` | ||
`fe80::ff:fe00:8000` | ||
`fdde:ad00:beef:0:946a:c722:a5d9:8481` | ||
`fe80::3984:f4eb:d182:5dae` | ||
The third address (fdde:ad00:beef:0:946a:c722:a5d9:8481) is the mesh address. | ||
5. Start posix udp server in port 80: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on which node ? |
||
`udp server start fdde:ad00:beef:0:946a:c722:a5d9:8481 80` | ||
6. Send UDP messages from another node: | ||
`udp send fdde:ad00:beef:0:946a:c722:a5d9:8481 80 RIOT` | ||
`Success: send 4 byte to fdde:ad00:beef:0:946a:c722:a5d9:8481:80` | ||
7. You should get a `Received data: RIOT` message in the receiving node. | ||
`1470061384.130128;m3-6;> Received data: RIOT` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like you are testing with serial_aggregator on IoT-Lab. Maybe say a few words about it in the readme. |
||
8. Enjoy! You can try to setup a big network to test multi-hop features of the Thread network. | ||
9. Also, you can try disabling some nodes. The network should automatically heal itself (add a new leader, replace | ||
children by routers, etc). | ||
|
||
|
||
## Port status | ||
* Only `conn_udp` supported for the moment (no `conn_ip` yet) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please port to |
||
* `ifconfig` not supported yet (use `ot_ipaddr` for ip addresses) | ||
* OpenThread and this port are still under development. If you find any bug please report it via Github issues. | ||
* Only tested with at86rf2xx radios. | ||
|
||
## Known issues | ||
|
||
* When the network traffic is really high, sometimes some nodes crash silently. | ||
* In some cases there are isolated leaders that are not able to recover to the main partition. These won't affect the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does |
||
rest of the network, but this node becomes unreachable. | ||
|
||
## Future work | ||
|
||
* Add support for Thread Border Router via NEST's Wpantund (https://github.com/openthread/wpantund) | ||
* Adapt to new conn API. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de> | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @ingroup examples | ||
* @{ | ||
* | ||
* @file | ||
* @brief Example application for demonstrating the RIOT's POSIX sockets | ||
* | ||
* @author Martine Lenders <mlenders@inf.fu-berlin.de> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "msg.h" | ||
#include "shell.h" | ||
|
||
#define MAIN_MSG_QUEUE_SIZE (4) | ||
static msg_t main_msg_queue[MAIN_MSG_QUEUE_SIZE]; | ||
|
||
extern int udp_cmd(int argc, char **argv); | ||
|
||
static const shell_command_t shell_commands[] = { | ||
{ "udp", "send data over UDP and listen on UDP ports", udp_cmd }, | ||
{ NULL, NULL, NULL } | ||
}; | ||
|
||
int main(void) | ||
{ | ||
/* a sendto() call performs an implicit bind(), hence, a message queue is | ||
* required for the thread executing the shell */ | ||
msg_init_queue(main_msg_queue, MAIN_MSG_QUEUE_SIZE); | ||
puts("RIOT socket example application"); | ||
/* start shell */ | ||
puts("All up, running the shell now"); | ||
char line_buf[SHELL_DEFAULT_BUFSIZE]; | ||
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE); | ||
|
||
/* should be never reached */ | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space around operator missing