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

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: Skip tests if Bluetooth Low Energy is not available Created 4 years, 9 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
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_device_mac.h ('k') | device/bluetooth/test/bluetooth_test_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 00712ae82ec1b4ab14a06c81423cad36c31ffc22..d0f3f3dc29d2d5f464cfe057d9d28d44204f4e79 100644
--- a/device/bluetooth/bluetooth_low_energy_device_mac.mm
+++ b/device/bluetooth/bluetooth_low_energy_device_mac.mm
@@ -43,6 +43,9 @@ BluetoothLowEnergyDeviceMac::BluetoothLowEnergyDeviceMac(
}
BluetoothLowEnergyDeviceMac::~BluetoothLowEnergyDeviceMac() {
+ if (IsGattConnected()) {
+ GetMacAdapter()->DisconnectGatt(this);
+ }
}
void BluetoothLowEnergyDeviceMac::Update(CBPeripheral* peripheral,
@@ -134,7 +137,7 @@ bool BluetoothLowEnergyDeviceMac::IsConnectable() const {
}
bool BluetoothLowEnergyDeviceMac::IsConnecting() const {
- return false;
+ return ([peripheral_ state] == CBPeripheralStateConnecting);
}
BluetoothDevice::UUIDList BluetoothLowEnergyDeviceMac::GetUUIDs() const {
@@ -220,12 +223,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();
}
@@ -235,15 +232,13 @@ std::string BluetoothLowEnergyDeviceMac::GetDeviceName() const {
}
void BluetoothLowEnergyDeviceMac::CreateGattConnectionImpl() {
- // Mac implementation does not yet use the default CreateGattConnection
- // implementation. http://crbug.com/520774
- NOTIMPLEMENTED();
+ if (!IsGattConnected()) {
+ GetMacAdapter()->CreateGattConnection(this);
+ }
}
void BluetoothLowEnergyDeviceMac::DisconnectGatt() {
- // Mac implementation does not yet use the default CreateGattConnection
- // implementation. http://crbug.com/520774
- NOTIMPLEMENTED();
+ GetMacAdapter()->DisconnectGatt(this);
}
// static
@@ -265,3 +260,19 @@ std::string BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(
std::string hash = base::HexEncode(raw, sizeof(raw));
return BluetoothDevice::CanonicalizeAddress(hash);
}
+
+device::BluetoothAdapterMac* BluetoothLowEnergyDeviceMac::GetMacAdapter() {
+ return static_cast<BluetoothAdapterMac*>(this->adapter_);
+}
+
+CBPeripheral* BluetoothLowEnergyDeviceMac::GetPeripheral() {
+ return peripheral_;
+}
+
+void BluetoothLowEnergyDeviceMac::DidDisconnectPeripheral() {
+ if (create_gatt_connection_error_callbacks_.empty()) {
+ DidDisconnectGatt();
+ } else {
+ DidFailToConnectGatt(ERROR_FAILED);
+ }
+}
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_device_mac.h ('k') | device/bluetooth/test/bluetooth_test_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698