• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2011-2012 Broadcom Corporation
4  *  Copyright 2018-2019, 2023-2025 NXP
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at:
9  *
10  *  http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *
18  ******************************************************************************/
19 
20 #ifndef __CONFIG_H
21 #define __CONFIG_H
22 
23 #include <cstddef>
24 #include <cstdint>
25 #include <limits>
26 #include <optional>
27 #include <span>
28 #include <string_view>
29 
30 #include "phNxpLog.h"
31 
32 void NxpConfig_Init(void);
33 void NxpConfig_Deinit(void);
34 bool NxpConfig_SetCountryCode(const char country_code[2]);
35 
36 std::optional<std::string_view> NxpConfig_GetStr(std::string_view key, bool include_factory = true);
37 
38 std::optional<std::span<const uint8_t>> NxpConfig_GetByteArray(std::string_view key, bool include_factory = true);
39 
40 std::optional<uint64_t> NxpConfig_GetUint64(std::string_view key, bool include_factory = true);
41 
42 template <typename T>
43 inline std::optional<T> NxpConfig_GetNum(std::string_view key, bool include_factory = true) {
44     static_assert(std::is_integral<T>::value);
45     auto res = NxpConfig_GetUint64(key, include_factory);
46     if (res.has_value() && *res > std::numeric_limits<T>::max()) {
47         std::string strkey(key);
48         NXPLOG_UCIHAL_W("Config %s overflow", strkey.c_str());
49     }
50     return res;
51 }
52 
53 // Returns true or false if key is existed as a number type parameter.
54 std::optional<bool> NxpConfig_GetBool(std::string_view key, bool include_factory = true);
55 
56 // Returns an array of string.
57 std::vector<std::string> NxpConfig_GetStrArray(std::string_view key, bool include_factory = true);
58 
59 // TODO: use constexpr
60 /* libuwb-nxp.conf parameters */
61 #define NAME_UWB_BOARD_VARIANT_CONFIG "UWB_BOARD_VARIANT_CONFIG"
62 #define NAME_UWB_BOARD_VARIANT_VERSION "UWB_BOARD_VARIANT_VERSION"
63 #define NAME_UWB_CORE_EXT_DEVICE_DEFAULT_CONFIG "UWB_CORE_EXT_DEVICE_DEFAULT_CONFIG"
64 #define NAME_UWB_DEBUG_DEFAULT_CONFIG "UWB_DEBUG_DEFAULT_CONFIG"
65 #define NAME_ANTENNA_PAIR_SELECTION_CONFIG1 "ANTENNA_PAIR_SELECTION_CONFIG1"
66 #define NAME_ANTENNA_PAIR_SELECTION_CONFIG2 "ANTENNA_PAIR_SELECTION_CONFIG2"
67 #define NAME_ANTENNA_PAIR_SELECTION_CONFIG3 "ANTENNA_PAIR_SELECTION_CONFIG3"
68 #define NAME_ANTENNA_PAIR_SELECTION_CONFIG4 "ANTENNA_PAIR_SELECTION_CONFIG4"
69 #define NAME_ANTENNA_PAIR_SELECTION_CONFIG5 "ANTENNA_PAIR_SELECTION_CONFIG5"
70 #define NAME_NXP_CORE_CONF_BLK "NXP_CORE_CONF_BLK_"
71 #define NAME_UWB_FW_DOWNLOAD_LOG "UWB_FW_DOWNLOAD_LOG"
72 #define NAME_NXP_UWB_FLASH_CONFIG "NXP_UWB_FLASH_CONFIG"
73 #define NAME_NXP_UWB_XTAL_38MHZ_CONFIG "NXP_UWB_XTAL_38MHZ_CONFIG"
74 #define NAME_NXP_UWB_EXTENDED_NTF_CONFIG "NXP_UWB_EXTENDED_NTF_CONFIG"
75 #define NAME_UWB_CORE_EXT_DEVICE_SR1XX_T_CONFIG "UWB_CORE_EXT_DEVICE_SR1XX_T_CONFIG"
76 #define NAME_UWB_CORE_EXT_DEVICE_SR1XX_S_CONFIG "UWB_CORE_EXT_DEVICE_SR1XX_S_CONFIG"
77 #define NAME_COUNTRY_CODE_CAP_FILE_LOCATION "COUNTRY_CODE_CAP_FILE_LOCATION"
78 #define NAME_UWB_VENDOR_CAPABILITY "UWB_VENDOR_CAPABILITY"
79 #define NAME_UWB_UCIX_UCIR_ERROR_LOG "UWB_UCIX_UCIR_ERROR_LOG"
80 #define NAME_UWB_DEBUG_LOG_FILE_SIZE "UWB_DEBUG_LOG_FILE_SIZE"
81 
82 #define NAME_UWB_BINDING_LOCKING_ALLOWED "UWB_BINDING_LOCKING_ALLOWED"
83 #define NAME_NXP_UWB_PROD_FW_FILENAME "NXP_UWB_PROD_FW_FILENAME"
84 #define NAME_NXP_UWB_DEV_FW_FILENAME "NXP_UWB_DEV_FW_FILENAME"
85 #define NAME_NXP_UWB_FW_FILENAME "NXP_UWB_FW_FILENAME"
86 #define NAME_NXP_UWB_EXT_APP_DEFAULT_CONFIG "NXP_UWB_EXT_APP_DEFAULT_CONFIG"
87 #define NAME_NXP_UWB_EXT_APP_SR1XX_T_CONFIG "NXP_UWB_EXT_APP_SR1XX_T_CONFIG"
88 #define NAME_NXP_UWB_EXT_APP_SR1XX_S_CONFIG "NXP_UWB_EXT_APP_SR1XX_S_CONFIG"
89 #define NAME_UWB_USER_FW_BOOT_MODE_CONFIG "UWB_USER_FW_BOOT_MODE_CONFIG"
90 #define NAME_NXP_UWB_COUNTRY_CODE_CAPS "UWB_COUNTRY_CODE_CAPS"
91 
92 #define NAME_NXP_SECURE_CONFIG_BLK "NXP_SECURE_CONFIG_BLK_"
93 #define NAME_PLATFORM_ID "PLATFORM_ID"
94 
95 #define NAME_REGION_MAP_PATH "REGION_MAP_PATH"
96 
97 #define NAME_NXP_UCI_CONFIG_PATH "NXP_UCI_CONFIG_PATH"
98 
99 /* libuwb-uci.conf parameters */
100 #define NAME_NXP_UWB_LOW_POWER_MODE "UWB_LOW_POWER_MODE"
101 
102 /* libuwb-countrycode.conf parameters */
103 #define NAME_NXP_COUNTRY_CODE_VERSION "VERSION"
104 
105 #define NAME_AUTO_SUSPEND_ENABLE        "AUTO_SUSPEND_ENABLE"
106 #define NAME_AUTO_SUSPEND_TIMEOUT_MS    "AUTO_SUSPEND_TIMEOUT_MS"
107 
108 #define NAME_DELETE_URSK_FOR_CCC_SESSION    "DELETE_URSK_FOR_CCC_SESSION"
109 #define NAME_DELETE_URSK_FOR_ALIRO_SESSION    "DELETE_URSK_FOR_ALIRO_SESSION"
110 
111 /* In case the HAL has to set STS index for CCC */
112 #define NAME_OVERRIDE_STS_INDEX_FOR_CCC_SESSION    "OVERRIDE_STS_INDEX_FOR_CCC_SESSION"
113 
114 /* default configuration */
115 #define default_storage_location "/data/vendor/uwb"
116 
117 #endif
118