drivers/nble: Update RPC to Nordic BLE chip

Update RPC functions and data types, works with NBLE firmware
niko-0301

Change-Id: I3538fab1d20c6e140d995a797d68486be6cd0f23
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2016-02-19 15:52:05 +02:00 committed by Gerrit Code Review
commit bef9fb8189
10 changed files with 264 additions and 566 deletions

View file

@ -336,7 +336,7 @@ void on_nble_gap_connect_evt(const struct nble_gap_connect_evt *ev)
{ {
struct bt_conn *conn; struct bt_conn *conn;
BT_DBG("handle %u role %u", ev->conn_handle, ev->role); BT_DBG("handle %u role %u", ev->conn_handle, ev->role_slave);
conn = conn_new(); conn = conn_new();
if (!conn) { if (!conn) {
@ -345,7 +345,7 @@ void on_nble_gap_connect_evt(const struct nble_gap_connect_evt *ev)
} }
conn->handle = ev->conn_handle; conn->handle = ev->conn_handle;
conn->role = ev->role; conn->role = ev->role_slave;
conn->interval = ev->conn_values.interval; conn->interval = ev->conn_values.interval;
conn->latency = ev->conn_values.latency; conn->latency = ev->conn_values.latency;
conn->timeout = ev->conn_values.supervision_to; conn->timeout = ev->conn_values.supervision_to;

View file

@ -378,7 +378,7 @@ void on_nble_gap_sm_config_rsp(struct nble_gap_sm_config_rsp *rsp)
return; return;
} }
BT_DBG("state %u", rsp->state); BT_DBG("status %u", rsp->status);
/* Get bdaddr queued after SM setup */ /* Get bdaddr queued after SM setup */
nble_gap_read_bda_req(NULL); nble_gap_read_bda_req(NULL);

View file

