generated from IRNAS/irnas-zephyr-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from IRNAS/release/v1.4.0
Release v1.4.0
- Loading branch information
Showing
17 changed files
with
993 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** @file user_settings_json.h | ||
* | ||
* @brief JSON encode/decode module | ||
* | ||
* @par | ||
* COPYRIGHT NOTICE: (c) 2023 Irnas. All rights reserved. | ||
*/ | ||
|
||
#ifndef USER_SETTINGS_JSON_H | ||
#define USER_SETTINGS_JSON_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <zephyr/kernel.h> | ||
#include <user_settings_types.h> | ||
/* JSON parser */ | ||
#include <cJSON.h> | ||
#include <cJSON_os.h> | ||
|
||
/** | ||
* @brief Set settings from a flat json structure | ||
* | ||
* Does not modify the passed in JSON. | ||
* | ||
* Expected structure looks like: | ||
* { | ||
* "s_key_1": <value>, | ||
* "s_key_2": <value>, | ||
* // ... | ||
* } | ||
* | ||
* @param[in] settings The settings to apply | ||
* | ||
* @retval 0 On success | ||
* @retval -ENOMEM If the new value is larger than the max_size | ||
* @retval -EIO if the setting value could not be stored to NVS | ||
* @retval -EINVAL if the invalid json structure | ||
*/ | ||
int user_settings_set_from_json(const cJSON *settings); | ||
|
||
/** | ||
* @brief Create a JSON with containing only settings marked changed. | ||
* Function will not clear changed flag. | ||
* | ||
* The caller is expected to free the created cJSON structure. | ||
* | ||
* @param[out] settings Created json | ||
* @retval 0 On success | ||
* @retval -ENOMEM If we failed to allocate JSON struct | ||
*/ | ||
int user_settings_get_changed_json(cJSON **settings); | ||
|
||
/** | ||
* @brief Create a JSON with containing all settings. | ||
* | ||
* The caller is expected to free the created cJSON structure. | ||
* | ||
* @param[out] settings Created json | ||
* @retval 0 On success | ||
* @retval -ENOMEM If we failed to allocate JSON struct | ||
*/ | ||
int user_settings_get_all_json(cJSON **settings); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // USER_SETTINGS_JSON_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.