net: dtls_server: Add support for Bluetooth
This enables using dtls_server with Bluetooth by passing CONF_FILE=prj_bt.conf, it is also enabled for testing so changes to dtls-server are actually tested with NETWORKING_WITH_BT. Change-Id: Ice4f409c8e2d9e97856159482969f6352264864b Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
758b159120
commit
0401d5a54a
|
@ -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
|
||||
|
|
6
samples/net/dtls_server/prj_bt.conf
Normal file
6
samples/net/dtls_server/prj_bt.conf
Normal file
|
@ -0,0 +1,6 @@
|
|||
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_TINYDTLS=y
|
|
@ -3,5 +3,10 @@ ccflags-y +=-I${srctree}/net/ip/contiki/os/lib
|
|||
ccflags-y +=-I${srctree}/net/ip/contiki/os
|
||||
ccflags-y +=-I${srctree}/net/ip/contiki/os/sys
|
||||
ccflags-y +=-I${srctree}/net/ip
|
||||
ccflags-y +=-I${srctree}/samples/bluetooth/
|
||||
|
||||
obj-y = dtls-server.o
|
||||
|
||||
ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
|
||||
obj-y += ../../../bluetooth/ipsp/src/ipss.o
|
||||
endif
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
|
||||
#include <net/tinydtls.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <ipsp/src/ipss.h>
|
||||
|
||||
static const unsigned char ecdsa_priv_key[] = {
|
||||
0xD9, 0xE2, 0x70, 0x7A, 0x72, 0xDA, 0x6A, 0x05,
|
||||
0x04, 0x99, 0x5C, 0x86, 0xED, 0xDB, 0xE3, 0xEF,
|
||||
|
@ -52,6 +55,7 @@ static const unsigned char ecdsa_pub_key_y[] = {
|
|||
0xD0, 0x43, 0xB1, 0xFB, 0x03, 0xE2, 0x2F, 0x4D,
|
||||
0x17, 0xDE, 0x43, 0xF9, 0xF9, 0xAD, 0xEE, 0x70};
|
||||
|
||||
#if !defined(CONFIG_BLUETOOTH)
|
||||
/* The peer is the client in our case. Just invent a mac
|
||||
* address for it because lower parts of the stack cannot set it
|
||||
* in this test as we do not have any radios.
|
||||
|
@ -61,6 +65,7 @@ static const unsigned char ecdsa_pub_key_y[] = {
|
|||
/* 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
|
||||
|
@ -88,6 +93,7 @@ static inline void init_app(void)
|
|||
{
|
||||
PRINT("%s: run dtls server\n", __func__);
|
||||
|
||||
#if !defined(CONFIG_BLUETOOTH)
|
||||
net_set_mac(my_mac, sizeof(my_mac));
|
||||
|
||||
#if defined(CONFIG_NETWORKING_WITH_IPV4)
|
||||
|
@ -106,6 +112,7 @@ static inline void init_app(void)
|
|||
uip_ds6_addr_add(addr, 0, ADDR_MANUAL);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void reverse(unsigned char *buf, int len)
|
||||
|
@ -394,6 +401,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
|
||||
|
||||
recv = get_context();
|
||||
if (!recv) {
|
||||
PRINT("%s: Cannot get network context\n", __func__);
|
||||
|
|
Loading…
Reference in a new issue