Skip to content

Commit e871ae9

Browse files
rlubosnashif
authored andcommitted
net: openthread: Allow to configure SED
Allow to select Sleepy End Device, and configure it during OpenThread initialization. According to Thread Specification, Sleepy End Devices should always attach to the network as SED, to indicate increased buffer requirement to a parent. Therefore, we reconfigure the Link Mode on each boot. Note, that Poll Period value is not stored in the persistent storage, hence we also need to initialize it on each boot. Signed-off-by: Robert Lubos <[email protected]>
1 parent 4fe1da9 commit e871ae9

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

subsys/net/l2/openthread/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ config OPENTHREAD_MTD
145145
bool "MTD - Minimal Thread Device"
146146
endchoice
147147

148+
config OPENTHREAD_MTD_SED
149+
bool "SED - Sleepy End Device"
150+
depends on OPENTHREAD_MTD
151+
152+
config OPENTHREAD_POLL_PERIOD
153+
int "Poll period for sleepy end devices [ms]"
154+
default 236000
155+
depends on OPENTHREAD_MTD_SED
156+
148157
config OPENTHREAD_SHELL
149158
bool "Enable OpenThread shell"
150159
select SHELL

subsys/net/l2/openthread/openthread.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ LOG_MODULE_REGISTER(net_l2_openthread, CONFIG_OPENTHREAD_L2_LOG_LEVEL);
5353
#define OT_PLATFORM_INFO ""
5454
#endif
5555

56+
#if defined(CONFIG_OPENTHREAD_POLL_PERIOD)
57+
#define OT_POLL_PERIOD CONFIG_OPENTHREAD_POLL_PERIOD
58+
#else
59+
#define OT_POLL_PERIOD 0
60+
#endif
61+
5662
extern void platformShellInit(otInstance *aInstance);
5763

5864
K_SEM_DEFINE(ot_sem, 0, 1);
@@ -318,6 +324,19 @@ static void openthread_start(struct openthread_context *ot_context)
318324
otInstance *ot_instance = ot_context->instance;
319325
otError error;
320326

327+
/* Sleepy End Device specific configuration. */
328+
if (IS_ENABLED(CONFIG_OPENTHREAD_MTD_SED)) {
329+
otLinkModeConfig ot_mode = otThreadGetLinkMode(ot_instance);
330+
331+
/* A SED should always attach the network as a SED to indicate
332+
* increased buffer requirement to a parent.
333+
*/
334+
ot_mode.mRxOnWhenIdle = false;
335+
336+
otThreadSetLinkMode(ot_context->instance, ot_mode);
337+
otLinkSetPollPeriod(ot_context->instance, OT_POLL_PERIOD);
338+
}
339+
321340
if (otDatasetIsCommissioned(ot_instance)) {
322341
/* OpenThread already has dataset stored - skip the
323342
* configuration.

0 commit comments

Comments
 (0)