net: echo_client: Add support for Bluetooth

This enables using echo_client with Bluetooth by passing
CONF_FILE=prj_bt.conf, it is also enabled for testing so changes to
echo_client are actually tested with NETWORKING_WITH_BT.

Change-Id: I1ff83a9d0049e121dc7e406656e3282b16ee8c91
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2016-02-22 14:04:21 +02:00 committed by Johan Hedberg
commit ccb00e01b0
6 changed files with 51 additions and 2 deletions

View file

@ -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

View file

@ -0,0 +1,15 @@
CONFIG_TEST_RANDOM_GENERATOR=y
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

View file

@ -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-client.o
ifeq ($(CONFIG_NETWORKING_WITH_BT), y)
obj-y += ../../../bluetooth/ipsp/src/ipss.o
endif

View file

@ -44,6 +44,9 @@
#include <contiki/ip/uip.h>
#include <contiki/ipv6/uip-ds6.h>
#include <bluetooth/bluetooth.h>
#include <ipsp/src/ipss.h>
/* Generated by http://www.lipsum.com/
* 3 paragraphs, 176 words, 1230 bytes of Lorem Ipsum
*/
@ -58,6 +61,7 @@ static const char *lorem_ipsum =
static int expecting;
static int ipsum_len;
#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
@ -67,6 +71,7 @@ static uint8_t peer_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d };
#endif
static uint8_t my_mac[] = { 0x15, 0x0a, 0xbe, 0xef, 0xf0, 0x0d };
#endif
#if defined(CONFIG_NETWORKING_WITH_IPV6)
#if 0
@ -107,6 +112,7 @@ static inline void init_app(void)
sys_rand32_init();
#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
}
static inline void reverse(unsigned char *buf, int len)
@ -371,6 +378,15 @@ void main(void)
ipsum_len = strlen(lorem_ipsum);
#if defined(CONFIG_NETWORKING_WITH_BT)
if (bt_enable(NULL)) {
PRINT("Bluetooth init failed\n");
return;
}
ipss_init();
ipss_advertise();
#endif
if (!get_context(&unicast, &multicast)) {
PRINT("%s: Cannot get network context\n", __func__);
return;

View file

@ -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

View file

@ -1,6 +1,7 @@
CONFIG_BLUETOOTH=y
CONFIG_BLUETOOTH_LE=y
CONFIG_BLUETOOTH_DEBUG=y
CONFIG_BLUETOOTH_DEBUG_L2CAP=y
CONFIG_BLUETOOTH_SMP=y
CONFIG_BLUETOOTH_SIGNING=y
CONFIG_BLUETOOTH_PERIPHERAL=y