samples/net: Getting rid of common ieee802154 settings altogether.
Only ieee802154 should have been using it, but it ended in various samples that did not require it anymore once they've been using net_app. Unlike former samples settings, net_app settings are tied to net_app, so let's just forget about all of it and silently use net_app. If something goes wrong in setting net options, it will be a unique place. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
12d52542a3
commit
91df111386
|
@ -6,13 +6,6 @@
|
||||||
|
|
||||||
# Common routines used in net samples
|
# Common routines used in net samples
|
||||||
|
|
||||||
ifeq ($(CONFIG_NET_L2_IEEE802154), y)
|
|
||||||
ifeq ($(CONFIG_NET_APP_SETTINGS), y)
|
|
||||||
ccflags-y += -I${ZEPHYR_BASE}/samples/net/common/
|
|
||||||
obj-y += ../../common/ieee802154_settings.o
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_IEEE802154_CC2520),y)
|
ifeq ($(CONFIG_IEEE802154_CC2520),y)
|
||||||
ifeq ($(CONFIG_BOARD_ARDUINO_101),y)
|
ifeq ($(CONFIG_BOARD_ARDUINO_101),y)
|
||||||
ccflags-y +=-I${ZEPHYR_BASE}/include/drivers/
|
ccflags-y +=-I${ZEPHYR_BASE}/include/drivers/
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
/* IEEE 802.15.4 Samples settings code */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2017 Intel Corporation.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <zephyr.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <net/net_if.h>
|
|
||||||
#include <net/net_core.h>
|
|
||||||
#include <net/net_mgmt.h>
|
|
||||||
#include <net/ieee802154.h>
|
|
||||||
|
|
||||||
int ieee802154_sample_setup(void)
|
|
||||||
{
|
|
||||||
u16_t channel = CONFIG_NET_APP_IEEE802154_CHANNEL;
|
|
||||||
u16_t pan_id = CONFIG_NET_APP_IEEE802154_PAN_ID;
|
|
||||||
s16_t tx_power = CONFIG_NET_APP_IEEE802154_RADIO_TX_POWER;
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_L2_IEEE802154_SECURITY
|
|
||||||
struct ieee802154_security_params sec_params = {
|
|
||||||
.key = CONFIG_NET_APP_IEEE802154_SECURITY_KEY,
|
|
||||||
.key_len = sizeof(CONFIG_NET_APP_IEEE802154_SECURITY_KEY),
|
|
||||||
.key_mode = CONFIG_NET_APP_IEEE802154_SECURITY_KEY_MODE,
|
|
||||||
.level = CONFIG_NET_APP_IEEE802154_SECURITY_LEVEL,
|
|
||||||
};
|
|
||||||
#endif /* CONFIG_NET_L2_IEEE802154_SECURITY */
|
|
||||||
|
|
||||||
struct net_if *iface;
|
|
||||||
struct device *dev;
|
|
||||||
|
|
||||||
dev = device_get_binding(CONFIG_NET_APP_IEEE802154_DEV_NAME);
|
|
||||||
if (!dev) {
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
iface = net_if_lookup_by_dev(dev);
|
|
||||||
if (!iface) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (net_mgmt(NET_REQUEST_IEEE802154_SET_PAN_ID,
|
|
||||||
iface, &pan_id, sizeof(u16_t)) ||
|
|
||||||
net_mgmt(NET_REQUEST_IEEE802154_SET_CHANNEL,
|
|
||||||
iface, &channel, sizeof(u16_t)) ||
|
|
||||||
net_mgmt(NET_REQUEST_IEEE802154_SET_TX_POWER,
|
|
||||||
iface, &tx_power, sizeof(s16_t))) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_L2_IEEE802154_SECURITY
|
|
||||||
if (net_mgmt(NET_REQUEST_IEEE802154_SET_SECURITY_SETTINGS, iface,
|
|
||||||
&sec_params, sizeof(struct ieee802154_security_params))) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_NET_L2_IEEE802154_SECURITY */
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
/* IEEE 802.15.4 Samples settings header */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2017 Intel Corporation.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_L2_IEEE802154) && defined(CONFIG_NET_APP_SETTINGS)
|
|
||||||
|
|
||||||
int ieee802154_sample_setup(void);
|
|
||||||
|
|
||||||
#else
|
|
||||||
#define ieee802154_sample_setup(...) 0
|
|
||||||
#endif
|
|
|
@ -1,4 +1 @@
|
||||||
obj-y = ieee802154_test.o
|
obj-y = ieee802154_test.o
|
||||||
|
|
||||||
ccflags-y +=-I${ZEPHYR_BASE}/samples/net/common/
|
|
||||||
obj-y += ieee802154_settings.o
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
/* Workaround build system bug that will put objects in source dir */
|
|
||||||
#include "../../../common/ieee802154_settings.c"
|
|
|
@ -4,43 +4,9 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if 1
|
|
||||||
#define SYS_LOG_DOMAIN "15_4_hw_test"
|
|
||||||
#define NET_SYS_LOG_LEVEL SYS_LOG_LEVEL_DEBUG
|
|
||||||
#define NET_LOG_ENABLED 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <zephyr.h>
|
#include <zephyr.h>
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <net/net_if.h>
|
|
||||||
#include <net/net_core.h>
|
|
||||||
|
|
||||||
#include <ieee802154_settings.h>
|
|
||||||
|
|
||||||
static void setup_ipv6(struct net_if *iface)
|
|
||||||
{
|
|
||||||
char hr_addr[NET_IPV6_ADDR_LEN];
|
|
||||||
struct in6_addr addr;
|
|
||||||
|
|
||||||
if (net_addr_pton(AF_INET6, CONFIG_NET_APP_MY_IPV6_ADDR, &addr)) {
|
|
||||||
NET_ERR("Invalid address: %s", CONFIG_NET_APP_MY_IPV6_ADDR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
net_if_ipv6_addr_add(iface, &addr, NET_ADDR_MANUAL, 0);
|
|
||||||
|
|
||||||
NET_INFO("IPv6 address: %s",
|
|
||||||
net_addr_ntop(AF_INET6, &addr, hr_addr, NET_IPV6_ADDR_LEN));
|
|
||||||
}
|
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
struct net_if *iface = net_if_get_default();
|
return;
|
||||||
|
|
||||||
if (ieee802154_sample_setup()) {
|
|
||||||
NET_ERR("IEEE 802.15.4 setup failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_ipv6(iface);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,61 +4,9 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if 1
|
|
||||||
#define SYS_LOG_DOMAIN "Setup"
|
|
||||||
#define NET_SYS_LOG_LEVEL SYS_LOG_LEVEL_DEBUG
|
|
||||||
#define NET_LOG_ENABLED 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <zephyr.h>
|
#include <zephyr.h>
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <net/net_if.h>
|
|
||||||
#include <net/net_core.h>
|
|
||||||
|
|
||||||
#define MCAST_IP6ADDR "ff84::2"
|
|
||||||
|
|
||||||
static void setup_device(void)
|
|
||||||
{
|
|
||||||
char hr_addr[NET_IPV6_ADDR_LEN];
|
|
||||||
struct net_if *iface;
|
|
||||||
struct in6_addr addr;
|
|
||||||
struct device *dev;
|
|
||||||
|
|
||||||
dev = device_get_binding(CONFIG_IEEE802154_UPIPE_DRV_NAME);
|
|
||||||
if (!dev) {
|
|
||||||
NET_INFO("Cannot get UPIPE device\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
iface = net_if_lookup_by_dev(dev);
|
|
||||||
if (!iface) {
|
|
||||||
NET_INFO("Cannot get UPIPE network interface\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (net_addr_pton(AF_INET6, CONFIG_NET_APP_MY_IPV6_ADDR, &addr)) {
|
|
||||||
NET_ERR("Invalid address: %s", CONFIG_NET_APP_MY_IPV6_ADDR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
net_if_ipv6_addr_add(iface, &addr, NET_ADDR_MANUAL, 0);
|
|
||||||
|
|
||||||
NET_INFO("IPv6 address: %s",
|
|
||||||
net_addr_ntop(AF_INET6, &addr, hr_addr, NET_IPV6_ADDR_LEN));
|
|
||||||
|
|
||||||
if (net_addr_pton(AF_INET6, MCAST_IP6ADDR, &addr)) {
|
|
||||||
NET_ERR("Invalid address: %s", MCAST_IP6ADDR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
NET_INFO("802.15.4 device up and running\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
setup_device();
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,3 @@ endif
|
||||||
ccflags-$(CONFIG_NET_L2_BT) += -I${ZEPHYR_BASE}/samples/bluetooth/
|
ccflags-$(CONFIG_NET_L2_BT) += -I${ZEPHYR_BASE}/samples/bluetooth/
|
||||||
|
|
||||||
obj-y = leds-demo.o
|
obj-y = leds-demo.o
|
||||||
|
|
||||||
ifeq ($(CONFIG_NET_L2_IEEE802154), y)
|
|
||||||
ccflags-y +=-I${ZEPHYR_BASE}/samples/net/common/
|
|
||||||
ifeq ($(CONFIG_NET_APP_SETTINGS), y)
|
|
||||||
obj-y += ieee802154_settings.o
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
/* Workaround build system bug that will put objects in source dir */
|
|
||||||
#include "../../common/ieee802154_settings.c"
|
|
|
@ -4,10 +4,3 @@ ccflags-y +=-DNET_TESTING_SERVER=1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
obj-y = zoap-server.o
|
obj-y = zoap-server.o
|
||||||
|
|
||||||
ifeq ($(CONFIG_NET_L2_IEEE802154), y)
|
|
||||||
ccflags-y +=-I${ZEPHYR_BASE}/samples/net/common/
|
|
||||||
ifeq ($(CONFIG_NET_APP_SETTINGS), y)
|
|
||||||
obj-y += ieee802154_settings.o
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
/* Workaround build system bug that will put objects in source dir */
|
|
||||||
#include "../../common/ieee802154_settings.c"
|
|
|
@ -15,10 +15,3 @@ ifeq (${PROFILER}, 1)
|
||||||
export PROFILER_NO_SHELL_REGISTER=1
|
export PROFILER_NO_SHELL_REGISTER=1
|
||||||
obj-y += ../../../task_profiler/profiler/
|
obj-y += ../../../task_profiler/profiler/
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_NET_L2_IEEE802154), y)
|
|
||||||
ccflags-y +=-I${ZEPHYR_BASE}/samples/net/common/
|
|
||||||
ifeq ($(CONFIG_NET_APP_SETTINGS), y)
|
|
||||||
obj-y += ieee802154_settings.o
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
/* Workaround build system bug that will put objects in source dir */
|
|
||||||
#include "../../common/ieee802154_settings.c"
|
|
Loading…
Reference in a new issue