diff --git a/internal/platform/implementation/linux/ble_v2.h b/internal/platform/implementation/linux/ble_v2.h index e69de29b..85e54d19 100644 --- a/internal/platform/implementation/linux/ble_v2.h +++ b/internal/platform/implementation/linux/ble_v2.h @@ -0,0 +1,69 @@ +#include "internal/platform/implementation/ble_v2.h" + +namespace nearby { +namespace linux { +class BleV2Peripheral : public api::ble_v2::BlePeripheral +{ + std::string GetAddress() const override; + UniqueId GetUniqueId() const override; + +}; + +class GattClient: public api::ble_v2::GattClient +{ + bool DiscoverServiceAndCharacteristics(const Uuid& service_uuid, const std::vector& characteristic_uuids) override; + + absl::optional + GetCharacteristic(const Uuid& service_uuid, const Uuid& characteristic_uuid) override; + + absl::optional + ReadCharacteristic(const api::ble_v2::GattCharacteristic& characteristic) override; + + bool WriteCharacteristic( + const api::ble_v2::GattCharacteristic& characteristic, + absl::string_view value, WriteType type) override; + + bool SetCharacteristicSubscription( + const api::ble_v2::GattCharacteristic& characteristic, + bool enable, absl::AnyInvocable on_characteristic_changed_cb) + override; + + void Disconnect() override; +}; + +class GattServer : public api::ble_v2::GattServer +{ + api::ble_v2::BlePeripheral& GetBlePeripheral() override; + + absl::optional CreateCharacteristic( + const Uuid& service_uuid, const Uuid& characteristic_uuid, + api::ble_v2::GattCharacteristic::Permission permission, + api::ble_v2::GattCharacteristic::Property property) + override; + + bool UpdateCharacteristic( + const api::ble_v2::GattCharacteristic& characteristic, const nearby::ByteArray& value) + override; + + absl::Status NotifyCharacteristicChanged( + const api::ble_v2::GattCharacteristic& characteristic, bool confirm, + const ByteArray& new_value) + override; + + void Stop() override; +}; + +class BleV2Socket: public api::ble_v2::BleSocket +{ + InputStream& GetInputStream() override; + OutputStream& GetOutputStream() override; + Exception Close() override; +}; + +class BleV2ServerSocket: public api::ble_v2::BleServerSocket +{ + std::unique_ptr Accept() override; + Exception Close() override; +}; +} +}