From 458bf4e848e86a852ccae3e5a7b5b7f65d4f8483 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald@gmail.com" Date: Thu, 16 Jan 2014 10:58:52 +0000 Subject: [PATCH] add bondable flag to hci and provide gap_set_bondable_mode --- example/libusb/profile.gatt | 2 +- src/gap.h | 52 +++++++++++++++++++++++++++++++++++++ src/hci.c | 12 ++++++++- src/hci.h | 1 + 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 src/gap.h diff --git a/example/libusb/profile.gatt b/example/libusb/profile.gatt index 8424424aa..882f83df4 100644 --- a/example/libusb/profile.gatt +++ b/example/libusb/profile.gatt @@ -8,5 +8,5 @@ CHARACTERISTIC, GATT_SERVICE_CHANGED, READ, PRIMARY_SERVICE, FFF0 CHARACTERISTIC, FFF1, READ | WRITE | DYNAMIC | AUTHORIZATION_REQUIRED | ENCRYPTION_KEY_SIZE_7 | AUTHENTICATION_REQUIRED, CHARACTERISTIC, FFF2, READ | WRITE | DYNAMIC, -CHARACTERISTIC, FFF3, READ | NOTIFY | INDICATE | CLIENT_CONFIGURATION, +CHARACTERISTIC, FFF3, READ | INDICATE | CLIENT_CONFIGURATION, CHARACTERISTIC, 00001234-0000-1000-8000-00805F9B34FB, READ | WRITE | DYNAMIC, diff --git a/src/gap.h b/src/gap.h new file mode 100644 index 000000000..fea02291f --- /dev/null +++ b/src/gap.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2011-2012 BlueKitchen GmbH + * + * 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 the copyright holders nor the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * 4. Any redistribution, use, or modification is done solely for + * personal benefit and not for any commercial purpose or for + * monetary gain. + * + * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD 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 MATTHIAS + * RINGWALD 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. + * + * Please inquire about commercial licensing options at contact@bluekitchen-gmbh.com + * + */ + +#pragma once + +#if defined __cplusplus +extern "C" { +#endif + +/** + * @bbrief enable/disable bonding. default is enabled + * @praram enabled + */ +void gap_set_bondable_mode(int enabled); + +#if defined __cplusplus +} +#endif + diff --git a/src/hci.c b/src/hci.c index 82867416e..232d9799e 100644 --- a/src/hci.c +++ b/src/hci.c @@ -825,7 +825,8 @@ void hci_init(hci_transport_t *transport, void *config, bt_control_t *control, r hci_stack.connections = NULL; hci_stack.discoverable = 0; hci_stack.connectable = 0; - + hci_stack.bondable = 1; + // no pending cmds hci_stack.decline_reason = 0; hci_stack.new_scan_enable_value = 0xff; @@ -1642,3 +1643,12 @@ void hci_emit_discoverable_enabled(uint8_t enabled){ hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); hci_stack.packet_handler(HCI_EVENT_PACKET, event, sizeof(event)); } + +// GAP API +/** + * @bbrief enable/disable bonding. default is enabled + * @praram enabled + */ +void gap_set_bondable_mode(int enabled);{ + hci_stack.bondable = enable ? 1 : 0; +} diff --git a/src/hci.h b/src/hci.h index b922d17d2..c585cf0aa 100644 --- a/src/hci.h +++ b/src/hci.h @@ -321,6 +321,7 @@ typedef struct { uint8_t discoverable; uint8_t connectable; + uint8_t bondable; /* buffer for scan enable cmd - 0xff no change */ uint8_t new_scan_enable_value;