Skip to content

Commit 0db9f10

Browse files
bukepoArekBalysNordic
authored andcommitted
[nrf fromtree] openthread: map Thread network interface state
The current mapping gets the network interface into dormant state when Thread is not attached. While the node is not capable of doing multi-hop communication when it's not attached, it should be able to do link-local communication. This commit changes the mapping to look at OpenThread's own network interface state instead without further checking Thread's device role, so that link-local communication is supported when a node in detached state. Signed-off-by: Yakun Xu <[email protected]> (cherry picked from commit eddb1af)
1 parent b010bae commit 0db9f10

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

subsys/net/l2/openthread/Kconfig

+10
Original file line numberDiff line numberDiff line change
@@ -353,4 +353,14 @@ config OPENTHREAD_PLATFORM_KEYS_EXPORTABLE_ENABLE
353353
help
354354
Enable the creation of exportable MAC keys in the OpenThread Key Manager.
355355

356+
config OPENTHREAD_INTERFACE_EARLY_UP
357+
bool "Make OpenThread interface ready as soon as Thread is enabled"
358+
help
359+
When enabled, OpenThread interface will be marked ready (operational
360+
UP) as soon as Thread has been enabled. This means the interface will
361+
be ready to transmit application packets during the Mesh Link
362+
Establishment phase.
363+
Otherwise, OpenThread interface will be marked operational UP only
364+
after the device joins a Thread network.
365+
356366
endif # NET_L2_OPENTHREAD_IMPLEMENTATION_ZEPHYR

subsys/net/l2/openthread/openthread.c

+12-3
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,20 @@ static void ot_state_changed_handler(uint32_t flags, void *context)
187187
{
188188
struct openthread_state_changed_cb *entry, *next;
189189
struct openthread_context *ot_context = context;
190+
bool is_up = otIp6IsEnabled(ot_context->instance);
190191

191-
NET_INFO("State changed! Flags: 0x%08" PRIx32 " Current role: %s",
192+
NET_INFO("State changed! Flags: 0x%08" PRIx32 " Current role: %s Ip6: %s",
192193
flags,
193-
otThreadDeviceRoleToString(otThreadGetDeviceRole(ot_context->instance))
194-
);
194+
otThreadDeviceRoleToString(otThreadGetDeviceRole(ot_context->instance)),
195+
(is_up ? "up" : "down"));
195196

197+
#if defined(CONFIG_OPENTHREAD_INTERFACE_EARLY_UP)
198+
if (is_up) {
199+
net_if_dormant_off(ot_context->iface);
200+
} else {
201+
net_if_dormant_on(ot_context->iface);
202+
}
203+
#else
196204
if (flags & OT_CHANGED_THREAD_ROLE) {
197205
switch (otThreadGetDeviceRole(ot_context->instance)) {
198206
case OT_DEVICE_ROLE_CHILD:
@@ -208,6 +216,7 @@ static void ot_state_changed_handler(uint32_t flags, void *context)
208216
break;
209217
}
210218
}
219+
#endif
211220

212221
if (flags & OT_CHANGED_IP6_ADDRESS_REMOVED) {
213222
NET_DBG("Ipv6 address removed");

0 commit comments

Comments
 (0)