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

Unified Diff: components/proximity_auth/ble/proximity_auth_ble_system.cc

Issue 1116963002: Bluetooth low energy connection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | « components/proximity_auth/ble/proximity_auth_ble_system.h ('k') | components/proximity_auth/connection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/proximity_auth/ble/proximity_auth_ble_system.cc
diff --git a/components/proximity_auth/ble/proximity_auth_ble_system.cc b/components/proximity_auth/ble/proximity_auth_ble_system.cc
index 673792d82ed51705a3fa6e6250a43bff40c46039..ebe6af3504031bd2eb634cd5cbdede754003ea9a 100644
--- a/components/proximity_auth/ble/proximity_auth_ble_system.cc
+++ b/components/proximity_auth/ble/proximity_auth_ble_system.cc
@@ -6,8 +6,10 @@
#include "base/bind.h"
#include "base/logging.h"
+#include "components/proximity_auth/ble/bluetooth_low_energy_connection.h"
#include "components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h"
#include "components/proximity_auth/connection.h"
+#include "components/proximity_auth/remote_device.h"
#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_gatt_connection.h"
@@ -18,6 +20,12 @@ namespace {
// The UUID of the Bluetooth Low Energy service.
const char kSmartLockServiceUUID[] = "b3b7e28e-a000-3e17-bd86-6e97b9e28c11";
+// The UUID of the characteristic used to send data to the peripheral.
+const char kToPeripheralCharUUID[] = "977c6674-1239-4e72-993b-502369b8bb5a";
+
+// The UUID of the characteristic used to receive data from the peripheral.
+const char kFromPeripheralCharUUID[] = "f4b904a2-a030-43b3-98a8-221c536c03cb";
+
} // namespace
ProximityAuthBleSystem::ProximityAuthBleSystem(
@@ -46,8 +54,9 @@ void ProximityAuthBleSystem::OnScreenDidLock(
break;
case ScreenlockBridge::LockHandler::LOCK_SCREEN:
DCHECK(!connection_finder_);
- connection_finder_.reset(
- new BluetoothLowEnergyConnectionFinder(kSmartLockServiceUUID));
+ connection_finder_.reset(new BluetoothLowEnergyConnectionFinder(
+ kSmartLockServiceUUID, kToPeripheralCharUUID,
+ kFromPeripheralCharUUID));
connection_finder_->Find(
base::Bind(&ProximityAuthBleSystem::OnConnectionFound,
weak_ptr_factory_.GetWeakPtr()));
@@ -61,6 +70,8 @@ void ProximityAuthBleSystem::OnScreenDidLock(
void ProximityAuthBleSystem::OnScreenDidUnlock(
ScreenlockBridge::LockHandler::ScreenType screen_type) {
VLOG(1) << "OnScreenDidUnlock: " << screen_type;
+ connection_->Disconnect();
+ connection_.reset();
connection_finder_.reset();
};
@@ -69,11 +80,10 @@ void ProximityAuthBleSystem::OnFocusedUserChanged(const std::string& user_id) {
};
void ProximityAuthBleSystem::OnConnectionFound(
- scoped_ptr<device::BluetoothGattConnection> connection) {
+ scoped_ptr<Connection> connection) {
VLOG(1) << "Connection found. Unlock.";
- // Close the connection as it it no longer needed.
- connection_finder_->CloseConnection(connection.Pass());
+ connection_ = connection.Pass();
// Unlock the screen when a connection is found.
//
« no previous file with comments | « components/proximity_auth/ble/proximity_auth_ble_system.h ('k') | components/proximity_auth/connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698