~aleteoryx/muditaos

muditaos/module-bluetooth/Bluetooth/BtKeysStorage.hpp -rw-r--r-- 1.6 KiB
a405cad6Aleteoryx trim readme 6 days 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
33
34
35
36
37
38
39
40
41
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#pragma once

#include <btstack_link_key_db_memory.h>
#include <btstack_util.h>

#include <json11.hpp>
#include <service-bluetooth/SettingsHolder.hpp>

namespace bluetooth
{

    class KeyStorage
    {
      public:
        static auto getKeyStorage() -> btstack_link_key_db_t *;
        static std::shared_ptr<bluetooth::SettingsHolder> settings;

      private:
        static void openStorage();
        static void closeStorage();
        static auto getLinkKey(uint8_t *bd_addr, link_key_t link_key, link_key_type_t *type) -> int;
        static void putLinkKey(uint8_t *bd_addr, uint8_t *link_key, link_key_type_t type);
        static void deleteLinkKey(uint8_t *bd_addr);
        static auto iterator_init(btstack_link_key_iterator_t *it) -> int;
        static auto iterator_get_next(btstack_link_key_iterator_t *it,
                                      bd_addr_t bd_addr,
                                      link_key_t link_key,
                                      link_key_type_t *type) -> int;
        static void iterator_done(btstack_link_key_iterator_t *it);
        static void set_local_bd_addr(bd_addr_t bd_addr);
        static auto processOnFoundKey(bd_addr_t bd_addr, const std::function<int(json11::Json, bd_addr_t)> &fun) -> int;
        static void writeSettings();
        static json11::Json keysJson;
        static btstack_link_key_db_t keyStorage;
        static json11::Json::array keys;
    };

} // namespace bluetooth