diff options
author | Sathish Narasimman <sathish.narasimman@intel.com> | 2016-09-06 20:58:24 +0530 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2016-11-09 08:57:52 +0200 |
commit | 46972b1822f6eadeb14972a09582b380ceb884b9 (patch) | |
tree | f01a1cde3b3a2307d52917444186070b90dcf978 /samples/bluetooth | |
parent | 6ccfa64b5cb62e8c3f7753b1d75080cbc0c0a6fa (diff) |
Bluetooth: Sample: handsfree sample application
Samble bluetooth application for handsfree profile
Change-Id: I280a313afef4c842896c6470a473127e03dacd88
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
Diffstat (limited to 'samples/bluetooth')
-rw-r--r-- | samples/bluetooth/handsfree/Makefile | 25 | ||||
-rw-r--r-- | samples/bluetooth/handsfree/prj.conf | 9 | ||||
-rw-r--r-- | samples/bluetooth/handsfree/src/Makefile | 3 | ||||
-rw-r--r-- | samples/bluetooth/handsfree/src/main.c | 93 | ||||
-rw-r--r-- | samples/bluetooth/handsfree/testcase.ini | 4 |
5 files changed, 134 insertions, 0 deletions
diff --git a/samples/bluetooth/handsfree/Makefile b/samples/bluetooth/handsfree/Makefile new file mode 100644 index 000000000..124701b14 --- /dev/null +++ b/samples/bluetooth/handsfree/Makefile @@ -0,0 +1,25 @@ +# Makefile - Bluetooth handsfree HF sample makefile + +# +# Copyright (c) 2015-2016 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# DESCRIPTION +# Makefile for the Bluetooth handsfree profile HF side +BOARD ?= qemu_x86 +CONF_FILE = prj.conf +QEMU_EXTRA_FLAGS = -serial unix:/tmp/bt-server-bredr + +include $(ZEPHYR_BASE)/Makefile.inc diff --git a/samples/bluetooth/handsfree/prj.conf b/samples/bluetooth/handsfree/prj.conf new file mode 100644 index 000000000..4debd315b --- /dev/null +++ b/samples/bluetooth/handsfree/prj.conf @@ -0,0 +1,9 @@ +CONFIG_MINIMAL_LIBC_EXTENDED=y +CONFIG_BLUETOOTH=y +CONFIG_BLUETOOTH_BREDR=y +CONFIG_BLUETOOTH_RFCOMM=y +CONFIG_BLUETOOTH_HFP_HF=y +CONFIG_BLUETOOTH_MAX_HF_CONN=1 +CONFIG_BLUETOOTH_PERIPHERAL=y +CONFIG_BLUETOOTH_RFCOMM_MTU=127 +CONFIG_BLUETOOTH_BREDR_NAME="test-Handsfree" diff --git a/samples/bluetooth/handsfree/src/Makefile b/samples/bluetooth/handsfree/src/Makefile new file mode 100644 index 000000000..2e79ed45e --- /dev/null +++ b/samples/bluetooth/handsfree/src/Makefile @@ -0,0 +1,3 @@ +ccflags-y +=-I${ZEPHYR_BASE}/samples/bluetooth + +obj-y = main.o diff --git a/samples/bluetooth/handsfree/src/main.c b/samples/bluetooth/handsfree/src/main.c new file mode 100644 index 000000000..042c02db0 --- /dev/null +++ b/samples/bluetooth/handsfree/src/main.c @@ -0,0 +1,93 @@ +/* main.c - Application main entry point */ + +/* + * Copyright (c) 2015-2016 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdint.h> +#include <stddef.h> +#include <string.h> +#include <errno.h> +#include <misc/printk.h> +#include <misc/byteorder.h> +#include <zephyr.h> + +#include <bluetooth/bluetooth.h> +#include <bluetooth/conn.h> +#include <bluetooth/hfp_hf.h> + +static void connected(struct bt_conn *conn) +{ + printk("HFP HF Connected!\n"); +} + +static void disconnected(struct bt_conn *conn) +{ + printk("HFP HF Disconnected!\n"); +} + +static struct bt_hfp_hf_cb hf_cb = { + .connected = connected, + .disconnected = disconnected, +}; + +static void bt_ready(int err) +{ + if (err) { + printk("Bluetooth init failed (err %d)\n", err); + return; + } + + printk("Bluetooth initialized\n"); + + err = bt_br_set_connectable(true); + if (err) { + printk("BR/EDR set/rest connectable failed (err %d)\n", err); + return; + } + err = bt_br_set_discoverable(true); + if (err) { + printk("BR/EDR set discoverable failed (err %d)\n", err); + return; + } + + printk("BR/EDR set connectable and discoverable done\n"); +} + +static void handsfree_enable(void) +{ + int err; + + err = bt_hfp_hf_register(&hf_cb); + if (err < 0) { + printk("HFP HF Registration failed (err %d)\n", err); + } +} + +void main(void) +{ + int err; + + handsfree_enable(); + err = bt_enable(bt_ready); + if (err) { + printk("Bluetooth init failed (err %d)\n", err); + return; + } + + while (1) { + task_sleep(sys_clock_ticks_per_sec); + } +} diff --git a/samples/bluetooth/handsfree/testcase.ini b/samples/bluetooth/handsfree/testcase.ini new file mode 100644 index 000000000..150def455 --- /dev/null +++ b/samples/bluetooth/handsfree/testcase.ini @@ -0,0 +1,4 @@ +[test] +tags = bluetooth +build_only = true +platform_whitelist = qemu_cortex_m3 qemu_x86 |