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

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

Issue 2205693003: bluetooth: Replace old advertised uuids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Fix mac Created 4 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
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 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = 59 BluetoothUUID service_uuid =
60 BluetoothAdapterMac::BluetoothUUIDWithCBUUID(uuid); 60 BluetoothAdapterMac::BluetoothUUIDWithCBUUID(uuid);
61 SetServiceData(service_uuid, static_cast<const char*>([data bytes]), 61 SetServiceData(service_uuid, static_cast<const char*>([data bytes]),
62 [data length]); 62 [data length]);
63 } 63 }
64 NSArray* service_uuids = 64 NSArray* service_uuids =
65 [advertisement_data objectForKey:CBAdvertisementDataServiceUUIDsKey]; 65 [advertisement_data objectForKey:CBAdvertisementDataServiceUUIDsKey];
66 advertised_uuids_.clear();
66 for (CBUUID* uuid in service_uuids) { 67 for (CBUUID* uuid in service_uuids) {
67 advertised_uuids_.insert( 68 advertised_uuids_.insert(
68 BluetoothUUID(std::string([[uuid UUIDString] UTF8String]))); 69 BluetoothUUID(std::string([[uuid UUIDString] UTF8String])));
69 } 70 }
70 NSArray* overflow_service_uuids = [advertisement_data 71 NSArray* overflow_service_uuids = [advertisement_data
71 objectForKey:CBAdvertisementDataOverflowServiceUUIDsKey]; 72 objectForKey:CBAdvertisementDataOverflowServiceUUIDsKey];
72 for (CBUUID* uuid in overflow_service_uuids) { 73 for (CBUUID* uuid in overflow_service_uuids) {
73 advertised_uuids_.insert( 74 advertised_uuids_.insert(
74 BluetoothUUID(std::string([[uuid UUIDString] UTF8String]))); 75 BluetoothUUID(std::string([[uuid UUIDString] UTF8String])));
75 } 76 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 135 }
135 136
136 bool BluetoothLowEnergyDeviceMac::IsConnectable() const { 137 bool BluetoothLowEnergyDeviceMac::IsConnectable() const {
137 return connectable_; 138 return connectable_;
138 } 139 }
139 140
140 bool BluetoothLowEnergyDeviceMac::IsConnecting() const { 141 bool BluetoothLowEnergyDeviceMac::IsConnecting() const {
141 return ([peripheral_ state] == CBPeripheralStateConnecting); 142 return ([peripheral_ state] == CBPeripheralStateConnecting);
142 } 143 }
143 144
144 BluetoothDevice::UUIDList BluetoothLowEnergyDeviceMac::GetUUIDs() const {
145 return BluetoothDevice::UUIDList(advertised_uuids_.begin(),
146 advertised_uuids_.end());
147 }
148
149 int16_t BluetoothLowEnergyDeviceMac::GetInquiryRSSI() const { 145 int16_t BluetoothLowEnergyDeviceMac::GetInquiryRSSI() const {
150 return kUnknownPower; 146 return kUnknownPower;
151 } 147 }
152 148
153 int16_t BluetoothLowEnergyDeviceMac::GetInquiryTxPower() const { 149 int16_t BluetoothLowEnergyDeviceMac::GetInquiryTxPower() const {
154 NOTIMPLEMENTED(); 150 NOTIMPLEMENTED();
155 return kUnknownPower; 151 return kUnknownPower;
156 } 152 }
157 153
158 bool BluetoothLowEnergyDeviceMac::ExpectingPinCode() const { 154 bool BluetoothLowEnergyDeviceMac::ExpectingPinCode() const {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 GattServiceMap gatt_services_swapped; 383 GattServiceMap gatt_services_swapped;
388 gatt_services_swapped.swap(gatt_services_); 384 gatt_services_swapped.swap(gatt_services_);
389 gatt_services_swapped.clear(); 385 gatt_services_swapped.clear();
390 if (create_gatt_connection_error_callbacks_.empty()) { 386 if (create_gatt_connection_error_callbacks_.empty()) {
391 // TODO(http://crbug.com/585897): Need to pass the error. 387 // TODO(http://crbug.com/585897): Need to pass the error.
392 DidDisconnectGatt(); 388 DidDisconnectGatt();
393 } else { 389 } else {
394 DidFailToConnectGatt(error_code); 390 DidFailToConnectGatt(error_code);
395 } 391 }
396 } 392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698