| 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 46b56318925ac2ab804aba8b73f5711373034db2..7721d031ef1081dbbeb7cb28246dc86307a7df2d 100644
|
| --- a/device/bluetooth/bluetooth_low_energy_win_fake.h
|
| +++ b/device/bluetooth/bluetooth_low_energy_win_fake.h
|
| @@ -16,6 +16,7 @@ namespace win {
|
| struct BLEDevice;
|
| struct GattService;
|
| struct GattCharacteristic;
|
| +struct GattCharacteristicObserver;
|
| struct GattDescriptor;
|
|
|
| // The key of BLEDevicesMap is the string of the BLE device address.
|
| @@ -31,12 +32,19 @@ typedef std::unordered_map<std::string, scoped_ptr<GattDescriptor>>
|
| // The key of BLEAttributeHandleTable is the string of the BLE device address.
|
| typedef std::unordered_map<std::string, scoped_ptr<std::set<USHORT>>>
|
| BLEAttributeHandleTable;
|
| +// The key of GattCharacteristicObserverTable is GattCharacteristicObserver
|
| +// pointer.
|
| +// Note: The underlying data type of BLUETOOTH_GATT_EVENT_HANDLE is PVOID.
|
| +typedef std::unordered_map<BLUETOOTH_GATT_EVENT_HANDLE,
|
| + scoped_ptr<GattCharacteristicObserver>>
|
| + GattCharacteristicObserverTable;
|
|
|
| struct BLEDevice {
|
| BLEDevice();
|
| ~BLEDevice();
|
| scoped_ptr<BluetoothLowEnergyDeviceInfo> device_info;
|
| GattServicesMap primary_services;
|
| + bool marked_as_deleted;
|
| };
|
|
|
| struct GattService {
|
| @@ -55,6 +63,7 @@ struct GattCharacteristic {
|
| GattDescriptorsMap included_descriptors;
|
| std::vector<HRESULT> read_errors;
|
| std::vector<HRESULT> write_errors;
|
| + std::vector<BLUETOOTH_GATT_EVENT_HANDLE> observers;
|
| };
|
|
|
| struct GattDescriptor {
|
| @@ -64,6 +73,13 @@ struct GattDescriptor {
|
| scoped_ptr<BTH_LE_GATT_DESCRIPTOR_VALUE> value;
|
| };
|
|
|
| +struct GattCharacteristicObserver {
|
| + GattCharacteristicObserver();
|
| + ~GattCharacteristicObserver();
|
| + PFNBLUETOOTH_GATT_EVENT_CALLBACK callback;
|
| + PVOID context;
|
| +};
|
| +
|
| // Fake implementation of BluetoothLowEnergyWrapper. Used for BluetoothTestWin.
|
| class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper {
|
| public:
|
| @@ -72,8 +88,12 @@ class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper {
|
| Observer() {}
|
| ~Observer() {}
|
|
|
| - virtual void onWriteGattCharacteristicValue(
|
| + virtual void OnReadGattCharacteristicValue() = 0;
|
| + virtual void OnWriteGattCharacteristicValue(
|
| const PBTH_LE_GATT_CHARACTERISTIC_VALUE value) = 0;
|
| + virtual void OnStartCharacteristicNotification() = 0;
|
| + virtual void OnWriteGattDescriptorValue(
|
| + const std::vector<uint8_t>& value) = 0;
|
| };
|
|
|
| BluetoothLowEnergyWrapperFake();
|
| @@ -108,6 +128,18 @@ class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper {
|
| base::FilePath& service_path,
|
| const PBTH_LE_GATT_CHARACTERISTIC characteristic,
|
| PBTH_LE_GATT_CHARACTERISTIC_VALUE new_value) override;
|
| + HRESULT RegisterGattEvents(base::FilePath& service_path,
|
| + BTH_LE_GATT_EVENT_TYPE type,
|
| + PVOID event_parameter,
|
| + PFNBLUETOOTH_GATT_EVENT_CALLBACK callback,
|
| + PVOID context,
|
| + BLUETOOTH_GATT_EVENT_HANDLE* out_handle) override;
|
| + HRESULT UnregisterGattEvent(
|
| + BLUETOOTH_GATT_EVENT_HANDLE event_handle) override;
|
| + HRESULT WriteDescriptorValue(
|
| + base::FilePath& service_path,
|
| + const PBTH_LE_GATT_DESCRIPTOR descriptor,
|
| + PBTH_LE_GATT_DESCRIPTOR_VALUE new_value) override;
|
|
|
| BLEDevice* SimulateBLEDevice(std::string device_name,
|
| BLUETOOTH_ADDRESS device_address);
|
| @@ -141,10 +173,14 @@ class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper {
|
| std::string attribute_handle);
|
| void SimulateGattCharacteristicValue(GattCharacteristic* characteristic,
|
| const std::vector<uint8_t>& value);
|
| + void SimulateCharacteristicValueChangeNotification(
|
| + GattCharacteristic* characteristic);
|
| void SimulateGattCharacteristicReadError(GattCharacteristic* characteristic,
|
| HRESULT error);
|
| void SimulateGattCharacteristicWriteError(GattCharacteristic* characteristic,
|
| HRESULT error);
|
| + void RememberCharacteristicForSubsequentAction(GattService* parent_service,
|
| + std::string attribute_handle);
|
| void SimulateGattDescriptor(std::string device_address,
|
| GattCharacteristic* characteristic,
|
| const BTH_LE_UUID& uuid);
|
| @@ -186,6 +222,8 @@ class BluetoothLowEnergyWrapperFake : public BluetoothLowEnergyWrapper {
|
| BLEAttributeHandleTable attribute_handle_table_;
|
| BLEDevicesMap simulated_devices_;
|
| Observer* observer_;
|
| + GattCharacteristicObserverTable gatt_characteristic_observers_;
|
| + GattCharacteristic* remembered_characteristic_;
|
| };
|
|
|
| } // namespace win
|
|
|