OSDN Git Service

service: Handle configure_mtu_cb, search_complete_cb and search_result_cb events
authorJakub Pawlowski <jpawlowski@google.com>
Fri, 22 Jan 2016 03:44:43 +0000 (19:44 -0800)
committerJakub Pawlowski <jpawlowski@google.com>
Mon, 25 Jan 2016 17:47:36 +0000 (09:47 -0800)
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
service/hal/bluetooth_gatt_interface.h

index d366411..719d7a5 100644 (file)
@@ -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<shared_timed_mutex> 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<shared_timed_mutex> 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<shared_timed_mutex> 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<shared_timed_mutex> 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<shared_timed_mutex> 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 */,
index 723ef76..99c6f6c 100644 (file)
@@ -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);