diff --git a/drivers/nble/gap_internal.h b/drivers/nble/gap_internal.h index 6e9a7c567ec..d9a032cb48b 100644 --- a/drivers/nble/gap_internal.h +++ b/drivers/nble/gap_internal.h @@ -702,12 +702,9 @@ struct ble_gap_cancel_connect_params { * The response to this request is received through * @ref on_ble_gap_cancel_connect_rsp * - * @param par Contains address of device for which the connection shall - * be canceled * @param user_data Pointer to user data */ -void ble_gap_cancel_connect_req(const struct ble_gap_cancel_connect_params *par, - void *priv); +void ble_gap_cancel_connect_req(void *user_data); /** * Response to @ref ble_gap_cancel_connect_req. diff --git a/drivers/nble/gatt.c b/drivers/nble/gatt.c index 049bfbd5619..38c50d71145 100644 --- a/drivers/nble/gatt.c +++ b/drivers/nble/gatt.c @@ -186,16 +186,15 @@ void on_ble_gatts_get_attribute_value_rsp(const struct ble_gatts_attribute_respo BT_DBG(""); } -void on_ble_gatt_register_rsp(const struct ble_gatt_register *par, - const struct ble_gatt_attr_idx_entry *attr, +void on_ble_gatt_register_rsp(const struct ble_gatt_register_rsp *rsp, + const struct ble_gatt_attr_handles *handles, uint8_t len) { BT_DBG(""); } -void on_ble_gattc_discover_rsp(const struct ble_gattc_evt *ev, - const struct ble_gattc_attr *data, - uint8_t data_len) +void on_ble_gattc_discover_rsp(const struct ble_gattc_disc_rsp *rsp, + const uint8_t *data, uint8_t len) { BT_DBG(""); } diff --git a/drivers/nble/gatt_internal.h b/drivers/nble/gatt_internal.h index 451dfab783a..ff5b15a27c9 100644 --- a/drivers/nble/gatt_internal.h +++ b/drivers/nble/gatt_internal.h @@ -46,12 +46,19 @@ enum BLE_GATT_IND_TYPES { }; /** GATT Register structure for one service */ -struct ble_gatt_register { - /**< Index of service data base, used in response to match request */ - uint8_t service_idx; +struct ble_gatt_register_req { + /**< Base address of the attribute table in the Quark mem space */ + struct bt_gatt_attr *attr_base; uint8_t attr_count; /**< Number of of attributes in this service */ }; +/** GATT Register structure for one service */ +struct ble_gatt_register_rsp { + int status; /**< Status of the registration op */ + struct bt_gatt_attr *attr_base; /**< Pointer to the registered table */ + uint8_t attr_count; /**< Number of attributes added */ +}; + /** Service index and Attribute index mapping structure. * * Mapping index into attribute tables as registered with bt_gatt_register/ @@ -94,6 +101,23 @@ struct ble_gatt_wr_evt { uint8_t op; /**< @ref BLE_GATTS_WR_OPS */ }; +/** + * Read event context data structure. + */ +struct nble_gatt_rd_evt { + struct bt_gatt_attr *attr; /**< GATT Attribute */ + uint16_t conn_handle; /**< Connection handle */ + uint16_t attr_handle; /**< handle of attribute to write */ + uint16_t offset; /**< offset in attribute buffer */ +}; + +struct ble_gatts_rw_reply_params { + int status; /**< Reply status, from errno */ + uint16_t conn_handle; /**< Connection handle */ + uint16_t offset; /**< Offset in attribute buffer */ + uint8_t write_reply; /**< 0 if read reply, otherwise rsp */ +}; + /** * Notification/Indication parameters */ @@ -155,7 +179,13 @@ struct ble_gattc_prim_svc { */ struct ble_gattc_rsp { int status; - uint16_t conn_handle; /**< GAP connection handle */ + uint16_t conn_handle; /**< GAP connection handle */ +}; + +struct ble_gattc_disc_rsp { + int status; + uint16_t conn_handle; + uint8_t type; /**< @ref BLE_GATT_DISC_TYPES */ }; struct ble_gattc_evt { @@ -289,7 +319,7 @@ void on_ble_gatts_send_svc_changed_rsp(const struct ble_core_response *par); * @param attr Serialized attribute buffer * @param attr_len Length of buffer */ -void ble_gatt_register_req(const struct ble_gatt_register *par, +void ble_gatt_register_req(const struct ble_gatt_register_req *par, uint8_t *buf, uint16_t len); /** @@ -297,8 +327,8 @@ void ble_gatt_register_req(const struct ble_gatt_register *par, * * This is returned as a table on registering. */ -struct ble_gatt_attr_idx_entry { - uint16_t handle; /* handle from ble contr should be sufficient */ +struct ble_gatt_attr_handles { + uint16_t handle; /* handle from ble controller should be sufficient */ }; /** Response to registering a BLE GATT Service. @@ -308,10 +338,10 @@ struct ble_gatt_attr_idx_entry { * * @param par Parameters of attribute data base * @param attr Returned attributes index list - * @param attr_len Length of buffer + * @param len Length of buffer */ -void on_ble_gatt_register_rsp(const struct ble_gatt_register *par, - const struct ble_gatt_attr_idx_entry *attr, +void on_ble_gatt_register_rsp(const struct ble_gatt_register_rsp *par, + const struct ble_gatt_attr_handles *attr, uint8_t len); /** @@ -390,13 +420,12 @@ void ble_gattc_discover_req(const struct ble_core_discover_params *req, /** * Response to @ref ble_gattc_discover_req. * - * @param ev Pointer to the event structure + * @param rsp Response * @param data Pointer to the data - * @param data_len Length of the data + * @param len Length of the data */ -void on_ble_gattc_discover_rsp(const struct ble_gattc_evt *ev, - const struct ble_gattc_attr *data, - uint8_t data_len); +void on_ble_gattc_discover_rsp(const struct ble_gattc_disc_rsp *rsp, + const uint8_t *data, uint8_t len); /** GATT Attribute stream structure. * diff --git a/drivers/nble/rpc_functions_to_ble_core.h b/drivers/nble/rpc_functions_to_ble_core.h index 520d47db900..ce3a0d34e27 100644 --- a/drivers/nble/rpc_functions_to_ble_core.h +++ b/drivers/nble/rpc_functions_to_ble_core.h @@ -28,18 +28,22 @@ FN_SIG_P(ble_gap_clr_white_list_req, void *) \ FN_SIG_P(ble_gap_stop_scan_req, void *) \ FN_SIG_P(ble_gap_sm_clear_bonds_req, void *) \ + FN_SIG_P(ble_gap_cancel_connect_req, void *) \ FN_SIG_P(ble_get_bonded_device_list_req, void *) #define LIST_FN_SIG_S_B \ FN_SIG_S_B(ble_gatt_register_req, \ - const struct ble_gatt_register *, \ + const struct ble_gatt_register_req *, \ uint8_t *, uint16_t) \ FN_SIG_S_B(ble_gatt_send_notif_req, \ const struct ble_gatt_send_notif_ind_params *, \ uint8_t *, uint16_t) \ FN_SIG_S_B(ble_gatt_send_ind_req, \ const struct ble_gatt_send_notif_ind_params *, \ - uint8_t *, uint8_t) + uint8_t *, uint8_t) \ + FN_SIG_S_B(nble_gatts_rw_authorize_reply_req, \ + const struct ble_gatts_rw_reply_params *, \ + uint8_t *, uint16_t) #define LIST_FN_SIG_B_B_P \ FN_SIG_B_B_P(ble_gap_wr_white_list_req, bt_addr_le_t *, \ @@ -61,8 +65,6 @@ const struct ble_gap_connect_req_params *, void *) \ FN_SIG_S_P(ble_gap_start_scan_req, \ const struct ble_gap_scan_params *, void *) \ - FN_SIG_S_P(ble_gap_cancel_connect_req, \ - const struct ble_gap_cancel_connect_params *, void *)\ FN_SIG_S_P(ble_gap_generic_cmd_req, \ const struct ble_gap_gen_cmd_params *, void *) \ FN_SIG_S_P(ble_gap_set_option_req, \ diff --git a/drivers/nble/rpc_functions_to_quark.h b/drivers/nble/rpc_functions_to_quark.h index c2ade5f2543..3479a1d3c4a 100644 --- a/drivers/nble/rpc_functions_to_quark.h +++ b/drivers/nble/rpc_functions_to_quark.h @@ -37,30 +37,20 @@ const struct ble_gap_timout_evt *) \ FN_SIG_S(on_ble_gap_rssi_evt, \ const struct ble_gap_rssi_evt *) \ - FN_SIG_S(on_ble_gap_service_read_rsp, \ + FN_SIG_S(on_ble_common_rsp, \ + const struct ble_core_response *) \ + FN_SIG_S(on_ble_gap_connect_rsp, \ + const struct ble_core_response *) \ + FN_SIG_S(on_ble_gap_cancel_connect_rsp, \ const struct ble_core_response *) \ FN_SIG_S(on_ble_gap_read_bda_rsp, \ const struct ble_service_read_bda_response *) \ FN_SIG_S(on_ble_gap_disconnect_rsp, \ const struct ble_core_response *) \ - FN_SIG_S(on_ble_gap_sm_pairing_rsp, \ - const struct ble_core_response *) \ FN_SIG_S(on_ble_gap_sm_config_rsp, \ struct ble_gap_sm_config_rsp *) \ - FN_SIG_S(on_ble_gap_clr_white_list_rsp, \ - const struct ble_core_response *) \ FN_SIG_S(on_ble_gap_sm_passkey_reply_rsp, \ const struct ble_core_response *) \ - FN_SIG_S(on_ble_gap_connect_rsp, \ - const struct ble_core_response *) \ - FN_SIG_S(on_ble_gap_start_scan_rsp, \ - const struct ble_core_response *) \ - FN_SIG_S(on_ble_gap_stop_scan_rsp, \ - const struct ble_core_response *) \ - FN_SIG_S(on_ble_gap_cancel_connect_rsp, \ - const struct ble_core_response *) \ - FN_SIG_S(on_ble_gap_set_option_rsp, \ - const struct ble_core_response *) \ FN_SIG_S(on_ble_gap_generic_cmd_rsp, \ const struct ble_core_response *) \ FN_SIG_S(on_ble_gap_conn_update_rsp, \ @@ -73,8 +63,6 @@ const struct ble_core_response *) \ FN_SIG_S(on_ble_gap_set_rssi_report_rsp, \ const struct ble_core_response *) \ - FN_SIG_S(on_ble_gap_wr_white_list_rsp, \ - const struct ble_core_response *) \ FN_SIG_S(on_ble_gap_dbg_rsp, \ const struct debug_response *) \ FN_SIG_S(on_ble_gatts_send_svc_changed_rsp, \ @@ -88,7 +76,9 @@ FN_SIG_S(on_ble_gap_start_advertise_rsp, \ const struct ble_core_response *) \ FN_SIG_S(on_ble_gap_stop_advertise_rsp, \ - const struct ble_core_response *) + const struct ble_core_response *) \ + FN_SIG_S(on_ble_gatts_read_evt, \ + const struct nble_gatt_rd_evt *) #define LIST_FN_SIG_P \ FN_SIG_P(on_ble_gap_dtm_init_rsp, void *) @@ -106,12 +96,12 @@ const struct ble_gatts_attribute_response *, \ uint8_t *, uint8_t) \ FN_SIG_S_B(on_ble_gatt_register_rsp, \ - const struct ble_gatt_register *, \ - const struct ble_gatt_attr_idx_entry *, \ + const struct ble_gatt_register_rsp *, \ + const struct ble_gatt_attr_handles *, \ uint8_t) \ FN_SIG_S_B(on_ble_gattc_discover_rsp, \ - const struct ble_gattc_evt *, \ - const struct ble_gattc_attr *, uint8_t) + const struct ble_gattc_disc_rsp *, \ + const uint8_t *, uint8_t) #define LIST_FN_SIG_B_B_P