2021-10-26 08:24:54 +00:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2019-01-07 07:16:47 +00:00
|
|
|
|
|
|
|
#ifndef _BLE_MESH_SETTINGS_NVS_H_
|
|
|
|
#define _BLE_MESH_SETTINGS_NVS_H_
|
|
|
|
|
2020-05-26 09:44:59 +00:00
|
|
|
#include "nvs_flash.h"
|
2019-01-07 07:16:47 +00:00
|
|
|
#include "mesh_buf.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-05-26 09:44:59 +00:00
|
|
|
typedef nvs_handle_t bt_mesh_nvs_handle_t;
|
|
|
|
|
2020-12-07 09:03:11 +00:00
|
|
|
#define SETTINGS_ITEM_SIZE sizeof(uint16_t)
|
2019-09-02 05:01:06 +00:00
|
|
|
|
2020-12-07 09:03:11 +00:00
|
|
|
#define BLE_MESH_GET_ELEM_IDX(x) ((uint8_t)((x) >> 8))
|
|
|
|
#define BLE_MESH_GET_MODEL_IDX(x) ((uint8_t)(x))
|
|
|
|
#define BLE_MESH_GET_MODEL_KEY(a, b) ((uint16_t)(((uint16_t)((a) << 8)) | (b)))
|
2019-01-07 07:16:47 +00:00
|
|
|
|
2020-11-24 12:51:09 +00:00
|
|
|
int bt_mesh_settings_nvs_open(const char* name, bt_mesh_nvs_handle_t *handle);
|
|
|
|
void bt_mesh_settings_nvs_close(bt_mesh_nvs_handle_t handle);
|
|
|
|
|
2020-05-26 10:31:46 +00:00
|
|
|
void bt_mesh_settings_init_foreach(void);
|
2020-05-29 02:06:34 +00:00
|
|
|
void bt_mesh_settings_deinit_foreach(bool erase);
|
2019-01-07 07:16:47 +00:00
|
|
|
|
2020-11-24 12:51:09 +00:00
|
|
|
int bt_mesh_settings_direct_open(bt_mesh_nvs_handle_t *handle);
|
|
|
|
void bt_mesh_settings_direct_close(void);
|
|
|
|
|
2020-05-26 10:31:46 +00:00
|
|
|
int bt_mesh_save_settings(bt_mesh_nvs_handle_t handle, const char *key,
|
2020-12-07 09:03:11 +00:00
|
|
|
const uint8_t *val, size_t len);
|
|
|
|
int bt_mesh_save_core_settings(const char *key, const uint8_t *val, size_t len);
|
|
|
|
int bt_mesh_save_uid_settings(const char *key, const uint8_t *val, size_t len);
|
2019-01-07 07:16:47 +00:00
|
|
|
|
2020-05-27 01:11:53 +00:00
|
|
|
int bt_mesh_erase_settings(bt_mesh_nvs_handle_t handle, const char *key);
|
|
|
|
int bt_mesh_erase_core_settings(const char *key);
|
2020-11-24 12:51:09 +00:00
|
|
|
int bt_mesh_erase_uid_settings(const char *name);
|
2020-05-27 01:11:53 +00:00
|
|
|
|
2020-05-26 10:31:46 +00:00
|
|
|
int bt_mesh_load_settings(bt_mesh_nvs_handle_t handle, const char *key,
|
2020-12-07 09:03:11 +00:00
|
|
|
uint8_t *buf, size_t buf_len, bool *exist);
|
|
|
|
int bt_mesh_load_core_settings(const char *key, uint8_t *buf, size_t buf_len, bool *exist);
|
|
|
|
int bt_mesh_load_uid_settings(const char *key, uint8_t *buf, size_t buf_len, bool *exist);
|
2019-01-07 07:16:47 +00:00
|
|
|
|
2020-05-26 10:31:46 +00:00
|
|
|
struct net_buf_simple *bt_mesh_get_settings_item(bt_mesh_nvs_handle_t handle, const char *key);
|
2019-01-07 07:16:47 +00:00
|
|
|
struct net_buf_simple *bt_mesh_get_core_settings_item(const char *key);
|
2020-11-24 12:51:09 +00:00
|
|
|
struct net_buf_simple *bt_mesh_get_uid_settings_item(const char *key);
|
2019-01-07 07:16:47 +00:00
|
|
|
|
2020-12-07 09:03:11 +00:00
|
|
|
int bt_mesh_add_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const uint16_t val);
|
|
|
|
int bt_mesh_add_core_settings_item(const char *key, const uint16_t val);
|
|
|
|
int bt_mesh_add_uid_settings_item(const char *key, const uint16_t val);
|
2019-01-07 07:16:47 +00:00
|
|
|
|
2020-12-07 09:03:11 +00:00
|
|
|
int bt_mesh_remove_settings_item(bt_mesh_nvs_handle_t handle, const char *key, const uint16_t val);
|
|
|
|
int bt_mesh_remove_core_settings_item(const char *key, const uint16_t val);
|
|
|
|
int bt_mesh_remove_uid_settings_item(const char *key, const uint16_t val);
|
2020-11-24 12:51:09 +00:00
|
|
|
|
|
|
|
int bt_mesh_settings_erase_key(bt_mesh_nvs_handle_t handle, const char *key);
|
|
|
|
int bt_mesh_settings_erase_all(bt_mesh_nvs_handle_t handle);
|
2019-01-07 07:16:47 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _BLE_MESH_SETTINGS_NVS_H_ */
|