• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 The Android Open Source Project
3  *  Copyright 2018-2020 NXP
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #include <config.h>
21 
22 #include <string>
23 #include <vector>
24 
25 #define NAME_UWB_CORE_DEVICE_DEFAULT_CONFIG "UWB_CORE_DEVICE_DEFAULT_CONFIG"
26 #define NAME_UWB_LOW_POWER_MODE "UWB_LOW_POWER_MODE"
27 #define NAME_UWB_DPD_ENTRY_TIMEOUT "UWB_DPD_ENTRY_TIMEOUT"
28 
29 #define CHECK_RETURN(condition, str, ret) \
30   do {                                    \
31     if (condition) {                      \
32       return ret;                         \
33     }                                     \
34   } while (0)
35 #define CHECK_RETURN_VOID(condition, str) \
36   do {                                    \
37     if (condition) {                      \
38       return;                             \
39     }                                     \
40   } while (0)
41 class UwbConfig {
42  public:
43   static bool hasKey(const std::string& key);
44   static std::string getString(const std::string& key);
45   static std::string getString(const std::string& key,
46                                std::string default_value);
47   static unsigned getUnsigned(const std::string& key);
48   static unsigned getUnsigned(const std::string& key, unsigned default_value);
49   static std::vector<uint8_t> getBytes(const std::string& key);
50   static void clear();
51 
52  private:
53   void loadConfig();
54   static UwbConfig& getInstance();
55   UwbConfig();
56 
57   ConfigFile config_;
58 };
59