Use references in GATT client/server API (1/3)
This allows to get rid of some unnecessary null checks, and guarantee
proper values are passed.
Test: compilation test
Change-Id: Id5508477809a5c0b038eed71403a8bf93bd03203
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);