Bluetooth: Add Bluetooth init sample

This patch adds a very simple application for demonstrating the use of
the bt_init() API. Right now this is just tested to work with qemu and
the HCI UART driver with the help of the btproxy tool on the host OS
side. More information is available in the samples/bluetooth/README
file.

Change-Id: I03f92d158e9e5d57275241502bb8fa94350fc335
Co-authored-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-04-13 14:39:47 +03:00 committed by Anas Nashif
parent 2581ad9313
commit 7b6d006255
5 changed files with 139 additions and 0 deletions

29
samples/bluetooth/README Normal file
View file

@ -0,0 +1,29 @@
Bluetooth subsystem
= Architecture =
All processing is done in fibers. Basic structure for packet processing
is bt_buf. Packets are queued to different queues and processed. Packet
allocation is done through a free packets queue which gets populated
during the stack init.
= Building =
$ make -C host/src
$ make -C samples/bluetooth/<app>
= Testing =
Host Bluetooth controler is connected to the second qemu serial line
through a UNIX socket (qemu option -serial unix:/tmp/bt-server-bredr).
On the host side BlueZ allows to "connect" Bluetooth controller through
a so-called user channel. Use the btproxy tool for that:
$ sudo tools/btproxy -u
Listening on /tmp/bt-server-bredr
Now qemu can connect serial line to the 'bt-server-bredr' UNIX socket
with following command:
$ make -C samples/bluetooth/<app> NODE1.qemu

View file

@ -0,0 +1,51 @@
# Makefile - Bluetooth init sample makefile
#
# Copyright (c) 2015 Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1) Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2) Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3) Neither the name of Intel Corporation nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# DESCRIPTION
# Makefile for the Bluetooth init sample
include $(subst \,/,${VXMICRO_BASE})/make/env/defs.base
# default BSP
BSP ?= generic_pc
PRJ_CONF = prj_${vARCH}.conf
VPFILE = prj.vpf
PRJ_INCPATH += ${vBSP_BASE_DIR}/${BSP}
PRJ_INCPATH += ${vBASE}/drivers
PRJ_INCPATH += ${vBASE}/arch/${vARCH}
# UART for Bluetooth
QEMU_EXTRA_FLAGS += -serial unix:/tmp/bt-server-bredr
include ${vMAKE}/target/make.ukernel

View file

@ -0,0 +1,5 @@
% Application : Bluetooth init
% TASK NAME PRIO ENTRY STACK GROUPS
% ===================================================
TASK MAIN 7 mainloop 2048 [EXE]

View file

@ -0,0 +1,4 @@
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_BLUETOOTH=y
CONFIG_BLUETOOTH_UART=y
CONFIG_UART_INTERRUPT_DRIVEN=y

View file

@ -0,0 +1,50 @@
/* main.c - Application main entry point */
/*
* Copyright (c) 2015 Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2) Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3) Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <bluetooth/bluetooth.h>
void mainloop(void)
{
int err;
err = bt_init();
if (err) {
printk("Bluetooth init failed (err %d)\n", err);
return;
}
printk("Bluetooth initialized\n");
}