TuyaOS
结构体 | 宏定义 | 类型定义 | 函数
tuya_ws_db.h 文件参考

tuya key-value database module 更多...

#include "tuya_cloud_types.h"
tuya_ws_db.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

结构体

struct  TY_DB_RW_S
 tuya key-value database property, used for serialize/deserialize data to json format 更多...
 

宏定义

#define VT_BOOL   5
 
#define VT_BYTE   1
 
#define VT_CHAR   0
 
#define VT_INT   4
 
#define VT_RAW   7
 
#define VT_SHORT   2
 
#define VT_STRING   6
 
#define VT_USHORT   3
 

类型定义

typedef BYTE_T VAR_TP_T
 tuya key-value database property define, used for serialize/deserialize data to json format
 

函数

OPERATE_RET wd_common_delete (IN CONST CHAR_T *key)
 delete the entry from key-value database 更多...
 
OPERATE_RET wd_common_exist (IN CONST CHAR_T *key, OUT BOOL_T *exist)
 check the entry from key-value database 更多...
 
OPERATE_RET wd_common_free_data (IN BYTE_T *data)
 free the buffer which allocated by wd_common_read or wd_common_fuzzy_read 更多...
 
OPERATE_RET wd_common_fuzzy_delete (IN CONST CHAR_T *key)
 fuzzy delete the entry from key-value database 更多...
 
OPERATE_RET wd_common_fuzzy_read (IN CONST CHAR_T *fuzzy_name, INOUT UINT_T *index, OUT BYTE_T **data, OUT UINT_T *len)
 tuya key-value database fuzzy read entry 更多...
 
OPERATE_RET wd_common_read (IN CONST CHAR_T *key, OUT BYTE_T **value, OUT UINT_T *p_len)
 tuya key-value database read entry 更多...
 
OPERATE_RET wd_common_write (IN CONST CHAR_T *key, IN CONST BYTE_T *value, IN CONST UINT_T len)
 tuya key-value database write entry 更多...
 
OPERATE_RET wd_protected_delete (IN CONST CHAR_T *key)
 delete the entry from protected storage 更多...
 
OPERATE_RET wd_protected_read (IN CONST CHAR_T *key, OUT BYTE_T **value, OUT UINT_T *p_len)
 tuya protected storage read entry 更多...
 
OPERATE_RET wd_protected_write (IN CONST CHAR_T *key, IN CONST BYTE_T *value, IN CONST UINT_T len)
 tuya protected storage write entry 更多...
 
OPERATE_RET wd_user_param_read (OUT BYTE_T **buf, OUT UINT_T *len)
 read the user parameter from tuya key-value database 更多...
 
OPERATE_RET wd_user_param_write (IN CONST BYTE_T *data, IN CONST UINT_T len)
 write the user parameter to tuya key-value database 更多...
 
OPERATE_RET wd_utils_deserialize (IN CONST CHAR_T *in, INOUT TY_DB_RW_S *rw, IN CONST UINT_T rw_cnt)
 tuya key-value deserialize, transfer the data from json format to property array 更多...
 
OPERATE_RET wd_utils_free_outbuf (IN CHAR_T *out_buf)
 free the buffer which allocated by wd_utils_serialize_restore 更多...
 
OPERATE_RET wd_utils_serialize (IN CONST TY_DB_RW_S *rw, IN CONST UINT_T rw_cnt, OUT CHAR_T **out, OUT UINT_T *out_len)
 tuya key-value serialize, transfer the data from TY_DB_RW_S array to json format 更多...
 
OPERATE_RET wd_utils_serialize_restore (IN CONST CHAR_T *key, INOUT TY_DB_RW_S *rw, IN CONST UINT_T rw_cnt)
 tuya key-value serialize restore, will read the data from tuya key-value database and restore to database property entry 更多...
 
OPERATE_RET wd_utils_serialize_save (IN CONST CHAR_T *key, IN CONST TY_DB_RW_S *rw, IN CONST UINT_T rw_cnt)
 tuya key-value serialize and save in tuya key-value database 更多...
 
OPERATE_RET ws_db_format (VOID)
 tuya key-value database format 更多...
 
CHAR_T * ws_db_get_storage_path (VOID)
 tuya key-value database get storage path 更多...
 
