/** * @file BluetoothService.cpp * @brief BluetoothService implementation. * * DigiRadio firmware — https://github.com/manvalan/DigiRadio * * Copyright 2026 Michele Bigi * SPDX-License-Identifier: Apache-2.0 * * @author Michele Bigi * @date 2026-07-06 */ #include "bluetooth/BluetoothService.hpp" namespace bluetooth { BluetoothService::BluetoothService(bt1035::Bt1035Driver& driver) : driver_(driver) , pairingActive_(false) { } std::expected BluetoothService::refreshStatus() { core::BluetoothStatus status{ .booted = driver_.isBooted(), .pairing = pairingActive_, .a2dpState = core::Bt1035A2dpState::Standby, }; if (!status.booted) { return status; } auto a2dp = driver_.queryA2dpState(); if (!a2dp) { return std::unexpected(a2dp.error()); } status.a2dpState = *a2dp; return status; } std::expected BluetoothService::startPairing() { if (auto result = driver_.enterPairingMode(); !result) { return result; } pairingActive_ = true; return {}; } std::expected BluetoothService::stopPairing() { if (auto result = driver_.leavePairingMode(); !result) { return result; } pairingActive_ = false; return {}; } std::expected BluetoothService::disconnect() { return driver_.disconnectA2dp(); } } // namespace bluetooth