~aleteoryx/muditaos

ref: 52d5a35c1b9584612587fa62bf8e83c5c5a641fe muditaos/module-bluetooth/Bluetooth/interface/BluetoothDriver.hpp -rw-r--r-- 1.2 KiB
52d5a35c — Bartosz Cichocki [EGD-6447] Add Bluetooth PIN pairing 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
// 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 "Error.hpp"

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

        [[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(uint8_t *addr, std::uint8_t protectionLevel = 0) -> bool = 0;
        [[nodiscard]] virtual auto unpair(uint8_t *addr) -> bool                                 = 0;

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