1 // Copyright 2023 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 15 #pragma once 16 #include "pw_async/heap_dispatcher.h" 17 #include "pw_bluetooth_sapphire/internal/host/common/device_address.h" 18 #include "pw_bluetooth_sapphire/internal/host/hci/local_address_delegate.h" 19 20 namespace bt::hci { 21 22 class FakeLocalAddressDelegate : public LocalAddressDelegate { 23 public: FakeLocalAddressDelegate(pw::async::Dispatcher & pw_dispatcher)24 explicit FakeLocalAddressDelegate(pw::async::Dispatcher& pw_dispatcher) 25 : heap_dispatcher_(pw_dispatcher) {} 26 ~FakeLocalAddressDelegate() override = default; 27 irk()28 std::optional<UInt128> irk() const override { return std::nullopt; } identity_address()29 DeviceAddress identity_address() const override { return identity_address_; } 30 void EnsureLocalAddress(AddressCallback callback) override; 31 32 // If set to true EnsureLocalAddress runs its callback asynchronously. set_async(bool value)33 void set_async(bool value) { async_ = value; } 34 set_identity_address(const DeviceAddress & value)35 void set_identity_address(const DeviceAddress& value) { 36 identity_address_ = value; 37 } set_local_address(const DeviceAddress & value)38 void set_local_address(const DeviceAddress& value) { local_address_ = value; } 39 40 private: 41 bool async_ = false; 42 DeviceAddress local_address_ = 43 DeviceAddress(DeviceAddress::Type::kLEPublic, {0}); 44 DeviceAddress identity_address_ = 45 DeviceAddress(DeviceAddress::Type::kLEPublic, {0}); 46 pw::async::HeapDispatcher heap_dispatcher_; 47 }; 48 49 } // namespace bt::hci 50