mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-20 21:14:12 -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!
43 lines
1.5 KiB
C++
43 lines
1.5 KiB
C++
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
#include "HSP.hpp"
|
|
#include "Error.hpp"
|
|
#include "SCO.hpp"
|
|
#include <Audio/AudioCommon.hpp>
|
|
|
|
namespace bluetooth
|
|
{
|
|
static constexpr int serviceBufferLength = 150;
|
|
static constexpr int commandBufferLength = 150;
|
|
|
|
class HSP::HSPImpl
|
|
{
|
|
public:
|
|
static void packetHandler(uint8_t packetType, uint16_t channel, uint8_t *event, uint16_t eventSize);
|
|
auto init() -> Error::Code;
|
|
void start();
|
|
void stop();
|
|
void connect();
|
|
void disconnect();
|
|
void setDeviceAddress(bd_addr_t addr);
|
|
void setOwnerService(const sys::Service *service);
|
|
auto getStreamData() -> std::shared_ptr<BluetoothStreamData>;
|
|
|
|
private:
|
|
static void sendAudioEvent(audio::EventType event, audio::Event::DeviceState state);
|
|
static void processHCIEvent(uint8_t *event);
|
|
static void processHSPEvent(uint8_t *event);
|
|
static std::array<uint8_t, serviceBufferLength> serviceBuffer;
|
|
static constexpr uint8_t rfcommChannelNr = 1;
|
|
static std::string agServiceName;
|
|
static uint16_t scoHandle;
|
|
static std::unique_ptr<SCO> sco;
|
|
static std::array<char, commandBufferLength> ATcommandBuffer;
|
|
static bd_addr_t deviceAddr;
|
|
static const sys::Service *ownerService;
|
|
static bool isConnected;
|
|
};
|
|
} // namespace Bt
|