| 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 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 | 11 |
| 12 #if defined(__OBJC__) |
| 13 #import <CoreBluetooth/CoreBluetooth.h> |
| 14 #else |
| 12 @class CBCharacteristic; | 15 @class CBCharacteristic; |
| 16 typedef NS_ENUM(NSInteger, CBCharacteristicWriteType); |
| 17 #endif // defined(__OBJC__) |
| 13 | 18 |
| 14 namespace device { | 19 namespace device { |
| 15 | 20 |
| 16 class BluetoothRemoteGattServiceMac; | 21 class BluetoothRemoteGattServiceMac; |
| 17 | 22 |
| 18 // The BluetoothRemoteGattCharacteristicMac class implements | 23 // The BluetoothRemoteGattCharacteristicMac class implements |
| 19 // BluetoothRemoteGattCharacteristic for remote GATT services on OS X. | 24 // BluetoothRemoteGattCharacteristic for remote GATT services on OS X. |
| 20 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicMac | 25 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattCharacteristicMac |
| 21 : public BluetoothRemoteGattCharacteristic { | 26 : public BluetoothRemoteGattCharacteristic { |
| 22 public: | 27 public: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 48 | 53 |
| 49 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicMac); | 54 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicMac); |
| 50 | 55 |
| 51 private: | 56 private: |
| 52 friend class BluetoothRemoteGattServiceMac; | 57 friend class BluetoothRemoteGattServiceMac; |
| 53 friend class BluetoothTestMac; | 58 friend class BluetoothTestMac; |
| 54 | 59 |
| 55 // Called by the BluetoothRemoteGattServiceMac instance when the | 60 // Called by the BluetoothRemoteGattServiceMac instance when the |
| 56 // characteristics value has been read. | 61 // characteristics value has been read. |
| 57 void DidUpdateValue(NSError* error); | 62 void DidUpdateValue(NSError* error); |
| 63 // Called by the BluetoothRemoteGattServiceMac instance when the |
| 64 // characteristics value has been written. |
| 65 void DidWriteValue(NSError* error); |
| 58 // Returns true if the characteristic is readable. | 66 // Returns true if the characteristic is readable. |
| 59 bool IsReadable() const; | 67 bool IsReadable() const; |
| 68 // Returns true if the characteristic is writable. |
| 69 bool IsWritable() const; |
| 70 // Returns the write type (with or without responses). |
| 71 CBCharacteristicWriteType GetCBWriteType() const; |
| 60 // Returns CoreBluetooth characteristic. | 72 // Returns CoreBluetooth characteristic. |
| 61 CBCharacteristic* GetCBCharacteristic() const; | 73 CBCharacteristic* GetCBCharacteristic() const; |
| 62 | 74 |
| 63 // gatt_service_ owns instances of this class. | 75 // gatt_service_ owns instances of this class. |
| 64 BluetoothRemoteGattServiceMac* gatt_service_; | 76 BluetoothRemoteGattServiceMac* gatt_service_; |
| 65 // A characteristic from CBPeripheral.services.characteristics. | 77 // A characteristic from CBPeripheral.services.characteristics. |
| 66 base::scoped_nsobject<CBCharacteristic> cb_characteristic_; | 78 base::scoped_nsobject<CBCharacteristic> cb_characteristic_; |
| 67 // Characteristic identifier. | 79 // Characteristic identifier. |
| 68 std::string identifier_; | 80 std::string identifier_; |
| 69 // Service UUID. | 81 // Service UUID. |
| 70 BluetoothUUID uuid_; | 82 BluetoothUUID uuid_; |
| 71 // Characteristic value. | 83 // Characteristic value. |
| 72 std::vector<uint8_t> value_; | 84 std::vector<uint8_t> value_; |
| 73 // True if a gatt read or write request is in progress. | 85 // True if a gatt read or write request is in progress. |
| 74 bool characteristic_value_read_or_write_in_progress_; | 86 bool characteristic_value_read_or_write_in_progress_; |
| 75 // ReadRemoteCharacteristic request callbacks. | 87 // ReadRemoteCharacteristic request callbacks. |
| 76 std::pair<ValueCallback, ErrorCallback> read_characteristic_value_callbacks_; | 88 std::pair<ValueCallback, ErrorCallback> read_characteristic_value_callbacks_; |
| 89 // WriteRemoteCharacteristic request callbacks. |
| 90 std::pair<base::Closure, ErrorCallback> write_characteristic_value_callbacks_; |
| 77 }; | 91 }; |
| 78 | 92 |
| 79 } // namespace device | 93 } // namespace device |
| 80 | 94 |
| 81 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_ | 95 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_MAC_H_ |
| OLD | NEW |