Loading system/btif/src/btif_gatt_server.cc +14 −13 Original line number Diff line number Diff line Loading @@ -188,21 +188,19 @@ static void btapp_gatts_handle_cback(uint16_t event, char* p_param) { case BTA_GATTS_WRITE_CHARACTERISTIC_EVT: { const auto& req = p_data->req_data.p_data->write_req; vector<uint8_t> value(req.value, req.value + req.len); HAL_CBACK(bt_gatt_callbacks, server->request_write_characteristic_cb, p_data->req_data.conn_id, p_data->req_data.trans_id, p_data->req_data.remote_bda, req.handle, req.offset, req.need_rsp, req.is_prep, value); req.need_rsp, req.is_prep, req.value, req.len); break; } case BTA_GATTS_WRITE_DESCRIPTOR_EVT: { const auto& req = p_data->req_data.p_data->write_req; vector<uint8_t> value(req.value, req.value + req.len); HAL_CBACK(bt_gatt_callbacks, server->request_write_descriptor_cb, p_data->req_data.conn_id, p_data->req_data.trans_id, p_data->req_data.remote_bda, req.handle, req.offset, req.need_rsp, req.is_prep, value); req.need_rsp, req.is_prep, req.value, req.len); break; } Loading Loading @@ -348,7 +346,7 @@ static bt_status_t btif_gatts_close(int server_if, const RawAddress& bd_addr, static void on_service_added_cb(tGATT_STATUS status, int server_if, vector<btgatt_db_element_t> service) { HAL_CBACK(bt_gatt_callbacks, server->service_added_cb, status, server_if, std::move(service)); service.data(), service.size()); } static void add_service_impl(int server_if, Loading @@ -360,7 +358,7 @@ static void add_service_impl(int server_if, service[0].uuid == Uuid::From16Bit(UUID_SERVCLASS_GAP_SERVER)) { LOG_ERROR("%s: Attept to register restricted service", __func__); HAL_CBACK(bt_gatt_callbacks, server->service_added_cb, BT_STATUS_FAIL, server_if, std::move(service)); server_if, service.data(), service.size()); return; } Loading @@ -370,10 +368,12 @@ static void add_service_impl(int server_if, } static bt_status_t btif_gatts_add_service(int server_if, vector<btgatt_db_element_t> service) { const btgatt_db_element_t* service, size_t service_count) { CHECK_BTGATT_INIT(); return do_in_jni_thread( FROM_HERE, Bind(&add_service_impl, server_if, std::move(service))); return do_in_jni_thread(FROM_HERE, Bind(&add_service_impl, server_if, std::vector(service, service + service_count))); } static bt_status_t btif_gatts_stop_service(int server_if, int service_handle) { Loading @@ -389,14 +389,15 @@ static bt_status_t btif_gatts_delete_service(int server_if, static bt_status_t btif_gatts_send_indication(int server_if, int attribute_handle, int conn_id, int confirm, vector<uint8_t> value) { int confirm, const uint8_t* value, size_t length) { CHECK_BTGATT_INIT(); if (value.size() > BTGATT_MAX_ATTR_LEN) value.resize(BTGATT_MAX_ATTR_LEN); if (length > BTGATT_MAX_ATTR_LEN) length = BTGATT_MAX_ATTR_LEN; return do_in_jni_thread(Bind(&BTA_GATTS_HandleValueIndication, conn_id, attribute_handle, std::move(value), confirm)); attribute_handle, std::vector(value, value + length), confirm)); // TODO: Might need to send an ACK if handle value indication is // invoked without need for confirmation. } Loading system/include/hardware/bt_gatt_server.h +8 −8 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ #define ANDROID_INCLUDE_BT_GATT_SERVER_H #include <stdint.h> #include <vector> #include "bt_gatt_types.h" Loading Loading @@ -51,8 +50,9 @@ typedef void (*connection_callback)(int conn_id, int server_if, int connected, const RawAddress& bda); /** Callback invoked in response to create_service */ typedef void (*service_added_callback)( int status, int server_if, std::vector<btgatt_db_element_t> service); typedef void (*service_added_callback)(int status, int server_if, const btgatt_db_element_t* service, size_t service_count); /** Callback invoked in response to stop_service */ typedef void (*service_stopped_callback)(int status, int server_if, Loading @@ -77,7 +77,7 @@ typedef void (*request_read_callback)(int conn_id, int trans_id, typedef void (*request_write_callback)(int conn_id, int trans_id, const RawAddress& bda, int attr_handle, int offset, bool need_rsp, bool is_prep, std::vector<uint8_t> value); const uint8_t* value, size_t length); /** Callback invoked when a previously prepared write is to be executed */ typedef void (*request_exec_write_callback)(int conn_id, int trans_id, Loading Loading @@ -153,8 +153,8 @@ typedef struct { int conn_id); /** Create a new service */ bt_status_t (*add_service)(int server_if, std::vector<btgatt_db_element_t> service); bt_status_t (*add_service)(int server_if, const btgatt_db_element_t* service, size_t service_count); /** Stops a local service */ bt_status_t (*stop_service)(int server_if, int service_handle); Loading @@ -164,8 +164,8 @@ typedef struct { /** Send value indication to a remote device */ bt_status_t (*send_indication)(int server_if, int attribute_handle, int conn_id, int confirm, std::vector<uint8_t> value); int conn_id, int confirm, const uint8_t* value, size_t length); /** Send a response to a read/write operation */ bt_status_t (*send_response)(int conn_id, int trans_id, int status, Loading system/service/gatt_server.cc +6 −5 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ bool GattServer::AddService(const bluetooth::Service& service, bt_status_t status = hal::BluetoothGattInterface::Get()->GetServerHALInterface()->add_service( server_id_, svc); server_id_, svc.data(), svc.size()); if (status != BT_STATUS_SUCCESS) { LOG(ERROR) << "Failed to initiate call to populate GATT service"; CleanUpPendingData(); Loading Loading @@ -216,10 +216,11 @@ bool GattServer::SendNotification(const std::string& device_address, // The HAL API takes char* rather const char* for |value|, so we have to // cast away the const. // TODO(armansito): Make HAL accept const char*. bt_status_t status = hal::BluetoothGattInterface::Get() bt_status_t status = hal::BluetoothGattInterface::Get() ->GetServerHALInterface() ->send_indication(server_id_, handle, conn->conn_id, confirm, value); ->send_indication(server_id_, handle, conn->conn_id, confirm, value.data(), value.size()); // Increment the send count if this was successful. We don't immediately // fail if the HAL returned an error. It's better to report success as long Loading system/service/gatt_server_old.cc +14 −11 Original line number Diff line number Diff line Loading @@ -144,9 +144,10 @@ void RegisterServerCallback(int status, int server_if, } void ServiceAddedCallback(int status, int server_if, std::vector<btgatt_db_element_t> service) { const btgatt_db_element_t* service, size_t service_count) { LOG_INFO("%s: status:%d server_if:%d count:%zu svc_handle:%d", __func__, status, server_if, service.size(), service[0].attribute_handle); status, server_if, service_count, service[0].attribute_handle); std::lock_guard<std::mutex> lock(g_internal->lock); g_internal->server_if = server_if; Loading @@ -155,7 +156,7 @@ void ServiceAddedCallback(int status, int server_if, uint16_t prev_char_handle = 0; uint16_t prev_char_properties = 0; for (size_t i = 1; i < service.size(); i++) { for (size_t i = 1; i < service_count; i++) { const btgatt_db_element_t& el = service[i]; if (el.type == BTGATT_DB_DESCRIPTOR) { LOG_INFO("%s: descr_handle:%d", __func__, el.attribute_handle); Loading Loading @@ -252,23 +253,23 @@ void RequestReadCallback(int conn_id, int trans_id, const RawAddress& bda, void RequestWriteCallback(int conn_id, int trans_id, const RawAddress& bda, int attr_handle, int attribute_offset, bool need_rsp, bool is_prep, std::vector<uint8_t> value) { bool is_prep, const uint8_t* value, size_t length) { std::string addr(BtAddrString(&bda)); LOG_INFO( "%s: connection:%d (%s:trans:%d) write attr:%d attribute_offset:%d " "length:%zu " "need_resp:%u is_prep:%u", __func__, conn_id, addr.c_str(), trans_id, attr_handle, attribute_offset, value.size(), need_rsp, is_prep); length, need_rsp, is_prep); std::lock_guard<std::mutex> lock(g_internal->lock); bluetooth::gatt::Characteristic& ch = g_internal->characteristics[attr_handle]; ch.blob.resize(attribute_offset + value.size()); ch.blob.resize(attribute_offset + length); std::copy(value.begin(), value.end(), ch.blob.begin() + attribute_offset); std::copy(value, value + length, ch.blob.begin() + attribute_offset); auto target_blob = g_internal->controlled_blobs.find(attr_handle); // If this is a control attribute, adjust offset of the target blob. Loading Loading @@ -298,11 +299,11 @@ void RequestWriteCallback(int conn_id, int trans_id, const RawAddress& bda, btgatt_response_t response; response.attr_value.handle = attr_handle; response.attr_value.offset = attribute_offset; response.attr_value.len = value.size(); response.attr_value.len = length; response.attr_value.auth_req = 0; // Provide written data back to sender for the response. // Remote stacks use this to validate the success of the write. std::copy(value.begin(), value.end(), response.attr_value.value); std::copy(value, value + length, response.attr_value.value); g_internal->gatt->server->send_response(conn_id, trans_id, 0, response); } Loading Loading @@ -663,7 +664,7 @@ bool Server::AddBlob(const Uuid& id, const Uuid& control_id, int properties, bool Server::Start() { std::unique_lock<std::mutex> lock(internal_->lock); bt_status_t btstat = internal_->gatt->server->add_service( internal_->server_if, pending_svc_decl); internal_->server_if, pending_svc_decl.data(), pending_svc_decl.size()); if (btstat != BT_STATUS_SUCCESS) { LOG_ERROR("Failed to start service with handle: 0x%04x", internal_->service_handle); Loading Loading @@ -712,9 +713,11 @@ bool Server::SetCharacteristicValue(const Uuid& id, if (!ch.notify) return true; std::vector<uint8_t> ind_value = {0}; for (auto connection : internal_->connections) { internal_->gatt->server->send_indication(internal_->server_if, attribute_id, connection, true, {0}); connection, true, ind_value.data(), ind_value.size()); } return true; } Loading system/service/hal/bluetooth_gatt_interface.cc +17 −16 Original line number Diff line number Diff line Loading @@ -246,17 +246,18 @@ void ConnectionCallback(int conn_id, int server_if, int connected, ConnectionCallback(g_interface, conn_id, server_if, connected, bda)); } void ServiceAddedCallback( int status, int server_if, std::vector<btgatt_db_element_t> service) { // NOLINT(pass-by-value) void ServiceAddedCallback(int status, int server_if, const btgatt_db_element_t* service, size_t service_count) { shared_lock<shared_mutex_impl> lock(g_instance_lock); VLOG(2) << __func__ << " - status: " << status << " server_if: " << server_if << " count: " << service.size(); << " count: " << service_count; VERIFY_INTERFACE_OR_RETURN(); CHECK(service.size()); CHECK(service_count); FOR_EACH_SERVER_OBSERVER( ServiceAddedCallback(g_interface, status, server_if, service)); FOR_EACH_SERVER_OBSERVER(ServiceAddedCallback( g_interface, status, server_if, std::vector<btgatt_db_element_t>(service, service + service_count))); } void ServiceStoppedCallback(int status, int server_if, int srvc_handle) { Loading Loading @@ -308,33 +309,33 @@ void RequestReadDescriptorCallback(int conn_id, int trans_id, void RequestWriteCharacteristicCallback(int conn_id, int trans_id, const RawAddress& bda, int attr_handle, int offset, bool need_rsp, bool is_prep, std::vector<uint8_t> value) { const uint8_t* value, size_t length) { shared_lock<shared_mutex_impl> lock(g_instance_lock); VLOG(2) << __func__ << " - conn_id: " << conn_id << " trans_id: " << trans_id << " attr_handle: " << attr_handle << " offset: " << offset << " length: " << value.size() << " need_rsp: " << need_rsp << " length: " << length << " need_rsp: " << need_rsp << " is_prep: " << is_prep; VERIFY_INTERFACE_OR_RETURN(); FOR_EACH_SERVER_OBSERVER(RequestWriteCharacteristicCallback( g_interface, conn_id, trans_id, bda, attr_handle, offset, need_rsp, is_prep, value)); is_prep, std::vector(value, value + length))); } void RequestWriteDescriptorCallback( int conn_id, int trans_id, const RawAddress& bda, int attr_handle, void RequestWriteDescriptorCallback(int conn_id, int trans_id, const RawAddress& bda, int attr_handle, int offset, bool need_rsp, bool is_prep, std::vector<uint8_t> value) { // NOLINT(pass-by-value) const uint8_t* value, size_t length) { shared_lock<shared_mutex_impl> lock(g_instance_lock); VLOG(2) << __func__ << " - conn_id: " << conn_id << " trans_id: " << trans_id << " attr_handle: " << attr_handle << " offset: " << offset << " length: " << value.size() << " need_rsp: " << need_rsp << " length: " << length << " need_rsp: " << need_rsp << " is_prep: " << is_prep; VERIFY_INTERFACE_OR_RETURN(); FOR_EACH_SERVER_OBSERVER(RequestWriteDescriptorCallback( g_interface, conn_id, trans_id, bda, attr_handle, offset, need_rsp, is_prep, value)); is_prep, std::vector(value, value + length))); } void RequestExecWriteCallback(int conn_id, int trans_id, const RawAddress& bda, Loading Loading
system/btif/src/btif_gatt_server.cc +14 −13 Original line number Diff line number Diff line Loading @@ -188,21 +188,19 @@ static void btapp_gatts_handle_cback(uint16_t event, char* p_param) { case BTA_GATTS_WRITE_CHARACTERISTIC_EVT: { const auto& req = p_data->req_data.p_data->write_req; vector<uint8_t> value(req.value, req.value + req.len); HAL_CBACK(bt_gatt_callbacks, server->request_write_characteristic_cb, p_data->req_data.conn_id, p_data->req_data.trans_id, p_data->req_data.remote_bda, req.handle, req.offset, req.need_rsp, req.is_prep, value); req.need_rsp, req.is_prep, req.value, req.len); break; } case BTA_GATTS_WRITE_DESCRIPTOR_EVT: { const auto& req = p_data->req_data.p_data->write_req; vector<uint8_t> value(req.value, req.value + req.len); HAL_CBACK(bt_gatt_callbacks, server->request_write_descriptor_cb, p_data->req_data.conn_id, p_data->req_data.trans_id, p_data->req_data.remote_bda, req.handle, req.offset, req.need_rsp, req.is_prep, value); req.need_rsp, req.is_prep, req.value, req.len); break; } Loading Loading @@ -348,7 +346,7 @@ static bt_status_t btif_gatts_close(int server_if, const RawAddress& bd_addr, static void on_service_added_cb(tGATT_STATUS status, int server_if, vector<btgatt_db_element_t> service) { HAL_CBACK(bt_gatt_callbacks, server->service_added_cb, status, server_if, std::move(service)); service.data(), service.size()); } static void add_service_impl(int server_if, Loading @@ -360,7 +358,7 @@ static void add_service_impl(int server_if, service[0].uuid == Uuid::From16Bit(UUID_SERVCLASS_GAP_SERVER)) { LOG_ERROR("%s: Attept to register restricted service", __func__); HAL_CBACK(bt_gatt_callbacks, server->service_added_cb, BT_STATUS_FAIL, server_if, std::move(service)); server_if, service.data(), service.size()); return; } Loading @@ -370,10 +368,12 @@ static void add_service_impl(int server_if, } static bt_status_t btif_gatts_add_service(int server_if, vector<btgatt_db_element_t> service) { const btgatt_db_element_t* service, size_t service_count) { CHECK_BTGATT_INIT(); return do_in_jni_thread( FROM_HERE, Bind(&add_service_impl, server_if, std::move(service))); return do_in_jni_thread(FROM_HERE, Bind(&add_service_impl, server_if, std::vector(service, service + service_count))); } static bt_status_t btif_gatts_stop_service(int server_if, int service_handle) { Loading @@ -389,14 +389,15 @@ static bt_status_t btif_gatts_delete_service(int server_if, static bt_status_t btif_gatts_send_indication(int server_if, int attribute_handle, int conn_id, int confirm, vector<uint8_t> value) { int confirm, const uint8_t* value, size_t length) { CHECK_BTGATT_INIT(); if (value.size() > BTGATT_MAX_ATTR_LEN) value.resize(BTGATT_MAX_ATTR_LEN); if (length > BTGATT_MAX_ATTR_LEN) length = BTGATT_MAX_ATTR_LEN; return do_in_jni_thread(Bind(&BTA_GATTS_HandleValueIndication, conn_id, attribute_handle, std::move(value), confirm)); attribute_handle, std::vector(value, value + length), confirm)); // TODO: Might need to send an ACK if handle value indication is // invoked without need for confirmation. } Loading
system/include/hardware/bt_gatt_server.h +8 −8 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ #define ANDROID_INCLUDE_BT_GATT_SERVER_H #include <stdint.h> #include <vector> #include "bt_gatt_types.h" Loading Loading @@ -51,8 +50,9 @@ typedef void (*connection_callback)(int conn_id, int server_if, int connected, const RawAddress& bda); /** Callback invoked in response to create_service */ typedef void (*service_added_callback)( int status, int server_if, std::vector<btgatt_db_element_t> service); typedef void (*service_added_callback)(int status, int server_if, const btgatt_db_element_t* service, size_t service_count); /** Callback invoked in response to stop_service */ typedef void (*service_stopped_callback)(int status, int server_if, Loading @@ -77,7 +77,7 @@ typedef void (*request_read_callback)(int conn_id, int trans_id, typedef void (*request_write_callback)(int conn_id, int trans_id, const RawAddress& bda, int attr_handle, int offset, bool need_rsp, bool is_prep, std::vector<uint8_t> value); const uint8_t* value, size_t length); /** Callback invoked when a previously prepared write is to be executed */ typedef void (*request_exec_write_callback)(int conn_id, int trans_id, Loading Loading @@ -153,8 +153,8 @@ typedef struct { int conn_id); /** Create a new service */ bt_status_t (*add_service)(int server_if, std::vector<btgatt_db_element_t> service); bt_status_t (*add_service)(int server_if, const btgatt_db_element_t* service, size_t service_count); /** Stops a local service */ bt_status_t (*stop_service)(int server_if, int service_handle); Loading @@ -164,8 +164,8 @@ typedef struct { /** Send value indication to a remote device */ bt_status_t (*send_indication)(int server_if, int attribute_handle, int conn_id, int confirm, std::vector<uint8_t> value); int conn_id, int confirm, const uint8_t* value, size_t length); /** Send a response to a read/write operation */ bt_status_t (*send_response)(int conn_id, int trans_id, int status, Loading
system/service/gatt_server.cc +6 −5 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ bool GattServer::AddService(const bluetooth::Service& service, bt_status_t status = hal::BluetoothGattInterface::Get()->GetServerHALInterface()->add_service( server_id_, svc); server_id_, svc.data(), svc.size()); if (status != BT_STATUS_SUCCESS) { LOG(ERROR) << "Failed to initiate call to populate GATT service"; CleanUpPendingData(); Loading Loading @@ -216,10 +216,11 @@ bool GattServer::SendNotification(const std::string& device_address, // The HAL API takes char* rather const char* for |value|, so we have to // cast away the const. // TODO(armansito): Make HAL accept const char*. bt_status_t status = hal::BluetoothGattInterface::Get() bt_status_t status = hal::BluetoothGattInterface::Get() ->GetServerHALInterface() ->send_indication(server_id_, handle, conn->conn_id, confirm, value); ->send_indication(server_id_, handle, conn->conn_id, confirm, value.data(), value.size()); // Increment the send count if this was successful. We don't immediately // fail if the HAL returned an error. It's better to report success as long Loading
system/service/gatt_server_old.cc +14 −11 Original line number Diff line number Diff line Loading @@ -144,9 +144,10 @@ void RegisterServerCallback(int status, int server_if, } void ServiceAddedCallback(int status, int server_if, std::vector<btgatt_db_element_t> service) { const btgatt_db_element_t* service, size_t service_count) { LOG_INFO("%s: status:%d server_if:%d count:%zu svc_handle:%d", __func__, status, server_if, service.size(), service[0].attribute_handle); status, server_if, service_count, service[0].attribute_handle); std::lock_guard<std::mutex> lock(g_internal->lock); g_internal->server_if = server_if; Loading @@ -155,7 +156,7 @@ void ServiceAddedCallback(int status, int server_if, uint16_t prev_char_handle = 0; uint16_t prev_char_properties = 0; for (size_t i = 1; i < service.size(); i++) { for (size_t i = 1; i < service_count; i++) { const btgatt_db_element_t& el = service[i]; if (el.type == BTGATT_DB_DESCRIPTOR) { LOG_INFO("%s: descr_handle:%d", __func__, el.attribute_handle); Loading Loading @@ -252,23 +253,23 @@ void RequestReadCallback(int conn_id, int trans_id, const RawAddress& bda, void RequestWriteCallback(int conn_id, int trans_id, const RawAddress& bda, int attr_handle, int attribute_offset, bool need_rsp, bool is_prep, std::vector<uint8_t> value) { bool is_prep, const uint8_t* value, size_t length) { std::string addr(BtAddrString(&bda)); LOG_INFO( "%s: connection:%d (%s:trans:%d) write attr:%d attribute_offset:%d " "length:%zu " "need_resp:%u is_prep:%u", __func__, conn_id, addr.c_str(), trans_id, attr_handle, attribute_offset, value.size(), need_rsp, is_prep); length, need_rsp, is_prep); std::lock_guard<std::mutex> lock(g_internal->lock); bluetooth::gatt::Characteristic& ch = g_internal->characteristics[attr_handle]; ch.blob.resize(attribute_offset + value.size()); ch.blob.resize(attribute_offset + length); std::copy(value.begin(), value.end(), ch.blob.begin() + attribute_offset); std::copy(value, value + length, ch.blob.begin() + attribute_offset); auto target_blob = g_internal->controlled_blobs.find(attr_handle); // If this is a control attribute, adjust offset of the target blob. Loading Loading @@ -298,11 +299,11 @@ void RequestWriteCallback(int conn_id, int trans_id, const RawAddress& bda, btgatt_response_t response; response.attr_value.handle = attr_handle; response.attr_value.offset = attribute_offset; response.attr_value.len = value.size(); response.attr_value.len = length; response.attr_value.auth_req = 0; // Provide written data back to sender for the response. // Remote stacks use this to validate the success of the write. std::copy(value.begin(), value.end(), response.attr_value.value); std::copy(value, value + length, response.attr_value.value); g_internal->gatt->server->send_response(conn_id, trans_id, 0, response); } Loading Loading @@ -663,7 +664,7 @@ bool Server::AddBlob(const Uuid& id, const Uuid& control_id, int properties, bool Server::Start() { std::unique_lock<std::mutex> lock(internal_->lock); bt_status_t btstat = internal_->gatt->server->add_service( internal_->server_if, pending_svc_decl); internal_->server_if, pending_svc_decl.data(), pending_svc_decl.size()); if (btstat != BT_STATUS_SUCCESS) { LOG_ERROR("Failed to start service with handle: 0x%04x", internal_->service_handle); Loading Loading @@ -712,9 +713,11 @@ bool Server::SetCharacteristicValue(const Uuid& id, if (!ch.notify) return true; std::vector<uint8_t> ind_value = {0}; for (auto connection : internal_->connections) { internal_->gatt->server->send_indication(internal_->server_if, attribute_id, connection, true, {0}); connection, true, ind_value.data(), ind_value.size()); } return true; } Loading
system/service/hal/bluetooth_gatt_interface.cc +17 −16 Original line number Diff line number Diff line Loading @@ -246,17 +246,18 @@ void ConnectionCallback(int conn_id, int server_if, int connected, ConnectionCallback(g_interface, conn_id, server_if, connected, bda)); } void ServiceAddedCallback( int status, int server_if, std::vector<btgatt_db_element_t> service) { // NOLINT(pass-by-value) void ServiceAddedCallback(int status, int server_if, const btgatt_db_element_t* service, size_t service_count) { shared_lock<shared_mutex_impl> lock(g_instance_lock); VLOG(2) << __func__ << " - status: " << status << " server_if: " << server_if << " count: " << service.size(); << " count: " << service_count; VERIFY_INTERFACE_OR_RETURN(); CHECK(service.size()); CHECK(service_count); FOR_EACH_SERVER_OBSERVER( ServiceAddedCallback(g_interface, status, server_if, service)); FOR_EACH_SERVER_OBSERVER(ServiceAddedCallback( g_interface, status, server_if, std::vector<btgatt_db_element_t>(service, service + service_count))); } void ServiceStoppedCallback(int status, int server_if, int srvc_handle) { Loading Loading @@ -308,33 +309,33 @@ void RequestReadDescriptorCallback(int conn_id, int trans_id, void RequestWriteCharacteristicCallback(int conn_id, int trans_id, const RawAddress& bda, int attr_handle, int offset, bool need_rsp, bool is_prep, std::vector<uint8_t> value) { const uint8_t* value, size_t length) { shared_lock<shared_mutex_impl> lock(g_instance_lock); VLOG(2) << __func__ << " - conn_id: " << conn_id << " trans_id: " << trans_id << " attr_handle: " << attr_handle << " offset: " << offset << " length: " << value.size() << " need_rsp: " << need_rsp << " length: " << length << " need_rsp: " << need_rsp << " is_prep: " << is_prep; VERIFY_INTERFACE_OR_RETURN(); FOR_EACH_SERVER_OBSERVER(RequestWriteCharacteristicCallback( g_interface, conn_id, trans_id, bda, attr_handle, offset, need_rsp, is_prep, value)); is_prep, std::vector(value, value + length))); } void RequestWriteDescriptorCallback( int conn_id, int trans_id, const RawAddress& bda, int attr_handle, void RequestWriteDescriptorCallback(int conn_id, int trans_id, const RawAddress& bda, int attr_handle, int offset, bool need_rsp, bool is_prep, std::vector<uint8_t> value) { // NOLINT(pass-by-value) const uint8_t* value, size_t length) { shared_lock<shared_mutex_impl> lock(g_instance_lock); VLOG(2) << __func__ << " - conn_id: " << conn_id << " trans_id: " << trans_id << " attr_handle: " << attr_handle << " offset: " << offset << " length: " << value.size() << " need_rsp: " << need_rsp << " length: " << length << " need_rsp: " << need_rsp << " is_prep: " << is_prep; VERIFY_INTERFACE_OR_RETURN(); FOR_EACH_SERVER_OBSERVER(RequestWriteDescriptorCallback( g_interface, conn_id, trans_id, bda, attr_handle, offset, need_rsp, is_prep, value)); is_prep, std::vector(value, value + length))); } void RequestExecWriteCallback(int conn_id, int trans_id, const RawAddress& bda, Loading