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

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

Issue 1538173003: Implementing GATT connection/disconnect on OS X. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing chromium.gyp_env Created 4 years, 11 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 bool BluetoothLowEnergyDeviceMac::IsGattConnected() const { 121 bool BluetoothLowEnergyDeviceMac::IsGattConnected() const {
122 return (GetPeripheralState() == CBPeripheralStateConnected); 122 return (GetPeripheralState() == CBPeripheralStateConnected);
123 } 123 }
124 124
125 bool BluetoothLowEnergyDeviceMac::IsConnectable() const { 125 bool BluetoothLowEnergyDeviceMac::IsConnectable() const {
126 return connectable_; 126 return connectable_;
127 } 127 }
128 128
129 bool BluetoothLowEnergyDeviceMac::IsConnecting() const { 129 bool BluetoothLowEnergyDeviceMac::IsConnecting() const {
130 return false; 130 return (GetPeripheralState() == CBPeripheralStateConnecting);
131 } 131 }
132 132
133 BluetoothDevice::UUIDList BluetoothLowEnergyDeviceMac::GetUUIDs() const { 133 BluetoothDevice::UUIDList BluetoothLowEnergyDeviceMac::GetUUIDs() const {
134 return BluetoothDevice::UUIDList(advertised_uuids_.begin(), 134 return BluetoothDevice::UUIDList(advertised_uuids_.begin(),
135 advertised_uuids_.end()); 135 advertised_uuids_.end());
136 } 136 }
137 137
138 int16_t BluetoothLowEnergyDeviceMac::GetInquiryRSSI() const { 138 int16_t BluetoothLowEnergyDeviceMac::GetInquiryRSSI() const {
139 return kUnknownPower; 139 return kUnknownPower;
140 } 140 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 NOTIMPLEMENTED(); 206 NOTIMPLEMENTED();
207 } 207 }
208 208
209 void BluetoothLowEnergyDeviceMac::ConnectToServiceInsecurely( 209 void BluetoothLowEnergyDeviceMac::ConnectToServiceInsecurely(
210 const device::BluetoothUUID& uuid, 210 const device::BluetoothUUID& uuid,
211 const ConnectToServiceCallback& callback, 211 const ConnectToServiceCallback& callback,
212 const ConnectToServiceErrorCallback& error_callback) { 212 const ConnectToServiceErrorCallback& error_callback) {
213 NOTIMPLEMENTED(); 213 NOTIMPLEMENTED();
214 } 214 }
215 215
216 void BluetoothLowEnergyDeviceMac::CreateGattConnection(
217 const GattConnectionCallback& callback,
218 const ConnectErrorCallback& error_callback) {
219 NOTIMPLEMENTED();
220 }
221
222 NSDate* BluetoothLowEnergyDeviceMac::GetLastUpdateTime() const { 216 NSDate* BluetoothLowEnergyDeviceMac::GetLastUpdateTime() const {
223 return last_update_time_.get(); 217 return last_update_time_.get();
224 } 218 }
225 219
226 std::string BluetoothLowEnergyDeviceMac::GetDeviceName() const { 220 std::string BluetoothLowEnergyDeviceMac::GetDeviceName() const {
227 return base::SysNSStringToUTF8([peripheral_ name]); 221 return base::SysNSStringToUTF8([peripheral_ name]);
228 } 222 }
229 223
230 void BluetoothLowEnergyDeviceMac::CreateGattConnectionImpl() { 224 void BluetoothLowEnergyDeviceMac::CreateGattConnectionImpl() {
231 // Mac implementation does not yet use the default CreateGattConnection 225 BluetoothAdapterMac* adapter =
232 // implementation. http://crbug.com/520774 226 static_cast<BluetoothAdapterMac*>(this->adapter_);
233 NOTIMPLEMENTED(); 227 adapter->CreateGattConnection(this);
228 }
229
230 void BluetoothLowEnergyDeviceMac::GattConnected() {
scheib 2016/01/27 01:09:03 Please match declaration and definition order. (mo
jlebel 2016/02/10 13:38:51 Done.
231 this->DidConnectGatt();
234 } 232 }
235 233
236 void BluetoothLowEnergyDeviceMac::DisconnectGatt() { 234 void BluetoothLowEnergyDeviceMac::DisconnectGatt() {
237 // Mac implementation does not yet use the default CreateGattConnection 235 BluetoothAdapterMac* adapter =
238 // implementation. http://crbug.com/520774 236 static_cast<BluetoothAdapterMac*>(this->adapter_);
239 NOTIMPLEMENTED(); 237 adapter->DisconnectGatt(this);
238 }
239
240 device::BluetoothAdapterMac*
241 BluetoothLowEnergyDeviceMac::GetBluetoothAdapterMac() {
242 BluetoothAdapterMac* adapter =
243 static_cast<BluetoothAdapterMac*>(this->adapter_);
244 return adapter;
245 }
246
247 CBPeripheral* BluetoothLowEnergyDeviceMac::GetPeripheral() {
248 return peripheral_;
240 } 249 }
241 250
242 // static 251 // static
243 std::string BluetoothLowEnergyDeviceMac::GetPeripheralIdentifier( 252 std::string BluetoothLowEnergyDeviceMac::GetPeripheralIdentifier(
244 CBPeripheral* peripheral) { 253 CBPeripheral* peripheral) {
245 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); 254 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable());
246 NSUUID* uuid = [peripheral identifier]; 255 NSUUID* uuid = [peripheral identifier];
247 NSString* uuidString = [uuid UUIDString]; 256 NSString* uuidString = [uuid UUIDString];
248 return base::SysNSStringToUTF8(uuidString); 257 return base::SysNSStringToUTF8(uuidString);
249 } 258 }
(...skipping 15 matching lines...) Expand all
265 instanceMethodSignatureForSelector:@selector(state)] retain]); 274 instanceMethodSignatureForSelector:@selector(state)] retain]);
266 base::scoped_nsobject<NSInvocation> invocation( 275 base::scoped_nsobject<NSInvocation> invocation(
267 [[NSInvocation invocationWithMethodSignature:signature] retain]); 276 [[NSInvocation invocationWithMethodSignature:signature] retain]);
268 [invocation setTarget:peripheral_]; 277 [invocation setTarget:peripheral_];
269 [invocation setSelector:@selector(state)]; 278 [invocation setSelector:@selector(state)];
270 [invocation invoke]; 279 [invocation invoke];
271 CBPeripheralState state = CBPeripheralStateDisconnected; 280 CBPeripheralState state = CBPeripheralStateDisconnected;
272 [invocation getReturnValue:&state]; 281 [invocation getReturnValue:&state];
273 return state; 282 return state;
274 } 283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698