Bluetooth: Add conn.h public header file
This one should be used for all public connection related APIs. Right now it includes the reference counting and connection callback APIs. Change-Id: Ib9b67e6115bb2e51322644757da1170851c3ca17 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
651e9a4b2e
commit
2b61b44cbc
4 changed files with 57 additions and 15 deletions
|
@ -111,13 +111,4 @@ int bt_start_advertising(uint8_t type, const struct bt_eir *ad,
|
||||||
int bt_start_scanning(uint8_t scan_type, uint8_t scan_filter);
|
int bt_start_scanning(uint8_t scan_type, uint8_t scan_filter);
|
||||||
int bt_stop_scanning();
|
int bt_stop_scanning();
|
||||||
|
|
||||||
struct bt_conn_cb {
|
|
||||||
void (*connected)(const bt_addr_le_t *addr);
|
|
||||||
void (*disconnected)(const bt_addr_le_t *addr);
|
|
||||||
|
|
||||||
struct bt_conn_cb *_next;
|
|
||||||
};
|
|
||||||
|
|
||||||
void bt_conn_cb_register(struct bt_conn_cb *cb);
|
|
||||||
|
|
||||||
#endif /* __BT_BLUETOOTH_H */
|
#endif /* __BT_BLUETOOTH_H */
|
||||||
|
|
54
include/bluetooth/conn.h
Normal file
54
include/bluetooth/conn.h
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*! @file
|
||||||
|
* @brief Bluetooth connection handling
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef __BT_CONN_H
|
||||||
|
#define __BT_CONN_H
|
||||||
|
|
||||||
|
struct bt_conn;
|
||||||
|
|
||||||
|
/* Increment conn reference count */
|
||||||
|
struct bt_conn *bt_conn_get(struct bt_conn *conn);
|
||||||
|
|
||||||
|
/* Decrement conn reference count */
|
||||||
|
void bt_conn_put(struct bt_conn *conn);
|
||||||
|
|
||||||
|
struct bt_conn_cb {
|
||||||
|
void (*connected)(const bt_addr_le_t *addr);
|
||||||
|
void (*disconnected)(const bt_addr_le_t *addr);
|
||||||
|
|
||||||
|
struct bt_conn_cb *_next;
|
||||||
|
};
|
||||||
|
|
||||||
|
void bt_conn_cb_register(struct bt_conn_cb *cb);
|
||||||
|
|
||||||
|
#endif /* __BT_CONN_H */
|
|
@ -32,6 +32,8 @@
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <bluetooth/conn.h>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
BT_CONN_DISCONNECTED,
|
BT_CONN_DISCONNECTED,
|
||||||
BT_CONN_CONNECTED,
|
BT_CONN_CONNECTED,
|
||||||
|
@ -92,9 +94,3 @@ struct bt_conn *bt_conn_lookup_handle(uint16_t handle);
|
||||||
|
|
||||||
/* Look up an existing connection by address */
|
/* Look up an existing connection by address */
|
||||||
struct bt_conn *bt_conn_lookup_addr_le(const bt_addr_le_t *peer);
|
struct bt_conn *bt_conn_lookup_addr_le(const bt_addr_le_t *peer);
|
||||||
|
|
||||||
/* Increment conn reference count */
|
|
||||||
struct bt_conn *bt_conn_get(struct bt_conn *conn);
|
|
||||||
|
|
||||||
/* Decrement conn reference count */
|
|
||||||
void bt_conn_put(struct bt_conn *conn);
|
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
#include "bluetooth/bluetooth.h"
|
#include "bluetooth/bluetooth.h"
|
||||||
#include "bluetooth/hci.h"
|
#include "bluetooth/hci.h"
|
||||||
|
#include "bluetooth/conn.h"
|
||||||
#include "bluetooth/uuid.h"
|
#include "bluetooth/uuid.h"
|
||||||
#include "bluetooth/gatt.h"
|
#include "bluetooth/gatt.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue