From 91df1113860a411bbb44eb110c2e4177c01ca048 Mon Sep 17 00:00:00 2001 From: Tomasz Bursztyka Date: Thu, 5 Oct 2017 10:51:00 +0200 Subject: [PATCH] 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 --- samples/net/common/Makefile.common | 7 --- samples/net/common/ieee802154_settings.c | 62 ------------------- samples/net/common/ieee802154_settings.h | 15 ----- samples/net/ieee802154/hw/src/Makefile | 3 - .../ieee802154/hw/src/ieee802154_settings.c | 2 - .../net/ieee802154/hw/src/ieee802154_test.c | 36 +---------- .../qemu/src/ieee802154_qemu_test.c | 52 ---------------- samples/net/leds_demo/src/Makefile | 7 --- .../net/leds_demo/src/ieee802154_settings.c | 2 - samples/net/zoap_server/src/Makefile | 7 --- .../net/zoap_server/src/ieee802154_settings.c | 2 - samples/net/zperf/src/Makefile | 7 --- samples/net/zperf/src/ieee802154_settings.c | 2 - 13 files changed, 1 insertion(+), 203 deletions(-) delete mode 100644 samples/net/common/ieee802154_settings.c delete mode 100644 samples/net/common/ieee802154_settings.h delete mode 100644 samples/net/ieee802154/hw/src/ieee802154_settings.c delete mode 100644 samples/net/leds_demo/src/ieee802154_settings.c delete mode 100644 samples/net/zoap_server/src/ieee802154_settings.c delete mode 100644 samples/net/zperf/src/ieee802154_settings.c diff --git a/samples/net/common/Makefile.common b/samples/net/common/Makefile.common index 280208b581..628d014388 100644 --- a/samples/net/common/Makefile.common +++ b/samples/net/common/Makefile.common @@ -6,13 +6,6 @@ # 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_BOARD_ARDUINO_101),y) ccflags-y +=-I${ZEPHYR_BASE}/include/drivers/ diff --git a/samples/net/common/ieee802154_settings.c b/samples/net/common/ieee802154_settings.c deleted file mode 100644 index 478c1f8357..0000000000 --- a/samples/net/common/ieee802154_settings.c +++ /dev/null @@ -1,62 +0,0 @@ -/* IEEE 802.15.4 Samples settings code */ - -/* - * Copyright (c) 2017 Intel Corporation. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include - -#include -#include -#include -#include - -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; -} diff --git a/samples/net/common/ieee802154_settings.h b/samples/net/common/ieee802154_settings.h deleted file mode 100644 index ae7f1e6af2..0000000000 --- a/samples/net/common/ieee802154_settings.h +++ /dev/null @@ -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 diff --git a/samples/net/ieee802154/hw/src/Makefile b/samples/net/ieee802154/hw/src/Makefile index 278b414518..8b7441f537 100644 --- a/samples/net/ieee802154/hw/src/Makefile +++ b/samples/net/ieee802154/hw/src/Makefile @@ -1,4 +1 @@ obj-y = ieee802154_test.o - -ccflags-y +=-I${ZEPHYR_BASE}/samples/net/common/ -obj-y += ieee802154_settings.o diff --git a/samples/net/ieee802154/hw/src/ieee802154_settings.c b/samples/net/ieee802154/hw/src/ieee802154_settings.c deleted file mode 100644 index c0be135873..0000000000 --- a/samples/net/ieee802154/hw/src/ieee802154_settings.c +++ /dev/null @@ -1,2 +0,0 @@ -/* Workaround build system bug that will put objects in source dir */ -#include "../../../common/ieee802154_settings.c" diff --git a/samples/net/ieee802154/hw/src/ieee802154_test.c b/samples/net/ieee802154/hw/src/ieee802154_test.c index 14617516b2..4c3dd9796a 100644 --- a/samples/net/ieee802154/hw/src/ieee802154_test.c +++ b/samples/net/ieee802154/hw/src/ieee802154_test.c @@ -4,43 +4,9 @@ * 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 -#include - -#include -#include - -#include - -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) { - struct net_if *iface = net_if_get_default(); - - if (ieee802154_sample_setup()) { - NET_ERR("IEEE 802.15.4 setup failed"); - } - - setup_ipv6(iface); + return; } diff --git a/samples/net/ieee802154/qemu/src/ieee802154_qemu_test.c b/samples/net/ieee802154/qemu/src/ieee802154_qemu_test.c index 9293c3d5be..4c3dd9796a 100644 --- a/samples/net/ieee802154/qemu/src/ieee802154_qemu_test.c +++ b/samples/net/ieee802154/qemu/src/ieee802154_qemu_test.c @@ -4,61 +4,9 @@ * 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 -#include - -#include -#include - -#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) { - setup_device(); - return; } diff --git a/samples/net/leds_demo/src/Makefile b/samples/net/leds_demo/src/Makefile index d7b1bafd88..cdf4af01a9 100644 --- a/samples/net/leds_demo/src/Makefile +++ b/samples/net/leds_demo/src/Makefile @@ -8,10 +8,3 @@ endif ccflags-$(CONFIG_NET_L2_BT) += -I${ZEPHYR_BASE}/samples/bluetooth/ 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 diff --git a/samples/net/leds_demo/src/ieee802154_settings.c b/samples/net/leds_demo/src/ieee802154_settings.c deleted file mode 100644 index 5374f4a3c2..0000000000 --- a/samples/net/leds_demo/src/ieee802154_settings.c +++ /dev/null @@ -1,2 +0,0 @@ -/* Workaround build system bug that will put objects in source dir */ -#include "../../common/ieee802154_settings.c" diff --git a/samples/net/zoap_server/src/Makefile b/samples/net/zoap_server/src/Makefile index 2b65cdce54..445fdde48d 100644 --- a/samples/net/zoap_server/src/Makefile +++ b/samples/net/zoap_server/src/Makefile @@ -4,10 +4,3 @@ ccflags-y +=-DNET_TESTING_SERVER=1 endif 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 diff --git a/samples/net/zoap_server/src/ieee802154_settings.c b/samples/net/zoap_server/src/ieee802154_settings.c deleted file mode 100644 index 5374f4a3c2..0000000000 --- a/samples/net/zoap_server/src/ieee802154_settings.c +++ /dev/null @@ -1,2 +0,0 @@ -/* Workaround build system bug that will put objects in source dir */ -#include "../../common/ieee802154_settings.c" diff --git a/samples/net/zperf/src/Makefile b/samples/net/zperf/src/Makefile index b03a2bdc89..57a9867db9 100644 --- a/samples/net/zperf/src/Makefile +++ b/samples/net/zperf/src/Makefile @@ -15,10 +15,3 @@ ifeq (${PROFILER}, 1) export PROFILER_NO_SHELL_REGISTER=1 obj-y += ../../../task_profiler/profiler/ 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 diff --git a/samples/net/zperf/src/ieee802154_settings.c b/samples/net/zperf/src/ieee802154_settings.c deleted file mode 100644 index 5374f4a3c2..0000000000 --- a/samples/net/zperf/src/ieee802154_settings.c +++ /dev/null @@ -1,2 +0,0 @@ -/* Workaround build system bug that will put objects in source dir */ -#include "../../common/ieee802154_settings.c"