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 <xyk@google.com>
This commit is contained in:
parent
1ac9b14804
commit
eddb1af9aa
2 changed files with 22 additions and 3 deletions
|
@ -353,4 +353,14 @@ config OPENTHREAD_PLATFORM_KEYS_EXPORTABLE_ENABLE
|
|||
help
|
||||
Enable the creation of exportable MAC keys in the OpenThread Key Manager.
|
||||
|
||||
config OPENTHREAD_INTERFACE_EARLY_UP
|
||||
bool "Make OpenThread interface ready as soon as Thread is enabled"
|
||||
help
|
||||
When enabled, OpenThread interface will be marked ready (operational
|
||||
UP) as soon as Thread has been enabled. This means the interface will
|
||||
be ready to transmit application packets during the Mesh Link
|
||||
Establishment phase.
|
||||
Otherwise, OpenThread interface will be marked operational UP only
|
||||
after the device joins a Thread network.
|
||||
|
||||
endif # NET_L2_OPENTHREAD_IMPLEMENTATION_ZEPHYR
|
||||
|
|
|
@ -187,12 +187,20 @@ static void ot_state_changed_handler(uint32_t flags, void *context)
|
|||
{
|
||||
struct openthread_state_changed_cb *entry, *next;
|
||||
struct openthread_context *ot_context = context;
|
||||
bool is_up = otIp6IsEnabled(ot_context->instance);
|
||||
|
||||
NET_INFO("State changed! Flags: 0x%08" PRIx32 " Current role: %s",
|
||||
NET_INFO("State changed! Flags: 0x%08" PRIx32 " Current role: %s Ip6: %s",
|
||||
flags,
|
||||
otThreadDeviceRoleToString(otThreadGetDeviceRole(ot_context->instance))
|
||||
);
|
||||
otThreadDeviceRoleToString(otThreadGetDeviceRole(ot_context->instance)),
|
||||
(is_up ? "up" : "down"));
|
||||
|
||||
#if defined(CONFIG_OPENTHREAD_INTERFACE_EARLY_UP)
|
||||
if (is_up) {
|
||||
net_if_dormant_off(ot_context->iface);
|
||||
} else {
|
||||
net_if_dormant_on(ot_context->iface);
|
||||
}
|
||||
#else
|
||||
if (flags & OT_CHANGED_THREAD_ROLE) {
|
||||
switch (otThreadGetDeviceRole(ot_context->instance)) {
|
||||
case OT_DEVICE_ROLE_CHILD:
|
||||
|
@ -208,6 +216,7 @@ static void ot_state_changed_handler(uint32_t flags, void *context)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (flags & OT_CHANGED_IP6_ADDRESS_REMOVED) {
|
||||
NET_DBG("Ipv6 address removed");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue