OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provi
der.h" | 5 #include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_service_provi
der.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "device/bluetooth/dbus/bluez_dbus_manager.h" | 9 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
10 #include "device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h" | 10 #include "device/bluetooth/dbus/fake_bluetooth_gatt_manager_client.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 << object_path_.value(); | 47 << object_path_.value(); |
48 | 48 |
49 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = | 49 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = |
50 static_cast<FakeBluetoothGattManagerClient*>( | 50 static_cast<FakeBluetoothGattManagerClient*>( |
51 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); | 51 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); |
52 fake_bluetooth_gatt_manager_client->UnregisterCharacteristicServiceProvider( | 52 fake_bluetooth_gatt_manager_client->UnregisterCharacteristicServiceProvider( |
53 this); | 53 this); |
54 } | 54 } |
55 | 55 |
56 void FakeBluetoothGattCharacteristicServiceProvider::SendValueChanged( | 56 void FakeBluetoothGattCharacteristicServiceProvider::SendValueChanged( |
57 const std::vector<uint8>& value) { | 57 const std::vector<uint8_t>& value) { |
58 VLOG(1) << "Sent characteristic value changed: " << object_path_.value() | 58 VLOG(1) << "Sent characteristic value changed: " << object_path_.value() |
59 << " UUID: " << uuid_; | 59 << " UUID: " << uuid_; |
60 } | 60 } |
61 | 61 |
62 void FakeBluetoothGattCharacteristicServiceProvider::GetValue( | 62 void FakeBluetoothGattCharacteristicServiceProvider::GetValue( |
63 const Delegate::ValueCallback& callback, | 63 const Delegate::ValueCallback& callback, |
64 const Delegate::ErrorCallback& error_callback) { | 64 const Delegate::ErrorCallback& error_callback) { |
65 VLOG(1) << "GATT characteristic value Get request: " << object_path_.value() | 65 VLOG(1) << "GATT characteristic value Get request: " << object_path_.value() |
66 << " UUID: " << uuid_; | 66 << " UUID: " << uuid_; |
67 | 67 |
68 // Check if this characteristic is registered. | 68 // Check if this characteristic is registered. |
69 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = | 69 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = |
70 static_cast<FakeBluetoothGattManagerClient*>( | 70 static_cast<FakeBluetoothGattManagerClient*>( |
71 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); | 71 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); |
72 if (!fake_bluetooth_gatt_manager_client->IsServiceRegistered(service_path_)) { | 72 if (!fake_bluetooth_gatt_manager_client->IsServiceRegistered(service_path_)) { |
73 VLOG(1) << "GATT characteristic not registered."; | 73 VLOG(1) << "GATT characteristic not registered."; |
74 error_callback.Run(); | 74 error_callback.Run(); |
75 return; | 75 return; |
76 } | 76 } |
77 | 77 |
78 // Pass on to the delegate. | 78 // Pass on to the delegate. |
79 DCHECK(delegate_); | 79 DCHECK(delegate_); |
80 delegate_->GetCharacteristicValue(callback, error_callback); | 80 delegate_->GetCharacteristicValue(callback, error_callback); |
81 } | 81 } |
82 | 82 |
83 void FakeBluetoothGattCharacteristicServiceProvider::SetValue( | 83 void FakeBluetoothGattCharacteristicServiceProvider::SetValue( |
84 const std::vector<uint8>& value, | 84 const std::vector<uint8_t>& value, |
85 const base::Closure& callback, | 85 const base::Closure& callback, |
86 const Delegate::ErrorCallback& error_callback) { | 86 const Delegate::ErrorCallback& error_callback) { |
87 VLOG(1) << "GATT characteristic value Set request: " << object_path_.value() | 87 VLOG(1) << "GATT characteristic value Set request: " << object_path_.value() |
88 << " UUID: " << uuid_; | 88 << " UUID: " << uuid_; |
89 | 89 |
90 // Check if this characteristic is registered. | 90 // Check if this characteristic is registered. |
91 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = | 91 FakeBluetoothGattManagerClient* fake_bluetooth_gatt_manager_client = |
92 static_cast<FakeBluetoothGattManagerClient*>( | 92 static_cast<FakeBluetoothGattManagerClient*>( |
93 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); | 93 bluez::BluezDBusManager::Get()->GetBluetoothGattManagerClient()); |
94 if (!fake_bluetooth_gatt_manager_client->IsServiceRegistered(service_path_)) { | 94 if (!fake_bluetooth_gatt_manager_client->IsServiceRegistered(service_path_)) { |
95 VLOG(1) << "GATT characteristic not registered."; | 95 VLOG(1) << "GATT characteristic not registered."; |
96 error_callback.Run(); | 96 error_callback.Run(); |
97 return; | 97 return; |
98 } | 98 } |
99 | 99 |
100 // Pass on to the delegate. | 100 // Pass on to the delegate. |
101 DCHECK(delegate_); | 101 DCHECK(delegate_); |
102 delegate_->SetCharacteristicValue(value, callback, error_callback); | 102 delegate_->SetCharacteristicValue(value, callback, error_callback); |
103 } | 103 } |
104 | 104 |
105 } // namespace bluez | 105 } // namespace bluez |
OLD | NEW |