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 CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ |
6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 virtual std::vector<dbus::ObjectPath> GetCharacteristics() OVERRIDE; | 49 virtual std::vector<dbus::ObjectPath> GetCharacteristics() OVERRIDE; |
50 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) | 50 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) |
51 OVERRIDE; | 51 OVERRIDE; |
52 | 52 |
53 // Makes the group of characteristics belonging to a particular GATT based | 53 // Makes the group of characteristics belonging to a particular GATT based |
54 // profile available under the GATT service with object path |service_path|. | 54 // profile available under the GATT service with object path |service_path|. |
55 // Characteristic paths are hierarchical to service paths. | 55 // Characteristic paths are hierarchical to service paths. |
56 void ExposeHeartRateCharacteristics(const dbus::ObjectPath& service_path); | 56 void ExposeHeartRateCharacteristics(const dbus::ObjectPath& service_path); |
57 void HideHeartRateCharacteristics(); | 57 void HideHeartRateCharacteristics(); |
58 | 58 |
| 59 // Returns whether or not the heart rate characteristics are visible and |
| 60 // performs the appropriate assertions. |
| 61 bool IsHeartRateVisible() const; |
| 62 |
| 63 // Returns the current object paths of exposed characteristics. If the |
| 64 // characteristic is not visible, returns an invalid empty path. |
| 65 dbus::ObjectPath GetHeartRateMeasurementPath() const; |
| 66 dbus::ObjectPath GetBodySensorLocationPath() const; |
| 67 dbus::ObjectPath GetHeartRateControlPointPath() const; |
| 68 |
59 // Object path components and UUIDs of GATT characteristics. | 69 // Object path components and UUIDs of GATT characteristics. |
60 // Heart Rate Service: | 70 // Heart Rate Service: |
61 static const char kHeartRateMeasurementPathComponent[]; | 71 static const char kHeartRateMeasurementPathComponent[]; |
62 static const char kHeartRateMeasurementUUID[]; | 72 static const char kHeartRateMeasurementUUID[]; |
63 static const char kBodySensorLocationPathComponent[]; | 73 static const char kBodySensorLocationPathComponent[]; |
64 static const char kBodySensorLocationUUID[]; | 74 static const char kBodySensorLocationUUID[]; |
65 static const char kHeartRateControlPointPathComponent[]; | 75 static const char kHeartRateControlPointPathComponent[]; |
66 static const char kHeartRateControlPointUUID[]; | 76 static const char kHeartRateControlPointUUID[]; |
67 | 77 |
68 private: | 78 private: |
69 // Property callback passed when we create Properties structures. | 79 // Property callback passed when we create Properties structures. |
70 void OnPropertyChanged(const dbus::ObjectPath& object_path, | 80 void OnPropertyChanged(const dbus::ObjectPath& object_path, |
71 const std::string& property_name); | 81 const std::string& property_name); |
72 | 82 |
73 // Notifies observers. | 83 // Notifies observers. |
74 void NotifyCharacteristicAdded(const dbus::ObjectPath& object_path); | 84 void NotifyCharacteristicAdded(const dbus::ObjectPath& object_path); |
75 void NotifyCharacteristicRemoved(const dbus::ObjectPath& object_path); | 85 void NotifyCharacteristicRemoved(const dbus::ObjectPath& object_path); |
76 | 86 |
77 // Schedules a heart rate measurement value change, if the heart rate | 87 // Schedules a heart rate measurement value change, if the heart rate |
78 // characteristics are visible. | 88 // characteristics are visible. |
79 void ScheduleHeartRateMeasurementValueChange(); | 89 void ScheduleHeartRateMeasurementValueChange(); |
80 | 90 |
81 // Returns a random Heart Rate Measurement value. All the fields of the value | 91 // Returns a random Heart Rate Measurement value. All the fields of the value |
82 // are populated according to the the fake behavior. The measurement value | 92 // are populated according to the the fake behavior. The measurement value |
83 // is a random value within a reasonable range. | 93 // is a random value within a reasonable range. |
84 std::vector<uint8> GetHeartRateMeasurementValue(); | 94 std::vector<uint8> GetHeartRateMeasurementValue(); |
85 | 95 |
86 // Returns whether or not the heart rate characteristics are visible and | |
87 // performs the appropriate assertions. | |
88 bool IsHeartRateVisible() const; | |
89 | |
90 // If true, characteristics of the Heart Rate Service are visible. Use | 96 // If true, characteristics of the Heart Rate Service are visible. Use |
91 // IsHeartRateVisible() to check the value. | 97 // IsHeartRateVisible() to check the value. |
92 bool heart_rate_visible_; | 98 bool heart_rate_visible_; |
93 | 99 |
94 // Total calories burned, used for the Heart Rate Measurement characteristic. | 100 // Total calories burned, used for the Heart Rate Measurement characteristic. |
95 uint16 calories_burned_; | 101 uint16 calories_burned_; |
96 | 102 |
97 // Static properties returned for simulated characteristics for the Heart | 103 // Static properties returned for simulated characteristics for the Heart |
98 // Rate Service. These pointers are not NULL only if the characteristics are | 104 // Rate Service. These pointers are not NULL only if the characteristics are |
99 // actually exposed. | 105 // actually exposed. |
(...skipping 16 matching lines...) Expand all Loading... |
116 // invalidate its weak pointers before any other members are destroyed. | 122 // invalidate its weak pointers before any other members are destroyed. |
117 base::WeakPtrFactory<FakeBluetoothGattCharacteristicClient> | 123 base::WeakPtrFactory<FakeBluetoothGattCharacteristicClient> |
118 weak_ptr_factory_; | 124 weak_ptr_factory_; |
119 | 125 |
120 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattCharacteristicClient); | 126 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothGattCharacteristicClient); |
121 }; | 127 }; |
122 | 128 |
123 } // namespace chromeos | 129 } // namespace chromeos |
124 | 130 |
125 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ | 131 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ |
OLD | NEW |