~aleteoryx/muditaos

ref: 7c75cdaf9d61ed60e710101f20a03a9f9f56474d muditaos/module-bluetooth/Bluetooth/interface/BluetoothDriver.hpp -rw-r--r-- 1.4 KiB
7c75cdaf — Jakub Pyszczak [EGD-7849] Fixed compilation with sensitive logs 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// 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 <functional>
#include "Device.hpp"
#include "Error.hpp"

namespace bluetooth
{
    using PowerOnCallback = std::function<void()>;

    class AbstractDriver
    {
      public:
        virtual ~AbstractDriver() noexcept = default;
        using ErrorCallback                = std::function<void(uint8_t)>;

        [[nodiscard]] virtual auto init() -> Error::Code                     = 0;
        [[nodiscard]] virtual auto run() -> Error::Code                      = 0;
        [[nodiscard]] virtual auto stop() -> Error::Code                     = 0;
        [[nodiscard]] virtual auto scan() -> Error                                               = 0;
        virtual void stopScan()                                                                  = 0;
        virtual void setVisibility(bool visibility)                                              = 0;
        [[nodiscard]] virtual auto pair(Devicei device, std::uint8_t protectionLevel = 0) -> bool = 0;
        [[nodiscard]] virtual auto unpair(Devicei device) -> bool                                 = 0;

        virtual void registerErrorCallback(const ErrorCallback &newCallback)     = 0;
        virtual void registerPowerOnCallback(const PowerOnCallback &newCallback) = 0;
    };
} // namespace bluetooth