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

Side by Side Diff: device/bluetooth/device.h

Issue 2627243002: bluetooth: Add control for reading/writing of characteristics to internals page. (Closed)
Patch Set: Remove TypeConverter, add EnumTraits for GattResult Created 3 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 unified diff | Download patch
OLDNEW
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 #ifndef DEVICE_BLUETOOTH_DEVICE_H_ 5 #ifndef DEVICE_BLUETOOTH_DEVICE_H_
6 #define DEVICE_BLUETOOTH_DEVICE_H_ 6 #define DEVICE_BLUETOOTH_DEVICE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
14 #include "device/bluetooth/bluetooth_adapter.h" 15 #include "device/bluetooth/bluetooth_adapter.h"
15 #include "device/bluetooth/bluetooth_device.h" 16 #include "device/bluetooth/bluetooth_device.h"
16 #include "device/bluetooth/bluetooth_gatt_connection.h" 17 #include "device/bluetooth/bluetooth_gatt_connection.h"
17 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" 18 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h"
19 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h"
18 #include "device/bluetooth/bluetooth_remote_gatt_service.h" 20 #include "device/bluetooth/bluetooth_remote_gatt_service.h"
19 #include "device/bluetooth/public/interfaces/device.mojom.h" 21 #include "device/bluetooth/public/interfaces/device.mojom.h"
20 #include "mojo/public/cpp/bindings/strong_binding.h" 22 #include "mojo/public/cpp/bindings/strong_binding.h"
21 23
22 namespace bluetooth { 24 namespace bluetooth {
23 25
24 // Implementation of Mojo Device located in 26 // Implementation of Mojo Device located in
25 // device/bluetooth/public/interfaces/device.mojom. 27 // device/bluetooth/public/interfaces/device.mojom.
26 // It handles requests to interact with Bluetooth Device. 28 // It handles requests to interact with Bluetooth Device.
27 // Uses the platform abstraction of device/bluetooth. 29 // Uses the platform abstraction of device/bluetooth.
(...skipping 18 matching lines...) Expand all
46 device::BluetoothDevice* device) override; 48 device::BluetoothDevice* device) override;
47 void GattServicesDiscovered(device::BluetoothAdapter* adapter, 49 void GattServicesDiscovered(device::BluetoothAdapter* adapter,
48 device::BluetoothDevice* device) override; 50 device::BluetoothDevice* device) override;
49 51
50 // mojom::Device overrides: 52 // mojom::Device overrides:
51 void Disconnect() override; 53 void Disconnect() override;
52 void GetInfo(const GetInfoCallback& callback) override; 54 void GetInfo(const GetInfoCallback& callback) override;
53 void GetServices(const GetServicesCallback& callback) override; 55 void GetServices(const GetServicesCallback& callback) override;
54 void GetCharacteristics(const std::string& service_id, 56 void GetCharacteristics(const std::string& service_id,
55 const GetCharacteristicsCallback& callback) override; 57 const GetCharacteristicsCallback& callback) override;
58 void ReadValueForCharacteristic(
59 const std::string& service_id,
60 const std::string& characteristic_id,
61 const ReadValueForCharacteristicCallback& callback) override;
62 void WriteValueForCharacteristic(
63 const std::string& service_id,
64 const std::string& characteristic_id,
65 const std::vector<uint8_t>& value,
66 const WriteValueForCharacteristicCallback& callback) override;
67 void GetDescriptors(const std::string& service_id,
68 const std::string& characteristic_id,
69 const GetDescriptorsCallback& callback) override;
56 70
57 private: 71 private:
58 Device(scoped_refptr<device::BluetoothAdapter> adapter, 72 Device(scoped_refptr<device::BluetoothAdapter> adapter,
59 std::unique_ptr<device::BluetoothGattConnection> connection); 73 std::unique_ptr<device::BluetoothGattConnection> connection);
60 74
61 void GetServicesImpl(const GetServicesCallback& callback); 75 void GetServicesImpl(const GetServicesCallback& callback);
62 76
63 mojom::ServiceInfoPtr ConstructServiceInfoStruct( 77 mojom::ServiceInfoPtr ConstructServiceInfoStruct(
64 const device::BluetoothRemoteGattService& service); 78 const device::BluetoothRemoteGattService& service);
65 79
80 void OnReadRemoteCharacteristic(
81 const ReadValueForCharacteristicCallback& callback,
82 const std::vector<uint8_t>& value);
83
84 void OnReadRemoteCharacteristicError(
85 const ReadValueForCharacteristicCallback& callback,
86 device::BluetoothGattService::GattErrorCode error_code);
87
88 void OnWriteRemoteCharacteristic(
89 const WriteValueForCharacteristicCallback& callback);
90
91 void OnWriteRemoteCharacteristicError(
92 const WriteValueForCharacteristicCallback& callback,
93 device::BluetoothGattService::GattErrorCode error_code);
94
66 const std::string& GetAddress(); 95 const std::string& GetAddress();
67 96
68 // The current BluetoothAdapter. 97 // The current BluetoothAdapter.
69 scoped_refptr<device::BluetoothAdapter> adapter_; 98 scoped_refptr<device::BluetoothAdapter> adapter_;
70 99
71 // The GATT connection to this device. 100 // The GATT connection to this device.
72 std::unique_ptr<device::BluetoothGattConnection> connection_; 101 std::unique_ptr<device::BluetoothGattConnection> connection_;
73 102
74 mojo::StrongBindingPtr<mojom::Device> binding_; 103 mojo::StrongBindingPtr<mojom::Device> binding_;
75 104
76 // The services request queue which holds callbacks that are waiting for 105 // The services request queue which holds callbacks that are waiting for
77 // services to be discovered for this device. 106 // services to be discovered for this device.
78 std::vector<base::Closure> pending_services_requests_; 107 std::vector<base::Closure> pending_services_requests_;
79 108
109 base::WeakPtrFactory<Device> weak_ptr_factory_;
110
80 DISALLOW_COPY_AND_ASSIGN(Device); 111 DISALLOW_COPY_AND_ASSIGN(Device);
81 }; 112 };
82 113
83 } // namespace bluetooth 114 } // namespace bluetooth
84 115
85 #endif // DEVICE_BLUETOOTH_DEVICE_H_ 116 #endif // DEVICE_BLUETOOTH_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698