Skip to content

Commit 6b27eb5

Browse files
committed
net: config: Add support for yaml file based configuration
If user has supplied a yaml file, it is used as configuration data that is applied to network configuration. In this case the CONFIG_NET_CONFIG_* Kconfig variables used for configuration are ignored. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 469cef5 commit 6b27eb5

File tree

6 files changed

+748
-388
lines changed

6 files changed

+748
-388
lines changed

include/zephyr/net/net_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <zephyr/types.h>
1515
#include <zephyr/device.h>
1616
#include <zephyr/net/net_if.h>
17+
#include <zephyr/net/ieee802154_mgmt.h>
1718

1819
#ifdef __cplusplus
1920
extern "C" {

subsys/net/lib/config/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ zephyr_library_compile_definitions_ifdef(
66
)
77

88
zephyr_library_sources_ifdef(CONFIG_NET_CONFIG_SETTINGS init.c)
9+
zephyr_library_include_directories(${ZEPHYR_BASE}/subsys/net/ip)
910

1011
if(CONFIG_NET_CONFIG_SETTINGS)
1112
zephyr_library_sources_ifdef(

subsys/net/lib/config/ieee802154_settings.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,14 @@ LOG_MODULE_DECLARE(net_config, CONFIG_NET_CONFIG_LOG_LEVEL);
1717
#include <zephyr/net/net_mgmt.h>
1818
#include <zephyr/net/ieee802154_mgmt.h>
1919

20-
int z_net_config_ieee802154_setup(struct net_if *iface)
20+
int z_net_config_ieee802154_setup(struct net_if *iface,
21+
uint16_t channel,
22+
uint16_t pan_id,
23+
int16_t tx_power,
24+
struct ieee802154_security_params *sec_params)
2125
{
22-
uint16_t channel = CONFIG_NET_CONFIG_IEEE802154_CHANNEL;
23-
uint16_t pan_id = CONFIG_NET_CONFIG_IEEE802154_PAN_ID;
2426
const struct device *const dev = iface == NULL ? DEVICE_DT_GET(DT_CHOSEN(zephyr_ieee802154))
2527
: net_if_get_device(iface);
26-
int16_t tx_power = CONFIG_NET_CONFIG_IEEE802154_RADIO_TX_POWER;
27-
28-
#ifdef CONFIG_NET_L2_IEEE802154_SECURITY
29-
struct ieee802154_security_params sec_params = {
30-
.key = CONFIG_NET_CONFIG_IEEE802154_SECURITY_KEY,
31-
.key_len = sizeof(CONFIG_NET_CONFIG_IEEE802154_SECURITY_KEY),
32-
.key_mode = CONFIG_NET_CONFIG_IEEE802154_SECURITY_KEY_MODE,
33-
.level = CONFIG_NET_CONFIG_IEEE802154_SECURITY_LEVEL,
34-
};
35-
#endif /* CONFIG_NET_L2_IEEE802154_SECURITY */
36-
3728
if (!device_is_ready(dev)) {
3829
return -ENODEV;
3930
}
@@ -62,7 +53,7 @@ int z_net_config_ieee802154_setup(struct net_if *iface)
6253

6354
#ifdef CONFIG_NET_L2_IEEE802154_SECURITY
6455
if (net_mgmt(NET_REQUEST_IEEE802154_SET_SECURITY_SETTINGS, iface,
65-
&sec_params, sizeof(struct ieee802154_security_params))) {
56+
sec_params, sizeof(struct ieee802154_security_params))) {
6657
return -EINVAL;
6758
}
6859
#endif /* CONFIG_NET_L2_IEEE802154_SECURITY */

subsys/net/lib/config/ieee802154_settings.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@
66
* SPDX-License-Identifier: Apache-2.0
77
*/
88

9+
#include <zephyr/net/ieee802154_mgmt.h>
10+
911
#if defined(CONFIG_NET_L2_IEEE802154) && defined(CONFIG_NET_CONFIG_SETTINGS)
1012
struct net_if;
1113

12-
int z_net_config_ieee802154_setup(struct net_if *iface);
14+
int z_net_config_ieee802154_setup(struct net_if *iface,
15+
uint16_t channel,
16+
uint16_t pan_id,
17+
int16_t tx_power,
18+
struct ieee802154_security_params *sec_params);
1319
#else
1420
#define z_net_config_ieee802154_setup(...) 0
1521
#endif

0 commit comments

Comments
 (0)