| 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::Optional<std::string>( |
| 117 base::SysNSStringToUTF8([peripheral_ name])); |
| 118 return base::Optional<std::string>(); |
| 119 } |
| 120 |
| 114 int BluetoothLowEnergyDeviceMac::GetRSSI() const { | 121 int BluetoothLowEnergyDeviceMac::GetRSSI() const { |
| 115 return rssi_; | 122 return rssi_; |
| 116 } | 123 } |
| 117 | 124 |
| 118 bool BluetoothLowEnergyDeviceMac::IsPaired() const { | 125 bool BluetoothLowEnergyDeviceMac::IsPaired() const { |
| 119 return false; | 126 return false; |
| 120 } | 127 } |
| 121 | 128 |
| 122 bool BluetoothLowEnergyDeviceMac::IsConnected() const { | 129 bool BluetoothLowEnergyDeviceMac::IsConnected() const { |
| 123 return IsGattConnected(); | 130 return IsGattConnected(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 NOTIMPLEMENTED(); | 218 NOTIMPLEMENTED(); |
| 212 } | 219 } |
| 213 | 220 |
| 214 void BluetoothLowEnergyDeviceMac::ConnectToServiceInsecurely( | 221 void BluetoothLowEnergyDeviceMac::ConnectToServiceInsecurely( |
| 215 const device::BluetoothUUID& uuid, | 222 const device::BluetoothUUID& uuid, |
| 216 const ConnectToServiceCallback& callback, | 223 const ConnectToServiceCallback& callback, |
| 217 const ConnectToServiceErrorCallback& error_callback) { | 224 const ConnectToServiceErrorCallback& error_callback) { |
| 218 NOTIMPLEMENTED(); | 225 NOTIMPLEMENTED(); |
| 219 } | 226 } |
| 220 | 227 |
| 221 std::string BluetoothLowEnergyDeviceMac::GetDeviceName() const { | |
| 222 return base::SysNSStringToUTF8([peripheral_ name]); | |
| 223 } | |
| 224 | |
| 225 void BluetoothLowEnergyDeviceMac::CreateGattConnectionImpl() { | 228 void BluetoothLowEnergyDeviceMac::CreateGattConnectionImpl() { |
| 226 if (!IsGattConnected()) { | 229 if (!IsGattConnected()) { |
| 227 GetMacAdapter()->CreateGattConnection(this); | 230 GetMacAdapter()->CreateGattConnection(this); |
| 228 } | 231 } |
| 229 } | 232 } |
| 230 | 233 |
| 231 void BluetoothLowEnergyDeviceMac::DisconnectGatt() { | 234 void BluetoothLowEnergyDeviceMac::DisconnectGatt() { |
| 232 GetMacAdapter()->DisconnectGatt(this); | 235 GetMacAdapter()->DisconnectGatt(this); |
| 233 } | 236 } |
| 234 | 237 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 GattServiceMap gatt_services_swapped; | 388 GattServiceMap gatt_services_swapped; |
| 386 gatt_services_swapped.swap(gatt_services_); | 389 gatt_services_swapped.swap(gatt_services_); |
| 387 gatt_services_swapped.clear(); | 390 gatt_services_swapped.clear(); |
| 388 if (create_gatt_connection_error_callbacks_.empty()) { | 391 if (create_gatt_connection_error_callbacks_.empty()) { |
| 389 // TODO(http://crbug.com/585897): Need to pass the error. | 392 // TODO(http://crbug.com/585897): Need to pass the error. |
| 390 DidDisconnectGatt(); | 393 DidDisconnectGatt(); |
| 391 } else { | 394 } else { |
| 392 DidFailToConnectGatt(error_code); | 395 DidFailToConnectGatt(error_code); |
| 393 } | 396 } |
| 394 } | 397 } |
| OLD | NEW |