From 6ae23ab1654a3434713bd0fcdaec1fd6011ebe3f Mon Sep 17 00:00:00 2001 From: "matthias.ringwald@gmail.com" Date: Sun, 5 Jan 2014 20:13:37 +0000 Subject: [PATCH] extract minimal gap_le.h --- example/libusb/ble_server.c | 1 + example/libusb/gap_le.h | 52 +++++++++++++++++++++++++++++++++++++ example/libusb/sm.c | 3 ++- example/libusb/sm.h | 14 ---------- 4 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 example/libusb/gap_le.h diff --git a/example/libusb/ble_server.c b/example/libusb/ble_server.c index e83ca1750..db535fc78 100644 --- a/example/libusb/ble_server.c +++ b/example/libusb/ble_server.c @@ -59,6 +59,7 @@ #include "sm.h" #include "att.h" +#include "gap_le.h" #include "central_device_db.h" diff --git a/example/libusb/gap_le.h b/example/libusb/gap_le.h new file mode 100644 index 000000000..8d461b098 --- /dev/null +++ b/example/libusb/gap_le.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 + +// address type +typedef enum { + GAP_RANDOM_ADDRESS_TYPE_OFF = 0, + GAP_RANDOM_ADDRESS_NON_RESOLVABLE, + GAP_RANDOM_ADDRESS_RESOLVABLE, +} gap_random_address_type_t; + +// +// GAP LE API +// +void gap_random_address_set_mode(gap_random_address_type_t random_address_type); +void gap_random_address_set_update_period(int period_ms); + + diff --git a/example/libusb/sm.c b/example/libusb/sm.c index 41bfd3de7..ec4da1940 100644 --- a/example/libusb/sm.c +++ b/example/libusb/sm.c @@ -34,7 +34,6 @@ * */ -#include "sm.h" #include #include @@ -42,6 +41,8 @@ #include "hci.h" #include "l2cap.h" #include "central_device_db.h" +#include "sm.h" +#include "gap_le.h" // // SM internal types and globals diff --git a/example/libusb/sm.h b/example/libusb/sm.h index 7103b5634..cccca6fb2 100644 --- a/example/libusb/sm.h +++ b/example/libusb/sm.h @@ -106,13 +106,6 @@ typedef enum { // also, invalid parameters // and reserved -// address type -typedef enum { - GAP_RANDOM_ADDRESS_TYPE_OFF = 0, - GAP_RANDOM_ADDRESS_NON_RESOLVABLE, - GAP_RANDOM_ADDRESS_RESOLVABLE, -} gap_random_address_type_t; - // Security Manager Events typedef struct sm_event_bonding { uint8_t type; // see SM_... @@ -143,13 +136,6 @@ void sm_set_request_security(int enable); // Support for signed writes int sm_cmac_ready(); void sm_cmac_start(sm_key_t k, uint16_t message_len, uint8_t * message, void (*done_handler)(uint8_t hash[8])); - -// -// GAP LE API -// -void gap_random_address_set_mode(gap_random_address_type_t random_address_type); -void gap_random_address_set_update_period(int period_ms); - #if defined __cplusplus } #endif