OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/proximity_auth/ble/bluetooth_low_energy_weave_client_connec
tion.h" | 5 #include "components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.
h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/task_runner.h" | 11 #include "base/task_runner.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
13 #include "components/proximity_auth/bluetooth_throttler.h" | 13 #include "components/cryptauth/bluetooth_throttler.h" |
14 #include "components/proximity_auth/connection_finder.h" | 14 #include "components/cryptauth/connection_finder.h" |
| 15 #include "components/cryptauth/wire_message.h" |
15 #include "components/proximity_auth/logging/logging.h" | 16 #include "components/proximity_auth/logging/logging.h" |
16 #include "components/proximity_auth/wire_message.h" | |
17 #include "device/bluetooth/bluetooth_gatt_connection.h" | 17 #include "device/bluetooth/bluetooth_gatt_connection.h" |
18 | 18 |
19 using device::BluetoothAdapter; | 19 using device::BluetoothAdapter; |
20 using device::BluetoothDevice; | 20 using device::BluetoothDevice; |
21 using device::BluetoothGattConnection; | 21 using device::BluetoothGattConnection; |
22 using device::BluetoothRemoteGattService; | 22 using device::BluetoothRemoteGattService; |
23 using device::BluetoothRemoteGattCharacteristic; | 23 using device::BluetoothRemoteGattCharacteristic; |
24 using device::BluetoothGattNotifySession; | 24 using device::BluetoothGattNotifySession; |
25 using device::BluetoothUUID; | 25 using device::BluetoothUUID; |
26 | 26 |
27 namespace proximity_auth { | 27 namespace cryptauth { |
28 namespace weave { | 28 namespace weave { |
29 namespace { | 29 namespace { |
30 | 30 |
31 typedef BluetoothLowEnergyWeavePacketReceiver::State ReceiverState; | 31 typedef BluetoothLowEnergyWeavePacketReceiver::State ReceiverState; |
32 | 32 |
33 // The UUID of the TX characteristic used to transmit data to the server. | 33 // The UUID of the TX characteristic used to transmit data to the server. |
34 const char kTXCharacteristicUUID[] = "00000100-0004-1000-8000-001A11000101"; | 34 const char kTXCharacteristicUUID[] = "00000100-0004-1000-8000-001A11000101"; |
35 | 35 |
36 // The UUID of the RX characteristic used to receive data from the server. | 36 // The UUID of the RX characteristic used to receive data from the server. |
37 const char kRXCharacteristicUUID[] = "00000100-0004-1000-8000-001A11000102"; | 37 const char kRXCharacteristicUUID[] = "00000100-0004-1000-8000-001A11000102"; |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 BluetoothLowEnergyWeaveClientConnection:: | 41 BluetoothLowEnergyWeaveClientConnection:: |
42 BluetoothLowEnergyWeaveClientConnection( | 42 BluetoothLowEnergyWeaveClientConnection( |
43 const cryptauth::RemoteDevice& device, | 43 const cryptauth::RemoteDevice& device, |
44 scoped_refptr<device::BluetoothAdapter> adapter, | 44 scoped_refptr<device::BluetoothAdapter> adapter, |
45 const BluetoothUUID remote_service_uuid, | 45 const BluetoothUUID remote_service_uuid, |
46 BluetoothThrottler* bluetooth_throttler, | 46 cryptauth::BluetoothThrottler* bluetooth_throttler, |
47 int max_number_of_write_attempts) | 47 int max_number_of_write_attempts) |
48 : Connection(device), | 48 : Connection(device), |
49 adapter_(adapter), | 49 adapter_(adapter), |
50 remote_service_({remote_service_uuid, ""}), | 50 remote_service_({remote_service_uuid, ""}), |
51 packet_generator_( | 51 packet_generator_( |
52 BluetoothLowEnergyWeavePacketGenerator::Factory::NewInstance()), | 52 BluetoothLowEnergyWeavePacketGenerator::Factory::NewInstance()), |
53 packet_receiver_( | 53 packet_receiver_( |
54 BluetoothLowEnergyWeavePacketReceiver::Factory::NewInstance( | 54 BluetoothLowEnergyWeavePacketReceiver::Factory::NewInstance( |
55 BluetoothLowEnergyWeavePacketReceiver::ReceiverType::CLIENT)), | 55 BluetoothLowEnergyWeavePacketReceiver::ReceiverType::CLIENT)), |
56 tx_characteristic_({BluetoothUUID(kTXCharacteristicUUID), ""}), | 56 tx_characteristic_({BluetoothUUID(kTXCharacteristicUUID), ""}), |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // operations. Otherwise, it'll trigger observers that can pontentially | 155 // operations. Otherwise, it'll trigger observers that can pontentially |
156 // destroy the current instance (causing a crash). | 156 // destroy the current instance (causing a crash). |
157 SetSubStatus(SubStatus::DISCONNECTED); | 157 SetSubStatus(SubStatus::DISCONNECTED); |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 void BluetoothLowEnergyWeaveClientConnection::SetSubStatus( | 161 void BluetoothLowEnergyWeaveClientConnection::SetSubStatus( |
162 SubStatus new_sub_status) { | 162 SubStatus new_sub_status) { |
163 sub_status_ = new_sub_status; | 163 sub_status_ = new_sub_status; |
164 | 164 |
165 // Sets the status of parent class proximity_auth::Connection accordingly. | 165 // Sets the status of parent class cryptauth::Connection accordingly. |
166 if (new_sub_status == SubStatus::CONNECTED) { | 166 if (new_sub_status == SubStatus::CONNECTED) { |
167 SetStatus(Status::CONNECTED); | 167 SetStatus(Status::CONNECTED); |
168 } else if (new_sub_status == SubStatus::DISCONNECTED) { | 168 } else if (new_sub_status == SubStatus::DISCONNECTED) { |
169 SetStatus(Status::DISCONNECTED); | 169 SetStatus(Status::DISCONNECTED); |
170 } else { | 170 } else { |
171 SetStatus(Status::IN_PROGRESS); | 171 SetStatus(Status::IN_PROGRESS); |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 void BluetoothLowEnergyWeaveClientConnection::SetTaskRunnerForTesting( | 175 void BluetoothLowEnergyWeaveClientConnection::SetTaskRunnerForTesting( |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 message(nullptr), | 629 message(nullptr), |
630 number_of_failed_attempts(0) {} | 630 number_of_failed_attempts(0) {} |
631 | 631 |
632 BluetoothLowEnergyWeaveClientConnection::WriteRequest::WriteRequest( | 632 BluetoothLowEnergyWeaveClientConnection::WriteRequest::WriteRequest( |
633 const WriteRequest& other) = default; | 633 const WriteRequest& other) = default; |
634 | 634 |
635 BluetoothLowEnergyWeaveClientConnection::WriteRequest::~WriteRequest() {} | 635 BluetoothLowEnergyWeaveClientConnection::WriteRequest::~WriteRequest() {} |
636 | 636 |
637 } // namespace weave | 637 } // namespace weave |
638 | 638 |
639 } // namespace proximity_auth | 639 } // namespace cryptauth |
OLD | NEW |