| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_mac.h" |
| 6 |
| 7 #include "base/strings/sys_string_conversions.h" |
| 8 #include "device/bluetooth/bluetooth_adapter_mac.h" |
| 9 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h" |
| 10 |
| 11 namespace device { |
| 12 |
| 13 BluetoothRemoteGattDescriptorMac::BluetoothRemoteGattDescriptorMac( |
| 14 BluetoothRemoteGattCharacteristicMac* characteristic, |
| 15 CBDescriptor* descriptor) |
| 16 : gatt_characteristic_(characteristic), |
| 17 cb_descriptor_(descriptor, base::scoped_policy::RETAIN) { |
| 18 uuid_ = |
| 19 BluetoothAdapterMac::BluetoothUUIDWithCBUUID([cb_descriptor_.get() UUID]); |
| 20 identifier_ = base::SysNSStringToUTF8( |
| 21 [NSString stringWithFormat:@"%s-%p", uuid_.canonical_value().c_str(), |
| 22 (void*)cb_descriptor_]); |
| 23 } |
| 24 |
| 25 std::string BluetoothRemoteGattDescriptorMac::GetIdentifier() const { |
| 26 return identifier_; |
| 27 } |
| 28 |
| 29 BluetoothUUID BluetoothRemoteGattDescriptorMac::GetUUID() const { |
| 30 return uuid_; |
| 31 } |
| 32 |
| 33 BluetoothGattCharacteristic::Permissions |
| 34 BluetoothRemoteGattDescriptorMac::GetPermissions() const { |
| 35 NOTIMPLEMENTED(); |
| 36 return BluetoothGattCharacteristic::PERMISSION_NONE; |
| 37 } |
| 38 |
| 39 const std::vector<uint8_t>& BluetoothRemoteGattDescriptorMac::GetValue() const { |
| 40 return value_; |
| 41 } |
| 42 |
| 43 BluetoothRemoteGattDescriptorMac::~BluetoothRemoteGattDescriptorMac() {} |
| 44 |
| 45 // Returns a pointer to the GATT characteristic that this characteristic |
| 46 // descriptor belongs to. |
| 47 BluetoothRemoteGattCharacteristic* |
| 48 BluetoothRemoteGattDescriptorMac::GetCharacteristic() const { |
| 49 return static_cast<BluetoothRemoteGattCharacteristic*>(gatt_characteristic_); |
| 50 } |
| 51 |
| 52 // Sends a read request to a remote characteristic descriptor to read its |
| 53 // value. |callback| is called to return the read value on success and |
| 54 // |error_callback| is called for failures. |
| 55 void BluetoothRemoteGattDescriptorMac::ReadRemoteDescriptor( |
| 56 const ValueCallback& callback, |
| 57 const ErrorCallback& error_callback) { |
| 58 NOTIMPLEMENTED(); |
| 59 } |
| 60 |
| 61 // Sends a write request to a remote characteristic descriptor, to modify the |
| 62 // value of the descriptor with the new value |new_value|. |callback| is |
| 63 // called to signal success and |error_callback| for failures. This method |
| 64 // only applies to remote descriptors and will fail for those that are locally |
| 65 // hosted. |
| 66 void BluetoothRemoteGattDescriptorMac::WriteRemoteDescriptor( |
| 67 const std::vector<uint8_t>& new_value, |
| 68 const base::Closure& callback, |
| 69 const ErrorCallback& error_callback) { |
| 70 NOTIMPLEMENTED(); |
| 71 } |
| 72 |
| 73 CBDescriptor* BluetoothRemoteGattDescriptorMac::GetCBDescriptor() const { |
| 74 return cb_descriptor_.get(); |
| 75 } |
| 76 |
| 77 } // namespace device. |
| OLD | NEW |