summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2016-02-23 13:41:18 +0200
committerJukka Rissanen <jukka.rissanen@linux.intel.com>2016-02-29 13:01:34 +0000
commit59fa70e8ff09127beb976d55affce63ea052e43b (patch)
tree061deaaef09b0d45e89b7796a1a357d752ac25cb /samples
parentc21de2eeb5e5675a813dbbbc7ab881f8673a55a5 (diff)
net: coap_server: Add support for Bluetooth
This enables using coap_server with Bluetooth by passing CONF_FILE=prj_bt.conf, it is also enabled for testing so changes to coap_server are actually tested with NETWORKING_WITH_BT. Change-Id: I58b286520da0e0e4cba77dd52ea3f64f0268582a Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Diffstat (limited to 'samples')
-rw-r--r--samples/net/coap_server/Makefile10
-rw-r--r--samples/net/coap_server/prj_bt.conf7
-rw-r--r--samples/net/coap_server/src/Makefile5
-rw-r--r--samples/net/coap_server/src/coap-server.c16
-rw-r--r--samples/net/coap_server/testcase.ini7
5 files changed, 42 insertions, 3 deletions
diff --git a/samples/net/coap_server/Makefile b/samples/net/coap_server/Makefile
index f6ba9bc25..f8cd0cdae 100644
--- a/samples/net/coap_server/Makefile
+++ b/samples/net/coap_server/Makefile
@@ -20,8 +20,12 @@ NET_IFACE ?= slip
MDEF_FILE = prj.mdef
KERNEL_TYPE ?= nano
BOARD ?= qemu_x86
-CONF_FILE = prj_$(NET_IFACE).conf
-
-QEMU_EXTRA_FLAGS = -serial none -serial unix:/tmp/slip.sock
+CONF_FILE ?= prj_$(NET_IFACE).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_server/prj_bt.conf b/samples/net/coap_server/prj_bt.conf
new file mode 100644
index 000000000..5e36ca37f
--- /dev/null
+++ b/samples/net/coap_server/prj_bt.conf
@@ -0,0 +1,7 @@
+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_DEBUG=y
diff --git a/samples/net/coap_server/src/Makefile b/samples/net/coap_server/src/Makefile
index cbc08b105..ab8a00133 100644
--- a/samples/net/coap_server/src/Makefile
+++ b/samples/net/coap_server/src/Makefile
@@ -6,9 +6,14 @@ 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}/net/ip
+ccflags-y +=-I${srctree}/samples/bluetooth/
obj-y = coap-server.o
+ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
+ obj-y += ../../../bluetooth/ipsp/src/ipss.o
+endif
+
obj-y += \
resources/res-plugtest-create1.o \
resources/res-plugtest-create2.o \
diff --git a/samples/net/coap_server/src/coap-server.c b/samples/net/coap_server/src/coap-server.c
index f45bd7923..503d04f54 100644
--- a/samples/net/coap_server/src/coap-server.c
+++ b/samples/net/coap_server/src/coap-server.c
@@ -59,6 +59,10 @@ char fiberStack[STACKSIZE];
#include <net/tinydtls.h>
#endif
+#include <bluetooth/bluetooth.h>
+#include <ipsp/src/ipss.h>
+
+#if !defined(CONFIG_BLUETOOTH)
#if defined(CONFIG_NETWORKING_IPV6_NO_ND)
/* The peer is the client in our case. Just invent a mac
* address for it because lower parts of the stack cannot set it
@@ -70,6 +74,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
@@ -107,6 +112,7 @@ static inline void init_app(void)
{
PRINT("%s: run coap server\n", __func__);
+#if !defined(CONFIG_BLUETOOTH)
net_set_mac(my_mac, sizeof(my_mac));
#if defined(CONFIG_NETWORKING_WITH_IPV4)
@@ -140,6 +146,7 @@ static inline void init_app(void)
uip_ds6_addr_add(addr, 0, ADDR_MANUAL);
}
#endif
+#endif
}
#if defined(DTLS_PSK)
@@ -303,6 +310,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
+
/* Activate the application-specific resources. */
rest_activate_resource(&res_plugtest_test, "test");
rest_activate_resource(&res_plugtest_longpath, "seg1/seg2/seg3");
diff --git a/samples/net/coap_server/testcase.ini b/samples/net/coap_server/testcase.ini
index d82566bf3..5fc5cf5ed 100644
--- a/samples/net/coap_server/testcase.ini
+++ b/samples/net/coap_server/testcase.ini
@@ -12,3 +12,10 @@ extra_args = KERNEL_TYPE=micro
kernel = 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