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

Unified 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: Sorting methods between bluetooth_adapter_mac.h and bluetooth_adapter_mac.mm Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_low_energy_device_mac.mm
diff --git a/device/bluetooth/bluetooth_low_energy_device_mac.mm b/device/bluetooth/bluetooth_low_energy_device_mac.mm
index 677c59557087bc8be0e1cb5f92a9d631ec910e7b..176b58284c5207560e97d8b6f329ebfe38196183 100644
--- a/device/bluetooth/bluetooth_low_energy_device_mac.mm
+++ b/device/bluetooth/bluetooth_low_energy_device_mac.mm
@@ -43,6 +43,11 @@ BluetoothLowEnergyDeviceMac::BluetoothLowEnergyDeviceMac(
}
BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() {
+ if (this->IsGattConnected()) {
scheib 2016/02/10 18:59:46 if (IsGattConnected())
jlebel 2016/02/10 21:20:07 Done.
+ BluetoothAdapterMac* adapter =
+ static_cast<BluetoothAdapterMac*>(this->adapter_);
+ adapter->DisconnectGatt(this);
scheib 2016/02/10 18:59:46 GetMacAdapter()->DisconnectGatt(this);
jlebel 2016/02/10 21:20:07 Done.
+ }
}
void BluetoothLowEnergyDeviceMac::Update(CBPeripheral* peripheral,
@@ -127,7 +132,7 @@ bool BluetoothLowEnergyDeviceMac::IsConnectable() const {
}
bool BluetoothLowEnergyDeviceMac::IsConnecting() const {
- return false;
+ return (GetPeripheralState() == CBPeripheralStateConnecting);
}
BluetoothDevice::UUIDList BluetoothLowEnergyDeviceMac::GetUUIDs() const {
@@ -213,12 +218,6 @@ void BluetoothLowEnergyDeviceMac::ConnectToServiceInsecurely(
NOTIMPLEMENTED();
}
-void BluetoothLowEnergyDeviceMac::CreateGattConnection(
- const GattConnectionCallback& callback,
- const ConnectErrorCallback& error_callback) {
- NOTIMPLEMENTED();
-}
-
NSDate* BluetoothLowEnergyDeviceMac::GetLastUpdateTime() const {
return last_update_time_.get();
}
@@ -228,15 +227,17 @@ std::string BluetoothLowEnergyDeviceMac::GetDeviceName() const {
}
void BluetoothLowEnergyDeviceMac::CreateGattConnectionImpl() {
- // Mac implementation does not yet use the default CreateGattConnection
- // implementation. http://crbug.com/520774
- NOTIMPLEMENTED();
+ if (!this->IsGattConnected()) {
+ BluetoothAdapterMac* adapter =
+ static_cast<BluetoothAdapterMac*>(this->adapter_);
+ adapter->CreateGattConnection(this);
scheib 2016/02/10 18:59:45 GetMacAdapter()->CreateGattConnection(this);
jlebel 2016/02/10 21:20:07 Done.
+ }
}
void BluetoothLowEnergyDeviceMac::DisconnectGatt() {
- // Mac implementation does not yet use the default CreateGattConnection
- // implementation. http://crbug.com/520774
- NOTIMPLEMENTED();
+ BluetoothAdapterMac* adapter =
+ static_cast<BluetoothAdapterMac*>(this->adapter_);
+ adapter->DisconnectGatt(this);
scheib 2016/02/10 18:59:46 GetMacAdapter()->CreateGattConnection(this);
jlebel 2016/02/10 21:20:07 Done.
}
// static
@@ -259,6 +260,29 @@ std::string BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(
return BluetoothDevice::CanonicalizeAddress(hash);
}
+device::BluetoothAdapterMac*
+BluetoothLowEnergyDeviceMac::GetBluetoothAdapterMac() {
+ BluetoothAdapterMac* adapter =
+ static_cast<BluetoothAdapterMac*>(this->adapter_);
+ return adapter;
scheib 2016/02/10 18:59:46 return static_cast<BluetoothAdapterMac*>(this->ada
jlebel 2016/02/10 21:20:07 Done.
+}
+
+CBPeripheral* BluetoothLowEnergyDeviceMac::GetPeripheral() {
+ return peripheral_;
+}
+
+void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral() {
+ if (create_gatt_connection_error_callbacks_.empty()) {
+ DidDisconnectGatt();
+ } else {
+ DidFailToConnectGatt(ERROR_FAILED);
+ }
+}
+
+void BluetoothLowEnergyDeviceMac::GattConnected() {
+ this->DidConnectGatt();
scheib 2016/02/10 18:59:46 DidConnectGatt();
jlebel 2016/02/10 21:20:07 Done.
+}
+
CBPeripheralState BluetoothLowEnergyDeviceMac::GetPeripheralState() const {
Class peripheral_class = NSClassFromString(@"CBPeripheral");
base::scoped_nsobject<NSMethodSignature> signature([[peripheral_class

Powered by Google App Engine
This is Rietveld 408576698