Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: device/bluetooth/bluetooth_low_energy_device_mac.mm

Issue 1272503002: Fixed 2 bugs so that RequestDevice() works for non-paired devices (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test3
Patch Set: scheib fix Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_device_mac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 NSDictionary* advertisement_data, 46 NSDictionary* advertisement_data,
47 int rssi) { 47 int rssi) {
48 last_update_time_.reset([[NSDate date] retain]); 48 last_update_time_.reset([[NSDate date] retain]);
49 peripheral_.reset([peripheral retain]); 49 peripheral_.reset([peripheral retain]);
50 rssi_ = rssi; 50 rssi_ = rssi;
51 NSNumber* connectable = 51 NSNumber* connectable =
52 [advertisement_data objectForKey:CBAdvertisementDataIsConnectable]; 52 [advertisement_data objectForKey:CBAdvertisementDataIsConnectable];
53 connectable_ = [connectable boolValue]; 53 connectable_ = [connectable boolValue];
54 ClearServiceData(); 54 ClearServiceData();
55 NSDictionary* service_data = 55 NSDictionary* service_data =
56 [advertisement_data objectForKey:@"CBAdvertisementDataServiceDataKey"]; 56 [advertisement_data objectForKey:CBAdvertisementDataServiceDataKey];
57 for (CBUUID* uuid in service_data) { 57 for (CBUUID* uuid in service_data) {
58 NSData* data = [service_data objectForKey:uuid]; 58 NSData* data = [service_data objectForKey:uuid];
59 BluetoothUUID service_uuid = BluetoothUUIDWithCBUUID(uuid); 59 BluetoothUUID service_uuid = BluetoothUUIDWithCBUUID(uuid);
60 SetServiceData(service_uuid, static_cast<const char*>([data bytes]), 60 SetServiceData(service_uuid, static_cast<const char*>([data bytes]),
61 [data length]); 61 [data length]);
62 } 62 }
63 advertised_uuids_.clear();
64 NSArray* service_uuids = 63 NSArray* service_uuids =
65 [advertisement_data objectForKey:@"CBAdvertisementDataServiceUUIDsKey"]; 64 [advertisement_data objectForKey:CBAdvertisementDataServiceUUIDsKey];
66 for (CBUUID* uuid in service_uuids) { 65 for (CBUUID* uuid in service_uuids) {
67 advertised_uuids_.push_back( 66 advertised_uuids_.insert(
67 BluetoothUUID(std::string([[uuid UUIDString] UTF8String])));
68 }
69 NSArray* overflow_service_uuids = [advertisement_data
70 objectForKey:CBAdvertisementDataOverflowServiceUUIDsKey];
71 for (CBUUID* uuid in overflow_service_uuids) {
72 advertised_uuids_.insert(
68 BluetoothUUID(std::string([[uuid UUIDString] UTF8String]))); 73 BluetoothUUID(std::string([[uuid UUIDString] UTF8String])));
69 } 74 }
70 } 75 }
71 76
72 std::string BluetoothLowEnergyDeviceMac::GetIdentifier() const { 77 std::string BluetoothLowEnergyDeviceMac::GetIdentifier() const {
73 return identifier_; 78 return identifier_;
74 } 79 }
75 80
76 uint32 BluetoothLowEnergyDeviceMac::GetBluetoothClass() const { 81 uint32 BluetoothLowEnergyDeviceMac::GetBluetoothClass() const {
77 return 0x1F00; // Unspecified Device Class 82 return 0x1F00; // Unspecified Device Class
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 117
113 bool BluetoothLowEnergyDeviceMac::IsConnectable() const { 118 bool BluetoothLowEnergyDeviceMac::IsConnectable() const {
114 return connectable_; 119 return connectable_;
115 } 120 }
116 121
117 bool BluetoothLowEnergyDeviceMac::IsConnecting() const { 122 bool BluetoothLowEnergyDeviceMac::IsConnecting() const {
118 return false; 123 return false;
119 } 124 }
120 125
121 BluetoothDevice::UUIDList BluetoothLowEnergyDeviceMac::GetUUIDs() const { 126 BluetoothDevice::UUIDList BluetoothLowEnergyDeviceMac::GetUUIDs() const {
122 return advertised_uuids_; 127 return BluetoothDevice::UUIDList(advertised_uuids_.begin(),
128 advertised_uuids_.end());
123 } 129 }
124 130
125 int16 BluetoothLowEnergyDeviceMac::GetInquiryRSSI() const { 131 int16 BluetoothLowEnergyDeviceMac::GetInquiryRSSI() const {
126 return kUnknownPower; 132 return kUnknownPower;
127 } 133 }
128 134
129 int16 BluetoothLowEnergyDeviceMac::GetInquiryTxPower() const { 135 int16 BluetoothLowEnergyDeviceMac::GetInquiryTxPower() const {
130 NOTIMPLEMENTED(); 136 NOTIMPLEMENTED();
131 return kUnknownPower; 137 return kUnknownPower;
132 } 138 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 instanceMethodSignatureForSelector:@selector(state)] retain]); 245 instanceMethodSignatureForSelector:@selector(state)] retain]);
240 base::scoped_nsobject<NSInvocation> invocation( 246 base::scoped_nsobject<NSInvocation> invocation(
241 [[NSInvocation invocationWithMethodSignature:signature] retain]); 247 [[NSInvocation invocationWithMethodSignature:signature] retain]);
242 [invocation setTarget:peripheral_]; 248 [invocation setTarget:peripheral_];
243 [invocation setSelector:@selector(state)]; 249 [invocation setSelector:@selector(state)];
244 [invocation invoke]; 250 [invocation invoke];
245 CBPeripheralState state = CBPeripheralStateDisconnected; 251 CBPeripheralState state = CBPeripheralStateDisconnected;
246 [invocation getReturnValue:&state]; 252 [invocation getReturnValue:&state];
247 return state; 253 return state;
248 } 254 }
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_device_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698