@ -24,13 +24,8 @@
#include "bluetooth/hci.h" #include "bluetooth/hci.h"
#include "version.h" #include "version.h"
/* Must be the same with nble_service_gap_api.h ! */ /* Maximum security key len (LTK, CSRK) */
/**< Maximum security key len (LTK, CSRK) */
#define BLE_GAP_SEC_MAX_KEY_LEN 16 #define BLE_GAP_SEC_MAX_KEY_LEN 16
#define BLE_PASSKEY_LEN 6
/* Must be the same with BLE_GAP_SM_OPTIONS ! */
/** /**
* GAP security manager options for bonding/authentication procedures, * GAP security manager options for bonding/authentication procedures,
@ -43,25 +38,17 @@ enum BLE_CORE_GAP_SM_OPTIONS {
BLE_CORE_GAP_OOB = 0x08 /**< SMP supports Out Of Band data */ BLE_CORE_GAP_OOB = 0x08 /**< SMP supports Out Of Band data */
}; };
/* Must be the same with BLE_CORE_GAP_SM_PASSKEY_TYPE ! */ enum NBLE_GAP_SM_PASSKEY_TYPE {
/** NBLE_GAP_SM_REJECT = 0,
* Security manager passkey type. NBLE_GAP_SM_PK_PASSKEY,
*/ NBLE_GAP_SM_PK_OOB,
enum BLE_CORE_GAP_SM_PASSKEY_TYPE {
BLE_CORE_GAP_SM_PK_NONE = 0, /**< No key (may be used to reject). */
BLE_CORE_GAP_SM_PK_PASSKEY, /**< Sec data is a 6-digit passkey. */
BLE_CORE_GAP_SM_PK_OOB, /**< Sec data is 16 bytes of OOB data */
}; };
/* Must be the same with BLE_GAP_SM_STATUS ! */ enum NBLE_GAP_SM_EVT {
/** NBLE_GAP_SM_EVT_START_PAIRING,
* GAP security manager status codes. NBLE_GAP_SM_EVT_BONDING_COMPLETE,
*/ NBLE_GAP_SM_EVT_LINK_ENCRYPTED,
enum BLE_CORE_GAP_SM_STATUS { NBLE_GAP_SM_EVT_LINK_SECURITY_CHANGE,
BLE_CORE_GAP_SM_ST_START_PAIRING, /*< Pairing has started */
BLE_CORE_GAP_SM_ST_BONDING_COMPLETE, /*< Bonding has completed */
BLE_CORE_GAP_SM_ST_LINK_ENCRYPTED, /*< Link is encrypted */
BLE_CORE_GAP_SM_ST_SECURITY_UPDATE, /*< Link keys updated */
}; };
/* Must be the same with BLE_GAP_RSSI_OPS ! */ /* Must be the same with BLE_GAP_RSSI_OPS ! */
@ -75,45 +62,49 @@ enum BLE_CORE_GAP_RSSI_OPS {
/** Test Mode opcodes. The same with nble_service_gap_api.h */ /** Test Mode opcodes. The same with nble_service_gap_api.h */
enum BLE_CORE_TEST_OPCODE { enum BLE_CORE_TEST_OPCODE {
/**< Put BLE controller in HCI UART DTM test mode */
BLE_CORE_TEST_INIT_DTM = 0x01, BLE_CORE_TEST_INIT_DTM = 0x01,
BLE_CORE_TEST_START_DTM_RX = 0x1d, /**< LE rcv test HCI op */ BLE_CORE_TEST_START_DTM_RX = 0x1d,
BLE_CORE_TEST_START_DTM_TX = 0x1e, /**< LE trans test HCI op */ BLE_CORE_TEST_START_DTM_TX = 0x1e,
BLE_CORE_TEST_END_DTM = 0x1f, /**< End LE DTM TEST */ BLE_CORE_TEST_END_DTM = 0x1f,
/** vendor specific commands start at 0x80 /* vendor specific commands start at 0x80 */
* Set Tx power. To be called before start of tx test /* Set Tx power. To be called before start of tx test */
*/
BLE_CORE_TEST_SET_TXPOWER = 0x80, BLE_CORE_TEST_SET_TXPOWER = 0x80,
BLE_CORE_TEST_START_TX_CARRIER, /**< Start Tx Carrier Test */ BLE_CORE_TEST_START_TX_CARRIER,
}; };
struct nble_response { struct nble_response {
int status; /**< Status of the operation */ int status;
void *user_data; void *user_data;
}; };
struct nble_gap_device_name { struct nble_gap_device_name {
/**< Security mode for writing device name, @ref BLE_GAP_SEC_MODES */ /* Security mode for writing device name, @ref BLE_GAP_SEC_MODES */
uint8_t sec_mode; uint8_t sec_mode;
/**< 0: no authorization, 1: authorization required */ /* 0: no authorization, 1: authorization required */
uint8_t authorization; uint8_t authorization;
uint8_t len; /**< Device name length (0-248) */ /* Device name length (0-248) */
uint8_t name_array[20]; /**< Device */ uint8_t len;
uint8_t name_array[20];
}; };
struct nble_gap_connection_values { struct nble_gap_connection_values {
uint16_t interval; /**< Conn interval (unit 1.25 ms) */ /* Connection interval (unit 1.25 ms) */
uint16_t latency; /**< Conn latency (unit interval) */ uint16_t interval;
uint16_t supervision_to; /**< Conn supervision timeout (10ms) */ /* Connection latency (unit interval) */
uint16_t latency;
/* Connection supervision timeout (unit 10ms)*/
uint16_t supervision_to;
}; };
enum BLE_GAP_SVC_ATTR_TYPE { enum BLE_GAP_SVC_ATTR_TYPE {
GAP_SVC_ATTR_NAME = 0, /**< Device Name, UUID 0x2a00 */ /* Device Name, UUID 0x2a00 */
GAP_SVC_ATTR_APPEARANCE, /**< Appearance, UUID 0x2a01 */ GAP_SVC_ATTR_NAME = 0,
/**< Peripheral Preferred Connection Parameters (PPCP), UUID 0x2a04 */ /* Appearance, UUID 0x2a01 */
GAP_SVC_ATTR_APPEARANCE,
/* Peripheral Preferred Connection Parameters (PPCP), UUID 0x2a04 */
GAP_SVC_ATTR_PPCP = 4, GAP_SVC_ATTR_PPCP = 4,
/**< Central Address Resolution (CAR), UUID 0x2aa6, BT 4.2 */ /* Central Address Resolution (CAR), UUID 0x2aa6, BT 4.2 */
GAP_SVC_ATTR_CAR = 0xa6, GAP_SVC_ATTR_CAR = 0xa6,
}; };
@ -121,13 +112,13 @@ enum BLE_GAP_SVC_ATTR_TYPE {
* Connection requested parameters. * Connection requested parameters.
*/ */
struct nble_gap_connection_params { struct nble_gap_connection_params {
/**< minimal conne interval: range 0x0006 to 0x0c80 (unit 1.25ms) */ /* minimal connection interval: range 0x0006 to 0x0c80 (unit 1.25ms) */
uint16_t interval_min; uint16_t interval_min;
/**< max conn interv: range 0x0006 to 0x0c80 must be bigger then min */ /* maximum connection interval: range 0x0006 to 0x0c80 must be bigger then min! */
uint16_t interval_max; uint16_t interval_max;
/**< maximum connection slave latency: 0x0000 to 0x01f3 */ /* maximum connection slave latency: 0x0000 to 0x01f3 */
uint16_t slave_latency; uint16_t slave_latency;
/**< link supervision timeout: 0x000a to 0x0c80 (unit 10ms) */ /* link supervision timeout: 0x000a to 0x0c80 (unit 10ms) */
uint16_t link_sup_to; uint16_t link_sup_to;
}; };
@ -135,78 +126,77 @@ struct nble_gap_connection_params {
* Connection scan requested parameters. * Connection scan requested parameters.
*/ */
struct nble_gap_scan_parameters { struct nble_gap_scan_parameters {
uint8_t active; /**< If 1, perform active scan (scan req) */ /* If 1, perform active scanning (scan requests). */
uint8_t selective; /**< If 1, ignore unknown dev (non whitelist) */ uint8_t active;
/**< Scan interval between 0x0004 and 0x4000 in 0.625ms units /* If 1, ignore unknown devices (non whitelisted). */
* (2.5ms to 10.24s). uint8_t selective;
*/ /* Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
uint16_t interval; uint16_t interval;
/**< Scan window between 0x0004 and 0x4000 in 0.625ms units /* Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
* (2.5ms to 10.24s). uint16_t window;
*/ /* Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
uint16_t window; uint16_t timeout;
/**< Scan timeout between 0x0001 and 0xFFFF in seconds,
* 0x0000 disables timeout.
*/
uint16_t timeout;
}; };
struct nble_gap_service_write_params { struct nble_gap_service_write_params {
/**< GAP Characteristics attribute type @ref BLE_GAP_SVC_ATTR_TYPE */ /* GAP Characteristics attribute type @ref BLE_GAP_SVC_ATTR_TYPE */
uint16_t attr_type; uint16_t attr_type;
union { union {
struct nble_gap_device_name name; struct nble_gap_device_name name;
uint16_t appearance; /**< Appearance UUID */ /* Appearance UUID */
/**< Preferred Peripheral Connection Parameters */ uint16_t appearance;
/* Preferred Peripheral Connection Parameters */
struct nble_gap_connection_params conn_params; struct nble_gap_connection_params conn_params;
/**< Central Address Resolution support 0: no, 1: yes */ /* Central Address Resolution support 0: no, 1: yes */
uint8_t car; uint8_t car;
}; };
}; };
struct nble_service_read_bda_response { struct nble_service_read_bda_response {
int status; /**< Status of the operation */ int status;
bt_addr_le_t bd; /**< If @ref status ok */ /* If @ref status ok */
bt_addr_le_t bd;
void *user_data; void *user_data;
}; };
struct nble_service_write_response { struct nble_service_write_response {
int status; /**< Status of the operation */ int status;
/**< GAP Characteristics attribute type @ref BLE_GAP_SVC_ATTR_TYPE */ /* GAP Characteristics attribute type @ref BLE_GAP_SVC_ATTR_TYPE */
uint16_t attr_type; uint16_t attr_type;
void *user_data; /**< Pointer to the user data of the request */ void *user_data;
}; };
struct nble_gap_service_read_params { struct nble_gap_service_read_params {
/**< Type of GAP data charact to read @ref BLE_GAP_SVC_ATTR_TYPE */ /* Type of GAP data characteristic to read @ref BLE_GAP_SVC_ATTR_TYPE */
uint16_t attr_type; uint16_t attr_type;
}; };
struct debug_params { struct debug_params {
uint32_t u0; /** user parameter */ uint32_t u0;
uint32_t u1; /** user parameter */ uint32_t u1;
}; };
struct debug_response { struct debug_response {
int status; /**< Status of the operation */ int status;
uint32_t u0; /** user parameter */ uint32_t u0;
uint32_t u1; /** user parameter */ uint32_t u1;
void *user_data; /**< Pointer to the user data of the request */ void *user_data;
}; };
struct nble_wr_config_params { typedef void (*nble_set_bda_cb_t)(int status, void *user_data);
struct nble_set_bda_params {
bt_addr_le_t bda; bt_addr_le_t bda;
uint8_t bda_present; nble_set_bda_cb_t cb;
int8_t tx_power; void *user_data;
/* Central supported range */
struct nble_gap_connection_params central_conn_params;
}; };
/** struct nble_set_bda_rsp {
* Advertisement parameters. nble_set_bda_cb_t cb;
*/ void *user_data;
int status;
};
/* Complete encoded eir data structure */
struct bt_eir_data { struct bt_eir_data {
uint8_t len; uint8_t len;
uint8_t data[31]; uint8_t data[31];
@ -214,14 +204,20 @@ struct bt_eir_data {
struct nble_gap_adv_params { struct nble_gap_adv_params {
uint16_t timeout; uint16_t timeout;
uint16_t interval_min; /**< min interval 0xffff: use default 0x0800 */ /* min interval 0xffff: use default 0x0800 */
uint16_t interval_max; /**< max interval 0xffff: use default 0x0800 */ uint16_t interval_min;
uint8_t type; /**< advertisement types @ref GAP_ADV_TYPES */ /* max interval 0xffff: use default 0x0800 */
uint8_t filter_policy; /**< filter policy to apply with white list */ uint16_t interval_max;
/**< bd address of peer device in case of directed advertisement */ /* 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 */
bt_addr_le_t peer_bda; bt_addr_le_t peer_bda;
struct bt_eir_data ad; /**< Advertisement data, maybe 0 (length) */ /* Advertisement data, maybe 0 (length) */
struct bt_eir_data sd; /**< Scan response data, maybe 0 (length) */ struct bt_eir_data ad;
/* Scan response data, maybe 0 (length) */
struct bt_eir_data sd;
}; };
struct nble_log_s { struct nble_log_s {
@ -233,8 +229,6 @@ struct nble_log_s {
void nble_log(const struct nble_log_s *p_param, char *p_buf, uint8_t buflen); void nble_log(const struct nble_log_s *p_param, char *p_buf, uint8_t buflen);
void nble_core_delete_conn_params_timer(void);
void on_nble_up(void); void on_nble_up(void);
/** /**
@ -247,7 +241,7 @@ void on_nble_up(void);
* @param user_data User data * @param user_data User data
*/ */
void nble_gap_service_write_req(const struct nble_gap_service_write_params *par, void nble_gap_service_write_req(const struct nble_gap_service_write_params *par,
void *user_data); void *user_data);
/** /**
* Response to @ref nble_gap_read_bda_req. * Response to @ref nble_gap_read_bda_req.
@ -280,22 +274,6 @@ void nble_gap_dbg_req(const struct debug_params *par, void *user_data);
*/ */
void on_nble_gap_dbg_rsp(const struct debug_response *par); void on_nble_gap_dbg_rsp(const struct debug_response *par);
/**
* Set Enable configuration parameters (BD address, etc).
*
* The response to this request is received through
* @ref on_nble_set_enable_config_rsp
*
* This shall put the controller stack into a usable (enabled) state.
* Hence this should be called first!
*
* @param config BLE write configuration
* @param user_data User data
*
*/
void nble_set_enable_config_req(const struct nble_wr_config_params *config,
void *user_data);
/** /**
* Start advertising. * Start advertising.
* *
@ -303,7 +281,6 @@ void nble_set_enable_config_req(const struct nble_wr_config_params *config,
* @ref on_nble_gap_start_advertise_rsp * @ref on_nble_gap_start_advertise_rsp
* *
* @param par Advertisement * @param par Advertisement
* @param p_adv_data Pointer to advertisement and scan response data
*/ */
void nble_gap_start_advertise_req(struct nble_gap_adv_params *par); void nble_gap_start_advertise_req(struct nble_gap_adv_params *par);
@ -345,7 +322,6 @@ struct nble_gap_irk_info {
* Write white list to the BLE controller. * Write white list to the BLE controller.
* *
* The response to this request is received through * The response to this request is received through
* @ref on_nble_gap_wr_white_list_rsp
* *
* Store white in BLE controller. It needs to be done BEFORE starting * Store white in BLE controller. It needs to be done BEFORE starting
* advertisement or start scanning * advertisement or start scanning
@ -360,35 +336,23 @@ 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, struct nble_gap_irk_info *irk_array,
uint8_t irk_array_size, void *priv); uint8_t irk_array_size, void *priv);
/**
* Response to @ref nble_gap_wr_white_list_req.
*
* @param par Response
*/
void on_nble_gap_wr_white_list_rsp(const struct nble_response *par);
/** /**
* Clear previously stored white list. * Clear previously stored white list.
* *
* The response to this request is received through * The response to this request is received through
* @ref on_nble_gap_clr_white_list_rsp
* *
* @param priv Pointer to private data * @param priv Pointer to private data
*/ */
void nble_gap_clr_white_list_req(void *priv); void nble_gap_clr_white_list_req(void *priv);
/**
* Response to @ref nble_gap_clr_white_list_req.
*
* @param par Response
*/
void on_nble_gap_clr_white_list_rsp(const struct nble_response *par);
struct nble_gap_connect_update_params { struct nble_gap_connect_update_params {
uint16_t conn_handle; uint16_t conn_handle;
struct nble_gap_connection_params params; struct nble_gap_connection_params params;
}; };
void on_nble_set_bda_rsp(const struct nble_set_bda_rsp *params);
void nble_set_bda_req(const struct nble_set_bda_params *params);
/** /**
* Update connection. * Update connection.
* *
@ -407,17 +371,8 @@ struct nble_gap_connect_update_params {
* is called. * is called.
* *
* @param par Connection parameters * @param par Connection parameters
* @param user_data User data
*/ */
void nble_gap_conn_update_req(const struct nble_gap_connect_update_params *par, void nble_gap_conn_update_req(const struct nble_gap_connect_update_params *par);
void *user_data);
/**
* Response to @ref nble_gap_conn_update_req.
*
* @param par Response
*/
void on_nble_gap_conn_update_rsp(const struct nble_response *par);
struct nble_gap_connect_req_params { struct nble_gap_connect_req_params {
bt_addr_le_t bda; bt_addr_le_t bda;
@ -426,8 +381,8 @@ struct nble_gap_connect_req_params {
}; };
struct nble_gap_disconnect_req_params { struct nble_gap_disconnect_req_params {
uint16_t conn_handle; /**< Connection handle */ uint16_t conn_handle;
uint8_t reason; /**< Reason of the disconnect */ uint8_t reason;
}; };
/** /**
@ -460,13 +415,6 @@ void on_nble_gap_disconnect_rsp(const struct nble_response *par);
void nble_gap_service_read_req(const struct nble_gap_service_read_params *par, void nble_gap_service_read_req(const struct nble_gap_service_read_params *par,
void *user_data); void *user_data);
/**
* Response to @ref nble_gap_service_read_req.
*
* @param par Response
*/
void on_nble_gap_service_read_rsp(const struct nble_response *par);
/** /**
* Security manager configuration parameters. * Security manager configuration parameters.
* *
@ -474,13 +422,12 @@ void on_nble_gap_service_read_rsp(const struct nble_response *par);
* It is assumed that io_caps and options are compatible. * It is assumed that io_caps and options are compatible.
*/ */
struct nble_gap_sm_config_params { struct nble_gap_sm_config_params {
/**< Sec options (@ref BLE_GAP_SM_OPTIONS) */ /* Security options (@ref BLE_GAP_SM_OPTIONS) */
uint8_t options; uint8_t options;
/**< I/O Capabilities to allow passkey exchange /* I/O Capabilities to allow passkey exchange (@ref BLE_GAP_IO_CAPABILITIES) */
* (@ref BLE_GAP_IO_CAPABILITIES)
*/
uint8_t io_caps; uint8_t io_caps;
uint8_t key_size; /**< Maximum encryption key size (7-16) */ /* Maximum encryption key size (7-16) */
uint8_t key_size;
uint8_t oob_present; uint8_t oob_present;
}; };
@ -495,9 +442,9 @@ struct nble_gap_sm_config_params {
void nble_gap_sm_config_req(const struct nble_gap_sm_config_params *par); void nble_gap_sm_config_req(const struct nble_gap_sm_config_params *par);
struct nble_gap_sm_config_rsp { struct nble_gap_sm_config_rsp {
void *user_data; /**< Pointer to user data structure */ void *user_data;
int status; /**< Result of sec manager initialization */ int status;
uint32_t state; /**< State of bond DB */ bool sm_bond_dev_avail;
}; };
/** /**
@ -507,20 +454,18 @@ struct nble_gap_sm_config_rsp {
*/ */
void on_nble_gap_sm_config_rsp(struct nble_gap_sm_config_rsp *par); void on_nble_gap_sm_config_rsp(struct nble_gap_sm_config_rsp *par);
/**
* Security manager pairing parameters. struct nble_gap_sm_pairing_params {
*/ /* authentication level see @ref BLE_GAP_SM_OPTIONS */
struct nble_core_gap_sm_pairing_params {
/**< authentication level see @ref BLE_GAP_SM_OPTIONS */
uint8_t auth_level; uint8_t auth_level;
}; };
struct nble_gap_sm_security_params { struct nble_gap_sm_security_params {
struct bt_conn *conn; struct bt_conn *conn;
/**< Connection on which bonding procedure is executed */ /* Connection on which bonding procedure is executed */
uint16_t conn_handle; uint16_t conn_handle;
/**< Local authentication/bonding parameters */ /* Local authentication/bonding parameters */
struct nble_core_gap_sm_pairing_params params; struct nble_gap_sm_pairing_params params;
}; };
/** /**
@ -533,29 +478,19 @@ struct nble_gap_sm_security_params {
*/ */
void nble_gap_sm_security_req(const struct nble_gap_sm_security_params *par); void nble_gap_sm_security_req(const struct nble_gap_sm_security_params *par);
/** struct nble_gap_sm_passkey {
* Response to @ref nble_gap_sm_pairing_req.
*
* @param par Response
*/
void on_nble_gap_sm_pairing_rsp(const struct nble_response *par);
/**
* Security reply to incoming security request.
*/
struct nble_core_gap_sm_passkey {
/**< Security data type in this reply @ref BLE_GAP_SM_PASSKEY_TYPE */
uint8_t type; uint8_t type;
union { union {
uint8_t passkey[6]; /**< 6 digits (string) */ uint32_t passkey;
uint8_t oob[16]; /**< 16 bytes of OOB security data */ uint8_t oob[16];
uint8_t reason;
}; };
}; };
struct nble_gap_sm_key_reply_req_params { struct nble_gap_sm_key_reply_req_params {
/**< Connection on which bonding is going on */ struct bt_conn *conn;
uint16_t conn_handle; uint16_t conn_handle;
struct nble_core_gap_sm_passkey params; /**< Bonding security reply */ struct nble_gap_sm_passkey params;
}; };
/** /**
@ -583,13 +518,6 @@ struct nble_gap_sm_clear_bond_req_params {
*/ */
void nble_gap_sm_clear_bonds_req(const struct nble_gap_sm_clear_bond_req_params *par); void nble_gap_sm_clear_bonds_req(const struct nble_gap_sm_clear_bond_req_params *par);
/**
* Response to @ref nble_gap_sm_clear_bonds_req.
*
* @param par Response
*/
void on_nble_gap_sm_clear_bonds_rsp(const struct nble_response *par);
struct nble_gap_sm_response { struct nble_gap_sm_response {
int status; int status;
struct bt_conn *conn; struct bt_conn *conn;
@ -599,10 +527,12 @@ struct nble_gap_sm_response {
* RSSI report parameters * RSSI report parameters
*/ */
struct nble_rssi_report_params { struct nble_rssi_report_params {
uint16_t conn_handle; /**< Connection handle */ uint16_t conn_handle;
uint8_t op; /**< RSSI operation @ref BLE_GAP_RSSI_OPS */ /* RSSI operation @ref BLE_GAP_RSSI_OPS */
uint8_t delta_dBm; /**< minimum RSSI dBm change report new val */ uint8_t op;
/**< number of delta_dBm changes before sending a new RSSI report */ /* 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 */
uint8_t min_count; uint8_t min_count;
}; };
@ -710,17 +640,20 @@ void nble_gap_cancel_connect_req(void *user_data);
void on_nble_gap_cancel_connect_rsp(const struct nble_response *par); void on_nble_gap_cancel_connect_rsp(const struct nble_response *par);
enum BLE_GAP_SET_OPTIONS { enum BLE_GAP_SET_OPTIONS {
BLE_GAP_SET_CH_MAP = 0, /**< Set channel map */ BLE_GAP_SET_CH_MAP = 0,
}; };
struct nble_gap_channel_map { struct nble_gap_channel_map {
uint16_t conn_handle; /**< conn on which to change channel map */ /* connection on which to change channel map */
uint8_t map[5]; /**< 37 bits are used of the 40 bits (LSB) */ uint16_t conn_handle;
/* 37 bits are used of the 40 bits (LSB) */
uint8_t map[5];
}; };
struct nble_gap_set_option_params { struct nble_gap_set_option_params {
uint8_t op; /**< Option to set @ref BLE_GAP_SET_OPTIONS */ /* Option to set @ref BLE_GAP_SET_OPTIONS */
uint8_t op;
union { union {
struct nble_gap_channel_map ch_map; struct nble_gap_channel_map ch_map;
}; };
@ -730,7 +663,6 @@ struct nble_gap_set_option_params {
* Set a gap option (channel map etc) on a connection. * Set a gap option (channel map etc) on a connection.
* *
* The response to this request is received through * The response to this request is received through
* @ref on_nble_gap_set_option_rsp
* *
* @param par Contains gap options parameters * @param par Contains gap options parameters
* @param user_data Pointer to user data * @param user_data Pointer to user data
@ -738,23 +670,19 @@ struct nble_gap_set_option_params {
void nble_gap_set_option_req(const struct nble_gap_set_option_params *par, void nble_gap_set_option_req(const struct nble_gap_set_option_params *par,
void *user_data); void *user_data);
/** /*
* Response to @ref nble_gap_set_option_req. * Generic request op codes.
*
* @param par Response
*/
void on_nble_gap_set_option_rsp(const struct nble_response *par);
/** Generic request op codes.
* This allows to access some non connection related commands like DTM. * This allows to access some non connection related commands like DTM.
*/ */
enum BLE_GAP_GEN_OPS { enum BLE_GAP_GEN_OPS {
DUMMY_VALUE = 0, /**< Not used now. */ /* Not used now. */
DUMMY_VALUE = 0,
}; };
/** Generic command parameters. */ /** Generic command parameters. */
struct nble_gap_gen_cmd_params { struct nble_gap_gen_cmd_params {
uint8_t op_code; /**< @ref BLE_GAP_GEN_OPS */ /* @ref BLE_GAP_GEN_OPS */
uint8_t op_code;
}; };
/** /**
@ -787,7 +715,7 @@ void nble_get_version_req(void *user_data);
struct nble_version_response { struct nble_version_response {
struct version_header version; struct version_header version;
void *user_data; /**< Pointer to response data structure */ void *user_data;
}; };
/** /**
@ -810,7 +738,9 @@ void nble_gap_dtm_init_req(void *user_data);
struct nble_gap_connect_evt { struct nble_gap_connect_evt {
uint16_t conn_handle; uint16_t conn_handle;
struct nble_gap_connection_values conn_values; struct nble_gap_connection_values conn_values;
uint8_t role; /* 0 if connected as master, otherwise as slave */
uint8_t role_slave;
/* Address of peer device */
bt_addr_le_t peer_bda; bt_addr_le_t peer_bda;
}; };
@ -822,8 +752,8 @@ struct nble_gap_connect_evt {
void on_nble_gap_connect_evt(const struct nble_gap_connect_evt *ev); void on_nble_gap_connect_evt(const struct nble_gap_connect_evt *ev);
struct nble_gap_disconnect_evt { struct nble_gap_disconnect_evt {
uint16_t conn_handle; /**< Connection handle */ uint16_t conn_handle;
uint8_t hci_reason; /**< HCI disconnect reason */ uint8_t hci_reason;
}; };
/** /**
@ -855,9 +785,17 @@ struct nble_gap_adv_report_evt {
uint8_t adv_type; uint8_t adv_type;
}; };
struct nble_gap_dir_adv_timeout_evt {
uint16_t conn_handle;
uint16_t error;
};
void on_nble_gap_dir_adv_timeout_evt(const struct nble_gap_dir_adv_timeout_evt *evt);
struct nble_gap_rssi_evt { struct nble_gap_rssi_evt {
uint16_t conn_handle; /**< Connection handle */ uint16_t conn_handle;
int8_t rssi_lvl; /**< RSSI level (compared to 0 dBm) */ /* RSSI level (compared to 0 dBm) */
int8_t rssi_lvl;
}; };
/** /**
@ -867,22 +805,8 @@ struct nble_gap_rssi_evt {
*/ */
void on_nble_gap_rssi_evt(const struct nble_gap_rssi_evt *ev); void on_nble_gap_rssi_evt(const struct nble_gap_rssi_evt *ev);
struct nble_gap_timout_evt {
uint16_t conn_handle; /**< Connection handle */
/**< reason for timeout @ref BLE_SVC_GAP_TIMEOUT_REASON */
int reason;
};
/**
* Function invoked by the BLE service upon timeout event.
*
* @param ev Pointer to the event structure.
*/
void on_nble_gap_to_evt(const struct nble_gap_timout_evt *ev);
struct nble_gap_sm_passkey_req_evt { struct nble_gap_sm_passkey_req_evt {
uint16_t conn_handle; /**< Connection handle */ uint16_t conn_handle;
/**< Passkey or OBB data see @ref BLE_GAP_SM_PASSKEY_TYPE */
uint8_t key_type; uint8_t key_type;
}; };
@ -895,23 +819,22 @@ struct nble_gap_sm_passkey_req_evt {
void on_nble_gap_sm_passkey_req_evt(const struct nble_gap_sm_passkey_req_evt *); void on_nble_gap_sm_passkey_req_evt(const struct nble_gap_sm_passkey_req_evt *);
struct nble_gap_sm_passkey_disp_evt { struct nble_gap_sm_passkey_disp_evt {
uint16_t conn_handle; /**< Connection handle */ uint16_t conn_handle;
uint8_t passkey[BLE_PASSKEY_LEN]; /**< Passkey to be displayed */ uint32_t passkey;
}; };
/** void on_nble_gap_sm_passkey_display_evt(const struct nble_gap_sm_passkey_disp_evt *evt);
* Function invoked by the BLE service upon security manager display event.
* struct nble_link_sec {
* @param ev Pointer to the event structure. bt_security_t sec_level;
*/ uint8_t enc_size;
void on_nble_gap_sm_passkey_display_evt(const struct nble_gap_sm_passkey_disp_evt *ev); };
struct nble_gap_sm_status_evt { struct nble_gap_sm_status_evt {
uint16_t conn_handle; /**< Connection handle */ uint16_t conn_handle;
/**< Security manager status @ref BLE_GAP_SM_STATUS */ uint8_t evt_type;
uint8_t status; int status;
/**< Result of SM procedure, non-null indicates failure */ struct nble_link_sec enc_link_sec;
uint8_t gap_status;
}; };
/** /**
@ -921,25 +844,6 @@ struct nble_gap_sm_status_evt {
*/ */
void on_nble_gap_sm_status_evt(const struct nble_gap_sm_status_evt *ev); void on_nble_gap_sm_status_evt(const struct nble_gap_sm_status_evt *ev);
/**
* Response to @ref nble_set_enable_config_req.
*
* @param par Response
*/
void on_ble_set_enable_config_rsp(const struct nble_response *par);
/**
* Get the list of bonded devices
*
* @param user_data User Data
*/
void nble_get_bonded_device_list_req(void *user_data);
/**@brief Structure containing list of bonded devices. */
struct nble_core_bonded_devices {
uint8_t addr_count; /**< Count of device addr in array. */
};
struct nble_gap_sm_bond_info; struct nble_gap_sm_bond_info;
typedef void (*ble_bond_info_cb_t)(const struct nble_gap_sm_bond_info *info, typedef void (*ble_bond_info_cb_t)(const struct nble_gap_sm_bond_info *info,

View file

@ -360,7 +360,7 @@ ssize_t bt_gatt_attr_read_cpf(struct bt_conn *conn,
int bt_gatt_notify(struct bt_conn *conn, const struct bt_gatt_attr *attr, int bt_gatt_notify(struct bt_conn *conn, const struct bt_gatt_attr *attr,
const void *data, uint16_t len) const void *data, uint16_t len)
{ {
struct nble_gatt_send_notif_ind_params notif; struct nble_gatt_send_notif_params notif;
if (conn) { if (conn) {
notif.conn_handle = conn->handle; notif.conn_handle = conn->handle;
@ -419,7 +419,7 @@ int bt_gatt_discover(struct bt_conn *conn,
conn->gatt_discover = params; conn->gatt_discover = params;
nble_gattc_discover_req(&discover_params, NULL); nble_gattc_discover_req(&discover_params);
break; break;
default: default:
BT_ERR("Unknown params type %u", params->type); BT_ERR("Unknown params type %u", params->type);
@ -562,7 +562,7 @@ static uint16_t parse_descriptor(struct bt_conn *conn, const uint8_t *data,
} }
void on_nble_gattc_discover_rsp(const struct nble_gattc_disc_rsp *rsp, void on_nble_gattc_discover_rsp(const struct nble_gattc_discover_rsp *rsp,
const uint8_t *data, uint8_t data_len) const uint8_t *data, uint8_t data_len)
{ {
uint16_t end_handle = 0; uint16_t end_handle = 0;

View file

@ -47,74 +47,48 @@ enum BLE_GATT_IND_TYPES {
/** GATT Register structure for one service */ /** GATT Register structure for one service */
struct nble_gatt_register_req { struct nble_gatt_register_req {
/**< Base address of the attribute table in the Quark mem space */ /* Base address of the attribute table in the Quark mem space */
struct bt_gatt_attr *attr_base; struct bt_gatt_attr *attr_base;
uint8_t attr_count; /**< Number of of attributes in this service */ /* Number of of attributes in this service */
uint8_t attr_count;
}; };
/** GATT Register structure for one service */ /** GATT Register structure for one service */
struct nble_gatt_register_rsp { struct nble_gatt_register_rsp {
int status; /**< Status of the registration op */ int status;
struct bt_gatt_attr *attr_base; /**< Pointer to the registered table */ struct bt_gatt_attr *attr_base;
uint8_t attr_count; /**< Number of attributes added */ /* Number of attributes successfully added */
}; uint8_t attr_count;
/** Service index and Attribute index mapping structure.
*
* Mapping index into attribute tables as registered with bt_gatt_register/
* nble_gatt_register.
*/
struct nble_gatt_attr_handle_mapping {
uint8_t svc_idx; /**< Service index */
uint8_t attr_idx; /**< Attribute index into service attribute table */
};
enum BLE_GATTS_WR_OPS {
BLE_GATTS_OP_NONE = 0,
/**< 3.4.5.1 Write Request (Attribute), expects write response */
BLE_GATTS_OP_WR,
/**< 3.4.5.3 Write Command (Attribute) NO response sent */
BLE_GATTS_OP_WR_CMD,
/**< 3.4.5.4 Write Command Signed (Attribute), NO response sent */
BLE_GATTS_OP_WR_CMD_SIGNED,
/**< 3.4.6.1 Write Prepare Request, expects a prepare write request
* response
*/
BLE_GATTS_OP_WR_PREP_REQ,
/**< 3.4.6.3 Cancel Executed Write Request, cancel and clear queue
* (flags = 0)
*/
BLE_GATTS_OP_WR_EXE_REQ_CANCEL,
/**< 3.4.6.3 Immediately Execute Write Request */
BLE_GATTS_OP_WR_EXE_REQ_IMM
}; };
/** /**
* Write event context data structure. * Write event context data structure.
*/ */
struct nble_gatt_wr_evt { struct nble_gatt_wr_evt {
struct bt_gatt_attr *attr; /**< GATT Attribute */ struct bt_gatt_attr *attr;
uint16_t conn_handle; /**< Connection handle */ uint16_t conn_handle;
uint16_t attr_handle; /**< handle of attribute to write */ uint16_t attr_handle;
uint16_t offset; /**< offset in attribute buffer */ uint16_t offset;
uint8_t reply; /**< 1 if reply required, 0 otherwise */ /* 1 if reply required, 0 otherwise */
uint8_t reply;
}; };
/** /**
* Read event context data structure. * Read event context data structure.
*/ */
struct nble_gatt_rd_evt { struct nble_gatt_rd_evt {
struct bt_gatt_attr *attr; /**< GATT Attribute */ struct bt_gatt_attr *attr;
uint16_t conn_handle; /**< Connection handle */ uint16_t conn_handle;
uint16_t attr_handle; /**< handle of attribute to write */ uint16_t attr_handle;
uint16_t offset; /**< offset in attribute buffer */ uint16_t offset;
}; };
struct nble_gatts_rw_reply_params { struct nble_gatts_rw_reply_params {
int status; /**< Reply status, from errno */ int status;
uint16_t conn_handle; /**< Connection handle */ uint16_t conn_handle;
uint16_t offset; /**< Offset in attribute buffer */ uint16_t offset;
uint8_t write_reply; /**< 0 if read reply, otherwise rsp */ /* 0 if read reply, otherwise write reply */
uint8_t write_reply;
}; };
/** /**
@ -129,19 +103,29 @@ struct nble_gatt_notif_ind_params {
* Indication or notification. * Indication or notification.
*/ */
struct nble_gatt_send_notif_ind_params { struct nble_gatt_send_notif_params {
void *cback; /* Function to be invoked when buffer is freed */
bt_gatt_notify_func_t cback;
uint16_t conn_handle; uint16_t conn_handle;
struct nble_gatt_notif_ind_params params; struct nble_gatt_notif_ind_params params;
}; };
enum nble_gatts_notif_ind_type { struct nble_gatt_notif_rsp {
MSG_ID_BLE_GATTS_SEND_NOTIF_RSP, /**< Notification type */ bt_gatt_notify_func_t cback;
MSG_ID_BLE_GATTS_SEND_IND_RSP, /**< Indication type */ int status;
uint16_t conn_handle;
struct bt_gatt_attr *attr;
}; };
struct nble_gatt_notif_ind_rsp { struct nble_gatt_send_ind_params {
bt_gatt_notify_func_t cback; /* Function to be invoked when buffer is freed */
bt_gatt_indicate_func_t cback;
uint16_t conn_handle;
struct nble_gatt_notif_ind_params params;
};
struct nble_gatt_ind_rsp {
bt_gatt_indicate_func_t cback;
int status; int status;
uint16_t conn_handle; uint16_t conn_handle;
struct bt_gatt_attr *attr; struct bt_gatt_attr *attr;
@ -155,23 +139,6 @@ struct nble_gatt_handle_range {
uint16_t end_handle; uint16_t end_handle;
}; };
/**
* Primary service
*/
struct nble_gattc_prim_svc {
uint16_t handle; /**< Attribute handle */
struct nble_gatt_handle_range handle_range; /**< handle range */
struct bt_uuid_128 uuid; /**< Attribute's UUID */
};
/**
* Generic GATTC response message.
*/
struct nble_gattc_rsp {
int status;
uint16_t conn_handle;
};
struct nble_gattc_primary { struct nble_gattc_primary {
uint16_t handle; uint16_t handle;
struct nble_gatt_handle_range range; struct nble_gatt_handle_range range;
@ -184,111 +151,29 @@ struct nble_gattc_included {
struct bt_uuid_128 uuid; struct bt_uuid_128 uuid;
}; };
struct nble_gattc_disc_rsp {
int status;
uint16_t conn_handle;
uint8_t type; /**< @ref BLE_GATT_DISC_TYPES */
};
struct nble_gattc_evt {
uint16_t conn_handle;
int status;
};
/**
* Included service.
*/
struct nble_gattc_incl_svc {
uint16_t handle; /**< Handle of included svc */
struct nble_gatt_handle_range handle_range; /**< handle range */
struct bt_uuid_128 uuid; /**< Service UUID */
};
/* GATTC characteristic */ /* GATTC characteristic */
struct nble_gattc_characteristic { struct nble_gattc_characteristic {
uint16_t handle; /**< Characteristic Definition handle */ uint16_t handle;
uint8_t prop; /**< Characteristic property */ uint8_t prop;
uint16_t value_handle; /**< Characteristic value handle */ uint16_t value_handle;
struct bt_uuid_128 uuid; /**< Characteristic UUID */ struct bt_uuid_128 uuid;
}; };
/** /**
* GATTC descriptor. * GATTC descriptor.
*/ */
struct nble_gattc_descriptor { struct nble_gattc_descriptor {
uint16_t handle; /**< descriptor handle */ uint16_t handle;
struct bt_uuid_128 uuid; /**< uuid of the descriptor */ struct bt_uuid_128 uuid;
}; };
struct nble_gattc_attr { struct nble_gattc_discover_rsp {
uint8_t type; /**< @ref BLE_GATT_DISC_TYPES */ int status;
union { void *user_data;
struct nble_gattc_prim_svc prim; uint16_t conn_handle;
struct nble_gattc_incl_svc incls; uint8_t type;
struct nble_gattc_characteristic chars;
struct nble_gattc_descriptor desc;
};
}; };
struct nble_gatts_set_attribute_params {
uint16_t value_handle; /* mandatory */
uint16_t offset; /* by default 0 */
};
struct nble_gatts_get_attribute_params {
uint16_t value_handle; /* mandatory */
};
struct nble_gatts_attribute_rsp {
int status; /**< Status of the operation. */
uint16_t value_handle; /* mandatory */
void *priv;
};
/**
* Set an attribute value.
*
* The response to this request is received through @ref
* on_ble_gatts_send_svc_changed_rsp
*
* @param par Attribute parameters
* @param data Attribute value data to write
* @param len Length of attribute value to write
* @param priv Pointer to private data
*/
void nble_gatts_set_attribute_value_req(const struct nble_gatts_set_attribute_params *par,
uint8_t *data, uint8_t len, void *priv);
/**
* Response to @ref nble_gatts_send_svc_changed_req.
*
* @param rsp Response
*/
void on_ble_gatts_set_attribute_value_rsp(const struct nble_gatts_attribute_rsp *rsp);
/**
* Get an attribute value.
*
* The response to this request is received through @ref
* on_ble_gatts_get_attribute_value_rsp
*
* @param par Getting attribute parameters
* @param priv Pointer to private data
*/
void nble_gatts_get_attribute_value_req(const struct nble_gatts_get_attribute_params *par,
void *priv);
/**
* Response to @ref nble_gatts_get_attribute_value_req.
*
* @param rsp Response
* @param data Attribute value
* @param length Length of attribute value
*/
void on_ble_gatts_get_attribute_value_rsp(const struct nble_gatts_attribute_rsp *rsp,
uint8_t *data, uint8_t length);
struct nble_gatts_svc_changed_params { struct nble_gatts_svc_changed_params {
uint16_t conn_handle; uint16_t conn_handle;
uint16_t start_handle; uint16_t start_handle;
@ -309,13 +194,6 @@ struct nble_gatts_svc_changed_params {
void nble_gatts_send_svc_changed_req(const struct nble_gatts_svc_changed_params *par, void nble_gatts_send_svc_changed_req(const struct nble_gatts_svc_changed_params *par,
void *priv); void *priv);
/**
* Response to @ref nble_gatts_send_svc_changed_req.
*
* @param par Response
*/
void on_ble_gatts_send_svc_changed_rsp(const struct nble_core_response *par);
/** Register a BLE GATT Service. /** Register a BLE GATT Service.
* *
* @param par Parameters of attribute data base * @param par Parameters of attribute data base
@ -364,61 +242,41 @@ void on_nble_gatt_register_rsp(const struct nble_gatt_register_rsp *par,
* @param buf Pointer to data buffer * @param buf Pointer to data buffer
* @param len Buffer length * @param len Buffer length
*/ */
void on_ble_gatts_write_evt(const struct nble_gatt_wr_evt *ev, void on_nble_gatts_write_evt(const struct nble_gatt_wr_evt *ev,
const uint8_t *buf, uint8_t len); const uint8_t *buf, uint8_t len);
/**
* Retrieves handle based on attribute array and index of attribute
*
* @param attrs Attribute array
* @param index Index of attribute
*
* @return Handle of attribute or 0 if not found
*/
uint16_t nble_attr_idx_to_handle(const struct bt_gatt_attr *attrs,
uint8_t index);
/** /**
* Send notification. * Send notification.
* *
* The response to this request is received through @ref * The response to this request is received
* on_ble_gatts_send_notif_ind_rsp
* *
* @param par Notification parameters * @param par Notification parameters
* @param data Indication data to write * @param data Indication data to write
* @param length Length of indication - may be 0, in this case already * @param length Length of indication - may be 0, in this case already
* stored data is sent * stored data is sent
*/ */
void nble_gatt_send_notif_req(const struct nble_gatt_send_notif_ind_params *par, void nble_gatt_send_notif_req(const struct nble_gatt_send_notif_params *par,
uint8_t *data, uint16_t length); uint8_t *data, uint16_t length);
/** /**
* Send indication. * Send indication.
* *
* The response to this request is received through @ref * The response to this request is received
* on_ble_gatts_send_notif_ind_rsp
* *
* @param par Indication parameters * @param par Indication parameters
* @param data Indication data to write * @param data Indication data to write
* @param length Length of indication - may be 0, in this case already * @param length Length of indication - may be 0, in this case already
* stored data is sent * stored data is sent
*/ */
void nble_gatt_send_ind_req(const struct nble_gatt_send_notif_ind_params *par, void nble_gatt_send_ind_req(const struct nble_gatt_send_ind_params *par,
uint8_t *data, uint8_t length); uint8_t *data, uint8_t length);
/**
* Response to @ref nble_gatts_send_ind_req and @ref nble_gatts_send_notif_req
*
* @param par Response
*/
void on_ble_gatts_send_notif_ind_rsp(const struct nble_gatt_notif_ind_rsp *par);
/** Discover parameters. */ /** Discover parameters. */
struct nble_discover_params { struct nble_discover_params {
struct bt_uuid_128 uuid; /**< Attribute UUID */ void *user_data;
struct nble_gatt_handle_range handle_range; /**< Discover range */ struct bt_uuid_128 uuid;
uint16_t conn_handle; /**< Connection handl */ struct nble_gatt_handle_range handle_range;
/**< Discover type @ref BLE_GATT_DISC_TYPES */ uint16_t conn_handle;
uint8_t type; uint8_t type;
}; };
@ -426,21 +284,8 @@ struct nble_discover_params {
* Discover service. * Discover service.
* *
* @param req Request structure. * @param req Request structure.
* @param user_data Pointer to private data.
*/ */
void nble_gattc_discover_req(const struct nble_discover_params *req, void nble_gattc_discover_req(const struct nble_discover_params *req);
void *user_data);
/**
* Response to @ref nble_gattc_discover_req.
*
* @param rsp Response
* @param data Pointer to the data
* @param len Length of the data
*/
void on_ble_gattc_discover_rsp(const struct nble_gattc_disc_rsp *rsp,
const uint8_t *data, uint8_t len);
/** GATT Attribute stream structure. /** GATT Attribute stream structure.
* *
@ -461,29 +306,30 @@ struct nble_gatt_attr {
}; };
struct nble_gattc_read_params { struct nble_gattc_read_params {
uint16_t conn_handle; /**< Connection handle*/ uint16_t conn_handle;
uint16_t char_handle; /**< Handle of the attribute to be read */ uint16_t handle;
uint16_t offset; /**< Offset into the attr value to be read */ uint16_t offset;
}; };
struct nble_gattc_read_rsp { struct nble_gattc_read_rsp {
uint16_t conn_handle; uint16_t conn_handle;
int status; int status;
uint16_t handle; /**< handle of char attr read */ uint16_t handle;
uint16_t offset; /**< offset of data returned */ uint16_t offset;
}; };
struct nble_gattc_write_params { struct nble_gattc_write_params {
uint16_t conn_handle; /**< Connection handle*/ uint16_t conn_handle;
uint16_t char_handle; /**< Handle of the attribute to be read */ uint16_t handle;
uint16_t offset; /**< Offset into the attr value to be write */ uint16_t offset;
bool with_resp; /**< Equal to true is response is needed */ /* different than 0 if response required */
uint8_t with_resp;
}; };
struct nble_gattc_write_rsp { struct nble_gattc_write_rsp {
uint16_t conn_handle; uint16_t conn_handle;
int status; int status;
uint16_t char_handle; uint16_t handle;
uint16_t len; uint16_t len;
}; };
@ -497,17 +343,6 @@ struct nble_gattc_write_rsp {
void nble_gattc_read_req(const struct nble_gattc_read_params *params, void nble_gattc_read_req(const struct nble_gattc_read_params *params,
void *priv); void *priv);
/**
* Response to @ref nble_gattc_read_req.
*
* @param ev Pointer to the event structure
* @param data Pointer to the data byte stream
* @param data_len Length of the data byte stream
* @param priv Pointer to private data.
*/
void on_ble_gattc_read_rsp(const struct nble_gattc_read_rsp *ev,
uint8_t *data, uint8_t data_len, void *priv);
/** /**
* Write characteristic on server. * Write characteristic on server.
* *
@ -520,47 +355,9 @@ void on_ble_gattc_read_rsp(const struct nble_gattc_read_rsp *ev,
void nble_gattc_write_req(const struct nble_gattc_write_params *params, void nble_gattc_write_req(const struct nble_gattc_write_params *params,
const uint8_t *buf, uint8_t len, void *priv); const uint8_t *buf, uint8_t len, void *priv);
/**
* Response to @ref nble_gattc_write_req.
*
* @param ev Pointer to the event structure
* @param priv Pointer to private data.
*/
void on_ble_gattc_write_rsp(const struct nble_gattc_write_rsp *ev,
void *priv);
#if defined(CONFIG_BLUETOOTH_GATT_CLIENT)
void bt_gatt_connected(struct bt_conn *conn);
void bt_gatt_disconnected(struct bt_conn *conn);
#endif
struct nble_gattc_value_evt { struct nble_gattc_value_evt {
uint16_t conn_handle; uint16_t conn_handle;
int status; int status;
/**< handle of characteristic being notified/indicated */
uint16_t handle; uint16_t handle;
/**< notification versus indication, @ref BLE_GATT_IND_TYPES */
uint8_t type; uint8_t type;
}; };
/**
* Function invoked by BLE service for value event
*
* @param ev Pointer to the event structure
* @param buf Pointer to the data byte stream
* @param len Length of the data byte stream
*/
void on_ble_gattc_value_evt(const struct nble_gattc_value_evt *ev,
uint8_t *buf, uint8_t len);
struct nble_gattc_to_evt {
uint16_t conn_handle;
uint16_t reason; /**< GATT timeout reason */
};
/**
* Function invoked by BLE service for gattc timeout protocol error
*
* @param ev Pointer to the event structure
*/
void on_ble_gattc_to_evt(const struct nble_gattc_to_evt *ev);

View file

@ -17,6 +17,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
/* for bt_security_t */
#include <bluetooth/conn.h>
#include <bluetooth/log.h> #include <bluetooth/log.h>
#ifdef CONFIG_PRINTK #ifdef CONFIG_PRINTK

View file

@ -32,7 +32,12 @@
FN_SIG_S(nble_gap_sm_security_req, \ FN_SIG_S(nble_gap_sm_security_req, \
const struct nble_gap_sm_security_params *) \ const struct nble_gap_sm_security_params *) \
FN_SIG_S(nble_gap_sm_clear_bonds_req, \ FN_SIG_S(nble_gap_sm_clear_bonds_req, \
const struct nble_gap_sm_clear_bond_req_params *) const struct nble_gap_sm_clear_bond_req_params *) \
FN_SIG_S(nble_set_bda_req, const struct nble_set_bda_params *) \
FN_SIG_S(nble_gap_conn_update_req, \
const struct nble_gap_connect_update_params *) \
FN_SIG_S(nble_gattc_discover_req, \
const struct nble_discover_params *)
#define LIST_FN_SIG_P \ #define LIST_FN_SIG_P \
FN_SIG_P(nble_get_version_req, void *) \ FN_SIG_P(nble_get_version_req, void *) \
@ -47,10 +52,10 @@
const struct nble_gatt_register_req *, \ const struct nble_gatt_register_req *, \
uint8_t *, uint16_t) \ uint8_t *, uint16_t) \
FN_SIG_S_B(nble_gatt_send_notif_req, \ FN_SIG_S_B(nble_gatt_send_notif_req, \
const struct nble_gatt_send_notif_ind_params *, \ const struct nble_gatt_send_notif_params *, \
uint8_t *, uint16_t) \ uint8_t *, uint16_t) \
FN_SIG_S_B(nble_gatt_send_ind_req, \ FN_SIG_S_B(nble_gatt_send_ind_req, \
const struct nble_gatt_send_notif_ind_params *, \ const struct nble_gatt_send_ind_params *, \
uint8_t *, uint8_t) \ uint8_t *, uint8_t) \
FN_SIG_S_B(nble_gatts_authorize_reply_req, \ FN_SIG_S_B(nble_gatts_authorize_reply_req, \
const struct nble_gatts_rw_reply_params *, \ const struct nble_gatts_rw_reply_params *, \
@ -71,28 +76,18 @@
const struct nble_gap_gen_cmd_params *, void *) \ const struct nble_gap_gen_cmd_params *, void *) \
FN_SIG_S_P(nble_gap_set_option_req, \ FN_SIG_S_P(nble_gap_set_option_req, \
const struct nble_gap_set_option_params *, void *) \ const struct nble_gap_set_option_params *, void *) \
FN_SIG_S_P(nble_gap_conn_update_req, \
const struct nble_gap_connect_update_params *, \
void *) \
FN_SIG_S_P(nble_gap_service_read_req, \ FN_SIG_S_P(nble_gap_service_read_req, \
const struct nble_gap_service_read_params *, void *) \ const struct nble_gap_service_read_params *, void *) \
FN_SIG_S_P(nble_set_enable_config_req, \
const struct nble_wr_config_params *, void *) \
FN_SIG_S_P(nble_gap_set_rssi_report_req, \ FN_SIG_S_P(nble_gap_set_rssi_report_req, \
const struct nble_rssi_report_params *, void *) \ const struct nble_rssi_report_params *, void *) \
FN_SIG_S_P(nble_gap_service_write_req, \ FN_SIG_S_P(nble_gap_service_write_req, \
const struct nble_gap_service_write_params *, void *)\ const struct nble_gap_service_write_params *, void *)\
FN_SIG_S_P(nble_gap_dbg_req, const struct debug_params *, \ FN_SIG_S_P(nble_gap_dbg_req, const struct debug_params *, \
void *) \ void *) \
FN_SIG_S_P(nble_gattc_discover_req, \
const struct nble_discover_params *, void *) \
FN_SIG_S_P(nble_gattc_read_req, \ FN_SIG_S_P(nble_gattc_read_req, \
const struct nble_gattc_read_params *, void *) \ const struct nble_gattc_read_params *, void *) \
FN_SIG_S_P(nble_gatts_send_svc_changed_req, \ FN_SIG_S_P(nble_gatts_send_svc_changed_req, \
const struct nble_gatts_svc_changed_params *, void *)\ const struct nble_gatts_svc_changed_params *, void *)
FN_SIG_S_P(nble_gatts_get_attribute_value_req, \
const struct nble_gatts_get_attribute_params *, \
void *)
#define LIST_FN_SIG_S_B_P \ #define LIST_FN_SIG_S_B_P \
FN_SIG_S_B_P(nble_gattc_write_req, \ FN_SIG_S_B_P(nble_gattc_write_req, \

View file

@ -33,8 +33,6 @@
const struct nble_gap_sm_passkey_disp_evt *) \ const struct nble_gap_sm_passkey_disp_evt *) \
FN_SIG_S(on_nble_gap_sm_passkey_req_evt, \ FN_SIG_S(on_nble_gap_sm_passkey_req_evt, \
const struct nble_gap_sm_passkey_req_evt *) \ const struct nble_gap_sm_passkey_req_evt *) \
FN_SIG_S(on_nble_gap_to_evt, \
const struct nble_gap_timout_evt *) \
FN_SIG_S(on_nble_gap_rssi_evt, \ FN_SIG_S(on_nble_gap_rssi_evt, \
const struct nble_gap_rssi_evt *) \ const struct nble_gap_rssi_evt *) \
FN_SIG_S(on_nble_common_rsp, \ FN_SIG_S(on_nble_common_rsp, \
@ -51,22 +49,24 @@
struct nble_gap_sm_config_rsp *) \ struct nble_gap_sm_config_rsp *) \
FN_SIG_S(on_nble_gap_generic_cmd_rsp, \ FN_SIG_S(on_nble_gap_generic_cmd_rsp, \
const struct nble_response *) \ const struct nble_response *) \
FN_SIG_S(on_nble_gap_conn_update_rsp, \
const struct nble_response *) \
FN_SIG_S(on_nble_gap_sm_common_rsp, \ FN_SIG_S(on_nble_gap_sm_common_rsp, \
const struct nble_gap_sm_response *) \ const struct nble_gap_sm_response *) \
FN_SIG_S(on_nble_gap_service_write_rsp, \ FN_SIG_S(on_nble_gap_service_write_rsp, \
const struct nble_service_write_response *) \ const struct nble_service_write_response *) \
FN_SIG_S(on_nble_set_enable_config_rsp, \ FN_SIG_S(on_nble_set_bda_rsp, \
const struct nble_response *) \ const struct nble_set_bda_rsp *) \
FN_SIG_S(on_nble_gap_set_rssi_report_rsp, \ FN_SIG_S(on_nble_gap_set_rssi_report_rsp, \
const struct nble_response *) \ const struct nble_response *) \
FN_SIG_S(on_nble_gap_dbg_rsp, \ FN_SIG_S(on_nble_gap_dbg_rsp, \
const struct debug_response *) \ const struct debug_response *) \
FN_SIG_S(on_nble_gatts_send_svc_changed_rsp, \ FN_SIG_S(on_nble_gatts_send_svc_changed_rsp, \
const struct nble_response *) \ const struct nble_response *) \
FN_SIG_S(on_nble_gatts_send_notif_ind_rsp, \ FN_SIG_S(on_nble_gap_dir_adv_timeout_evt, \
const struct nble_gatt_notif_ind_rsp *) \ const struct nble_gap_dir_adv_timeout_evt *) \
FN_SIG_S(on_nble_gatts_send_notif_rsp, \
const struct nble_gatt_notif_rsp *) \
FN_SIG_S(on_nble_gatts_send_ind_rsp, \
const struct nble_gatt_ind_rsp *) \
FN_SIG_S(on_nble_gap_start_advertise_rsp, \ FN_SIG_S(on_nble_gap_start_advertise_rsp, \
const struct nble_response *) \ const struct nble_response *) \
FN_SIG_S(on_nble_gap_stop_advertise_rsp, \ FN_SIG_S(on_nble_gap_stop_advertise_rsp, \
@ -88,15 +88,12 @@
FN_SIG_S_B(on_nble_gatts_write_evt, \ FN_SIG_S_B(on_nble_gatts_write_evt, \
const struct nble_gatt_wr_evt *, \ const struct nble_gatt_wr_evt *, \
const uint8_t *, uint8_t) \ const uint8_t *, uint8_t) \
FN_SIG_S_B(on_nble_gatts_get_attribute_value_rsp, \
const struct nble_gatts_attribute_rsp *, \
uint8_t *, uint8_t) \
FN_SIG_S_B(on_nble_gatt_register_rsp, \ FN_SIG_S_B(on_nble_gatt_register_rsp, \
const struct nble_gatt_register_rsp *, \ const struct nble_gatt_register_rsp *, \
const struct nble_gatt_attr_handles *, \ const struct nble_gatt_attr_handles *, \
uint8_t) \ uint8_t) \
FN_SIG_S_B(on_nble_gattc_discover_rsp, \ FN_SIG_S_B(on_nble_gattc_discover_rsp, \
const struct nble_gattc_disc_rsp *, \ const struct nble_gattc_discover_rsp *, \
const uint8_t *, uint8_t) \ const uint8_t *, uint8_t) \
FN_SIG_S_B(on_nble_gap_adv_report_evt, \ FN_SIG_S_B(on_nble_gap_adv_report_evt, \
const struct nble_gap_adv_report_evt *, \ const struct nble_gap_adv_report_evt *, \

View file

@ -16,6 +16,8 @@
#include <string.h> #include <string.h>
#include <bluetooth/conn.h>
#include "rpc.h" #include "rpc.h"
#include "gap_internal.h" #include "gap_internal.h"

View file

@ -14,6 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include <bluetooth/conn.h>
#include <bluetooth/log.h> #include <bluetooth/log.h>
#include "gap_internal.h" #include "gap_internal.h"