From f32a837c9b879c1a5e53308e8f26b611a9322697 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 25 Feb 2016 15:07:09 +0200 Subject: [PATCH] net: coap_observe_client: Add support for Bluetooth This enables using coap-observe-client with Bluetooth by passing CONF_FILE=prj_bt.conf, it is also enabled for testing so changes to coap-observe-client are actually tested with NETWORKING_WITH_BT. Change-Id: I02705f855c1974b065557986f9b231201ba310a7 Signed-off-by: Luiz Augusto von Dentz --- samples/net/coap_observe_client/Makefile | 10 +++++++--- samples/net/coap_observe_client/prj_bt.conf | 8 ++++++++ samples/net/coap_observe_client/src/Makefile | 5 +++++ .../src/coap-observe-client.c | 16 ++++++++++++++++ samples/net/coap_observe_client/testcase.ini | 7 +++++++ 5 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 samples/net/coap_observe_client/prj_bt.conf diff --git a/samples/net/coap_observe_client/Makefile b/samples/net/coap_observe_client/Makefile index ef064393880..8929e6a124a 100644 --- a/samples/net/coap_observe_client/Makefile +++ b/samples/net/coap_observe_client/Makefile @@ -19,8 +19,12 @@ MDEF_FILE = prj.mdef KERNEL_TYPE ?= nano BOARD ?= qemu_x86 -CONF_FILE = prj_$(ARCH).conf - -QEMU_EXTRA_FLAGS = -serial none -serial unix:/tmp/slip.sock +CONF_FILE ?= prj_$(ARCH).conf include $(ZEPHYR_BASE)/Makefile.inc + +ifeq ($(CONFIG_NETWORKING_WITH_BT), n) + QEMU_EXTRA_FLAGS = -serial none -serial unix:/tmp/slip.sock +else + QEMU_EXTRA_FLAGS = -serial unix:/tmp/bt-server-bredr +endif diff --git a/samples/net/coap_observe_client/prj_bt.conf b/samples/net/coap_observe_client/prj_bt.conf new file mode 100644 index 00000000000..99865d52cdc --- /dev/null +++ b/samples/net/coap_observe_client/prj_bt.conf @@ -0,0 +1,8 @@ +CONFIG_NETWORKING=y +CONFIG_NETWORKING_WITH_LOGGING=y +CONFIG_NETWORKING_WITH_BT=y +CONFIG_IP_BUF_RX_SIZE=5 +CONFIG_IP_BUF_TX_SIZE=3 +CONFIG_ER_COAP=y +CONFIG_ER_COAP_CLIENT=y +CONFIG_ER_COAP_DEBUG=y diff --git a/samples/net/coap_observe_client/src/Makefile b/samples/net/coap_observe_client/src/Makefile index 327beefc5f9..3f90b325292 100644 --- a/samples/net/coap_observe_client/src/Makefile +++ b/samples/net/coap_observe_client/src/Makefile @@ -6,5 +6,10 @@ ccflags-y +=-I${srctree}/net/ip/contiki/os ccflags-y +=-I${srctree}/net/ip/tinydtls ccflags-y +=-I${srctree}/net/ip/er-coap ccflags-y +=-I${srctree}/net/ip/rest-engine +ccflags-y +=-I${srctree}/samples/bluetooth/ obj-y = coap-observe-client.o + +ifeq ($(CONFIG_NETWORKING_WITH_BT), y) + obj-y += ../../../bluetooth/ipsp/src/ipss.o +endif diff --git a/samples/net/coap_observe_client/src/coap-observe-client.c b/samples/net/coap_observe_client/src/coap-observe-client.c index 66e34b9301e..7e4e8fcd035 100644 --- a/samples/net/coap_observe_client/src/coap-observe-client.c +++ b/samples/net/coap_observe_client/src/coap-observe-client.c @@ -43,6 +43,9 @@ #include "er-coap-engine.h" #include "er-coap-observe-client.h" +#include +#include + #if defined(CONFIG_NANOKERNEL) #define STACKSIZE 2000 char fiberStack[STACKSIZE]; @@ -50,6 +53,7 @@ char fiberStack[STACKSIZE]; static coap_observee_t *obs; +#if !defined(CONFIG_BLUETOOTH) #if defined(CONFIG_NETWORKING_IPV6_NO_ND) /* The peer is the server in our case. Just invent a mac * address for it because lower parts of the stack cannot set it @@ -61,6 +65,7 @@ static uint8_t peer_mac[] = { 0x15, 0x0a, 0xbe, 0xef, 0xf0, 0x0d }; /* This is my mac address */ static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d }; +#endif #if defined(CONFIG_NETWORKING_WITH_IPV6) #if 0 @@ -99,6 +104,7 @@ static inline void init_app(void) { PRINT("%s: run coap observe client\n", __func__); +#if !defined(CONFIG_BLUETOOTH) net_set_mac(my_mac, sizeof(my_mac)); #if defined(CONFIG_NETWORKING_WITH_IPV4) @@ -127,6 +133,7 @@ static inline void init_app(void) uip_ds6_addr_add(addr, 0, ADDR_MANUAL); } #endif +#endif } #if defined(DTLS_PSK) @@ -318,6 +325,15 @@ void startup(void) init_app(); +#if defined(CONFIG_NETWORKING_WITH_BT) + if (bt_enable(NULL)) { + PRINT("Bluetooth init failed\n"); + return; + } + ipss_init(); + ipss_advertise(); +#endif + coap_ctx = coap_context_new((uip_ipaddr_t *)&in6addr_my, MY_PORT); if (!coap_ctx) { PRINT("Cannot get CoAP context.\n"); diff --git a/samples/net/coap_observe_client/testcase.ini b/samples/net/coap_observe_client/testcase.ini index 08d582706fd..2f4c021ca6b 100644 --- a/samples/net/coap_observe_client/testcase.ini +++ b/samples/net/coap_observe_client/testcase.ini @@ -10,3 +10,10 @@ build_only = true extra_args = KERNEL_TYPE=micro arch_whitelist = x86 platform_whitelist = qemu_x86 + +[test_bt] +tags = net,bluetooth +build_only = true +extra_args = CONF_FILE="prj_bt.conf" +arch_whitelist = x86 +platform_whitelist = qemu_x86