| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_ |
| 7 | 7 |
| 8 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" | 8 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
| 9 | 9 |
| 10 #import <CoreBluetooth/CoreBluetooth.h> | 10 #import <CoreBluetooth/CoreBluetooth.h> |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 CBCharacteristic* GetCBCharacteristic() const; | 92 CBCharacteristic* GetCBCharacteristic() const; |
| 93 // Returns the mac adapter. | 93 // Returns the mac adapter. |
| 94 BluetoothAdapterMac* GetMacAdapter() const; | 94 BluetoothAdapterMac* GetMacAdapter() const; |
| 95 // Returns CoreBluetooth peripheral. | 95 // Returns CoreBluetooth peripheral. |
| 96 CBPeripheral* GetCBPeripheral() const; | 96 CBPeripheral* GetCBPeripheral() const; |
| 97 // Returns true if this characteristic has been fully discovered. | 97 // Returns true if this characteristic has been fully discovered. |
| 98 bool IsDiscoveryComplete() const; | 98 bool IsDiscoveryComplete() const; |
| 99 // Returns BluetoothRemoteGattDescriptorMac from CBDescriptor. | 99 // Returns BluetoothRemoteGattDescriptorMac from CBDescriptor. |
| 100 BluetoothRemoteGattDescriptorMac* GetBluetoothRemoteGattDescriptorMac( | 100 BluetoothRemoteGattDescriptorMac* GetBluetoothRemoteGattDescriptorMac( |
| 101 CBDescriptor* cb_descriptor) const; | 101 CBDescriptor* cb_descriptor) const; |
| 102 bool HasPendingRead() const { |
| 103 return !read_characteristic_value_callbacks_.first.is_null(); |
| 104 }; |
| 105 bool HasPendingWrite() const { |
| 106 return !write_characteristic_value_callbacks_.first.is_null(); |
| 107 }; |
| 102 // Is true if the characteristic has been discovered with all its descriptors. | 108 // Is true if the characteristic has been discovered with all its descriptors. |
| 103 bool is_discovery_complete_; | 109 bool is_discovery_complete_; |
| 104 // gatt_service_ owns instances of this class. | 110 // gatt_service_ owns instances of this class. |
| 105 BluetoothRemoteGattServiceMac* gatt_service_; | 111 BluetoothRemoteGattServiceMac* gatt_service_; |
| 106 // A characteristic from CBPeripheral.services.characteristics. | 112 // A characteristic from CBPeripheral.services.characteristics. |
| 107 base::scoped_nsobject<CBCharacteristic> cb_characteristic_; | 113 base::scoped_nsobject<CBCharacteristic> cb_characteristic_; |
| 108 // Characteristic identifier. | 114 // Characteristic identifier. |
| 109 std::string identifier_; | 115 std::string identifier_; |
| 110 // Service UUID. | 116 // Service UUID. |
| 111 BluetoothUUID uuid_; | 117 BluetoothUUID uuid_; |
| 112 // Characteristic value. | 118 // Characteristic value. |
| 113 std::vector<uint8_t> value_; | 119 std::vector<uint8_t> value_; |
| 114 // True if a gatt read or write request is in progress. | |
| 115 bool characteristic_value_read_or_write_in_progress_; | |
| 116 // ReadRemoteCharacteristic request callbacks. | 120 // ReadRemoteCharacteristic request callbacks. |
| 117 std::pair<ValueCallback, ErrorCallback> read_characteristic_value_callbacks_; | 121 std::pair<ValueCallback, ErrorCallback> read_characteristic_value_callbacks_; |
| 118 // WriteRemoteCharacteristic request callbacks. | 122 // WriteRemoteCharacteristic request callbacks. |
| 119 std::pair<base::Closure, ErrorCallback> write_characteristic_value_callbacks_; | 123 std::pair<base::Closure, ErrorCallback> write_characteristic_value_callbacks_; |
| 120 // Stores callbacks for SubscribeToNotifications and | 124 // Stores callbacks for SubscribeToNotifications and |
| 121 // UnsubscribeFromNotifications requests. | 125 // UnsubscribeFromNotifications requests. |
| 122 typedef std::pair<base::Closure, ErrorCallback> PendingNotifyCallbacks; | 126 typedef std::pair<base::Closure, ErrorCallback> PendingNotifyCallbacks; |
| 123 // Stores SubscribeToNotifications request callbacks. | 127 // Stores SubscribeToNotifications request callbacks. |
| 124 PendingNotifyCallbacks subscribe_to_notification_callbacks_; | 128 PendingNotifyCallbacks subscribe_to_notification_callbacks_; |
| 125 // Stores UnsubscribeFromNotifications request callbacks. | 129 // Stores UnsubscribeFromNotifications request callbacks. |
| 126 PendingNotifyCallbacks unsubscribe_from_notification_callbacks_; | 130 PendingNotifyCallbacks unsubscribe_from_notification_callbacks_; |
| 127 // Map of descriptors, keyed by descriptor identifier. | 131 // Map of descriptors, keyed by descriptor identifier. |
| 128 std::unordered_map<std::string, | 132 std::unordered_map<std::string, |
| 129 std::unique_ptr<BluetoothRemoteGattDescriptorMac>> | 133 std::unique_ptr<BluetoothRemoteGattDescriptorMac>> |
| 130 gatt_descriptor_macs_; | 134 gatt_descriptor_macs_; |
| 131 }; | 135 }; |
| 132 | 136 |
| 133 // Stream operator for logging. | 137 // Stream operator for logging. |
| 134 DEVICE_BLUETOOTH_EXPORT std::ostream& operator<<( | 138 DEVICE_BLUETOOTH_EXPORT std::ostream& operator<<( |
| 135 std::ostream& out, | 139 std::ostream& out, |
| 136 const BluetoothRemoteGattCharacteristicMac& characteristic); | 140 const BluetoothRemoteGattCharacteristicMac& characteristic); |
| 137 | 141 |
| 138 } // namespace device | 142 } // namespace device |
| 139 | 143 |
| 140 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_ | 144 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_ |
| OLD | NEW |