mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/add_api_to_update_config_file_path' into 'master'
Add API to update bluetooth config file path See merge request espressif/esp-idf!25560
This commit is contained in:
commit
66e720c7eb
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -11,6 +11,7 @@
|
|||||||
#include "device/controller.h"
|
#include "device/controller.h"
|
||||||
#include "btc/btc_task.h"
|
#include "btc/btc_task.h"
|
||||||
#include "btc/btc_dev.h"
|
#include "btc/btc_dev.h"
|
||||||
|
#include "btc/btc_config.h"
|
||||||
|
|
||||||
const uint8_t *esp_bt_dev_get_address(void)
|
const uint8_t *esp_bt_dev_get_address(void)
|
||||||
{
|
{
|
||||||
@ -68,3 +69,10 @@ esp_err_t esp_bt_dev_coex_status_config(esp_bt_dev_coex_type_t type, esp_bt_dev_
|
|||||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_dev_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
return (btc_transfer_context(&msg, &arg, sizeof(btc_dev_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
esp_err_t esp_bt_config_file_path_update(const char *file_path)
|
||||||
|
{
|
||||||
|
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_UNINITIALIZED);
|
||||||
|
|
||||||
|
return btc_config_file_path_update(file_path);
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -79,6 +79,18 @@ esp_err_t esp_bt_dev_set_device_name(const char *name);
|
|||||||
*/
|
*/
|
||||||
esp_err_t esp_bt_dev_coex_status_config(esp_bt_dev_coex_type_t type, esp_bt_dev_coex_op_t op, uint8_t status);
|
esp_err_t esp_bt_dev_coex_status_config(esp_bt_dev_coex_type_t type, esp_bt_dev_coex_op_t op, uint8_t status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function is used to update the path name of bluetooth bond keys saved in the NVS module
|
||||||
|
* and need to be called before esp_bluedroid_init().
|
||||||
|
* @param[in] file_path: the name of config file path, the length of file_path should be less than NVS_NS_NAME_MAX_SIZE
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - ESP_OK: success
|
||||||
|
* - other: failed
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
esp_err_t esp_bt_config_file_path_update(const char *file_path);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -20,14 +20,26 @@
|
|||||||
#include "osi/mutex.h"
|
#include "osi/mutex.h"
|
||||||
|
|
||||||
#include "stack/bt_types.h"
|
#include "stack/bt_types.h"
|
||||||
|
#include "nvs.h"
|
||||||
|
|
||||||
static const char *CONFIG_FILE_PATH = "bt_config.conf";
|
static char CONFIG_FILE_PATH[NVS_NS_NAME_MAX_SIZE] = "bt_config.conf";
|
||||||
static const period_ms_t CONFIG_SETTLE_PERIOD_MS = 3000;
|
static const period_ms_t CONFIG_SETTLE_PERIOD_MS = 3000;
|
||||||
|
|
||||||
static void btc_key_value_to_string(uint8_t *key_value, char *value_str, int key_length);
|
static void btc_key_value_to_string(uint8_t *key_value, char *value_str, int key_length);
|
||||||
static osi_mutex_t lock; // protects operations on |config|.
|
static osi_mutex_t lock; // protects operations on |config|.
|
||||||
static config_t *config;
|
static config_t *config;
|
||||||
|
|
||||||
|
int btc_config_file_path_update(const char *file_path)
|
||||||
|
{
|
||||||
|
if (file_path != NULL && strlen(file_path) < NVS_NS_NAME_MAX_SIZE) {
|
||||||
|
memcpy(CONFIG_FILE_PATH, file_path, strlen(file_path));
|
||||||
|
CONFIG_FILE_PATH[strlen(file_path)] = '\0';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
BTC_TRACE_ERROR("Update failed, file_path is NULL or length should be less than %d\n", NVS_NS_NAME_MAX_SIZE);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
bool btc_compare_address_key_value(const char *section, const char *key_type, void *key_value, int key_length)
|
bool btc_compare_address_key_value(const char *section, const char *key_type, void *key_value, int key_length)
|
||||||
{
|
{
|
||||||
assert(key_value != NULL);
|
assert(key_value != NULL);
|
||||||
|
@ -47,4 +47,5 @@ bool btc_get_device_type(const BD_ADDR bd_addr, int *p_device_type);
|
|||||||
void btc_config_lock(void);
|
void btc_config_lock(void);
|
||||||
void btc_config_unlock(void);
|
void btc_config_unlock(void);
|
||||||
|
|
||||||
|
int btc_config_file_path_update(const char *file_path);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user