-
Notifications
You must be signed in to change notification settings - Fork 0
/
storage.h
60 lines (52 loc) · 1.26 KB
/
storage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* storage.h - KNoT Thing Storage handler */
/*
* Copyright (c) 2018, CESAR. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "knot_protocol.h"
struct storage_app_settings {
uint64_t device_id;
char uuid[KNOT_PROTOCOL_UUID_LEN];
char token[KNOT_PROTOCOL_TOKEN_LEN];
};
/**
* @brief Prepare environment to use flash memory.
*
* @details Initialise flash device and load values.
*
* @retval 0 Success
* @retval -ERRNO errno code if error
*/
int8_t storage_init(void);
/**
* @brief Clear all stored values.
*
* @details Clear info of all credentials.
*
* @retval 0 Success
* @retval -ERRNO errno code if error
*/
int8_t storage_reset(void);
/**
* @brief Gets value loaded from storage.
*
* @details Gets UUID, TOKEN and Device Id loaded from flash memory.
*
* @param dest Destination buffer to receive loaded value.
*
* @retval 0 for SUCCESS.
* @retval -ERRNO errno code for Error.
*/
int8_t storage_get(struct storage_app_settings *dest);
/**
* @brief Store value on NVM.
*
* @details Save UUID, TOKEN and Device Id on flash memory.
*
* @param src Buffer structure containing values to be stored.
*
* @retval 0 for SUCCESS.
* @retval -ERRNO errno code for Error.
*/
int8_t storage_set(const struct storage_app_settings *src);