-
Notifications
You must be signed in to change notification settings - Fork 7.4k
openthread: Fix OpenThread independence from Zephyr network. #90861
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: Fix OpenThread independence from Zephyr network. #90861
Conversation
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.
In the commit message you wrote:
If CONFIG_OPENTHREAD_SYS_INIT is enabled, OpenThread initialisation
should also consider running OpenThread automatically if
CONFIG_OPENTHREAD_MANUAL_START is enabled
Did you mean "if CONFIG_OPENTHREAD_MANUAL_START is disabled"? That's what's implemented and what actually makes sense.
Otherwise LGTM
Right! I'm fixing the description. :) |
df92ae5
to
a7a0221
Compare
a7a0221
to
19ee59b
Compare
f965d0a
to
fb7f533
Compare
modules/openthread/openthread.c
Outdated
int error; | ||
|
||
error = openthread_init(); |
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.
int error; | |
error = openthread_init(); | |
int error = openthread_init(); |
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.
fixed.
modules/openthread/openthread.c
Outdated
error = otThreadSetExtendedPanId(openthread_instance, &xpanid); | ||
if (error != OT_ERROR_NONE) { | ||
LOG_ERR("Failed to set %s [%d]", "ext PAN ID", error); | ||
return false; | ||
} | ||
|
||
if (strlen(OT_NETWORKKEY)) { | ||
net_bytes_from_str(networkKey.m8, OT_NETWORK_KEY_SIZE, (char *)OT_NETWORKKEY); | ||
bytes_from_str(networkKey.m8, OT_NETWORK_KEY_SIZE, (char *)OT_NETWORKKEY); |
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.
Probably we don't need it, because otThread methods will handle it properly anyway due to internal checks, but please note that below we are passing buffer that may contain trash, as output result was not verified.
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.
Ok, I've added a check here.
} | ||
} | ||
|
||
(void)memset(buf, 0, buf_len); |
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.
Missing nullptr check for buf
?
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.
fixed
fb7f533
to
2fb121a
Compare
If CONFIG_OPENTHREAD_SYS_INIT is enabled, OpenThread initialisation should also consider running OpenThread automatically if CONFIG_OPENTHREAD_MANUAL_START is disabled. Removed also dependency on the `net_bytes_from_str` functions from the openthread.h file. Now, in the OpenThread module, there is an additional `openthread_utils.c/.h` file that can implement useful utilities for the OpenThread platform. Currently, it implements the `bytes_from_str` function to use it instead of `net_bytes_from_str`. Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
2fb121a
to
f1338c3
Compare
|
@@ -182,15 +183,22 @@ static bool ot_setup_default_configuration(void) | |||
return false; | |||
} | |||
|
|||
net_bytes_from_str(xpanid.m8, 8, (char *)OT_XPANID); | |||
if (bytes_from_str(xpanid.m8, 8, (char *)OT_XPANID) != 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.
if (bytes_from_str(xpanid.m8, 8, (char *)OT_XPANID) != 0)
if (bytes_from_str(xpanid.m8, sizeof(xpanid.m8), (char *)OT_XPANID) != 0)
If CONFIG_OPENTHREAD_SYS_INIT is enabled, OpenThread initialisation should also consider running OpenThread automatically if CONFIG_OPENTHREAD_MANUAL_START is disabled.
Removed also dependency on the
net_bytes_from_str
functions from the openthread.h file. Now, in the OpenThread module, there is an additionalopenthread_utils.c/.h
file that can implement useful utilities for the OpenThread platform. Currently, it implements thebytes_from_str
function to use it instead ofnet_bytes_from_str
.