OPERATE_RET ws_db_init (IN CONST CHAR_T *fs_storge_path, IN CONST BYTE_T *p_key)
 tuya key-value database initialization 更多...
 
OPERATE_RET ws_db_init_mf (VOID)
 tuya key-value database initialization in mf 更多...
 
OPERATE_RET ws_db_rebuild (VOID)
 tuya key-value database rebuild to recycle 更多...
 
VOID ws_db_uninit (VOID)
 tuya key-value database de-initialization 更多...
 

详细描述

tuya key-value database module

作者
niezy.nosp@m.@tuy.nosp@m.a.com
版本
1.0
日期
2021-01-09

函数说明

◆ wd_common_delete()

OPERATE_RET wd_common_delete ( IN CONST CHAR_T *  key)

delete the entry from key-value database

参数
[in]keykey of the entry you want to delete
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ wd_common_exist()

OPERATE_RET wd_common_exist ( IN CONST CHAR_T *  key,
OUT BOOL_T *  exist 
)

check the entry from key-value database

参数
[in]keykey of the entry you want to check
[OUT]exist TRUE on exist
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ wd_common_free_data()

OPERATE_RET wd_common_free_data ( IN BYTE_T *  data)

free the buffer which allocated by wd_common_read or wd_common_fuzzy_read

参数
[in]datathe buffer got from wd_common_read or wd_common_fuzzy_read
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ wd_common_fuzzy_delete()

OPERATE_RET wd_common_fuzzy_delete ( IN CONST CHAR_T *  key)

fuzzy delete the entry from key-value database

参数
[in]keykey of the entry you want to delete
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
delete all entries if the key match the prefix of entry key

◆ wd_common_fuzzy_read()

OPERATE_RET wd_common_fuzzy_read ( IN CONST CHAR_T *  fuzzy_name,
INOUT UINT_T *  index,
OUT BYTE_T **  data,
OUT UINT_T *  len 
)

tuya key-value database fuzzy read entry

参数
[in]fuzzy_namekey of the entry you want to read
[in]indexindex of the value sequnence
[out]databuffer of the value
[out]p_lenlength of the buffer
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
if we have three entry "x1","x2","x3" in database, and read use "x" as the key will got all these 3 entrys and will chose the return entry by index
must free the value buffer with wd_common_free_data when you nolonger need the buffer

◆ wd_common_read()

OPERATE_RET wd_common_read ( IN CONST CHAR_T *  key,
OUT BYTE_T **  value,
OUT UINT_T *  p_len 
)

tuya key-value database read entry

参数
[in]keykey of the entry you want to read
[out]valuebuffer of the value
[out]p_lenlength of the buffer
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
must free the value buffer with wd_common_free_data when you nolonger need the buffer

◆ wd_common_write()

OPERATE_RET wd_common_write ( IN CONST CHAR_T *  key,
IN CONST BYTE_T *  value,
IN CONST UINT_T  len 
)

tuya key-value database write entry

参数
[in]keykey of the entry you want to write
[in]valuevalue buffer you want to write
[in]lenthe numbers of byte you want to write
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ wd_protected_delete()

OPERATE_RET wd_protected_delete ( IN CONST CHAR_T *  key)

delete the entry from protected storage

参数
[in]keykey of the entry you want to delete
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ wd_protected_read()

OPERATE_RET wd_protected_read ( IN CONST CHAR_T *  key,
OUT BYTE_T **  value,
OUT UINT_T *  p_len 
)

tuya protected storage read entry

参数
[in]keykey of the entry you want to read
[out]valuebuffer of the value
[out]p_lenlength of the buffer
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
must free the value buffer with wd_common_free_data when you nolonger need the buffer

◆ wd_protected_write()

OPERATE_RET wd_protected_write ( IN CONST CHAR_T *  key,
IN CONST BYTE_T *  value,
IN CONST UINT_T  len 
)

tuya protected storage write entry

参数
[in]keykey of the entry you want to write
[in]valuevalue buffer you want to write
[in]lenthe numbers of byte you want to write
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ wd_user_param_read()

OPERATE_RET wd_user_param_read ( OUT BYTE_T **  buf,
OUT UINT_T *  len 
)

