Skip to content

Question regarding to some issues when work with OpenThread in Zephyr #27885

Answered by rlubos
oubotong asked this question in General
Discussion options

You must be logged in to vote

Hi, you shouldn't set up the OpenThread manually in the main() function - in Zephyr we initialize OpenThread during system startup (in the default configuration), and have a separate thread to process OpenThread:
https://github.com/zephyrproject-rtos/zephyr/blob/master/subsys/net/l2/openthread/openthread.c#L410
https://github.com/zephyrproject-rtos/zephyr/blob/master/subsys/net/l2/openthread/openthread.c#L262

In your case, as you need to register state handler, you'd need to start the OpenThread manually though (as it has to be done before the network is running). The following should be enough in your main:

int main(int aArgc, char *aArgv[])
{
	openthread_set_state_changed_cb(StateChange…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by nashif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #27885 on September 11, 2020 17:41.