Merge "Use references in GATT client/server API (1/3)"
diff --git a/include/hardware/bt_gatt_client.h b/include/hardware/bt_gatt_client.h
index 98d50d5..f0b22c3 100644
--- a/include/hardware/bt_gatt_client.h
+++ b/include/hardware/bt_gatt_client.h
@@ -99,15 +99,14 @@
/** BT-GATT Client callback structure. */
/** Callback invoked in response to register_client */
-typedef void (*register_client_callback)(int status, int client_if,
- bt_uuid_t *app_uuid);
+typedef void (*register_client_callback)(int status, int client_if, const bt_uuid_t& app_uuid);
/** GATT open callback invoked in response to open */
-typedef void (*connect_callback)(int conn_id, int status, int client_if, bt_bdaddr_t* bda);
+typedef void (*connect_callback)(int conn_id, int status, int client_if, const bt_bdaddr_t& bda);
/** Callback invoked in response to close */
typedef void (*disconnect_callback)(int conn_id, int status,
- int client_if, bt_bdaddr_t* bda);
+ int client_if, const bt_bdaddr_t& bda);
/**
* Invoked in response to search_service when the GATT service search
@@ -123,7 +122,7 @@
* Remote device notification callback, invoked when a remote device sends
* a notification or indication that a client has registered for.
*/
-typedef void (*notify_callback)(int conn_id, btgatt_notify_params_t *p_data);
+typedef void (*notify_callback)(int conn_id, const btgatt_notify_params_t& p_data);
/** Reports result of a GATT read operation */
typedef void (*read_characteristic_callback)(int conn_id, int status,
@@ -137,13 +136,13 @@
/** Callback invoked in response to read_descriptor */
typedef void (*read_descriptor_callback)(int conn_id, int status,
- btgatt_read_params_t *p_data);
+ const btgatt_read_params_t& p_data);
/** Callback invoked in response to write_descriptor */
typedef void (*write_descriptor_callback)(int conn_id, int status, uint16_t handle);
/** Callback triggered in response to read_remote_rssi */
-typedef void (*read_remote_rssi_callback)(int client_if, bt_bdaddr_t* bda,
+typedef void (*read_remote_rssi_callback)(int client_if, const bt_bdaddr_t& bda,
int rssi, int status);
/** Callback invoked when the MTU for a given connection changes */
@@ -158,13 +157,13 @@
typedef void (*congestion_callback)(int conn_id, bool congested);
/** GATT get database callback */
-typedef void (*get_gatt_db_callback)(int conn_id, btgatt_db_element_t *db, int count);
+typedef void (*get_gatt_db_callback)(int conn_id, const btgatt_db_element_t* db, int count);
/** GATT services between start_handle and end_handle were removed */
typedef void (*services_removed_callback)(int conn_id, uint16_t start_handle, uint16_t end_handle);
/** GATT services were added */
-typedef void (*services_added_callback)(int conn_id, btgatt_db_element_t *added, int added_count);
+typedef void (*services_added_callback)(int conn_id, const btgatt_db_element_t& added, int added_count);
/** Callback invoked when the PHY for a given connection changes */
typedef void (*phy_updated_callback)(int conn_id, uint8_t tx_phy,
@@ -201,32 +200,32 @@
typedef struct {
/** Registers a GATT client application with the stack */
- bt_status_t (*register_client)( bt_uuid_t *uuid );
+ bt_status_t (*register_client)(const bt_uuid_t& uuid);
/** Unregister a client application from the stack */
- bt_status_t (*unregister_client)(int client_if );
+ bt_status_t (*unregister_client)(int client_if);
/** Create a connection to a remote LE or dual-mode device */
- bt_status_t (*connect)(int client_if, const bt_bdaddr_t *bd_addr,
+ bt_status_t (*connect)(int client_if, const bt_bdaddr_t& bd_addr,
bool is_direct, int transport, int initiating_phys);
/** Disconnect a remote device or cancel a pending connection */
- bt_status_t (*disconnect)( int client_if, const bt_bdaddr_t *bd_addr,
+ bt_status_t (*disconnect)( int client_if, const bt_bdaddr_t& bd_addr,
int conn_id);
/** Clear the attribute cache for a given device */
- bt_status_t (*refresh)( int client_if, const bt_bdaddr_t *bd_addr );
+ bt_status_t (*refresh)( int client_if, const bt_bdaddr_t& bd_addr);
/**
* Enumerate all GATT services on a connected device.
* Optionally, the results can be filtered for a given UUID.
*/
- bt_status_t (*search_service)(int conn_id, bt_uuid_t *filter_uuid );
+ bt_status_t (*search_service)(int conn_id, const bt_uuid_t *filter_uuid);
/**
* Sead "Find service by UUID" request. Used only for PTS tests.
*/
- void (*btif_gattc_discover_service_by_uuid)(int conn_id, bt_uuid_t *uuid);
+ void (*btif_gattc_discover_service_by_uuid)(int conn_id, const bt_uuid_t& uuid);
/** Read a characteristic on a remote device */
bt_status_t (*read_characteristic)(int conn_id, uint16_t handle,
@@ -234,7 +233,7 @@
/** Read a characteristic on a remote device */
bt_status_t (*read_using_characteristic_uuid)(
- int conn_id, bt_uuid_t *uuid, uint16_t s_handle,
+ int conn_id, const bt_uuid_t& uuid, uint16_t s_handle,
uint16_t e_handle, int auth_req);
/** Write a remote characteristic */
@@ -257,23 +256,23 @@
* characteristic
*/
bt_status_t (*register_for_notification)( int client_if,
- const bt_bdaddr_t *bd_addr, uint16_t handle);
+ const bt_bdaddr_t& bd_addr, uint16_t handle);
/** Deregister a previous request for notifications/indications */
bt_status_t (*deregister_for_notification)( int client_if,
- const bt_bdaddr_t *bd_addr, uint16_t handle);
+ const bt_bdaddr_t& bd_addr, uint16_t handle);
/** Request RSSI for a given remote device */
- bt_status_t (*read_remote_rssi)( int client_if, const bt_bdaddr_t *bd_addr);
+ bt_status_t (*read_remote_rssi)(int client_if, const bt_bdaddr_t& bd_addr);
/** Determine the type of the remote device (LE, BR/EDR, Dual-mode) */
- int (*get_device_type)( const bt_bdaddr_t *bd_addr );
+ int (*get_device_type)(const bt_bdaddr_t &bd_addr);
/** Configure the MTU for a given connection */
bt_status_t (*configure_mtu)(int conn_id, int mtu);
/** Request a connection parameter update */
- bt_status_t (*conn_parameter_update)(const bt_bdaddr_t *bd_addr, int min_interval,
+ bt_status_t (*conn_parameter_update)(const bt_bdaddr_t& bd_addr, int min_interval,
int max_interval, int latency, int timeout);
bt_status_t (*set_preferred_phy)(const bt_bdaddr_t& bd_addr, uint8_t tx_phy,
@@ -285,7 +284,7 @@
cb);
/** Test mode interface */
- bt_status_t (*test_command)( int command, btgatt_test_params_t* params);
+ bt_status_t (*test_command)( int command, const btgatt_test_params_t& params);
/** Get gatt db content */
bt_status_t (*get_gatt_db)( int conn_id);
diff --git a/include/hardware/bt_gatt_server.h b/include/hardware/bt_gatt_server.h
index fcc0f30..c24575f 100644
--- a/include/hardware/bt_gatt_server.h
+++ b/include/hardware/bt_gatt_server.h
@@ -46,11 +46,11 @@
/** Callback invoked in response to register_server */
typedef void (*register_server_callback)(int status, int server_if,
- bt_uuid_t *app_uuid);
+ const bt_uuid_t& app_uuid);
/** Callback indicating that a remote device has connected or been disconnected */
typedef void (*connection_callback)(int conn_id, int server_if, int connected,
- bt_bdaddr_t *bda);
+ const bt_bdaddr_t& bda);
/** Callback invoked in response to create_service */
typedef void (*service_added_callback)(int status, int server_if,
@@ -68,20 +68,20 @@
* Callback invoked when a remote device has requested to read a characteristic
* or descriptor. The application must respond by calling send_response
*/
-typedef void (*request_read_callback)(int conn_id, int trans_id, bt_bdaddr_t *bda,
+typedef void (*request_read_callback)(int conn_id, int trans_id, const bt_bdaddr_t& bda,
int attr_handle, int offset, bool is_long);
/**
* Callback invoked when a remote device has requested to write to a
* characteristic or descriptor.
*/
-typedef void (*request_write_callback)(int conn_id, int trans_id, bt_bdaddr_t *bda,
+typedef void (*request_write_callback)(int conn_id, int trans_id, const bt_bdaddr_t& bda,
int attr_handle, int offset, bool need_rsp,
bool is_prep, std::vector<uint8_t> value);
/** Callback invoked when a previously prepared write is to be executed */
typedef void (*request_exec_write_callback)(int conn_id, int trans_id,
- bt_bdaddr_t *bda, int exec_write);
+ const bt_bdaddr_t& bda, int exec_write);
/**
* Callback triggered in response to send_response if the remote device
@@ -135,17 +135,17 @@
/** Represents the standard BT-GATT server interface. */
typedef struct {
/** Registers a GATT server application with the stack */
- bt_status_t (*register_server)( bt_uuid_t *uuid );
+ bt_status_t (*register_server)(const bt_uuid_t& uuid);
/** Unregister a server application from the stack */
bt_status_t (*unregister_server)(int server_if );
/** Create a connection to a remote peripheral */
- bt_status_t (*connect)(int server_if, const bt_bdaddr_t *bd_addr,
+ bt_status_t (*connect)(int server_if, const bt_bdaddr_t& bd_addr,
bool is_direct, int transport);
/** Disconnect an established connection or cancel a pending one */
- bt_status_t (*disconnect)(int server_if, const bt_bdaddr_t *bd_addr,
+ bt_status_t (*disconnect)(int server_if, const bt_bdaddr_t& bd_addr,
int conn_id );
/** Create a new service */
@@ -164,7 +164,7 @@
/** Send a response to a read/write operation */
bt_status_t (*send_response)(int conn_id, int trans_id,
- int status, btgatt_response_t *response);
+ int status, const btgatt_response_t& response);
bt_status_t (*set_preferred_phy)(const bt_bdaddr_t& bd_addr, uint8_t tx_phy,
uint8_t rx_phy, uint16_t phy_options);