Skip to content
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

Closed
wants to merge 279 commits into from
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
279 commits
Select commit Hold shift + click to select a range
c85f3d1
Added test for OpenThread
jia200x Jun 17, 2016
fd9888c
Re-renamed files
jia200x Jun 17, 2016
1ac5165
temporal commit
jia200x Jun 17, 2016
991400c
Temporal commit
jia200x Jun 21, 2016
2bb2e19
Working in native
jia200x Jun 21, 2016
68b5c74
openthread: added #ifdef MODULE_NETDEV2_TAP to netdev2 tap interface
jia200x Jun 22, 2016
3b48840
Half removed tap support
jia200x Jun 23, 2016
bdc1ba0
Removed support for TAP interfaces
jia200x Jun 23, 2016
0ffbbfb
Temporal fix to ARM cpu file
jia200x Jun 23, 2016
55159ad
Added CPU_ID line
jia200x Jun 23, 2016
0531e39
Removed comment
jia200x Jun 23, 2016
0908d84
openthread: Removed old code from TAP interfaces
jia200x Jun 23, 2016
f80447c
Added seed based on CPUID
jia200x Jun 28, 2016
aeddb7e
Added some comments
jia200x Jun 28, 2016
cbb4264
Half added RIOT OT compiler
jia200x Jun 28, 2016
d763a5a
openthread: Fully working commit
jia200x Jul 7, 2016
86d339a
openthread: improved radio code
jia200x Jul 11, 2016
c1acf84
openthread: removed old debug functions
jia200x Jul 11, 2016
5e2c8cb
openthread: added otPlatRadioTransmitDone events to NO_ACK and CHANNE…
jia200x Jul 11, 2016
686e9c8
openthread: changed init system to bootstrap and netdev2_init
jia200x Jul 11, 2016
96888f7
openthread: added OT as pseudomodule
jia200x Jul 11, 2016
d72c5e9
openthread: added auto_init support
jia200x Jul 11, 2016
0042cca
openthread: improved auto_init part
jia200x Jul 11, 2016
d71f1c5
openthread: added OT cli as option
jia200x Jul 11, 2016
2edbc70
openthread: added OT start without CLI
jia200x Jul 11, 2016
66ff178
openthread: reduced thread stack size
jia200x Jul 12, 2016
0d4bb42
openthread: added state command to RIOT shell
jia200x Jul 12, 2016
aad0226
Added udp sending from RIOT shell
jia200x Jul 13, 2016
2cbc50b
Added ot cli files
jia200x Jul 13, 2016
f8c1065
Added conn basic functions
jia200x Jul 13, 2016
b0aac67
openthread: added support for at86rf2xx
jia200x Jul 13, 2016
499888e
openthread: added conn wrapper to Makefiles
jia200x Jul 13, 2016
38e347a
openthread: conn: added recv
jia200x Jul 13, 2016
0f31057
openthread: fixed bug in recvfrom
jia200x Jul 14, 2016
361e981
openthread: recv fully working
jia200x Jul 14, 2016
803e97c
openthread: Added patches
jia200x Jul 14, 2016
2869464
Added UDP hook
jia200x Jul 15, 2016
86b7884
Temporal commit
jia200x Jul 16, 2016
4d50466
openthread: Added mixing patches
jia200x Jul 16, 2016
377b59f
openthread: Added mixing patch
jia200x Jul 16, 2016
25327d4
openthread: replaced numbers with labels
jia200x Jul 17, 2016
2e0ce6c
openthread: added init for kw2xrf
jia200x Jul 17, 2016
f738b25
openthread: temporally enabled OT Debug
jia200x Jul 18, 2016
99d3c20
Updated to latest version of OT commit
jia200x Jul 18, 2016
ca2ba08
Updated to latest version of OT
jia200x Jul 18, 2016
8f139b8
openthread: removed old git patches
jia200x Jul 18, 2016
8f37f24
openthread: changed serial functions to uart functios due to OT API c…
jia200x Jul 18, 2016
f1a054c
openthread: added new git patches
jia200x Jul 18, 2016
84c7b2b
openthread: removed old references to serial headers
jia200x Jul 18, 2016
bc02036
openthread: added missing bracket
jia200x Jul 18, 2016
a235cb1
openthread: added errno.h
jia200x Jul 18, 2016
d1962c3
fixed references to old serial headers
jia200x Jul 18, 2016
cc6fc73
radio: added TX_COMPLETE_DATA_PENDING in at86rf2xx
jia200x Jul 19, 2016
1b31ccd
openthread: at86rf2xx: adapted driver to OT
jia200x Jul 19, 2016
66f1126
openthread: fixed radio idle bug
jia200x Jul 19, 2016
681d392
openthread: added special case for tx_pending assert
jia200x Jul 20, 2016
8e79654
fixed assert in at86rf2xx
jia200x Jul 21, 2016
bb95c4c
openthread: improved hook functions
jia200x Jul 21, 2016
2440234
re-added assert in recv
jia200x Jul 21, 2016
d57176b
openthread:added wrappers for driver states
jia200x Jul 21, 2016
120a22c
openthread: added missing channel assign in otPlatRadioReceive
jia200x Jul 21, 2016
b0d1b11
openthread: temporal changes in at86rf
jia200x Jul 21, 2016
8293a99
openthread: added LISTENING option to driver
jia200x Jul 22, 2016
b58d316
openthread: fixed bug in recv
jia200x Jul 22, 2016
6fa89ec
removed unused functions and added comments
jia200x Jul 22, 2016
75db297
openthread: added NETOPT_TX_END_IRQ option set from init
jia200x Jul 22, 2016
170e711
openthread: added mutex to openthread core functions
jia200x Jul 25, 2016
3956a26
added mutex to conn files
jia200x Jul 25, 2016
17fe180
Added comments
jia200x Jul 25, 2016
1cc81a1
Removed unused functions
jia200x Jul 25, 2016
ccb9d88
openthread: added ot_random_init function
jia200x Jul 25, 2016
fec9a22
added cpuid header to random
jia200x Jul 25, 2016
083719f
moved ot_netdev2 chunks of code to functions (and renamed some)
jia200x Jul 25, 2016
e9fc6f4
Added #error if CPUID is not defined
jia200x Jul 25, 2016
710e6b0
Added comments and disclaimers
jia200x Jul 25, 2016
56e6471
Added driver selection in Makefile
jia200x Jul 25, 2016
0441745
Removed old crypto modules from Makefile
jia200x Jul 25, 2016
ef55b9f
Fixed disclaimers
jia200x Jul 25, 2016
9483874
Added doxygen documentation to some functions
jia200x Jul 25, 2016
08e6d30
Finished adding disclaimers
jia200x Jul 25, 2016
515eae6
added Network Co Processor for OpenThread
jia200x Jul 26, 2016
43d00d0
fixed auto ack bug
jia200x Jul 28, 2016
3137208
fixed auto ack bug
jia200x Jul 28, 2016
840ebfc
Renamed ot driver functions
jia200x Jul 28, 2016
7b1543b
Finished conn support
jia200x Jul 28, 2016
8a4c64c
added openthread shell commands to shell_commands
jia200x Jul 29, 2016
4367fd9
added DBG messages to conn
jia200x Jul 29, 2016
a64efbd
simplified _openthread_ipaddr shell command
jia200x Jul 29, 2016
089f6d5
Added missing #ifdef block
jia200x Jul 29, 2016
c82c4f1
added support for NCP uart
jia200x Jul 29, 2016
3cb21c4
Fixed missing #ifdef NCP
jia200x Jul 29, 2016
4b89640
Added NCP in Makefile
jia200x Jul 29, 2016
db5c505
Added NCP in Makefile
jia200x Jul 29, 2016
c016092
AT86RF2XX_TRX_STATE__TRAC_SUCCESS_DATA_PENDING was not sending NETDEV…
jia200x Aug 1, 2016
7b48780
removed unused files
jia200x Aug 1, 2016
db2c83e
Added #ifdef MODULE_OPENTHREAD to critical files
jia200x Aug 1, 2016
dd80410
Removed contrib cli as separated module
jia200x Aug 1, 2016
012423d
removed custom shell functions
jia200x Aug 1, 2016
32eefed
Moved conn.h to openthread include folder
jia200x Aug 1, 2016
269fe83
Renamed cpp file to c
jia200x Aug 1, 2016
85280e0
added debug msg to ot random
jia200x Aug 1, 2016
e590a86
Added comment in find best source
jia200x Aug 1, 2016
6ec062f
Removed old openthread test
jia200x Aug 1, 2016
6c5ee42
Added new openthread test
jia200x Aug 1, 2016
77df0e3
Added initial files of openthread posix example
jia200x Aug 1, 2016
0c944a2
added posix_sockets example main.c file
jia200x Aug 1, 2016
c58bc3d
added Makefile requirements for Thread
jia200x Aug 1, 2016
852112a
Uncrustified files
jia200x Aug 1, 2016
d715ffa
Removed old comment from ot_posix
jia200x Aug 1, 2016
17a1851
Added README for ot posix
jia200x Aug 1, 2016
0d9060c
Fixed README file of example
jia200x Aug 2, 2016
4e9daf1
Added README for OpenThread test
jia200x Aug 2, 2016
c5e537d
updated OT pkg
jia200x Sep 9, 2016
c278f35
removed old patches
jia200x Sep 16, 2016
f6646cb
added missing aLogRegion cases
jia200x Sep 16, 2016
fddb6a0
removed old otInit function
jia200x Sep 16, 2016
b251149
removed rx enable and disable functions
jia200x Sep 16, 2016
88f905c
updated pkg
jia200x Sep 16, 2016
6d2acf2
updated pkg
jia200x Oct 1, 2016
342e26c
added otInstance object to platform_alarm functions
jia200x Oct 1, 2016
69a4cb6
added kLogRegionNetDiag case option
jia200x Oct 1, 2016
bd0e18c
add aInstance to radio functions
jia200x Oct 1, 2016
672e5bb
add missing openthread.h
jia200x Oct 1, 2016
c2ed9e1
temporally disabled conn udp for OpenThread
jia200x Oct 1, 2016
cf1f12c
temporally commented shell commands of OpenThread
jia200x Oct 1, 2016
238ef6b
temporally enable openthread CLI
jia200x Oct 3, 2016
27b77d4
added meshcop makefile
jia200x Oct 3, 2016
1d2fa71
added otPlat diag functions
jia200x Oct 3, 2016
a79c7b0
added dummy function for get eui64
jia200x Oct 3, 2016
c40aee3
added otPlatReset
jia200x Oct 3, 2016
c4b652d
add new otPlatRadio functions
jia200x Oct 4, 2016
01bbc72
openthread_at86rf2xx: fix unrelated beautification
jia200x Oct 18, 2016
521c743
Makefile: removed whitespaces in dep
jia200x Oct 18, 2016
991795d
shell_commands: removed unrelated beautification
jia200x Oct 18, 2016
3f1ebe7
updated package
jia200x Jan 10, 2017
737d13d
modifications in Makefile
jia200x Jan 19, 2017
ab0076a
fixed Makefile
jia200x Feb 2, 2017
050aeb0
modified includes
jia200x Feb 2, 2017
1bd44c2
updated pkg
jia200x Feb 2, 2017
b69055e
fixed pkg Makefile
jia200x Feb 2, 2017
ff37d4d
added otInstance to platform alarm
jia200x Feb 2, 2017
444bded
fixed old calls
jia200x Feb 3, 2017
c0c84d0
added otPlatSettings functions
jia200x Feb 3, 2017
cc15076
made it work again
jia200x Feb 3, 2017
2fb1160
fixed TransmitDone
jia200x Feb 6, 2017
7b0d475
added support for full OpenThread
jia200x Feb 13, 2017
42a2714
replaced kThreadError_None with kThreadError_NotFound in SettingsGet
jia200x Feb 13, 2017
8199413
added \n to DEBUG message
jia200x Feb 13, 2017
1e2155a
fixed merge
jia200x Feb 13, 2017
d878028
reverted at86rf2xx driver to master version
jia200x Feb 13, 2017
d53d277
fixed old xtimer_now
jia200x Feb 13, 2017
a7bae16
added DEBUG msgs and ot_idle to Receive function
jia200x Feb 13, 2017
9056636
Merge branch 'ot2' into openthread
jia200x Apr 15, 2017
d5d9202
deleted old patches
jia200x Apr 16, 2017
47cae78
removed driver mod
jia200x Apr 16, 2017
ac86e48
handled merge conflicts
jia200x Apr 16, 2017
24e2564
removed netdev2 occurrencies
jia200x Apr 16, 2017
9eac7ef
reverted driver
jia200x Apr 17, 2017
2bcd0ed
updated to latest version of OpenThread
jia200x Apr 17, 2017
9074bb1
fixed byteorder in PAN ID
jia200x Apr 18, 2017
6422922
updated headers and function names (pkg update)
jia200x Apr 18, 2017
0732e31
removed deprecated openthread posix example
jia200x Apr 18, 2017
3bd15be
fixed copyright
jia200x Apr 18, 2017
6b409ad
removed unused radio functions
jia200x Apr 18, 2017
a3b8bb0
changed function names
jia200x Apr 18, 2017
0d003e9
removed unused _set_idle
jia200x Apr 18, 2017
9b89b6c
fixed bug in UART reception
jia200x Apr 20, 2017
65fbc89
turn off OpenThread CLI
jia200x May 2, 2017
87e5bd8
fixed unused variable
jia200x May 2, 2017
43e79e2
remove old OpenThread shell commands
jia200x May 2, 2017
b0bcf82
remove old OpenThread commands
jia200x May 3, 2017
5c2c779
add ot_get_instance
jia200x May 3, 2017
fa21d3d
added ot_state command
jia200x May 3, 2017
4fe3c64
remove left over of old ot shell commands
jia200x May 3, 2017
ffe979e
implement OT commands
jia200x May 3, 2017
a138cc2
add ip addr command
jia200x May 3, 2017
35bef27
remove old openthread_cli USEMODULE
jia200x May 3, 2017
a02d7da
add OT_CMD_IPADDRESS command
jia200x May 3, 2017
1f2b4ab
add OT jobs
jia200x May 3, 2017
e13ebc9
implement basic panid job
jia200x May 3, 2017
29fdd21
add get_ip_addresses job
jia200x May 3, 2017
bdb6876
remove unused job
jia200x May 4, 2017
1d27fde
add line for enabling OT CLI in Makefile
jia200x May 4, 2017
82445fd
add udp commands to test
jia200x May 5, 2017
a8405df
Add UDP Sock creation
fjmolinas May 5, 2017
3b6537a
New test for UDP sock
fjmolinas May 5, 2017
2ab9711
working on union ip6 bug
fjmolinas May 9, 2017
2ee1ca1
update pkg
jia200x May 9, 2017
1a3579e
turn off debug
jia200x May 9, 2017
3448d11
add missing otPlat
jia200x May 9, 2017
06f3114
remove old library
jia200x May 9, 2017
46155b6
fix udp socket
jia200x May 9, 2017
1b0a571
previous build
fjmolinas May 9, 2017
8440a5f
set socket struct to zero
jia200x May 11, 2017
a823694
Merge branch 'openthread_sock' of https://github.com/jia200x/RIOT int…
fjmolinas May 11, 2017
2b2d41c
UART read change (one char by one)
May 12, 2017
b13475a
Add send_udp using sock
fjmolinas May 12, 2017
0becba8
add ncp and cli lines to ./configure
jia200x May 12, 2017
86c6778
fix old ncp call
jia200x May 12, 2017
8534441
implement otPlatRadioDefaultTxPower
jia200x May 12, 2017
f8dad6e
add otPlatGetResetReason
jia200x May 12, 2017
396e76f
move misc function to misc.c file
jia200x May 12, 2017
1705621
change thread priority and name
jia200x May 12, 2017
139d456
Add udp send using sock
fjmolinas May 12, 2017
bf6ea72
Merge branch 'openthread_sock' into openthread
jia200x May 12, 2017
3295238
fix merge
jia200x May 12, 2017
7c83551
make sock_udp work
jia200x May 15, 2017
e84d52b
address style issues
jia200x May 15, 2017
0eb7844
fix copyright
jia200x May 15, 2017
9e8d304
remove tcp folder
jia200x May 15, 2017
c34b244
remove ip folder in sock
jia200x May 15, 2017
9f80348
updated README to dummy text
jia200x May 15, 2017
3ee1a70
fix style issues
jia200x May 15, 2017
f9b0b2e
fix pkg Makefile
jia200x May 15, 2017
ac3cff2
fix style issues (again)
jia200x May 15, 2017
24cecf4
remove conn
jia200x May 15, 2017
13ae220
rename netdev2 folder to netdev
jia200x May 15, 2017
c1051d4
remove mutex functions from OT
jia200x May 15, 2017
b3a0053
changed data property to context
jia200x May 15, 2017
5ee079b
remove deprecated ot_get_instance()
jia200x May 15, 2017
8849182
sort include files in platform_misc
jia200x May 16, 2017
78b0ed2
add usage to test
jia200x May 16, 2017
a05a6ee
Merge branch 'master' into openthread
jia200x May 16, 2017
a9c9e51
remove auto thread start from tests
jia200x May 16, 2017
96e756e
fix if in udp usage
jia200x May 16, 2017
fa1ccb4
revert unrelated changes in shell_commands file
jia200x May 16, 2017
9381a8b
revert unrelated change
jia200x May 16, 2017
792d71f
Add NCP, FTD and MTD example
May 16, 2017
0d185e0
Merge branch 'openthread' into openthread-NCP
May 16, 2017
9f5b779
ENABLE DEBUG on at86rf2xx to show packet too large when connecting FT…
May 16, 2017
746b510
Set correct name for Jose
May 16, 2017
f537b3c
Write README and fix typo
May 16, 2017
6013bcd
Fix typo according to aabadie review
May 16, 2017
0ac7846
Fix openthread NCP readme
biboc May 16, 2017
37392a1
Fix OpenThread MTD and FTD README
May 16, 2017
e9bbfc4
Refactor Makefile with new openthread library
May 16, 2017
584e417
Merge pull request #1 from biboc/openthread-NCP-FTD-MTD
jia200x May 18, 2017
6a8651c
fix merge
jia200x May 18, 2017
e5512c3
uncrustify files
jia200x May 18, 2017
d88e121
sorted openthread in pseudomodules
jia200x May 18, 2017
d4c0e08
revert debug in at86rf2xx
jia200x May 18, 2017
583658b
remove newline
jia200x May 18, 2017
459eb71
changed 1000U with US_PER_MS
jia200x May 18, 2017
a039dbf
fix space around operators
jia200x May 18, 2017
593ce1e
remove error variable
jia200x May 18, 2017
fe02b9a
Merge branch 'openthread' of https://github.com/jia200x/RIOT into ope…
jia200x May 18, 2017
1b253de
revert unrelated change
jia200x May 18, 2017
3acc830
fix ascii chars in copyright
jia200x May 18, 2017
a5e2bed
rewrite README
jia200x May 18, 2017
56ef435
revert ot.h file
jia200x May 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space around operator missing


