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_descriptor_client.h" | 5 #include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 if (properties->uuid.value() == kClientCharacteristicConfigurationUUID) { | 108 if (properties->uuid.value() == kClientCharacteristicConfigurationUUID) { |
109 BluetoothGattCharacteristicClient::Properties* chrc_props = | 109 BluetoothGattCharacteristicClient::Properties* chrc_props = |
110 bluez::BluezDBusManager::Get() | 110 bluez::BluezDBusManager::Get() |
111 ->GetBluetoothGattCharacteristicClient() | 111 ->GetBluetoothGattCharacteristicClient() |
112 ->GetProperties(properties->characteristic.value()); | 112 ->GetProperties(properties->characteristic.value()); |
113 DCHECK(chrc_props); | 113 DCHECK(chrc_props); |
114 | 114 |
115 uint8_t value_byte = chrc_props->notifying.value() ? 0x01 : 0x00; | 115 uint8_t value_byte = chrc_props->notifying.value() ? 0x01 : 0x00; |
116 const std::vector<uint8_t>& cur_value = properties->value.value(); | 116 const std::vector<uint8_t>& cur_value = properties->value.value(); |
117 | 117 |
118 if (!cur_value.size() || cur_value[0] != value_byte) { | 118 if (cur_value.empty() || cur_value[0] != value_byte) { |
119 std::vector<uint8_t> value = {value_byte, 0x00}; | 119 std::vector<uint8_t> value = {value_byte, 0x00}; |
120 properties->value.ReplaceValue(value); | 120 properties->value.ReplaceValue(value); |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 callback.Run(iter->second->properties->value.value()); | 124 callback.Run(iter->second->properties->value.value()); |
125 } | 125 } |
126 | 126 |
127 void FakeBluetoothGattDescriptorClient::WriteValue( | 127 void FakeBluetoothGattDescriptorClient::WriteValue( |
128 const dbus::ObjectPath& object_path, | 128 const dbus::ObjectPath& object_path, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 GattDescriptorAdded(object_path)); | 206 GattDescriptorAdded(object_path)); |
207 } | 207 } |
208 | 208 |
209 void FakeBluetoothGattDescriptorClient::NotifyDescriptorRemoved( | 209 void FakeBluetoothGattDescriptorClient::NotifyDescriptorRemoved( |
210 const dbus::ObjectPath& object_path) { | 210 const dbus::ObjectPath& object_path) { |
211 FOR_EACH_OBSERVER(BluetoothGattDescriptorClient::Observer, observers_, | 211 FOR_EACH_OBSERVER(BluetoothGattDescriptorClient::Observer, observers_, |
212 GattDescriptorRemoved(object_path)); | 212 GattDescriptorRemoved(object_path)); |
213 } | 213 } |
214 | 214 |
215 } // namespace bluez | 215 } // namespace bluez |
OLD | NEW |