Skip to content

Commit 32bd0b9

Browse files
Damian-Nordicrlubos
authored andcommitted
net: openthread: rpc: network interface changes
1. Enable implementation of RPC commands for sending and receiving IPv6 packets only if OPENTHREAD_RPC_NET_IF Kconfig option is set. This is to enable using OT RPC without the Zephyr networking stack. 2. Autostart OpenThread network interface on the RPC server even if the network interface is not present or enabled on the RPC client side. This is because when the interface is disabled on the server side, the received frames are not even delivered to the OpenThread stack. 3. Other minor cleanup. Signed-off-by: Damian Krolik <[email protected]>
1 parent e318da5 commit 32bd0b9

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

samples/nrf_rpc/protocols_serialization/server/snippets/openthread/openthread.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ CONFIG_NET_SOCKETS=y
1414
CONFIG_NET_SOCKETS_PACKET=y
1515
CONFIG_OPENTHREAD_RPC=y
1616
CONFIG_OPENTHREAD_RPC_SERVER=y
17-
CONFIG_IEEE802154_NET_IF_NO_AUTO_START=y # Let RPC client start the interface on demand
1817
CONFIG_OPENTHREAD_MANUAL_START=y
1918
CONFIG_NET_BUF_RX_COUNT=80
2019
CONFIG_NET_BUF_TX_COUNT=80

subsys/net/openthread/rpc/Kconfig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ choice OPENTHREAD_RPC_ROLE_CHOICE
2424

2525
config OPENTHREAD_RPC_CLIENT
2626
bool "OpenThread over RPC client"
27-
depends on NETWORKING
2827
help
2928
Enables OpenThread over RPC client role that uses nRF RPC library to
3029
invoke OpenThread functions on the remote core.
@@ -39,6 +38,15 @@ config OPENTHREAD_RPC_SERVER
3938

4039
endchoice
4140

41+
config OPENTHREAD_RPC_NET_IF
42+
bool "OpenThread over RPC network interface"
43+
default y
44+
depends on NETWORKING
45+
help
46+
Enables OpenThread RPC commands for sending and receiving IPv6 packets
47+
to/from the OpenThread stack. For the RPC client role, it additionally
48+
creates a Zephyr network interface that employs these commands.
49+
4250
menu "OpenThread over RPC client configuration"
4351
depends on OPENTHREAD_RPC_CLIENT
4452

subsys/net/openthread/rpc/client/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ zephyr_library_sources(
1111
ot_rpc_coap.c
1212
ot_rpc_diag.c
1313
ot_rpc_dataset.c
14-
ot_rpc_if.c
1514
ot_rpc_instance.c
1615
ot_rpc_ip6.c
1716
ot_rpc_link.c
@@ -22,6 +21,8 @@ zephyr_library_sources(
2221
ot_rpc_udp.c
2322
)
2423

24+
zephyr_library_sources_ifdef(CONFIG_OPENTHREAD_RPC_NET_IF ot_rpc_if.c)
25+
2526
zephyr_library_include_directories(
2627
${CMAKE_CURRENT_SOURCE_DIR}/../common
2728
)

subsys/net/openthread/rpc/client/ot_rpc_if.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,26 +159,23 @@ static int ot_rpc_l2_enable(struct net_if *iface, bool state)
159159
{
160160
const size_t cbor_buffer_size = 1;
161161
struct nrf_rpc_cbor_ctx ctx;
162-
int error = 0;
163-
164-
const otExtAddress *mac = otLinkGetExtendedAddress(0);
165162

166163
if (!state) {
167164
otRemoveStateChangeCallback(NULL, ot_state_changed_handler, iface);
168165
}
169166

170-
net_if_set_link_addr(iface, (uint8_t *)mac->m8, 8, NET_LINK_IEEE802154);
171-
172167
NRF_RPC_CBOR_ALLOC(&ot_group, ctx, cbor_buffer_size);
173168
zcbor_bool_put(ctx.zs, state);
174169
nrf_rpc_cbor_cmd_no_err(&ot_group, OT_RPC_CMD_IF_ENABLE, &ctx, ot_rpc_decode_void, NULL);
175170

176171
if (state) {
172+
net_if_set_link_addr(iface, (uint8_t *)otLinkGetExtendedAddress(NULL)->m8,
173+
OT_EXT_ADDRESS_SIZE, NET_LINK_IEEE802154);
177174
update_netif_addrs(iface);
178175
otSetStateChangedCallback(NULL, ot_state_changed_handler, iface);
179176
}
180177

181-
return error;
178+
return 0;
182179
}
183180

184181
static enum net_l2_flags ot_rpc_l2_flags(struct net_if *iface)
@@ -195,7 +192,6 @@ static int ot_rpc_dev_init(const struct device *dev)
195192

196193
static void ot_rpc_if_init(struct net_if *iface)
197194
{
198-
/* TODO: auto-start the interface when nRF RPC transport is ready? */
199195
net_if_flag_set(iface, NET_IF_NO_AUTO_START);
200196
net_if_flag_set(iface, NET_IF_IPV6_NO_ND);
201197
net_if_flag_set(iface, NET_IF_IPV6_NO_MLD);

subsys/net/openthread/rpc/server/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ zephyr_library_sources(
1919
)
2020

2121
zephyr_library_sources_ifdef(CONFIG_NET_L2_OPENTHREAD
22-
ot_rpc_if.c
2322
ot_rpc_diag.c
2423
ot_rpc_udp.c
2524
)
2625

26+
zephyr_library_sources_ifdef(CONFIG_OPENTHREAD_RPC_NET_IF ot_rpc_if.c)
27+
2728
zephyr_library_include_directories(
2829
${CMAKE_CURRENT_SOURCE_DIR}/../common
2930
)

0 commit comments

Comments
 (0)