mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-10-24 07:28:29 -04:00
Added HSP ring sound on incoming call event while there's bluetooth connection active and HSP is selected as the current profile. Possibility of pick up/decline the call using BT device buttons added. Slightly changed HSP initialization according to the UML-s added. Changed call hangup handler in service cellular.
63 lines
1.5 KiB
C++
63 lines
1.5 KiB
C++
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include <Service/Service.hpp>
|
|
#include <Error.hpp>
|
|
#include "Profile.hpp"
|
|
#include "interface/profiles/A2DP/A2DP.hpp"
|
|
#include "interface/profiles/HSP/HSP.hpp"
|
|
#include "audio/BluetoothAudioDevice.hpp"
|
|
|
|
#include <memory>
|
|
|
|
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;
|
|
auto startRinging() -> Error::Code;
|
|
auto stopRinging() -> Error::Code;
|
|
auto initializeCall() -> Error::Code;
|
|
|
|
auto setAudioDevice(std::shared_ptr<BluetoothAudioDevice> device) -> Error::Code;
|
|
|
|
private:
|
|
sys::Service *ownerService;
|
|
ProfileList profilesList;
|
|
bluetooth::Profile *currentProfilePtr = nullptr;
|
|
bd_addr_t remoteAddr{};
|
|
bool initialized = false;
|
|
};
|
|
} // namespace bluetooth
|