OLD | NEW |
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 #ifndef COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_LOW_ENERGY_CONNECTION_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_LOW_ENERGY_CONNECTION_H |
6 #define COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_LOW_ENERGY_CONNECTION_H | 6 #define COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_LOW_ENERGY_CONNECTION_H |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 enum class ControlSignal : uint32 { | 55 enum class ControlSignal : uint32 { |
56 kInviteToConnectSignal = 0, | 56 kInviteToConnectSignal = 0, |
57 kInvitationResponseSignal = 1, | 57 kInvitationResponseSignal = 1, |
58 kSendSignal = 2, | 58 kSendSignal = 2, |
59 kDisconnectSignal = 3, | 59 kDisconnectSignal = 3, |
60 }; | 60 }; |
61 | 61 |
62 // Constructs a Bluetooth low energy connection to the service with | 62 // Constructs a Bluetooth low energy connection to the service with |
63 // |remote_service_| on the |remote_device|. The |adapter| must be already | 63 // |remote_service_| on the |remote_device|. The |adapter| must be already |
64 // initaalized and ready. The GATT connection may alreaady be established and | 64 // initaalized and ready. The GATT connection may alreaady be established and |
65 // pass through |gatt_connection|. If |gatt_connection| is NULL, a subsequent | 65 // pass through |gatt_connection|. A subsequent call to Connect() must be |
66 // call to Connect() must be made. | 66 // made. |
67 BluetoothLowEnergyConnection( | 67 BluetoothLowEnergyConnection( |
68 const RemoteDevice& remote_device, | 68 const RemoteDevice& remote_device, |
69 scoped_refptr<device::BluetoothAdapter> adapter, | 69 scoped_refptr<device::BluetoothAdapter> adapter, |
70 const device::BluetoothUUID remote_service_uuid, | 70 const device::BluetoothUUID remote_service_uuid, |
71 const device::BluetoothUUID to_peripheral_char_uuid, | 71 const device::BluetoothUUID to_peripheral_char_uuid, |
72 const device::BluetoothUUID from_peripheral_char_uuid, | 72 const device::BluetoothUUID from_peripheral_char_uuid, |
73 scoped_ptr<device::BluetoothGattConnection> gatt_connection, | 73 scoped_ptr<device::BluetoothGattConnection> gatt_connection, |
74 int max_number_of_write_attempts); | 74 int max_number_of_write_attempts); |
75 | 75 |
76 ~BluetoothLowEnergyConnection() override; | 76 ~BluetoothLowEnergyConnection() override; |
(...skipping 13 matching lines...) Expand all Loading... |
90 CHARACTERISTICS_FOUND, | 90 CHARACTERISTICS_FOUND, |
91 WAITING_NOTIFY_SESSION, | 91 WAITING_NOTIFY_SESSION, |
92 NOTIFY_SESSION_READY, | 92 NOTIFY_SESSION_READY, |
93 WAITING_RESPONSE_SIGNAL, | 93 WAITING_RESPONSE_SIGNAL, |
94 CONNECTED, | 94 CONNECTED, |
95 }; | 95 }; |
96 | 96 |
97 void SetSubStatus(SubStatus status); | 97 void SetSubStatus(SubStatus status); |
98 SubStatus sub_status() { return sub_status_; } | 98 SubStatus sub_status() { return sub_status_; } |
99 | 99 |
| 100 // Virtual for testing. |
| 101 virtual BluetoothLowEnergyCharacteristicsFinder* CreateCharacteristicsFinder( |
| 102 const BluetoothLowEnergyCharacteristicsFinder::SuccessCallback& |
| 103 success_callback, |
| 104 const BluetoothLowEnergyCharacteristicsFinder::ErrorCallback& |
| 105 error_callback); |
| 106 |
100 // proximity_auth::Connection | 107 // proximity_auth::Connection |
101 void SendMessageImpl(scoped_ptr<WireMessage> message) override; | 108 void SendMessageImpl(scoped_ptr<WireMessage> message) override; |
102 scoped_ptr<WireMessage> DeserializeWireMessage( | 109 scoped_ptr<WireMessage> DeserializeWireMessage( |
103 bool* is_incomplete_message) override; | 110 bool* is_incomplete_message) override; |
104 | 111 |
105 // device::BluetoothAdapter::Observer | 112 // device::BluetoothAdapter::Observer |
106 void DeviceRemoved(device::BluetoothAdapter* adapter, | 113 void DeviceRemoved(device::BluetoothAdapter* adapter, |
107 device::BluetoothDevice* device) override; | 114 device::BluetoothDevice* device) override; |
108 void GattCharacteristicValueChanged( | 115 void GattCharacteristicValueChanged( |
109 device::BluetoothAdapter* adapter, | 116 device::BluetoothAdapter* adapter, |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 base::TimeTicks start_time_; | 274 base::TimeTicks start_time_; |
268 | 275 |
269 base::WeakPtrFactory<BluetoothLowEnergyConnection> weak_ptr_factory_; | 276 base::WeakPtrFactory<BluetoothLowEnergyConnection> weak_ptr_factory_; |
270 | 277 |
271 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnection); | 278 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnection); |
272 }; | 279 }; |
273 | 280 |
274 } // namespace proximity_auth | 281 } // namespace proximity_auth |
275 | 282 |
276 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_LOW_ENERGY_CONNECTION_H | 283 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_LOW_ENERGY_CONNECTION_H |
OLD | NEW |