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>
This commit is contained in:
parent
c21de2eeb5
commit
59fa70e8ff
5 changed files with 42 additions and 3 deletions
|
@ -20,8 +20,12 @@ NET_IFACE ?= slip
|
||||||
MDEF_FILE = prj.mdef
|
MDEF_FILE = prj.mdef
|
||||||
KERNEL_TYPE ?= nano
|
KERNEL_TYPE ?= nano
|
||||||
BOARD ?= qemu_x86
|
BOARD ?= qemu_x86
|
||||||
CONF_FILE = prj_$(NET_IFACE).conf
|
CONF_FILE ?= prj_$(NET_IFACE).conf
|
||||||
|
|
||||||
QEMU_EXTRA_FLAGS = -serial none -serial unix:/tmp/slip.sock
|
|
||||||
|
|
||||||
include $(ZEPHYR_BASE)/Makefile.inc
|
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
|
||||||
|
|
7
samples/net/coap_server/prj_bt.conf
Normal file
7
samples/net/coap_server/prj_bt.conf
Normal file
|
@ -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
|
|
@ -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/er-coap
|
||||||
ccflags-y +=-I${srctree}/net/ip/rest-engine
|
ccflags-y +=-I${srctree}/net/ip/rest-engine
|
||||||
ccflags-y +=-I${srctree}/net/ip
|
ccflags-y +=-I${srctree}/net/ip
|
||||||
|
ccflags-y +=-I${srctree}/samples/bluetooth/
|
||||||
|
|
||||||
obj-y = coap-server.o
|
obj-y = coap-server.o
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
|
||||||
|
obj-y += ../../../bluetooth/ipsp/src/ipss.o
|
||||||
|
endif
|
||||||
|
|
||||||
obj-y += \
|
obj-y += \
|
||||||
resources/res-plugtest-create1.o \
|
resources/res-plugtest-create1.o \
|
||||||
resources/res-plugtest-create2.o \
|
resources/res-plugtest-create2.o \
|
||||||
|
|
|
@ -59,6 +59,10 @@ char fiberStack[STACKSIZE];
|
||||||
#include <net/tinydtls.h>
|
#include <net/tinydtls.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <bluetooth/bluetooth.h>
|
||||||
|
#include <ipsp/src/ipss.h>
|
||||||
|
|
||||||
|
#if !defined(CONFIG_BLUETOOTH)
|
||||||
#if defined(CONFIG_NETWORKING_IPV6_NO_ND)
|
#if defined(CONFIG_NETWORKING_IPV6_NO_ND)
|
||||||
/* The peer is the client in our case. Just invent a mac
|
/* The peer is the client in our case. Just invent a mac
|
||||||
* address for it because lower parts of the stack cannot set it
|
* 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
|
/* This is my mac address
|
||||||
*/
|
*/
|
||||||
static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d };
|
static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d };
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NETWORKING_WITH_IPV6)
|
#if defined(CONFIG_NETWORKING_WITH_IPV6)
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -107,6 +112,7 @@ static inline void init_app(void)
|
||||||
{
|
{
|
||||||
PRINT("%s: run coap server\n", __func__);
|
PRINT("%s: run coap server\n", __func__);
|
||||||
|
|
||||||
|
#if !defined(CONFIG_BLUETOOTH)
|
||||||
net_set_mac(my_mac, sizeof(my_mac));
|
net_set_mac(my_mac, sizeof(my_mac));
|
||||||
|
|
||||||
#if defined(CONFIG_NETWORKING_WITH_IPV4)
|
#if defined(CONFIG_NETWORKING_WITH_IPV4)
|
||||||
|
@ -140,6 +146,7 @@ static inline void init_app(void)
|
||||||
uip_ds6_addr_add(addr, 0, ADDR_MANUAL);
|
uip_ds6_addr_add(addr, 0, ADDR_MANUAL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DTLS_PSK)
|
#if defined(DTLS_PSK)
|
||||||
|
@ -303,6 +310,15 @@ void startup(void)
|
||||||
|
|
||||||
init_app();
|
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. */
|
/* Activate the application-specific resources. */
|
||||||
rest_activate_resource(&res_plugtest_test, "test");
|
rest_activate_resource(&res_plugtest_test, "test");
|
||||||
rest_activate_resource(&res_plugtest_longpath, "seg1/seg2/seg3");
|
rest_activate_resource(&res_plugtest_longpath, "seg1/seg2/seg3");
|
||||||
|
|
|
@ -12,3 +12,10 @@ extra_args = KERNEL_TYPE=micro
|
||||||
kernel = micro
|
kernel = micro
|
||||||
arch_whitelist = x86
|
arch_whitelist = x86
|
||||||
platform_whitelist = qemu_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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue