Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/zephyr/net/net_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <zephyr/types.h>
#include <zephyr/device.h>
#include <zephyr/net/net_if.h>
#include <zephyr/net/ieee802154_mgmt.h>

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions subsys/net/lib/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ zephyr_library_compile_definitions_ifdef(
)

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

if(CONFIG_NET_CONFIG_SETTINGS)
zephyr_library_sources_ifdef(
Expand Down
3 changes: 3 additions & 0 deletions subsys/net/lib/config/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ menuconfig NET_CONFIG_SETTINGS
bool "Set network settings for applications"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool "Set network settings for applications"
bool "Set network settings for applications [EXPERIMENTAL]"

select NET_MGMT
select NET_MGMT_EVENT
select EXPERIMENTAL
help
Allow IP addresses to be set in config file for
networking client/server sample applications, or
some link-layer dedicated settings like the channel.
Beware this is not meant to be used for proper
provisioning but quick sampling/testing.
The experimental status is added because this version
starts to use Yaml file based configuration.

if NET_CONFIG_SETTINGS

Expand Down
21 changes: 6 additions & 15 deletions subsys/net/lib/config/ieee802154_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,14 @@ LOG_MODULE_DECLARE(net_config, CONFIG_NET_CONFIG_LOG_LEVEL);
#include <zephyr/net/net_mgmt.h>
#include <zephyr/net/ieee802154_mgmt.h>

int z_net_config_ieee802154_setup(struct net_if *iface)
int z_net_config_ieee802154_setup(struct net_if *iface,
uint16_t channel,
uint16_t pan_id,
int16_t tx_power,
struct ieee802154_security_params *sec_params)
{
uint16_t channel = CONFIG_NET_CONFIG_IEEE802154_CHANNEL;
uint16_t pan_id = CONFIG_NET_CONFIG_IEEE802154_PAN_ID;
const struct device *const dev = iface == NULL ? DEVICE_DT_GET(DT_CHOSEN(zephyr_ieee802154))
: net_if_get_device(iface);
int16_t tx_power = CONFIG_NET_CONFIG_IEEE802154_RADIO_TX_POWER;

#ifdef CONFIG_NET_L2_IEEE802154_SECURITY
struct ieee802154_security_params sec_params = {
.key = CONFIG_NET_CONFIG_IEEE802154_SECURITY_KEY,
.key_len = sizeof(CONFIG_NET_CONFIG_IEEE802154_SECURITY_KEY),
.key_mode = CONFIG_NET_CONFIG_IEEE802154_SECURITY_KEY_MODE,
.level = CONFIG_NET_CONFIG_IEEE802154_SECURITY_LEVEL,
};
#endif /* CONFIG_NET_L2_IEEE802154_SECURITY */

if (!device_is_ready(dev)) {
return -ENODEV;
}
Expand Down Expand Up @@ -62,7 +53,7 @@ int z_net_config_ieee802154_setup(struct net_if *iface)

#ifdef CONFIG_NET_L2_IEEE802154_SECURITY
if (net_mgmt(NET_REQUEST_IEEE802154_SET_SECURITY_SETTINGS, iface,
&sec_params, sizeof(struct ieee802154_security_params))) {
sec_params, sizeof(struct ieee802154_security_params))) {
return -EINVAL;
}
#endif /* CONFIG_NET_L2_IEEE802154_SECURITY */
Expand Down
8 changes: 7 additions & 1 deletion subsys/net/lib/config/ieee802154_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/net/ieee802154_mgmt.h>

#if defined(CONFIG_NET_L2_IEEE802154) && defined(CONFIG_NET_CONFIG_SETTINGS)
struct net_if;

int z_net_config_ieee802154_setup(struct net_if *iface);
int z_net_config_ieee802154_setup(struct net_if *iface,
uint16_t channel,
uint16_t pan_id,
int16_t tx_power,
struct ieee802154_security_params *sec_params);
#else
#define z_net_config_ieee802154_setup(...) 0
#endif
Loading