| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "device/bluetooth/bluetooth_low_energy_device_mac.h" | 5 #include "device/bluetooth/bluetooth_low_energy_device_mac.h" |
| 6 | 6 |
| 7 #import <CoreFoundation/CoreFoundation.h> | 7 #import <CoreFoundation/CoreFoundation.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 return 0; | 104 return 0; |
| 105 } | 105 } |
| 106 | 106 |
| 107 uint16_t BluetoothLowEnergyDeviceMac::GetAppearance() const { | 107 uint16_t BluetoothLowEnergyDeviceMac::GetAppearance() const { |
| 108 // TODO(crbug.com/588083): Implementing GetAppearance() | 108 // TODO(crbug.com/588083): Implementing GetAppearance() |
| 109 // on mac, win, and android platforms for chrome | 109 // on mac, win, and android platforms for chrome |
| 110 NOTIMPLEMENTED(); | 110 NOTIMPLEMENTED(); |
| 111 return 0; | 111 return 0; |
| 112 } | 112 } |
| 113 | 113 |
| 114 base::Optional<std::string> BluetoothLowEnergyDeviceMac::GetName() const { |
| 115 if ([peripheral_ name]) |
| 116 return base::SysNSStringToUTF8([peripheral_ name]); |
| 117 return base::nullopt; |
| 118 } |
| 119 |
| 114 int BluetoothLowEnergyDeviceMac::GetRSSI() const { | 120 int BluetoothLowEnergyDeviceMac::GetRSSI() const { |
| 115 return rssi_; | 121 return rssi_; |
| 116 } | 122 } |
| 117 | 123 |
| 118 bool BluetoothLowEnergyDeviceMac::IsPaired() const { | 124 bool BluetoothLowEnergyDeviceMac::IsPaired() const { |
| 119 return false; | 125 return false; |
| 120 } | 126 } |
| 121 | 127 |
| 122 bool BluetoothLowEnergyDeviceMac::IsConnected() const { | 128 bool BluetoothLowEnergyDeviceMac::IsConnected() const { |
| 123 return IsGattConnected(); | 129 return IsGattConnected(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 NOTIMPLEMENTED(); | 217 NOTIMPLEMENTED(); |
| 212 } | 218 } |
| 213 | 219 |
| 214 void BluetoothLowEnergyDeviceMac::ConnectToServiceInsecurely( | 220 void BluetoothLowEnergyDeviceMac::ConnectToServiceInsecurely( |
| 215 const device::BluetoothUUID& uuid, | 221 const device::BluetoothUUID& uuid, |
| 216 const ConnectToServiceCallback& callback, | 222 const ConnectToServiceCallback& callback, |
| 217 const ConnectToServiceErrorCallback& error_callback) { | 223 const ConnectToServiceErrorCallback& error_callback) { |
| 218 NOTIMPLEMENTED(); | 224 NOTIMPLEMENTED(); |
| 219 } | 225 } |
| 220 | 226 |
| 221 std::string BluetoothLowEnergyDeviceMac::GetDeviceName() const { | |
| 222 return base::SysNSStringToUTF8([peripheral_ name]); | |
| 223 } | |
| 224 | |
| 225 void BluetoothLowEnergyDeviceMac::CreateGattConnectionImpl() { | 227 void BluetoothLowEnergyDeviceMac::CreateGattConnectionImpl() { |
| 226 if (!IsGattConnected()) { | 228 if (!IsGattConnected()) { |
| 227 GetMacAdapter()->CreateGattConnection(this); | 229 GetMacAdapter()->CreateGattConnection(this); |
| 228 } | 230 } |
| 229 } | 231 } |
| 230 | 232 |
| 231 void BluetoothLowEnergyDeviceMac::DisconnectGatt() { | 233 void BluetoothLowEnergyDeviceMac::DisconnectGatt() { |
| 232 GetMacAdapter()->DisconnectGatt(this); | 234 GetMacAdapter()->DisconnectGatt(this); |
| 233 } | 235 } |
| 234 | 236 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 GattServiceMap gatt_services_swapped; | 387 GattServiceMap gatt_services_swapped; |
| 386 gatt_services_swapped.swap(gatt_services_); | 388 gatt_services_swapped.swap(gatt_services_); |
| 387 gatt_services_swapped.clear(); | 389 gatt_services_swapped.clear(); |
| 388 if (create_gatt_connection_error_callbacks_.empty()) { | 390 if (create_gatt_connection_error_callbacks_.empty()) { |
| 389 // TODO(http://crbug.com/585897): Need to pass the error. | 391 // TODO(http://crbug.com/585897): Need to pass the error. |
| 390 DidDisconnectGatt(); | 392 DidDisconnectGatt(); |
| 391 } else { | 393 } else { |
| 392 DidFailToConnectGatt(error_code); | 394 DidFailToConnectGatt(error_code); |
| 393 } | 395 } |
| 394 } | 396 } |
| OLD | NEW |