Expose discoverable mode and A2DP control over REST, add persisted DAB/FM preset list with web UI, and document gaps in docs/TODO.md. Co-authored-by: Cursor <cursoragent@cursor.com>
69 lines
1.5 KiB
C++
69 lines
1.5 KiB
C++
/**
|
|
* @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<core::BluetoothStatus, bt1035::Bt1035Error>
|
|
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<void, bt1035::Bt1035Error> BluetoothService::startPairing()
|
|
{
|
|
if (auto result = driver_.enterPairingMode(); !result) {
|
|
return result;
|
|
}
|
|
pairingActive_ = true;
|
|
return {};
|
|
}
|
|
|
|
std::expected<void, bt1035::Bt1035Error> BluetoothService::stopPairing()
|
|
{
|
|
if (auto result = driver_.leavePairingMode(); !result) {
|
|
return result;
|
|
}
|
|
pairingActive_ = false;
|
|
return {};
|
|
}
|
|
|
|
std::expected<void, bt1035::Bt1035Error> BluetoothService::disconnect()
|
|
{
|
|
return driver_.disconnectA2dp();
|
|
}
|
|
|
|
} // namespace bluetooth
|