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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 int BluetoothLowEnergyDeviceMac::GetRSSI() const { | 108 int BluetoothLowEnergyDeviceMac::GetRSSI() const { |
109 return rssi_; | 109 return rssi_; |
110 } | 110 } |
111 | 111 |
112 bool BluetoothLowEnergyDeviceMac::IsPaired() const { | 112 bool BluetoothLowEnergyDeviceMac::IsPaired() const { |
113 return false; | 113 return false; |
114 } | 114 } |
115 | 115 |
116 bool BluetoothLowEnergyDeviceMac::IsConnected() const { | 116 bool BluetoothLowEnergyDeviceMac::IsConnected() const { |
| 117 return IsGattConnected(); |
| 118 } |
| 119 |
| 120 bool BluetoothLowEnergyDeviceMac::IsGattConnected() const { |
117 return (GetPeripheralState() == CBPeripheralStateConnected); | 121 return (GetPeripheralState() == CBPeripheralStateConnected); |
118 } | 122 } |
119 | 123 |
120 bool BluetoothLowEnergyDeviceMac::IsConnectable() const { | 124 bool BluetoothLowEnergyDeviceMac::IsConnectable() const { |
121 return connectable_; | 125 return connectable_; |
122 } | 126 } |
123 | 127 |
124 bool BluetoothLowEnergyDeviceMac::IsConnecting() const { | 128 bool BluetoothLowEnergyDeviceMac::IsConnecting() const { |
125 return false; | 129 return false; |
126 } | 130 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 218 } |
215 | 219 |
216 NSDate* BluetoothLowEnergyDeviceMac::GetLastUpdateTime() const { | 220 NSDate* BluetoothLowEnergyDeviceMac::GetLastUpdateTime() const { |
217 return last_update_time_.get(); | 221 return last_update_time_.get(); |
218 } | 222 } |
219 | 223 |
220 std::string BluetoothLowEnergyDeviceMac::GetDeviceName() const { | 224 std::string BluetoothLowEnergyDeviceMac::GetDeviceName() const { |
221 return base::SysNSStringToUTF8([peripheral_ name]); | 225 return base::SysNSStringToUTF8([peripheral_ name]); |
222 } | 226 } |
223 | 227 |
| 228 void BluetoothLowEnergyDeviceMac::CreateGattConnectionImpl() { |
| 229 // Mac implementation does not yet use the default CreateGattConnection |
| 230 // implementation. http://crbug.com/520774 |
| 231 NOTIMPLEMENTED(); |
| 232 } |
| 233 |
| 234 void BluetoothLowEnergyDeviceMac::DisconnectGatt() { |
| 235 // Mac implementation does not yet use the default CreateGattConnection |
| 236 // implementation. http://crbug.com/520774 |
| 237 NOTIMPLEMENTED(); |
| 238 } |
| 239 |
224 // static | 240 // static |
225 std::string BluetoothLowEnergyDeviceMac::GetPeripheralIdentifier( | 241 std::string BluetoothLowEnergyDeviceMac::GetPeripheralIdentifier( |
226 CBPeripheral* peripheral) { | 242 CBPeripheral* peripheral) { |
227 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); | 243 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); |
228 NSUUID* uuid = [peripheral identifier]; | 244 NSUUID* uuid = [peripheral identifier]; |
229 NSString* uuidString = [uuid UUIDString]; | 245 NSString* uuidString = [uuid UUIDString]; |
230 return base::SysNSStringToUTF8(uuidString); | 246 return base::SysNSStringToUTF8(uuidString); |
231 } | 247 } |
232 | 248 |
233 // static | 249 // static |
(...skipping 13 matching lines...) Expand all Loading... |
247 instanceMethodSignatureForSelector:@selector(state)] retain]); | 263 instanceMethodSignatureForSelector:@selector(state)] retain]); |
248 base::scoped_nsobject<NSInvocation> invocation( | 264 base::scoped_nsobject<NSInvocation> invocation( |
249 [[NSInvocation invocationWithMethodSignature:signature] retain]); | 265 [[NSInvocation invocationWithMethodSignature:signature] retain]); |
250 [invocation setTarget:peripheral_]; | 266 [invocation setTarget:peripheral_]; |
251 [invocation setSelector:@selector(state)]; | 267 [invocation setSelector:@selector(state)]; |
252 [invocation invoke]; | 268 [invocation invoke]; |
253 CBPeripheralState state = CBPeripheralStateDisconnected; | 269 CBPeripheralState state = CBPeripheralStateDisconnected; |
254 [invocation getReturnValue:&state]; | 270 [invocation getReturnValue:&state]; |
255 return state; | 271 return state; |
256 } | 272 } |
OLD | NEW |