2016-01-18 20:04:08 +08:00
|
|
|
/** @file
|
|
|
|
* @brief Internal API for Generic Access Profile.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-02-19 21:52:05 +08:00
|
|
|
/* Maximum security key len (LTK, CSRK) */
|
2016-01-18 20:04:08 +08:00
|
|
|
#define BLE_GAP_SEC_MAX_KEY_LEN 16
|
|
|
|
|
2016-03-15 17:23:03 +08:00
|
|
|
#define BT_SMP_AUTH_NONE 0x00
|
|
|
|
#define BT_SMP_AUTH_BONDING 0x01
|
|
|
|
#define BT_SMP_AUTH_MITM 0x04
|
|
|
|
#define BT_SMP_AUTH_SC 0x08
|
|
|
|
|
2016-02-19 21:52:05 +08:00
|
|
|
enum NBLE_GAP_SM_PASSKEY_TYPE {
|
|
|
|
NBLE_GAP_SM_REJECT = 0,
|
|
|
|
NBLE_GAP_SM_PK_PASSKEY,
|
|
|
|
NBLE_GAP_SM_PK_OOB,
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-19 21:52:05 +08:00
|
|
|
enum NBLE_GAP_SM_EVT {
|
|
|
|
NBLE_GAP_SM_EVT_START_PAIRING,
|
|
|
|
NBLE_GAP_SM_EVT_BONDING_COMPLETE,
|
|
|
|
NBLE_GAP_SM_EVT_LINK_ENCRYPTED,
|
|
|
|
NBLE_GAP_SM_EVT_LINK_SECURITY_CHANGE,
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_response {
|
2016-02-19 21:52:05 +08:00
|
|
|
int status;
|
2016-01-18 20:04:08 +08:00
|
|
|
void *user_data;
|
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_device_name {
|
2016-03-08 18:02:03 +08:00
|
|
|
/* Security mode for writing device name */
|
2016-01-18 20:04:08 +08:00
|
|
|
uint8_t sec_mode;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* 0: no authorization, 1: authorization required */
|
2016-01-18 20:04:08 +08:00
|
|
|
uint8_t authorization;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* Device name length (0-248) */
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t name_array[20];
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_connection_values {
|
2016-02-19 21:52:05 +08:00
|
|
|
/* Connection interval (unit 1.25 ms) */
|
|
|
|
uint16_t interval;
|
|
|
|
/* Connection latency (unit interval) */
|
|
|
|
uint16_t latency;
|
|
|
|
/* Connection supervision timeout (unit 10ms)*/
|
|
|
|
uint16_t supervision_to;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_connection_params {
|
2016-02-19 21:52:05 +08:00
|
|
|
/* minimal connection interval: range 0x0006 to 0x0c80 (unit 1.25ms) */
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t interval_min;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* maximum connection interval: range 0x0006 to 0x0c80 must be bigger then min! */
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t interval_max;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* maximum connection slave latency: 0x0000 to 0x01f3 */
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t slave_latency;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* link supervision timeout: 0x000a to 0x0c80 (unit 10ms) */
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t link_sup_to;
|
|
|
|
};
|
|
|
|
|
2016-02-15 22:53:15 +08:00
|
|
|
struct nble_gap_scan_parameters {
|
2016-02-19 21:52:05 +08:00
|
|
|
/* If 1, perform active scanning (scan requests). */
|
|
|
|
uint8_t active;
|
|
|
|
/* If 1, ignore unknown devices (non whitelisted). */
|
|
|
|
uint8_t selective;
|
|
|
|
/* Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
|
|
|
|
uint16_t interval;
|
|
|
|
/* Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
|
|
|
|
uint16_t window;
|
|
|
|
/* Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
|
|
|
|
uint16_t timeout;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_service_write_params {
|
2016-02-19 21:52:05 +08:00
|
|
|
/* GAP Characteristics attribute type @ref BLE_GAP_SVC_ATTR_TYPE */
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t attr_type;
|
|
|
|
union {
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_device_name name;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* Appearance UUID */
|
|
|
|
uint16_t appearance;
|
|
|
|
/* Preferred Peripheral Connection Parameters */
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_connection_params conn_params;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* Central Address Resolution support 0: no, 1: yes */
|
2016-01-18 20:04:08 +08:00
|
|
|
uint8_t car;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_service_read_bda_response {
|
2016-02-19 21:52:05 +08:00
|
|
|
int status;
|
|
|
|
/* If @ref status ok */
|
|
|
|
bt_addr_le_t bd;
|
2016-01-18 20:04:08 +08:00
|
|
|
void *user_data;
|
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_service_write_response {
|
2016-02-19 21:52:05 +08:00
|
|
|
int status;
|
|
|
|
/* GAP Characteristics attribute type @ref BLE_GAP_SVC_ATTR_TYPE */
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t attr_type;
|
2016-02-19 21:52:05 +08:00
|
|
|
void *user_data;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_service_read_params {
|
2016-02-19 21:52:05 +08:00
|
|
|
/* Type of GAP data characteristic to read @ref BLE_GAP_SVC_ATTR_TYPE */
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t attr_type;
|
|
|
|
};
|
|
|
|
|
2016-04-04 16:27:34 +08:00
|
|
|
struct nble_debug_params {
|
2016-02-19 21:52:05 +08:00
|
|
|
uint32_t u0;
|
|
|
|
uint32_t u1;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-04-04 16:27:34 +08:00
|
|
|
struct nble_debug_resp {
|
2016-02-19 21:52:05 +08:00
|
|
|
int status;
|
|
|
|
uint32_t u0;
|
|
|
|
uint32_t u1;
|
|
|
|
void *user_data;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-19 21:52:05 +08:00
|
|
|
typedef void (*nble_set_bda_cb_t)(int status, void *user_data);
|
|
|
|
|
|
|
|
struct nble_set_bda_params {
|
2016-01-18 20:04:08 +08:00
|
|
|
bt_addr_le_t bda;
|
2016-02-19 21:52:05 +08:00
|
|
|
nble_set_bda_cb_t cb;
|
|
|
|
void *user_data;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-19 21:52:05 +08:00
|
|
|
struct nble_set_bda_rsp {
|
|
|
|
nble_set_bda_cb_t cb;
|
|
|
|
void *user_data;
|
|
|
|
int status;
|
|
|
|
};
|
2016-01-18 20:04:08 +08:00
|
|
|
|
|
|
|
struct bt_eir_data {
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t data[31];
|
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_adv_params {
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t timeout;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* min interval 0xffff: use default 0x0800 */
|
|
|
|
uint16_t interval_min;
|
|
|
|
/* max interval 0xffff: use default 0x0800 */
|
|
|
|
uint16_t interval_max;
|
|
|
|
/* advertisement types @ref GAP_ADV_TYPES */
|
|
|
|
uint8_t type;
|
|
|
|
/* filter policy to apply with white list */
|
|
|
|
uint8_t filter_policy;
|
|
|
|
/* bd address of peer device in case of directed advertisement */
|
2016-01-18 20:04:08 +08:00
|
|
|
bt_addr_le_t peer_bda;
|
2016-03-17 15:47:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nble_gap_ad_data_params {
|
2016-02-19 21:52:05 +08:00
|
|
|
/* Advertisement data, maybe 0 (length) */
|
|
|
|
struct bt_eir_data ad;
|
|
|
|
/* Scan response data, maybe 0 (length) */
|
|
|
|
struct bt_eir_data sd;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_log_s {
|
2016-01-18 20:04:08 +08:00
|
|
|
uint8_t param0;
|
|
|
|
uint8_t param1;
|
|
|
|
uint8_t param2;
|
|
|
|
uint8_t param3;
|
|
|
|
};
|
|
|
|
|
2016-03-08 18:02:03 +08:00
|
|
|
void nble_log(const struct nble_log_s *param, char *buf, uint8_t buflen);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
|
|
|
void on_nble_up(void);
|
|
|
|
|
2016-04-04 16:27:34 +08:00
|
|
|
void nble_gap_service_write_req(const struct nble_gap_service_write_params *);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void on_nble_gap_read_bda_rsp(const struct nble_service_read_bda_response *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void on_nble_gap_service_write_rsp(const struct nble_service_write_response *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-04-04 16:27:34 +08:00
|
|
|
void nble_gap_dbg_req(const struct nble_debug_params *par, void *user_data);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-04-04 16:27:34 +08:00
|
|
|
void on_nble_gap_dbg_rsp(const struct nble_debug_resp *rsp);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-03-08 18:02:03 +08:00
|
|
|
void on_nble_set_bda_rsp(const struct nble_set_bda_rsp *par);
|
|
|
|
|
|
|
|
void nble_set_bda_req(const struct nble_set_bda_params *par);
|
|
|
|
|
2016-03-17 15:47:05 +08:00
|
|
|
void nble_gap_set_adv_data_req(struct nble_gap_ad_data_params *ad_data_params);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-03-17 15:47:05 +08:00
|
|
|
void nble_gap_set_adv_params_req(struct nble_gap_adv_params *adv_params);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-03-17 15:47:05 +08:00
|
|
|
void nble_gap_start_adv_req(void);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-03-17 15:47:05 +08:00
|
|
|
void on_nble_gap_start_advertise_rsp(const struct nble_response *params);
|
|
|
|
|
|
|
|
void nble_gap_stop_adv_req(void *user_data);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_read_bda_req(void *priv);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_irk_info {
|
2016-01-18 20:04:08 +08:00
|
|
|
uint8_t irk[BLE_GAP_SEC_MAX_KEY_LEN];
|
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_wr_white_list_req(bt_addr_le_t *bd_array, uint8_t bd_array_size,
|
|
|
|
struct nble_gap_irk_info *irk_array,
|
|
|
|
uint8_t irk_array_size, void *priv);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_clr_white_list_req(void *priv);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_connect_update_params {
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t conn_handle;
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_connection_params params;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-19 21:52:05 +08:00
|
|
|
void nble_set_bda_req(const struct nble_set_bda_params *params);
|
|
|
|
|
|
|
|
void nble_gap_conn_update_req(const struct nble_gap_connect_update_params *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_connect_req_params {
|
2016-01-18 20:04:08 +08:00
|
|
|
bt_addr_le_t bda;
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_connection_params conn_params;
|
2016-02-15 22:53:15 +08:00
|
|
|
struct nble_gap_scan_parameters scan_params;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_disconnect_req_params {
|
2016-02-19 21:52:05 +08:00
|
|
|
uint16_t conn_handle;
|
|
|
|
uint8_t reason;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-04-04 16:27:34 +08:00
|
|
|
void nble_gap_disconnect_req(const struct nble_gap_disconnect_req_params *);
|
2016-03-08 18:02:03 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void on_nble_gap_disconnect_rsp(const struct nble_response *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_service_read_req(const struct nble_gap_service_read_params *par,
|
|
|
|
void *user_data);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_sm_config_params {
|
2016-02-19 21:52:05 +08:00
|
|
|
/* Security options (@ref BLE_GAP_SM_OPTIONS) */
|
2016-02-12 21:47:05 +08:00
|
|
|
uint8_t options;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* I/O Capabilities to allow passkey exchange (@ref BLE_GAP_IO_CAPABILITIES) */
|
2016-01-18 20:04:08 +08:00
|
|
|
uint8_t io_caps;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* Maximum encryption key size (7-16) */
|
|
|
|
uint8_t key_size;
|
2016-02-12 21:47:05 +08:00
|
|
|
uint8_t oob_present;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_sm_config_req(const struct nble_gap_sm_config_params *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_sm_config_rsp {
|
2016-02-19 21:52:05 +08:00
|
|
|
void *user_data;
|
|
|
|
int status;
|
|
|
|
bool sm_bond_dev_avail;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-19 21:52:05 +08:00
|
|
|
struct nble_gap_sm_pairing_params {
|
|
|
|
/* authentication level see @ref BLE_GAP_SM_OPTIONS */
|
2016-01-18 20:04:08 +08:00
|
|
|
uint8_t auth_level;
|
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_sm_security_params {
|
|
|
|
struct bt_conn *conn;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* Connection on which bonding procedure is executed */
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t conn_handle;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* Local authentication/bonding parameters */
|
|
|
|
struct nble_gap_sm_pairing_params params;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_sm_security_req(const struct nble_gap_sm_security_params *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-19 21:52:05 +08:00
|
|
|
struct nble_gap_sm_passkey {
|
2016-01-18 20:04:08 +08:00
|
|
|
uint8_t type;
|
|
|
|
union {
|
2016-02-19 21:52:05 +08:00
|
|
|
uint32_t passkey;
|
|
|
|
uint8_t oob[16];
|
|
|
|
uint8_t reason;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_sm_key_reply_req_params {
|
2016-02-19 21:52:05 +08:00
|
|
|
struct bt_conn *conn;
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t conn_handle;
|
2016-02-19 21:52:05 +08:00
|
|
|
struct nble_gap_sm_passkey params;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_sm_passkey_reply_req(const struct nble_gap_sm_key_reply_req_params *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_sm_clear_bond_req_params {
|
|
|
|
bt_addr_le_t addr;
|
|
|
|
};
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_sm_clear_bonds_req(const struct nble_gap_sm_clear_bond_req_params *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_sm_response {
|
|
|
|
int status;
|
|
|
|
struct bt_conn *conn;
|
|
|
|
};
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_rssi_report_params {
|
2016-02-19 21:52:05 +08:00
|
|
|
uint16_t conn_handle;
|
|
|
|
/* RSSI operation @ref BLE_GAP_RSSI_OPS */
|
|
|
|
uint8_t op;
|
2016-04-04 16:27:34 +08:00
|
|
|
/* Channel for RSSI enabling */
|
|
|
|
uint8_t channel;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* minimum RSSI dBm change to report a new RSSI value */
|
|
|
|
uint8_t delta_dBm;
|
|
|
|
/* number of delta_dBm changes before sending a new RSSI report */
|
2016-01-25 17:51:42 +08:00
|
|
|
uint8_t min_count;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_set_rssi_report_req(const struct nble_rssi_report_params *par,
|
|
|
|
void *user_data);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void on_nble_gap_set_rssi_report_rsp(const struct nble_response *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-10 16:37:05 +08:00
|
|
|
struct nble_gap_scan_params {
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t interval;
|
|
|
|
uint16_t window;
|
2016-02-10 16:37:05 +08:00
|
|
|
uint8_t scan_type;
|
|
|
|
uint8_t use_whitelist;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-10 16:37:05 +08:00
|
|
|
void nble_gap_start_scan_req(const struct nble_gap_scan_params *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_stop_scan_req(void);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-03-08 18:02:03 +08:00
|
|
|
void on_nble_gap_scan_start_stop_rsp(const struct nble_response *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-15 22:53:15 +08:00
|
|
|
void nble_gap_connect_req(const struct nble_gap_connect_req_params *req,
|
|
|
|
void *user_data);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-15 22:53:15 +08:00
|
|
|
void on_nble_gap_connect_rsp(const struct nble_response *rsp);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_cancel_connect_req(void *user_data);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void on_nble_gap_cancel_connect_rsp(const struct nble_response *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
|
|
|
enum BLE_GAP_SET_OPTIONS {
|
2016-02-19 21:52:05 +08:00
|
|
|
BLE_GAP_SET_CH_MAP = 0,
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_channel_map {
|
2016-02-19 21:52:05 +08:00
|
|
|
/* connection on which to change channel map */
|
|
|
|
uint16_t conn_handle;
|
|
|
|
/* 37 bits are used of the 40 bits (LSB) */
|
|
|
|
uint8_t map[5];
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_set_option_params {
|
2016-02-19 21:52:05 +08:00
|
|
|
/* Option to set @ref BLE_GAP_SET_OPTIONS */
|
|
|
|
uint8_t op;
|
2016-01-18 20:04:08 +08:00
|
|
|
union {
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_channel_map ch_map;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_set_option_req(const struct nble_gap_set_option_params *par,
|
|
|
|
void *user_data);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-19 21:52:05 +08:00
|
|
|
/*
|
2016-03-08 18:02:03 +08:00
|
|
|
* Generic request op codes.
|
2016-01-18 20:04:08 +08:00
|
|
|
* This allows to access some non connection related commands like DTM.
|
|
|
|
*/
|
|
|
|
enum BLE_GAP_GEN_OPS {
|
2016-02-19 21:52:05 +08:00
|
|
|
/* Not used now. */
|
|
|
|
DUMMY_VALUE = 0,
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Generic command parameters. */
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_gen_cmd_params {
|
2016-02-19 21:52:05 +08:00
|
|
|
/* @ref BLE_GAP_GEN_OPS */
|
|
|
|
uint8_t op_code;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_generic_cmd_req(const struct nble_gap_gen_cmd_params *par,
|
|
|
|
void *priv);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-03-17 15:47:05 +08:00
|
|
|
struct nble_uas_rssi_calibrate {
|
|
|
|
float distance;
|
|
|
|
};
|
|
|
|
void nble_uas_rssi_calibrate_req(const struct nble_uas_rssi_calibrate *);
|
|
|
|
|
|
|
|
struct nble_uas_bucket_change {
|
|
|
|
uint8_t distance;
|
|
|
|
};
|
|
|
|
void on_nble_uas_bucket_change(const struct nble_uas_bucket_change *);
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void on_nble_gap_generic_cmd_rsp(const struct nble_response *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_get_version_req(void *user_data);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_version_response {
|
2016-01-18 20:04:08 +08:00
|
|
|
struct version_header version;
|
2016-02-19 21:52:05 +08:00
|
|
|
void *user_data;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void on_nble_get_version_rsp(const struct nble_version_response *par);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void nble_gap_dtm_init_req(void *user_data);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_connect_evt {
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t conn_handle;
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_connection_values conn_values;
|
2016-02-19 21:52:05 +08:00
|
|
|
/* 0 if connected as master, otherwise as slave */
|
|
|
|
uint8_t role_slave;
|
|
|
|
/* Address of peer device */
|
2016-01-18 20:04:08 +08:00
|
|
|
bt_addr_le_t peer_bda;
|
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void on_nble_gap_connect_evt(const struct nble_gap_connect_evt *ev);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_disconnect_evt {
|
2016-02-19 21:52:05 +08:00
|
|
|
uint16_t conn_handle;
|
|
|
|
uint8_t hci_reason;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void on_nble_gap_disconnect_evt(const struct nble_gap_disconnect_evt *ev);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_conn_update_evt {
|
2016-01-18 20:04:08 +08:00
|
|
|
uint16_t conn_handle;
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_connection_values conn_values;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void on_nble_gap_conn_update_evt(const struct nble_gap_conn_update_evt *ev);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-10 16:37:05 +08:00
|
|
|
struct nble_gap_adv_report_evt {
|
|
|
|
bt_addr_le_t addr;
|
|
|
|
int8_t rssi;
|
|
|
|
uint8_t adv_type;
|
|
|
|
};
|
|
|
|
|
2016-02-19 21:52:05 +08:00
|
|
|
struct nble_gap_dir_adv_timeout_evt {
|
|
|
|
uint16_t conn_handle;
|
|
|
|
uint16_t error;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-19 21:52:05 +08:00
|
|
|
void on_nble_gap_dir_adv_timeout_evt(const struct nble_gap_dir_adv_timeout_evt *evt);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-04-04 16:27:34 +08:00
|
|
|
#define BLE_GAP_RSSI_EVT_SIZE 32
|
2016-02-19 21:52:05 +08:00
|
|
|
struct nble_gap_rssi_evt {
|
|
|
|
uint16_t conn_handle;
|
2016-04-04 16:27:34 +08:00
|
|
|
int8_t rssi_data[BLE_GAP_RSSI_EVT_SIZE];
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-19 21:52:05 +08:00
|
|
|
void on_nble_gap_rssi_evt(const struct nble_gap_rssi_evt *ev);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_sm_passkey_req_evt {
|
2016-02-19 21:52:05 +08:00
|
|
|
uint16_t conn_handle;
|
2016-01-18 20:04:08 +08:00
|
|
|
uint8_t key_type;
|
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void on_nble_gap_sm_passkey_req_evt(const struct nble_gap_sm_passkey_req_evt *);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_sm_passkey_disp_evt {
|
2016-02-19 21:52:05 +08:00
|
|
|
uint16_t conn_handle;
|
|
|
|
uint32_t passkey;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-19 21:52:05 +08:00
|
|
|
void on_nble_gap_sm_passkey_display_evt(const struct nble_gap_sm_passkey_disp_evt *evt);
|
|
|
|
|
|
|
|
struct nble_link_sec {
|
|
|
|
bt_security_t sec_level;
|
|
|
|
uint8_t enc_size;
|
|
|
|
};
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_sm_status_evt {
|
2016-02-19 21:52:05 +08:00
|
|
|
uint16_t conn_handle;
|
|
|
|
uint8_t evt_type;
|
|
|
|
int status;
|
|
|
|
struct nble_link_sec enc_link_sec;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
void on_nble_gap_sm_status_evt(const struct nble_gap_sm_status_evt *ev);
|
2016-01-18 20:04:08 +08:00
|
|
|
|
2016-02-12 21:47:05 +08:00
|
|
|
struct nble_gap_sm_bond_info;
|
|
|
|
|
|
|
|
typedef void (*ble_bond_info_cb_t)(const struct nble_gap_sm_bond_info *info,
|
|
|
|
const bt_addr_le_t *addr, uint16_t len,
|
|
|
|
void *user_data);
|
|
|
|
|
|
|
|
struct nble_gap_sm_bond_info_param {
|
|
|
|
ble_bond_info_cb_t cb;
|
|
|
|
void *user_data;
|
|
|
|
bool include_bonded_addrs;
|
|
|
|
};
|
|
|
|
|
|
|
|
void nble_gap_sm_bond_info_req(const struct nble_gap_sm_bond_info_param *params);
|
|
|
|
|
|
|
|
struct nble_gap_sm_bond_info {
|
|
|
|
int err;
|
|
|
|
uint8_t addr_count;
|
|
|
|
uint8_t irk_count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct nble_gap_sm_bond_info_rsp {
|
|
|
|
ble_bond_info_cb_t cb;
|
|
|
|
void *user_data;
|
|
|
|
struct nble_gap_sm_bond_info info;
|
2016-01-18 20:04:08 +08:00
|
|
|
};
|
2016-03-21 16:19:12 +08:00
|
|
|
|
|
|
|
struct nble {
|
|
|
|
/* Local Bluetooth LE Device Address */
|
|
|
|
bt_addr_le_t addr;
|
2016-03-21 16:25:10 +08:00
|
|
|
const struct bt_conn_auth_cb *auth;
|
2016-03-17 20:22:36 +08:00
|
|
|
bool keep_adv;
|
2016-03-21 16:19:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct nble nble;
|