read the user parameter from tuya key-value database

参数
[out]bufbuffer of the data
[out]lenlength of the data
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
the key of user parameter entry is "user_param_key",must free the value buffer with wd_common_free_data when you nolonger need the buffer

◆ wd_user_param_write()

OPERATE_RET wd_user_param_write ( IN CONST BYTE_T *  data,
IN CONST UINT_T  len 
)

write the user parameter to tuya key-value database

参数
[in]databuffer of the data
[in]lenlength of the data
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
the key of user parameter entry is "user_param_key"

◆ wd_utils_deserialize()

OPERATE_RET wd_utils_deserialize ( IN CONST CHAR_T *  in,
INOUT TY_DB_RW_S rw,
IN CONST UINT_T  rw_cnt 
)

tuya key-value deserialize, transfer the data from json format to property array

参数
[in]inthe json format data
[in,out]rwthe database entry which contains a property array
[in,out]rw_cntthe database entry property array count
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
deserialize the json format data to database property entry according the rw and rw_cnt, so must fill the rw and rw_cnt in right format.

◆ wd_utils_free_outbuf()

OPERATE_RET wd_utils_free_outbuf ( IN CHAR_T *  out_buf)

free the buffer which allocated by wd_utils_serialize_restore

参数
out_bufthe buffer got from wd_utils_serialize_restore
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ wd_utils_serialize()

OPERATE_RET wd_utils_serialize ( IN CONST TY_DB_RW_S rw,
IN CONST UINT_T  rw_cnt,
OUT CHAR_T **  out,
OUT UINT_T *  out_len 
)

tuya key-value serialize, transfer the data from TY_DB_RW_S array to json format

参数
[in]rwthe database entry which contains a property array
[in]rw_cntthe database entry property array count
[out]outthe serialized json format buffer
[out]out_lenthe serialized json format length
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ wd_utils_serialize_restore()

OPERATE_RET wd_utils_serialize_restore ( IN CONST CHAR_T *  key,
INOUT TY_DB_RW_S rw,
IN CONST UINT_T  rw_cnt 
)

tuya key-value serialize restore, will read the data from tuya key-value database and restore to database property entry

参数
[in]keykey of the database entry
[in,out]rwthe database entry which contains a property array
[in,out]rw_cntthe database entry property array count
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
tuya key-value database saved the json format data and this api will read and deserialize it to property entry according the rw and rw_cnt, so must fill the rw and rw_cnt in right format.

◆ wd_utils_serialize_save()

OPERATE_RET wd_utils_serialize_save ( IN CONST CHAR_T *  key,
IN CONST TY_DB_RW_S rw,
IN CONST UINT_T  rw_cnt 
)

tuya key-value serialize and save in tuya key-value database

参数
[in]keykey of the database entry
[in]rwthe database entry which contains a property array
[in]rw_cntthe database entry property array count
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ ws_db_format()

OPERATE_RET ws_db_format ( VOID  )

tuya key-value database format

返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ ws_db_get_storage_path()

CHAR_T * ws_db_get_storage_path ( VOID  )

tuya key-value database get storage path

注解
Caller shall free the buffer returned
返回
Buffer for storage path, NULL on error

◆ ws_db_init()

OPERATE_RET ws_db_init ( IN CONST CHAR_T *  fs_storge_path,
IN CONST BYTE_T *  p_key 
)

tuya key-value database initialization

参数
[in]fs_storge_paththe storage path of the key-value database, only used in linux system
[in]p_keythe encypto key of the key-value database, if p_key==NULL, will generate a random one
返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
user don't need to care about this function, it will be called when tuya IoTOS initialization.

◆ ws_db_init_mf()

OPERATE_RET ws_db_init_mf ( VOID  )

tuya key-value database initialization in mf

返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h
注解
user don't need to care about this function, it will be called when tuya IoTOS initialization.

◆ ws_db_rebuild()

OPERATE_RET ws_db_rebuild ( VOID  )

tuya key-value database rebuild to recycle

返回
OPRT_OK on success. Others on error, please refer to tuya_error_code.h

◆ ws_db_uninit()

VOID ws_db_uninit ( VOID  )

tuya key-value database de-initialization

返回
VOID