mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-10-25 16:08:30 -04:00
To be able to connect to the BT device with more than one audio profile, we need something to manage those profiles. Created here ProfileManager made it convenient To be able to work properly with BT, CPU freq has to be at least at Level_5 - to be fixed!
52 lines
1.0 KiB
C++
52 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <Service/Service.hpp>
|
|
#include <Error.hpp>
|
|
#include "Profile.hpp"
|
|
#include "interface/profiles/A2DP/A2DP.hpp"
|
|
#include "interface/profiles/HSP/HSP.hpp"
|
|
|
|
extern "C"
|
|
{
|
|
#include <bluetooth.h>
|
|
#include "btstack_util.h"
|
|
}
|
|
|
|
namespace bluetooth
|
|
{
|
|
|
|
enum class AudioProfile
|
|
{
|
|
A2DP,
|
|
HSP,
|
|
HFP,
|
|
None
|
|
};
|
|
|
|
using ProfileList = std::map<AudioProfile, std::shared_ptr<bluetooth::Profile>>;
|
|
|
|
class ProfileManager
|
|
{
|
|
public:
|
|
explicit ProfileManager(sys::Service *ownerService);
|
|
|
|
auto init() -> Error::Code;
|
|
|
|
auto connect(bd_addr_t address) -> Error::Code;
|
|
|
|
auto disconnect() -> Error::Code;
|
|
|
|
auto switchProfile(AudioProfile profile) -> Error::Code;
|
|
|
|
auto start() -> Error::Code;
|
|
auto stop() -> Error::Code;
|
|
|
|
private:
|
|
sys::Service *ownerService;
|
|
ProfileList profilesList;
|
|
bluetooth::Profile *currentProfilePtr = nullptr;
|
|
bd_addr_t remoteAddr{};
|
|
bool initialized = false;
|
|
};
|
|
} // namespace bluetooth
|