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

Unified Diff: device/bluetooth/bluetooth_low_energy_win_fake.h

Issue 1739383002: Implement read & write remote GATT characteristic value for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_low_energy_win_fake.h
diff --git a/device/bluetooth/bluetooth_low_energy_win_fake.h b/device/bluetooth/bluetooth_low_energy_win_fake.h
index f21fa5a8dcc41565158a09d1493d434c31d05a46..46b56318925ac2ab804aba8b73f5711373034db2 100644
--- a/device/bluetooth/bluetooth_low_energy_win_fake.h
+++ b/device/bluetooth/bluetooth_low_energy_win_fake.h
@@ -53,6 +53,8 @@ struct GattCharacteristic {
scoped_ptr<BTH_LE_GATT_CHARACTERISTIC> characteristic_info;
scoped_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE> value;
GattDescriptorsMap included_descriptors;
+ std::vector<HRESULT> read_errors;
+ std::vector<HRESULT> write_errors;
};
struct GattDescriptor {
@@ -65,6 +67,15 @@ struct GattDescriptor {
// Fake implementation of BluetoothLowEnergyWrapper. Used for BluetoothTestWin.
class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper {
public:
+ class Observer {
+ public:
+ Observer() {}
+ ~Observer() {}
+
+ virtual void onWriteGattCharacteristicValue(
+ const PBTH_LE_GATT_CHARACTERISTIC_VALUE value) = 0;
+ };
+
BluetoothLowEnergyWrapperFake();
~BluetoothLowEnergyWrapperFake() override;
@@ -89,10 +100,19 @@ class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper {
const PBTH_LE_GATT_CHARACTERISTIC characteristic,
scoped_ptr<BTH_LE_GATT_DESCRIPTOR>* out_included_descriptors,
USHORT* out_counts) override;
+ HRESULT ReadCharacteristicValue(
+ base::FilePath& service_path,
+ const PBTH_LE_GATT_CHARACTERISTIC characteristic,
+ scoped_ptr<BTH_LE_GATT_CHARACTERISTIC_VALUE>* out_value) override;
+ HRESULT WriteCharacteristicValue(
+ base::FilePath& service_path,
+ const PBTH_LE_GATT_CHARACTERISTIC characteristic,
+ PBTH_LE_GATT_CHARACTERISTIC_VALUE new_value) override;
BLEDevice* SimulateBLEDevice(std::string device_name,
BLUETOOTH_ADDRESS device_address);
BLEDevice* GetSimulatedBLEDevice(std::string device_address);
+ void RemoveSimulatedBLEDevice(std::string device_address);
// Note: |parent_service| may be nullptr to indicate a primary service.
GattService* SimulateGattService(BLEDevice* device,
@@ -119,9 +139,16 @@ class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper {
GattCharacteristic* GetSimulatedGattCharacteristic(
GattService* parent_service,
std::string attribute_handle);
+ void SimulateGattCharacteristicValue(GattCharacteristic* characteristic,
+ const std::vector<uint8_t>& value);
+ void SimulateGattCharacteristicReadError(GattCharacteristic* characteristic,
+ HRESULT error);
+ void SimulateGattCharacteristicWriteError(GattCharacteristic* characteristic,
+ HRESULT error);
void SimulateGattDescriptor(std::string device_address,
GattCharacteristic* characteristic,
const BTH_LE_UUID& uuid);
+ void AddObserver(Observer* observer);
private:
// Get simulated characteristic by |service_path| and |characteristic| info.
@@ -158,6 +185,7 @@ class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper {
// Table to store allocated attribute handle for a device.
BLEAttributeHandleTable attribute_handle_table_;
BLEDevicesMap simulated_devices_;
+ Observer* observer_;
};
} // namespace win

Powered by Google App Engine
This is Rietveld 408576698