| 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 | 8 |
| 9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #include "base/mac/scoped_cftyperef.h" | 10 #include "base/mac/scoped_cftyperef.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 bool BluetoothLowEnergyDeviceMac::IsGattConnected() const { | 120 bool BluetoothLowEnergyDeviceMac::IsGattConnected() const { |
| 121 return (GetPeripheralState() == CBPeripheralStateConnected); | 121 return (GetPeripheralState() == CBPeripheralStateConnected); |
| 122 } | 122 } |
| 123 | 123 |
| 124 bool BluetoothLowEnergyDeviceMac::IsConnectable() const { | 124 bool BluetoothLowEnergyDeviceMac::IsConnectable() const { |
| 125 return connectable_; | 125 return connectable_; |
| 126 } | 126 } |
| 127 | 127 |
| 128 bool BluetoothLowEnergyDeviceMac::IsConnecting() const { | 128 bool BluetoothLowEnergyDeviceMac::IsConnecting() const { |
| 129 return false; | 129 return (GetPeripheralState() == CBPeripheralStateConnecting); |
| 130 } | 130 } |
| 131 | 131 |
| 132 BluetoothDevice::UUIDList BluetoothLowEnergyDeviceMac::GetUUIDs() const { | 132 BluetoothDevice::UUIDList BluetoothLowEnergyDeviceMac::GetUUIDs() const { |
| 133 return BluetoothDevice::UUIDList(advertised_uuids_.begin(), | 133 return BluetoothDevice::UUIDList(advertised_uuids_.begin(), |
| 134 advertised_uuids_.end()); | 134 advertised_uuids_.end()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 int16 BluetoothLowEnergyDeviceMac::GetInquiryRSSI() const { | 137 int16 BluetoothLowEnergyDeviceMac::GetInquiryRSSI() const { |
| 138 return kUnknownPower; | 138 return kUnknownPower; |
| 139 } | 139 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 NOTIMPLEMENTED(); | 205 NOTIMPLEMENTED(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void BluetoothLowEnergyDeviceMac::ConnectToServiceInsecurely( | 208 void BluetoothLowEnergyDeviceMac::ConnectToServiceInsecurely( |
| 209 const device::BluetoothUUID& uuid, | 209 const device::BluetoothUUID& uuid, |
| 210 const ConnectToServiceCallback& callback, | 210 const ConnectToServiceCallback& callback, |
| 211 const ConnectToServiceErrorCallback& error_callback) { | 211 const ConnectToServiceErrorCallback& error_callback) { |
| 212 NOTIMPLEMENTED(); | 212 NOTIMPLEMENTED(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void BluetoothLowEnergyDeviceMac::CreateGattConnection( | |
| 216 const GattConnectionCallback& callback, | |
| 217 const ConnectErrorCallback& error_callback) { | |
| 218 NOTIMPLEMENTED(); | |
| 219 } | |
| 220 | |
| 221 NSDate* BluetoothLowEnergyDeviceMac::GetLastUpdateTime() const { | 215 NSDate* BluetoothLowEnergyDeviceMac::GetLastUpdateTime() const { |
| 222 return last_update_time_.get(); | 216 return last_update_time_.get(); |
| 223 } | 217 } |
| 224 | 218 |
| 225 std::string BluetoothLowEnergyDeviceMac::GetDeviceName() const { | 219 std::string BluetoothLowEnergyDeviceMac::GetDeviceName() const { |
| 226 return base::SysNSStringToUTF8([peripheral_ name]); | 220 return base::SysNSStringToUTF8([peripheral_ name]); |
| 227 } | 221 } |
| 228 | 222 |
| 229 void BluetoothLowEnergyDeviceMac::CreateGattConnectionImpl() { | 223 void BluetoothLowEnergyDeviceMac::CreateGattConnectionImpl() { |
| 230 // Mac implementation does not yet use the default CreateGattConnection | 224 BluetoothAdapterMac* adapter = |
| 231 // implementation. http://crbug.com/520774 | 225 static_cast<BluetoothAdapterMac*>(this->adapter_); |
| 232 NOTIMPLEMENTED(); | 226 adapter->CreateGattConnection(this); |
| 227 } |
| 228 |
| 229 void BluetoothLowEnergyDeviceMac::GattConnected() { |
| 230 this->DidConnectGatt(); |
| 233 } | 231 } |
| 234 | 232 |
| 235 void BluetoothLowEnergyDeviceMac::DisconnectGatt() { | 233 void BluetoothLowEnergyDeviceMac::DisconnectGatt() { |
| 236 // Mac implementation does not yet use the default CreateGattConnection | 234 BluetoothAdapterMac* adapter = |
| 237 // implementation. http://crbug.com/520774 | 235 static_cast<BluetoothAdapterMac*>(this->adapter_); |
| 238 NOTIMPLEMENTED(); | 236 adapter->DisconnectGatt(this); |
| 239 } | 237 } |
| 240 | 238 |
| 241 // static | 239 // static |
| 242 std::string BluetoothLowEnergyDeviceMac::GetPeripheralIdentifier( | 240 std::string BluetoothLowEnergyDeviceMac::GetPeripheralIdentifier( |
| 243 CBPeripheral* peripheral) { | 241 CBPeripheral* peripheral) { |
| 244 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); | 242 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); |
| 245 NSUUID* uuid = [peripheral identifier]; | 243 NSUUID* uuid = [peripheral identifier]; |
| 246 NSString* uuidString = [uuid UUIDString]; | 244 NSString* uuidString = [uuid UUIDString]; |
| 247 return base::SysNSStringToUTF8(uuidString); | 245 return base::SysNSStringToUTF8(uuidString); |
| 248 } | 246 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 264 instanceMethodSignatureForSelector:@selector(state)] retain]); | 262 instanceMethodSignatureForSelector:@selector(state)] retain]); |
| 265 base::scoped_nsobject<NSInvocation> invocation( | 263 base::scoped_nsobject<NSInvocation> invocation( |
| 266 [[NSInvocation invocationWithMethodSignature:signature] retain]); | 264 [[NSInvocation invocationWithMethodSignature:signature] retain]); |
| 267 [invocation setTarget:peripheral_]; | 265 [invocation setTarget:peripheral_]; |
| 268 [invocation setSelector:@selector(state)]; | 266 [invocation setSelector:@selector(state)]; |
| 269 [invocation invoke]; | 267 [invocation invoke]; |
| 270 CBPeripheralState state = CBPeripheralStateDisconnected; | 268 CBPeripheralState state = CBPeripheralStateDisconnected; |
| 271 [invocation getReturnValue:&state]; | 269 [invocation getReturnValue:&state]; |
| 272 return state; | 270 return state; |
| 273 } | 271 } |
| OLD | NEW |