Trident IoT Zigbee SDK
Loading...
Searching...
No Matches
tr_nvram_attr.h
Go to the documentation of this file.
1
67#ifndef TR_NVRAM_ATTR_H
68#define TR_NVRAM_ATTR_H
69
70#include "tr_af.h"
71
72// NV RAM data storage versions
73#define TR_NVRAM_STORAGE_VER_1 (1)
74#define TR_NVRAM_STORAGE_VER_2 (2)
75
76// the default time to delay writes to NV in ms
77// use this for the function tr_check_for_attr_nvram_update(...) for the argument delay_time_ms
78#define TR_NVRAM_WRITE_DELAY_MS (2000)
79
80// versions for zigbee attribute section
81#define TR_NVRAM_ATTR_STORAGE_VER_1 (1)
82#define TR_NVRAM_ATTR_STORAGE_CUR_VER (TR_NVRAM_ATTR_STORAGE_VER_1)
83
84#define TR_NVRAM_SECTION_ID_ZIGBEE_ATTRS 0x8001
85
86// turn these on to have this module print
87// #define TR_NVRAM_PRINT_ENABLE 1
88// #define TR_NVRAM_VERBOSE_PRINT_ENABLE 1
89
93#ifdef TR_NVRAM_PRINT_ENABLE
94#define tr_nvram_printf(...) tr_core_printf(__VA_ARGS__)
95#else
96#define tr_nvram_printf(...)
97#endif
98
102#ifdef TR_NVRAM_VERBOSE_PRINT_ENABLE
103#define tr_nvram_verbose_printf(...) tr_core_printf(__VA_ARGS__)
104#else
105#define tr_nvram_verbose_printf(...)
106#endif
107
113
132
141#ifdef TR_SCENES_SERVER_PLUGIN_ENABLE
142 #define TR_NVRAM_SCENES_SLOTS 1
143#else
144 #define TR_NVRAM_SCENES_SLOTS 0
145#endif
146
147#ifdef TR_DOOR_LOCK_SERVER_PLUGIN_ENABLE
148 #define TR_NVRAM_DOOR_LOCK_SLOTS 1
149#else
150 #define TR_NVRAM_DOOR_LOCK_SLOTS 0
151#endif
152
153#ifndef TR_NVRAM_NUM_APP_SECTIONS
154 #define TR_NVRAM_NUM_APP_SECTIONS 1
155#endif
156
157// number of slots used is app + door lock + scenes
158#define TR_NVRAM_NUM_TABLE_SLOTS (TR_NVRAM_NUM_APP_SECTIONS + TR_NVRAM_DOOR_LOCK_SLOTS + TR_NVRAM_SCENES_SLOTS)
159
170
174typedef ZB_PACKED_PRE struct
175{
176 zb_uint8_t endpoint;
177 zb_uint16_t cluster_id;
178 zb_uint16_t attr_id;
179 zb_uint8_t cluster_role;
180 zb_uint16_t manuf_code;
181 zb_uint8_t data_type;
183
187
196zb_uint16_t tr_get_nvram_data_size(void);
197
210zb_ret_t tr_nvram_write_app_data_cb(zb_uint8_t page,
211 zb_uint32_t pos);
212
226void tr_nvram_read_app_data_cb(zb_uint8_t page,
227 zb_uint32_t pos,
228 zb_uint16_t payload_length);
229
249 zb_uint16_t cluster_id,
250 zb_uint8_t cluster_role,
251 zb_uint16_t attr_id,
252 zb_uint16_t manuf_code);
253
264 zb_uint16_t cluster_id,
265 zb_uint8_t cluster_role,
266 zb_uint16_t attr_id,
267 zb_uint16_t manuf_code,
268 zb_uint16_t delay_time_ms);
269
273typedef zb_bool_t (*tr_nvram_clear_data_t)(void);
274
278typedef zb_bool_t (*tr_nvram_err_handler_t)(zb_uint8_t *saved_data_ptr,
279 zb_uint8_t data_entry_size,
280 zb_uint8_t data_num_entries);
281
285typedef struct
286{
287 tr_nvram_section_id_t section_id; // unique ID for data
288 zb_uint8_t data_version; // version number for data
289 zb_uint8_t entry_size_len; // data entry size, limited to 255
290 zb_uint8_t num_entries; // data num entries, limited to 255
291 zb_uint8_t *plugin_data_ptr; // pointer to the plugin data
292 tr_nvram_clear_data_t clear_data_fx; // function to clear data
293 tr_nvram_err_handler_t err_hndl_fx; // function to handle errors
295
301
306void tr_nvram_save(zb_uint16_t delay_time_ms);
307
309
310#endif // TR_NVRAM_ATTR_H
void tr_check_for_attr_nvram_update_delay(zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id, zb_uint16_t manuf_code, zb_uint16_t delay_time_ms)
check if a changed attr is supposed to be saved in NV and if so, save it
void tr_check_for_attr_nvram_update(zb_uint8_t ep, zb_uint16_t cluster_id, zb_uint8_t cluster_role, zb_uint16_t attr_id, zb_uint16_t manuf_code)
check if a changed attr is supposed to be saved in NV and if so, save it
zb_bool_t(* tr_nvram_err_handler_t)(zb_uint8_t *saved_data_ptr, zb_uint8_t data_entry_size, zb_uint8_t data_num_entries)
function pointer type for handling size or version errors or NULL to abort data read in this casee
Definition tr_nvram_attr.h:278
void tr_nvram_read_app_data_cb(zb_uint8_t page, zb_uint32_t pos, zb_uint16_t payload_length)
read API: do not change this without reading below
zb_bool_t(* tr_nvram_clear_data_t)(void)
function pointer type for clearing the callback data or NULL to use default behavior (set to 0)
Definition tr_nvram_attr.h:273
void tr_nvram_register(tr_nvram_data_info_t *register_data)
this API is called by a plugin to register to have its data saved
void tr_nvram_save(zb_uint16_t delay_time_ms)
this API is called by a plugin when plugin data has changed
ZB_PACKED_PRE struct @242232173312214114246275277065327230101147147264 tr_nvram_attr_storage_v1_t
structure for storing information about zigbee attributes in NV
tr_nvram_section_id_t
standard section IDs used by Trident plugins and reserved for use by the application
Definition tr_nvram_attr.h:124
zb_uint16_t tr_get_nvram_data_size(void)
there are 3 API functions needed by ZBOSS and passed by the apps
zb_ret_t tr_nvram_write_app_data_cb(zb_uint8_t page, zb_uint32_t pos)
write API: do not change this without reading below
@ TR_NVRAM_SECTION_TSTAT_SCHEDULE_TABLE
Definition tr_nvram_attr.h:128
@ TR_NVRAM_SECTION_ZIGBEE_ATTRIBUTES
Definition tr_nvram_attr.h:125
@ TR_NVRAM_SECTION_SCENES_TABLE
Definition tr_nvram_attr.h:126
@ TR_NVRAM_SECTION_APP_DATA_1
Definition tr_nvram_attr.h:129
@ TR_NVRAM_SECTION_DOOR_LOCK_USER_TABLE
Definition tr_nvram_attr.h:127
struct that a plugin fills in to have its plugin data saved
Definition tr_nvram_attr.h:286
tr_nvram_err_handler_t err_hndl_fx
Definition tr_nvram_attr.h:293
tr_nvram_section_id_t section_id
Definition tr_nvram_attr.h:287
zb_uint8_t * plugin_data_ptr
Definition tr_nvram_attr.h:291
zb_uint8_t entry_size_len
Definition tr_nvram_attr.h:289
zb_uint8_t data_version
Definition tr_nvram_attr.h:288
zb_uint8_t num_entries
Definition tr_nvram_attr.h:290
tr_nvram_clear_data_t clear_data_fx
Definition tr_nvram_attr.h:292
struct for the section header that starts each data section
Definition tr_nvram_attr.h:164
zb_uint8_t data_version
Definition tr_nvram_attr.h:166
zb_uint16_t entry_size
Definition tr_nvram_attr.h:167
tr_nvram_section_id_t section_id
Definition tr_nvram_attr.h:165
zb_uint8_t num_entries
Definition tr_nvram_attr.h:168
Trident application framework include.
zb_uint8_t endpoint
Definition tr_nvram_attr.h:176
zb_uint16_t cluster_id
Definition tr_nvram_attr.h:177
zb_uint8_t cluster_role
Definition tr_nvram_attr.h:179
zb_uint16_t manuf_code
Definition tr_nvram_attr.h:180
zb_uint16_t attr_id
Definition tr_nvram_attr.h:178
zb_uint8_t data_type
Definition tr_nvram_attr.h:181