From 9c68cdfcbf2220b7c1f30d1d0521775c238ba823 Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Thu, 21 Jan 2016 19:44:43 -0800 Subject: [PATCH] service: Handle configure_mtu_cb, search_complete_cb and search_result_cb events This patch adds HAL wrappers for those three events in preparation to triggering MTU exchange and service discovery. search_result_cb will not be propagated above HAL, new method will be implemented to get GATT database content when it's ready. Change-Id: Id25699879923ff64c8bdb8942581ea32c2390dac --- service/hal/bluetooth_gatt_interface.cpp | 51 ++++++++++++++++++++++++++++++-- service/hal/bluetooth_gatt_interface.h | 9 ++++++ 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/service/hal/bluetooth_gatt_interface.cpp b/service/hal/bluetooth_gatt_interface.cpp index d366411a0..719d7a59e 100644 --- a/service/hal/bluetooth_gatt_interface.cpp +++ b/service/hal/bluetooth_gatt_interface.cpp @@ -119,6 +119,24 @@ void DisconnectCallback(int conn_id, int status, int client_if, DisconnectCallback(g_interface, conn_id, status, client_if, *bda)); } +void SearchCompleteCallback(int conn_id, int status) { + shared_lock lock(g_instance_lock); + VERIFY_INTERFACE_OR_RETURN(); + + VLOG(2) << __func__ << " - conn_id: " << conn_id + << " - status: " << status; + FOR_EACH_CLIENT_OBSERVER( + SearchCompleteCallback(g_interface, conn_id, status)); +} + +void SearchResultCallback(int conn_id, btgatt_srvc_id_t *srvc_id) { + shared_lock lock(g_instance_lock); + VERIFY_INTERFACE_OR_RETURN(); + + VLOG(2) << __func__ << " - conn_id: " << conn_id; + // do not propagate this event, will do service discovery with new HAL call +} + void ListenCallback(int status, int client_if) { shared_lock lock(g_instance_lock); VLOG(2) << __func__ << " - status: " << status << " client_if: " << client_if; @@ -127,6 +145,17 @@ void ListenCallback(int status, int client_if) { FOR_EACH_CLIENT_OBSERVER(ListenCallback(g_interface, status, client_if)); } +void MtuChangedCallback(int conn_id, int status, int mtu) { + shared_lock lock(g_instance_lock); + VERIFY_INTERFACE_OR_RETURN(); + + VLOG(2) << __func__ << " - conn_id: " << conn_id + << " status: " << status + << " mtu: " << mtu; + + FOR_EACH_CLIENT_OBSERVER(MtuChangedCallback(g_interface, conn_id, status, mtu)); +} + void MultiAdvEnableCallback(int client_if, int status) { shared_lock lock(g_instance_lock); VLOG(2) << __func__ << " - status: " << status << " client_if: " << client_if; @@ -318,8 +347,8 @@ const btgatt_client_callbacks_t gatt_client_callbacks = { ScanResultCallback, ConnectCallback, DisconnectCallback, - nullptr, // search_complete_cb - nullptr, // search_result_cb + SearchCompleteCallback, + SearchResultCallback, nullptr, // get_characteristic_cb nullptr, // get_descriptor_cb nullptr, // get_included_service_cb @@ -332,7 +361,7 @@ const btgatt_client_callbacks_t gatt_client_callbacks = { nullptr, // execute_write_cb nullptr, // read_remote_rssi_cb ListenCallback, - nullptr, // configure_mtu_cb + MtuChangedCallback, nullptr, // scan_filter_cfg_cb nullptr, // scan_filter_param_cb nullptr, // scan_filter_status_cb @@ -513,12 +542,28 @@ void BluetoothGattInterface::ClientObserver::DisconnectCallback( // Do nothing } +void BluetoothGattInterface::ClientObserver::SearchCompleteCallback( + BluetoothGattInterface* /* gatt_iface */, + int /* conn_id */, + int /* status */) { + // Do nothing +} + void BluetoothGattInterface::ClientObserver::ListenCallback( BluetoothGattInterface* /* gatt_iface */, int /* status */, int /* client_if */) { // Do nothing. } + +void BluetoothGattInterface::ClientObserver::MtuChangedCallback( + BluetoothGattInterface* /* gatt_iface */, + int /* conn_id */, + int /* statis*/, + int /* mtu */) { + // Do nothing. +} + void BluetoothGattInterface::ClientObserver::MultiAdvEnableCallback( BluetoothGattInterface* /* gatt_iface */, int /* status */, diff --git a/service/hal/bluetooth_gatt_interface.h b/service/hal/bluetooth_gatt_interface.h index 723ef7640..99c6f6c79 100644 --- a/service/hal/bluetooth_gatt_interface.h +++ b/service/hal/bluetooth_gatt_interface.h @@ -75,10 +75,19 @@ class BluetoothGattInterface { int client_if, const bt_bdaddr_t& bda); + virtual void SearchCompleteCallback( + BluetoothGattInterface* gatt_iface, + int conn_id, + int status); + virtual void ListenCallback( BluetoothGattInterface* gatt_iface, int status, int client_if); + virtual void MtuChangedCallback( + BluetoothGattInterface* gatt_iface, + int conn_id, int status, int mtu); + virtual void MultiAdvEnableCallback( BluetoothGattInterface* gatt_iface, int client_if, int status); -- 2.11.0