-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
settings: API for get storage instance used
Added API function +int settings_storage_get(void **storage) which allows to get storage instance used by the settings backed to store its records. Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
- Loading branch information
1 parent
63aff01
commit ccf8c54
Showing
14 changed files
with
143 additions
and
7 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
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 was deleted.
Oops, something went wrong.
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,25 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
/* Copyright (c) 2022 Nordic semiconductor ASA */ | ||
|
||
#include <zephyr/zephyr.h> | ||
#include <ztest.h> | ||
#include <errno.h> | ||
#include <zephyr/settings/settings.h> | ||
#include <zephyr/fs/fcb.h> | ||
|
||
void test_setting_storage_get(void) | ||
{ | ||
int rc; | ||
void *storage; | ||
struct fcb_entry loc; | ||
|
||
rc = settings_storage_get(&storage); | ||
zassert_equal(0, rc, "Can't fetch storage reference (err=%d)", rc); | ||
|
||
zassert_not_null(storage, "Null reference."); | ||
|
||
loc.fe_sector = NULL; | ||
rc = fcb_getnext((struct fcb *)storage, &loc); | ||
|
||
zassert_equal(rc, 0, "Can't read fcb (err=%d)", rc); | ||
} |
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,25 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
/* Copyright (c) 2022 Nordic semiconductor ASA */ | ||
|
||
#include <zephyr/zephyr.h> | ||
#include <ztest.h> | ||
#include <errno.h> | ||
#include <zephyr/settings/settings.h> | ||
#include <zephyr/fs/fs.h> | ||
|
||
void test_setting_storage_get(void) | ||
{ | ||
int rc; | ||
void *storage; | ||
|
||
struct fs_dirent entry; | ||
|
||
rc = settings_storage_get(&storage); | ||
zassert_equal(0, rc, "Can't fetch storage reference (err=%d)", rc); | ||
|
||
zassert_not_null(storage, "Null reference."); | ||
|
||
rc = fs_stat((const char *)storage, &entry); | ||
|
||
zassert_true(rc >= 0, "Can't find the file (err=%d)", rc); | ||
} |
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 was deleted.
Oops, something went wrong.
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,25 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
/* Copyright (c) 2022 Nordic semiconductor ASA */ | ||
|
||
#include <zephyr/zephyr.h> | ||
#include <ztest.h> | ||
#include <errno.h> | ||
#include <zephyr/settings/settings.h> | ||
#include <zephyr/fs/nvs.h> | ||
|
||
void test_setting_storage_get(void) | ||
{ | ||
int rc; | ||
void *storage; | ||
uint16_t data = 0x5a5a; | ||
ssize_t nvs_rc; | ||
|
||
rc = settings_storage_get(&storage); | ||
zassert_equal(0, rc, "Can't fetch storage reference (err=%d)", rc); | ||
|
||
zassert_not_null(storage, "Null reference."); | ||
|
||
nvs_rc = nvs_write((struct nvs_fs *)storage, 26, &data, sizeof(data)); | ||
|
||
zassert_true(nvs_rc >= 0, "Can't read nvs record (err=%d).", rc); | ||
} |
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