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 #ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ | 5 #ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ |
6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ | 6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <string> | 11 #include <string> |
9 #include <vector> | 12 #include <vector> |
10 | 13 |
11 #include "base/basictypes.h" | 14 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
14 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
15 #include "dbus/object_path.h" | 18 #include "dbus/object_path.h" |
16 #include "dbus/property.h" | 19 #include "dbus/property.h" |
17 #include "device/bluetooth/bluetooth_export.h" | 20 #include "device/bluetooth/bluetooth_export.h" |
18 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" | 21 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" |
19 | 22 |
20 namespace bluez { | 23 namespace bluez { |
21 | 24 |
(...skipping 23 matching lines...) Expand all Loading... |
45 | 48 |
46 // BluetoothGattCharacteristicClient overrides. | 49 // BluetoothGattCharacteristicClient overrides. |
47 void AddObserver(Observer* observer) override; | 50 void AddObserver(Observer* observer) override; |
48 void RemoveObserver(Observer* observer) override; | 51 void RemoveObserver(Observer* observer) override; |
49 std::vector<dbus::ObjectPath> GetCharacteristics() override; | 52 std::vector<dbus::ObjectPath> GetCharacteristics() override; |
50 Properties* GetProperties(const dbus::ObjectPath& object_path) override; | 53 Properties* GetProperties(const dbus::ObjectPath& object_path) override; |
51 void ReadValue(const dbus::ObjectPath& object_path, | 54 void ReadValue(const dbus::ObjectPath& object_path, |
52 const ValueCallback& callback, | 55 const ValueCallback& callback, |
53 const ErrorCallback& error_callback) override; | 56 const ErrorCallback& error_callback) override; |
54 void WriteValue(const dbus::ObjectPath& object_path, | 57 void WriteValue(const dbus::ObjectPath& object_path, |
55 const std::vector<uint8>& value, | 58 const std::vector<uint8_t>& value, |
56 const base::Closure& callback, | 59 const base::Closure& callback, |
57 const ErrorCallback& error_callback) override; | 60 const ErrorCallback& error_callback) override; |
58 void StartNotify(const dbus::ObjectPath& object_path, | 61 void StartNotify(const dbus::ObjectPath& object_path, |
59 const base::Closure& callback, | 62 const base::Closure& callback, |
60 const ErrorCallback& error_callback) override; | 63 const ErrorCallback& error_callback) override; |
61 void StopNotify(const dbus::ObjectPath& object_path, | 64 void StopNotify(const dbus::ObjectPath& object_path, |
62 const base::Closure& callback, | 65 const base::Closure& callback, |
63 const ErrorCallback& error_callback) override; | 66 const ErrorCallback& error_callback) override; |
64 | 67 |
65 // Makes the group of characteristics belonging to a particular GATT based | 68 // Makes the group of characteristics belonging to a particular GATT based |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 void NotifyCharacteristicAdded(const dbus::ObjectPath& object_path); | 122 void NotifyCharacteristicAdded(const dbus::ObjectPath& object_path); |
120 void NotifyCharacteristicRemoved(const dbus::ObjectPath& object_path); | 123 void NotifyCharacteristicRemoved(const dbus::ObjectPath& object_path); |
121 | 124 |
122 // Schedules a heart rate measurement value change, if the heart rate | 125 // Schedules a heart rate measurement value change, if the heart rate |
123 // characteristics are visible. | 126 // characteristics are visible. |
124 void ScheduleHeartRateMeasurementValueChange(); | 127 void ScheduleHeartRateMeasurementValueChange(); |
125 | 128 |
126 // Returns a random Heart Rate Measurement value. All the fields of the value | 129 // Returns a random Heart Rate Measurement value. All the fields of the value |
127 // are populated according to the the fake behavior. The measurement value | 130 // are populated according to the the fake behavior. The measurement value |
128 // is a random value within a reasonable range. | 131 // is a random value within a reasonable range. |
129 std::vector<uint8> GetHeartRateMeasurementValue(); | 132 std::vector<uint8_t> GetHeartRateMeasurementValue(); |
130 | 133 |
131 // Callback that executes a delayed ReadValue action by updating the | 134 // Callback that executes a delayed ReadValue action by updating the |
132 // appropriate "Value" property and invoking the ValueCallback. | 135 // appropriate "Value" property and invoking the ValueCallback. |
133 void DelayedReadValueCallback(const dbus::ObjectPath& object_path, | 136 void DelayedReadValueCallback(const dbus::ObjectPath& object_path, |
134 const ValueCallback& callback, | 137 const ValueCallback& callback, |
135 const std::vector<uint8_t>& value); | 138 const std::vector<uint8_t>& value); |
136 | 139 |
137 // If true, characteristics of the Heart Rate Service are visible. Use | 140 // If true, characteristics of the Heart Rate Service are visible. Use |
138 // IsHeartRateVisible() to check the value. | 141 // IsHeartRateVisible() to check the value. |
139 bool heart_rate_visible_; | 142 bool heart_rate_visible_; |
140 | 143 |
141 // If true, the client is authorized to read and write. | 144 // If true, the client is authorized to read and write. |
142 bool authorized_; | 145 bool authorized_; |
143 | 146 |
144 // If true, the client is authenticated. | 147 // If true, the client is authenticated. |
145 bool authenticated_; | 148 bool authenticated_; |
146 | 149 |
147 // Total calories burned, used for the Heart Rate Measurement characteristic. | 150 // Total calories burned, used for the Heart Rate Measurement characteristic. |
148 uint16 calories_burned_; | 151 uint16_t calories_burned_; |
149 | 152 |
150 // Static properties returned for simulated characteristics for the Heart | 153 // Static properties returned for simulated characteristics for the Heart |
151 // Rate Service. These pointers are not NULL only if the characteristics are | 154 // Rate Service. These pointers are not NULL only if the characteristics are |
152 // actually exposed. | 155 // actually exposed. |
153 scoped_ptr<Properties> heart_rate_measurement_properties_; | 156 scoped_ptr<Properties> heart_rate_measurement_properties_; |
154 scoped_ptr<Properties> body_sensor_location_properties_; | 157 scoped_ptr<Properties> body_sensor_location_properties_; |
155 scoped_ptr<Properties> heart_rate_control_point_properties_; | 158 scoped_ptr<Properties> heart_rate_control_point_properties_; |
156 | 159 |
157 // Object paths of the exposed characteristics. If a characteristic is not | 160 // Object paths of the exposed characteristics. If a characteristic is not |
158 // exposed, these will be empty. | 161 // exposed, these will be empty. |
(...skipping 26 matching lines...) Expand all Loading... |
185 // Note: This should remain the last member so it'll be destroyed and | 188 // Note: This should remain the last member so it'll be destroyed and |
186 // invalidate its weak pointers before any other members are destroyed. | 189 // invalidate its weak pointers before any other members are destroyed. |
187 base::WeakPtrFactory<FakeBluetoothGattCharacteristicClient> weak_ptr_factory_; | 190 base::WeakPtrFactory<FakeBluetoothGattCharacteristicClient> weak_ptr_factory_; |
188 | 191 |
189 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattCharacteristicClient); | 192 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattCharacteristicClient); |
190 }; | 193 }; |
191 | 194 |
192 } // namespace bluez | 195 } // namespace bluez |
193 | 196 |
194 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ | 197 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ |
OLD | NEW |