Bluetooth: Disable parts of public API if not configured

Depending on selected Kconfig options some parts of public API
are disabled with #ifdefs. This should make it easy for user to
figure out which options should be enabled to specific API.

Change-Id: I4ae1bfd7bf535ea45869772c429ccd3d3d4c214e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
Szymon Janc 2015-09-14 17:10:38 +02:00 committed by Anas Nashif
commit 68382388ce
3 changed files with 16 additions and 1 deletions

View file

@ -136,6 +136,7 @@ int bt_start_scanning(bt_scan_filter_dup_t filter, bt_le_scan_cb_t cb);
*/ */
int bt_stop_scanning(void); int bt_stop_scanning(void);
#if defined(CONFIG_BLUETOOTH_SMP)
/** Authenticated pairing callback structure */ /** Authenticated pairing callback structure */
struct bt_auth_cb { struct bt_auth_cb {
void (*passkey_display)(struct bt_conn *conn, unsigned int passkey); void (*passkey_display)(struct bt_conn *conn, unsigned int passkey);
@ -171,6 +172,7 @@ void bt_auth_passkey_entry(struct bt_conn *conn, unsigned int passkey);
* @param conn Connection object. * @param conn Connection object.
*/ */
void bt_auth_cancel(struct bt_conn *conn); void bt_auth_cancel(struct bt_conn *conn);
#endif /* CONFIG_BLUETOOTH_SMP */
/** @def BT_ADDR_STR_LEN /** @def BT_ADDR_STR_LEN
* *

View file

@ -34,6 +34,7 @@
#ifndef __BT_CONN_H #ifndef __BT_CONN_H
#define __BT_CONN_H #define __BT_CONN_H
#if defined(CONFIG_BLUETOOTH_CENTRAL) || defined(CONFIG_BLUETOOTH_PERIPHERAL)
#include <stdbool.h> #include <stdbool.h>
#include <bluetooth/hci.h> #include <bluetooth/hci.h>
@ -91,6 +92,7 @@ const bt_addr_le_t *bt_conn_get_dst(const struct bt_conn *conn);
*/ */
int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason); int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason);
#if defined(CONFIG_BLUETOOTH_CENTRAL)
/** @brief Initiate an LE connection to a remote device. /** @brief Initiate an LE connection to a remote device.
* *
* Allows initiate new LE link to remote peer using its address. * Allows initiate new LE link to remote peer using its address.
@ -101,6 +103,7 @@ int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason);
* @return Valid connection object on success or NULL otherwise. * @return Valid connection object on success or NULL otherwise.
*/ */
struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer); struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer);
#endif
/** Security level. */ /** Security level. */
typedef enum { typedef enum {
@ -112,6 +115,7 @@ typedef enum {
*/ */
} bt_security_t; } bt_security_t;
#if defined(CONFIG_BLUETOOTH_SMP)
/** @brief Set security level for a connection. /** @brief Set security level for a connection.
* *
* This function enable security (encryption) for a connection. If device is * This function enable security (encryption) for a connection. If device is
@ -133,16 +137,18 @@ typedef enum {
* @return 0 on success or negative error * @return 0 on success or negative error
*/ */
int bt_conn_security(struct bt_conn *conn, bt_security_t sec); int bt_conn_security(struct bt_conn *conn, bt_security_t sec);
#endif
/** Connection callback structure */ /** Connection callback structure */
struct bt_conn_cb { struct bt_conn_cb {
void (*connected)(struct bt_conn *conn); void (*connected)(struct bt_conn *conn);
void (*disconnected)(struct bt_conn *conn); void (*disconnected)(struct bt_conn *conn);
#if defined(CONFIG_BLUETOOTH_SMP)
void (*identity_resolved)(struct bt_conn *conn, void (*identity_resolved)(struct bt_conn *conn,
const bt_addr_le_t *rpa, const bt_addr_le_t *rpa,
const bt_addr_le_t *identity); const bt_addr_le_t *identity);
void (*security_changed)(struct bt_conn *conn, bt_security_t level); void (*security_changed)(struct bt_conn *conn, bt_security_t level);
#endif
struct bt_conn_cb *_next; struct bt_conn_cb *_next;
}; };
@ -154,6 +160,7 @@ struct bt_conn_cb {
*/ */
void bt_conn_cb_register(struct bt_conn_cb *cb); void bt_conn_cb_register(struct bt_conn_cb *cb);
#if defined(CONFIG_BLUETOOTH_CENTRAL)
/** @brief Automatically connect to remote device if it's in range. /** @brief Automatically connect to remote device if it's in range.
* *
* This function enables/disables automatic connection initiation. * This function enables/disables automatic connection initiation.
@ -168,4 +175,6 @@ void bt_conn_cb_register(struct bt_conn_cb *cb);
*/ */
void bt_conn_set_auto_conn(struct bt_conn *conn, bool auto_conn); void bt_conn_set_auto_conn(struct bt_conn *conn, bool auto_conn);
#endif /* CONFIG_BLUETOOTH_CENTRAL */
#endif /* CONFIG_BLUETOOTH_CENTRAL || CONFIG_BLUETOOTH_PERIPHERAL */
#endif /* __BT_CONN_H */ #endif /* __BT_CONN_H */

View file

@ -34,6 +34,7 @@
#ifndef __BT_GATT_H #ifndef __BT_GATT_H
#define __BT_GATT_H #define __BT_GATT_H
#if defined(CONFIG_BLUETOOTH_CENTRAL) || defined(CONFIG_BLUETOOTH_PERIPHERAL)
#include <misc/util.h> #include <misc/util.h>
#include <bluetooth/conn.h> #include <bluetooth/conn.h>
#include <bluetooth/uuid.h> #include <bluetooth/uuid.h>
@ -615,6 +616,7 @@ int bt_gatt_attr_read_cep(struct bt_conn *conn,
*/ */
void bt_gatt_notify(uint16_t handle, const void *data, uint16_t len); void bt_gatt_notify(uint16_t handle, const void *data, uint16_t len);
#if defined(CONFIG_BLUETOOTH_GATT_CLIENT)
/* Client API */ /* Client API */
/** @brief Response callback function /** @brief Response callback function
@ -795,4 +797,6 @@ void bt_gatt_cancel(struct bt_conn *conn);
int bt_gatt_read_multiple(struct bt_conn *conn, const uint16_t *handles, int bt_gatt_read_multiple(struct bt_conn *conn, const uint16_t *handles,
size_t count, bt_gatt_read_func_t func); size_t count, bt_gatt_read_func_t func);
#endif /* CONFIG_BLUETOOTH_GATT_CLIENT */
#endif /* CONFIG_BLUETOOTH_CENTRAL || CONFIG_BLUETOOTH_PERIPHERAL */
#endif /* __BT_GATT_H */ #endif /* __BT_GATT_H */