FEATURES_REQUIRED += cpp
FEATURES_REQUIRED += periph_spi periph_gpio
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be split in 2 lines

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also, why SPI is mandatory here?
In native, SPI is not available

Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be renamed in openthread_contrib_netdev. Please add spaces around += for consistency.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need adaptation to #5891.

1 change: 1 addition & 0 deletions Makefile.pseudomodules
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ PSEUDOMODULES += saul_adc
PSEUDOMODULES += saul_default
PSEUDOMODULES += saul_gpio
PSEUDOMODULES += schedstatistics
PSEUDOMODULES += openthread

# include variants of the AT86RF2xx drivers as pseudo modules
PSEUDOMODULES += at86rf23%
Expand Down
23 changes: 23 additions & 0 deletions drivers/at86rf2xx/at86rf2xx_getset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought adaptations to the driver aren't necessary anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The 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 ;-).

Copy link
Member Author

Choose a reason for hiding this comment

The 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.
I will do my best.

Anyway, can we try to merge this for this release and then PR again the second branch?
Cheers!

Copy link
Member

Choose a reason for hiding this comment

The 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 :-/.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping?

Copy link
Member

Choose a reason for hiding this comment

The 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 ;-)

Copy link
Member

Choose a reason for hiding this comment

The 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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
38 changes: 38 additions & 0 deletions drivers/at86rf2xx/at86rf2xx_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ netopt_state_t _get_state(at86rf2xx_t *dev)
case AT86RF2XX_STATE_SLEEP:
return NETOPT_STATE_SLEEP;
case AT86RF2XX_STATE_BUSY_RX_AACK:
#ifdef MODULE_OPENTHREAD
/* Required for OpenThread abstraction */
if (at86rf2xx_receiver_listening(dev)) {
return NETOPT_STATE_IDLE;
}
#endif
return NETOPT_STATE_RX;
case AT86RF2XX_STATE_BUSY_TX_ARET:
case AT86RF2XX_STATE_TX_ARET_ON:
Expand Down Expand Up @@ -367,6 +373,12 @@ static int _get(netdev2_t *netdev, netopt_t opt, void *val, size_t max_len)
}
break;

