net: echo_server: Add support for Bluetooth
This enables using echo_server with Bluetooth by passing CONF_FILE=prj_bt.conf, it is also enabled for testing so changes to echo_server are actually tested with NETWORKING_WITH_BT. Change-Id: I1d949798c7a9689ebc2d342ae7342dce32f319e5 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
53dbe52f7d
commit
ce83b0f955
5 changed files with 49 additions and 4 deletions
|
@ -20,7 +20,12 @@ NET_IFACE ?= slip
|
|||
MDEF_FILE = prj.mdef
|
||||
KERNEL_TYPE ?= nano
|
||||
BOARD ?= qemu_x86
|
||||
CONF_FILE = prj_$(NET_IFACE).conf
|
||||
CONF_FILE ?= prj_$(NET_IFACE).conf
|
||||
|
||||
include $(ZEPHYR_BASE)/Makefile.inc
|
||||
include $(ZEPHYR_BASE)/samples/net/echo_server/Makefile.ipstack
|
||||
|
||||
ifeq ($(CONFIG_NETWORKING_WITH_BT), n)
|
||||
include $(ZEPHYR_BASE)/samples/net/echo_server/Makefile.ipstack
|
||||
else
|
||||
QEMU_EXTRA_FLAGS = -serial unix:/tmp/bt-server-bredr
|
||||
endif
|
||||
|
|
14
samples/net/echo_server/prj_bt.conf
Normal file
14
samples/net/echo_server/prj_bt.conf
Normal file
|
@ -0,0 +1,14 @@
|
|||
CONFIG_BLUETOOTH=y
|
||||
CONFIG_BLUETOOTH_LE=y
|
||||
CONFIG_BLUETOOTH_DEBUG=y
|
||||
CONFIG_BLUETOOTH_SMP=y
|
||||
CONFIG_BLUETOOTH_SIGNING=y
|
||||
CONFIG_BLUETOOTH_PERIPHERAL=y
|
||||
CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL=y
|
||||
CONFIG_NETWORKING=y
|
||||
CONFIG_NETWORKING_WITH_LOGGING=y
|
||||
CONFIG_NETWORKING_WITH_6LOWPAN=y
|
||||
CONFIG_6LOWPAN_COMPRESSION_IPHC=y
|
||||
CONFIG_NETWORKING_WITH_BT=y
|
||||
CONFIG_IP_BUF_RX_SIZE=5
|
||||
CONFIG_IP_BUF_TX_SIZE=3
|
|
@ -2,5 +2,10 @@ ccflags-y +=-I${srctree}/net/ip/contiki
|
|||
ccflags-y +=-I${srctree}/net/ip/contiki/os/lib
|
||||
ccflags-y +=-I${srctree}/net/ip/contiki/os
|
||||
ccflags-y +=-I${srctree}/net/ip
|
||||
ccflags-y +=-I${srctree}/samples/bluetooth/
|
||||
|
||||
obj-y = echo-server.o
|
||||
|
||||
ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
|
||||
obj-y += ../../../bluetooth/ipsp/src/ipss.o
|
||||
endif
|
||||
|
|
|
@ -35,7 +35,10 @@
|
|||
#include <contiki/ip/uip.h>
|
||||
#include <contiki/ipv6/uip-ds6.h>
|
||||
|
||||
#if !defined(CONFIG_ETHERNET)
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <ipsp/src/ipss.h>
|
||||
|
||||
#if !defined(CONFIG_ETHERNET) && !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.
|
||||
|
@ -70,6 +73,7 @@ static inline void init_server()
|
|||
{
|
||||
PRINT("%s: run echo server\n", __func__);
|
||||
|
||||
#if !defined(CONFIG_BLUETOOTH)
|
||||
#if !defined(CONFIG_ETHERNET)
|
||||
net_set_mac(my_mac, sizeof(my_mac));
|
||||
#endif
|
||||
|
@ -111,6 +115,7 @@ static inline void init_server()
|
|||
uip_ds6_addr_add(addr, 0, ADDR_MANUAL);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void reverse(unsigned char *buf, int len)
|
||||
|
@ -138,7 +143,7 @@ static inline struct net_buf *prepare_reply(const char *name,
|
|||
*/
|
||||
reverse(ip_buf_appdata(buf), ip_buf_appdatalen(buf));
|
||||
|
||||
#if !defined(CONFIG_ETHERNET)
|
||||
#if !defined(CONFIG_ETHERNET) && !defined(CONFIG_BLUETOOTH)
|
||||
/* Set the mac address of the peer in net_buf because
|
||||
* there is no radio layer involved in this test app.
|
||||
* Normally there is no need to do this.
|
||||
|
@ -263,6 +268,15 @@ void main(void)
|
|||
|
||||
init_server();
|
||||
|
||||
#if defined(CONFIG_NETWORKING_WITH_BT)
|
||||
if (bt_enable(NULL)) {
|
||||
PRINT("Bluetooth init failed\n");
|
||||
return;
|
||||
}
|
||||
ipss_init();
|
||||
ipss_advertise();
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_MICROKERNEL)
|
||||
receive();
|
||||
#else
|
||||
|
|
|
@ -3,3 +3,10 @@ tags = net
|
|||
build_only = true
|
||||
arch_whitelist = x86
|
||||
platform_whitelist = minnowboard
|
||||
|
||||
[test_bt]
|
||||
tags = net,bluetooth
|
||||
build_only = true
|
||||
extra_args = CONF_FILE="prj_bt.conf"
|
||||
arch_whitelist = x86
|
||||
platform_whitelist = minnowboard
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue