Bluetooth: Move bt_security to conn.h and rename it appropriately

Change-Id: Ibea6e4ef08c68e9debf0c53036dd2e4f75ea9a72
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-07-15 14:21:37 +03:00 committed by Anas Nashif
commit fe41cec885
6 changed files with 29 additions and 25 deletions

View file

@ -38,7 +38,6 @@
#include <string.h>
#include <bluetooth/buf.h>
#include <bluetooth/conn.h>
#include <bluetooth/hci.h>
/** @brief Initialize the Bluetooth Subsystem.
@ -130,28 +129,6 @@ typedef enum {
*/
} bt_security_t;
/** @brief Set security level for a connection.
*
* This function enable security (encryption) for a connection. If device is
* already paired with sufficiently strong key encryption will be enabled. If
* link is already encrypted with sufficiently strong key this function does
* nothing.
*
* If device is not paired pairing will be initiated. If device is paired and
* keys are too weak but input output capabilities allow for strong enough keys
* pairing will be initiated.
*
* This function may return error if required level of security is not possible
* to achieve due to local or remote device limitation (eg input output
* capabilities).
*
* @param conn Connection object.
* @param sec Requested security level.
*
* @return 0 on success or negative error
*/
int bt_security(struct bt_conn *conn, bt_security_t sec);
/** @def BT_ADDR_STR_LEN
*
* @brief Recommended length of user string buffer for Bluetooth address

View file

@ -36,6 +36,7 @@
#include <stdbool.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
/** Opaque type representing a connection to a remote device */
@ -102,6 +103,28 @@ int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason);
*/
struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer);
/** @brief Set security level for a connection.
*
* This function enable security (encryption) for a connection. If device is
* already paired with sufficiently strong key encryption will be enabled. If
* link is already encrypted with sufficiently strong key this function does
* nothing.
*
* If device is not paired pairing will be initiated. If device is paired and
* keys are too weak but input output capabilities allow for strong enough keys
* pairing will be initiated.
*
* This function may return error if required level of security is not possible
* to achieve due to local or remote device limitation (eg input output
* capabilities).
*
* @param conn Connection object.
* @param sec Requested security level.
*
* @return 0 on success or negative error
*/
int bt_conn_security(struct bt_conn *conn, bt_security_t sec);
/** Connection callback structure */
struct bt_conn_cb {
void (*connected)(struct bt_conn *conn);

View file

@ -431,7 +431,7 @@ const bt_addr_le_t *bt_conn_get_dst(const struct bt_conn *conn)
return &conn->dst;
}
int bt_security(struct bt_conn *conn, bt_security_t sec)
int bt_conn_security(struct bt_conn *conn, bt_security_t sec)
{
struct bt_keys *keys;

View file

@ -33,6 +33,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <bluetooth/conn.h>
struct bt_smp_hdr {
uint8_t code;
} __packed;

View file

@ -43,6 +43,7 @@
#include <console/uart_console.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/conn.h>
#include <bluetooth/gatt.h>
#include "btshell.h"
@ -301,7 +302,7 @@ static void cmd_security(int argc, char *argv[])
sec = *argv[3] - '0';
err = bt_security(conn, sec);
err = bt_conn_security(conn, sec);
if (err) {
printk("Setting security failed (err %d)\n", err);
}

View file

@ -35,6 +35,7 @@
#include <toolchain.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/conn.h>
#include "bttester.h"