#ifdef MODULE_OPENTHREAD
case NETOPT_RX_LISTENING:
*((bool *)val) = at86rf2xx_receiver_listening(dev) ? true : false;
res = sizeof(bool);
break;
#endif
default:
res = -ENOTSUP;
}
Expand Down Expand Up @@ -566,6 +578,13 @@ static int _set(netdev2_t *netdev, netopt_t opt, void *val, size_t len)
}
break;

#ifdef MODULE_OPENTHREAD
case NETOPT_RX_LISTENING:
at86rf2xx_set_option(dev, AT86RF2XX_OPT_RX_LISTENING,
((bool *)val)[0]);
res = sizeof(netopt_enable_t);
break;
#endif
default:
break;
}
Expand Down Expand Up @@ -614,9 +633,17 @@ static void _isr(netdev2_t *netdev)
if (state == AT86RF2XX_STATE_RX_AACK_ON ||
state == AT86RF2XX_STATE_BUSY_RX_AACK) {
DEBUG("[at86rf2xx] EVT - RX_END\n");

#ifdef MODULE_OPENTHREAD
if (!(dev->netdev.flags & AT86RF2XX_OPT_TELL_RX_END) || !at86rf2xx_receiver_listening(dev)) {
return;
}
#else
if (!(dev->netdev.flags & AT86RF2XX_OPT_TELL_RX_END)) {
return;
}
#endif

netdev->event_callback(netdev, NETDEV2_EVENT_RX_COMPLETE);
}
else if (state == AT86RF2XX_STATE_TX_ARET_ON ||
Expand All @@ -633,11 +660,22 @@ static void _isr(netdev2_t *netdev)

if (netdev->event_callback && (dev->netdev.flags & AT86RF2XX_OPT_TELL_TX_END)) {
switch (trac_status) {
#ifdef MODULE_OPENTHREAD
case AT86RF2XX_TRX_STATE__TRAC_SUCCESS:
netdev->event_callback(netdev, NETDEV2_EVENT_TX_COMPLETE);
DEBUG("[at86rf2xx] TX SUCCESS\n");
break;
case AT86RF2XX_TRX_STATE__TRAC_SUCCESS_DATA_PENDING:
netdev->event_callback(netdev, NETDEV2_EVENT_TX_COMPLETE_DATA_PENDING);
DEBUG("[at86rf2xx] TX SUCCESS DATA PENDING\n");
break;
#else
case AT86RF2XX_TRX_STATE__TRAC_SUCCESS:
case AT86RF2XX_TRX_STATE__TRAC_SUCCESS_DATA_PENDING:
netdev->event_callback(netdev, NETDEV2_EVENT_TX_COMPLETE);
DEBUG("[at86rf2xx] TX SUCCESS\n");
break;
#endif
case AT86RF2XX_TRX_STATE__TRAC_NO_ACK:
netdev->event_callback(netdev, NETDEV2_EVENT_TX_NOACK);
DEBUG("[at86rf2xx] TX NO_ACK\n");
Expand Down
12 changes: 12 additions & 0 deletions drivers/include/at86rf2xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ extern "C" {
* start */
#define AT86RF2XX_OPT_TELL_RX_END (0x4000) /**< notify MAC layer on RX
* finished */
#ifdef MODULE_OPENTHREAD
#define AT86RF2XX_OPT_RX_LISTENING (0x8000) /**< detection of reception active */
#endif
/** @} */

/**
Expand Down Expand Up @@ -260,6 +263,15 @@ void at86rf2xx_set_chan(at86rf2xx_t *dev, uint8_t chan);
*/
uint8_t at86rf2xx_get_page(at86rf2xx_t *dev);


#ifdef MODULE_OPENTHREAD
/**
* @brief Enable/disable AT86RF2XX receiver
*
* @param[in] dev device to change receiver status
*/
bool at86rf2xx_receiver_listening(at86rf2xx_t *dev);
#endif
/**
* @brief Set the channel page of the given device
*
Expand Down
3 changes: 3 additions & 0 deletions drivers/include/net/netdev2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 **/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I see this and NETDEV2_EVENT_TX_COMPLETE are two distinct event types, so why were they throw in the first place? @daniel-k according to the log you introduced this in #3729. Any memory of why those were not separated?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miri64 Not sure what you mean. I introduced TX_NOACK and TX_MEDIUM_BUSY in #3729.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The 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 TX_COMPLETE_DATA_PENDING and since I started examining the trac status, this seemed like a sensible default. I guess the driver didn't support the feature that would cause such a status.

But there was no other particular reason I can remember.

Copy link
Member

Choose a reason for hiding this comment

The 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 */
Expand Down
47 changes: 47 additions & 0 deletions examples/openthread_posix_example/Makefile
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces around += here and below


ifneq (,$(filter samr21-xpro,$(BOARD)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really required ? I thought auto_init could handle that.

Copy link
Member

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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
57 changes: 57 additions & 0 deletions examples/openthread_posix_example/README.md
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer the example to run on top of sock instead of posix_sockets ;-)

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor but I would use the [text](url) markdown format here


## 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`
Copy link
Contributor

Choose a reason for hiding this comment

The 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`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better use markdown code block syntax with ``` or <pre>commands</pre> and all commands in between.

`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:
Copy link
Contributor

Choose a reason for hiding this comment

The 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`
Copy link
Contributor

Choose a reason for hiding this comment

The 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please port to sock_udp. Shouldn't be to difficult.

* `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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does main partition mean ?

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.
49 changes: 49 additions & 0 deletions examples/openthread_posix_example/main.c
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;
}
Loading