 Chromium Code Reviews
 Chromium Code Reviews Issue 1211013005:
  Added class BluetoothDeviceMac, returns mac device timing data  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@pre-hash
    
  
    Issue 1211013005:
  Added class BluetoothDeviceMac, returns mac device timing data  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@pre-hash| 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/scoped_cftyperef.h" | 9 #include "base/mac/scoped_cftyperef.h" | 
| 10 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 BluetoothLowEnergyDeviceMac::BluetoothLowEnergyDeviceMac( | 65 BluetoothLowEnergyDeviceMac::BluetoothLowEnergyDeviceMac( | 
| 66 CBPeripheral* peripheral, | 66 CBPeripheral* peripheral, | 
| 67 NSDictionary* advertisementData, | 67 NSDictionary* advertisementData, | 
| 68 int rssi) { | 68 int rssi) { | 
| 69 Update(peripheral, advertisementData, rssi); | 69 Update(peripheral, advertisementData, rssi); | 
| 70 } | 70 } | 
| 71 | 71 | 
| 72 BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() { | 72 BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() { | 
| 73 } | 73 } | 
| 74 | 74 | 
| 75 void BluetoothLowEnergyDeviceMac::Update(CBPeripheral* peripheral, | 75 void BluetoothLowEnergyDeviceMac::Update(CBPeripheral* peripheral, | 
| 
scheib
2015/06/30 16:58:18
If a device is known, added to the adapter, and th
 
krstnmnlsn
2015/06/30 17:39:11
Yes BluetoothAdapterMac::LowEnergyDeviceUpdated(..
 | |
| 76 NSDictionary* advertisementData, | 76 NSDictionary* advertisementData, | 
| 77 int rssi) { | 77 int rssi) { | 
| 78 last_update_time = [NSDate date]; | |
| 
armansito
2015/06/30 20:44:39
Does Chrome have ARC enabled? If you're explicitly
 
krstnmnlsn
2015/07/01 17:37:16
We don't use ARC.  Meant for this to be a scoped_n
 | |
| 78 peripheral_.reset([peripheral retain]); | 79 peripheral_.reset([peripheral retain]); | 
| 79 rssi_ = rssi; | 80 rssi_ = rssi; | 
| 80 ClearServiceData(); | 81 ClearServiceData(); | 
| 81 NSNumber* nbConnectable = | 82 NSNumber* nbConnectable = | 
| 82 [advertisementData objectForKey:CBAdvertisementDataIsConnectable]; | 83 [advertisementData objectForKey:CBAdvertisementDataIsConnectable]; | 
| 83 connectable_ = [nbConnectable boolValue]; | 84 connectable_ = [nbConnectable boolValue]; | 
| 84 NSDictionary* serviceData = | 85 NSDictionary* serviceData = | 
| 85 [advertisementData objectForKey:CBAdvertisementDataServiceDataKey]; | 86 [advertisementData objectForKey:CBAdvertisementDataServiceDataKey]; | 
| 86 for (CBUUID* uuid in serviceData) { | 87 for (CBUUID* uuid in serviceData) { | 
| 87 NSData* data = [serviceData objectForKey:uuid]; | 88 NSData* data = [serviceData objectForKey:uuid]; | 
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 const ConnectToServiceErrorCallback& error_callback) { | 220 const ConnectToServiceErrorCallback& error_callback) { | 
| 220 NOTIMPLEMENTED(); | 221 NOTIMPLEMENTED(); | 
| 221 } | 222 } | 
| 222 | 223 | 
| 223 void BluetoothLowEnergyDeviceMac::CreateGattConnection( | 224 void BluetoothLowEnergyDeviceMac::CreateGattConnection( | 
| 224 const GattConnectionCallback& callback, | 225 const GattConnectionCallback& callback, | 
| 225 const ConnectErrorCallback& error_callback) { | 226 const ConnectErrorCallback& error_callback) { | 
| 226 NOTIMPLEMENTED(); | 227 NOTIMPLEMENTED(); | 
| 227 } | 228 } | 
| 228 | 229 | 
| 230 NSDate* BluetoothLowEnergyDeviceMac::GetLastUpdateTime() const { | |
| 231 return last_update_time; | |
| 232 } | |
| 233 | |
| 229 std::string BluetoothLowEnergyDeviceMac::GetDeviceName() const { | 234 std::string BluetoothLowEnergyDeviceMac::GetDeviceName() const { | 
| 230 return base::SysNSStringToUTF8([peripheral_ name]); | 235 return base::SysNSStringToUTF8([peripheral_ name]); | 
| 231 } | 236 } | 
| 232 | 237 | 
| 233 std::string BluetoothLowEnergyDeviceMac::GetPeripheralIdentifier( | 238 std::string BluetoothLowEnergyDeviceMac::GetPeripheralIdentifier( | 
| 234 CBPeripheral* peripheral) { | 239 CBPeripheral* peripheral) { | 
| 235 // TODO(dvh): Remove this once we moved to OSX SDK >= 10.9. | 240 // TODO(dvh): Remove this once we moved to OSX SDK >= 10.9. | 
| 236 if ([peripheral respondsToSelector:@selector(identifier)]) { | 241 if ([peripheral respondsToSelector:@selector(identifier)]) { | 
| 237 // When -[CBPeripheral identifier] is available. | 242 // When -[CBPeripheral identifier] is available. | 
| 238 NSUUID* uuid = [peripheral identifier]; | 243 NSUUID* uuid = [peripheral identifier]; | 
| 239 NSString* uuidString = [uuid UUIDString]; | 244 NSString* uuidString = [uuid UUIDString]; | 
| 240 return base::SysNSStringToUTF8(uuidString); | 245 return base::SysNSStringToUTF8(uuidString); | 
| 241 } | 246 } | 
| 242 | 247 | 
| 243 base::ScopedCFTypeRef<CFStringRef> str( | 248 base::ScopedCFTypeRef<CFStringRef> str( | 
| 244 CFUUIDCreateString(NULL, [peripheral UUID])); | 249 CFUUIDCreateString(NULL, [peripheral UUID])); | 
| 245 return SysCFStringRefToUTF8(str); | 250 return SysCFStringRefToUTF8(str); | 
| 246 } | 251 } | 
| OLD | NEW |