TuyaOS
include
adapter
utilities
include
tuya_tools.h
浏览该文件的文档.
1
10
#ifndef __TUYA_TOOLS_H__
11
#define __TUYA_TOOLS_H__
12
13
#include "tuya_cloud_types.h"
14
15
#ifdef __cplusplus
16
extern
"C"
{
17
#endif
18
19
28
#define TUYA_PALIGN_DOWN(x, align) (x & ~(align-1))
29
38
#define TUYA_PALIGN_UP(x, align) ((x + (align-1)) & ~(align-1))
39
40
48
SIZE_T
tuya_strlen
(
const
CHAR_T *str);
49
58
CHAR_T *
tuya_strcpy
(CHAR_T *dst,
const
CHAR_T *src);
59
68
CHAR_T *
tuya_strcat
(CHAR_T* dst,
const
CHAR_T* src);
69
79
INT_T
tuya_strncasecmp
(
const
CHAR_T *s1,
const
CHAR_T *s2, SIZE_T n);
80
89
INT_T
tuya_strcmp
(
const
CHAR_T *src,
const
CHAR_T *dst);
90
98
UCHAR_T
tuya_asc2hex
(CHAR_T asccode);
99
109
VOID_T
tuya_ascs2hex
(UCHAR_T *hex, UCHAR_T *ascs, INT_T srclen);
110
121
VOID_T
tuya_hex2str
(UCHAR_T *str, UCHAR_T *hex, INT_T hexlen);
122
133
BOOL_T
tuya_str2num
(UINT_T *number,
const
CHAR_T *str, UINT8_T strlen);
134
144
UINT_T
tuya_int2intArray
(UINT_T num, UINT8_T *intArray, UINT8_T len);
145
155
UINT_T
tuya_intArray2int
(UINT8_T *intArray, UINT_T index, UINT8_T len);
156
164
VOID_T
tuya_buff_reverse
(UINT8_T *buf, UINT16_T len);
165
174
VOID_T
tuya_data_reverse
(UINT8_T *dst, UINT8_T *src, UINT16_T srclen);
175
185
VOID_T
tuya_byte_sort
(UCHAR_T is_ascend, UCHAR_T *buf, INT_T len);
186
196
INT_T
tuya_find_char_with_reverse_idx
(
const
CHAR_T *str,
const
INT_T index,
const
CHAR_T ch);
197
205
UINT_T
tuya_bit1_count
(UINT_T num);
206
214
UINT_T
tuya_leading_zeros_count
(UINT_T num);
215
224
UINT8_T
tuya_check_sum8
(UINT8_T *buf, UINT32_T len);
225
234
UINT16_T
tuya_check_sum16
(UINT8_T *buf, UINT32_T len);
235
236
237
#ifdef __cplusplus
238
}
239
#endif
240
#endif
241
tuya_check_sum8
UINT8_T tuya_check_sum8(UINT8_T *buf, UINT32_T len)
8-bit cumulative checksum calculation
tuya_strncasecmp
INT_T tuya_strncasecmp(const CHAR_T *s1, const CHAR_T *s2, SIZE_T n)
compare the first n characters of two string
tuya_leading_zeros_count
UINT_T tuya_leading_zeros_count(UINT_T num)
the software calculates the number of leading zeros
tuya_buff_reverse
void tuya_buff_reverse(UINT8_T *buf, UINT16_T len)
tuya_bit1_count
UINT_T tuya_bit1_count(UINT_T num)
calculate the number of bits 1 in a number
tuya_find_char_with_reverse_idx
INT_T tuya_find_char_with_reverse_idx(const CHAR_T *str, const INT_T index, const CHAR_T ch)
find <ch> in <str>, start find in index <revr_index>, find in reverse order.
tuya_hex2str
void tuya_hex2str(UCHAR_T *str, UCHAR_T *hex, INT_T hexlen)
convert the input hex array to string array
tuya_check_sum16
UINT16_T tuya_check_sum16(UINT8_T *buf, UINT32_T len)
16-bit cumulative checksum calculation
tuya_strcpy
CHAR_T * tuya_strcpy(CHAR_T *dst, const CHAR_T *src)
string copy
tuya_str2num
BOOL_T tuya_str2num(UINT_T *number, const CHAR_T *str, UINT8_T strlen)
convert the input string to number
tuya_intArray2int
UINT_T tuya_intArray2int(UINT8_T *intArray, UINT_T index, UINT8_T len)
int array convert to a int number
tuya_ascs2hex
void tuya_ascs2hex(UCHAR_T *hex, UCHAR_T *ascs, INT_T srclen)
convert the hex character array to hex array
tuya_int2intArray
UINT_T tuya_int2intArray(UINT_T num, UINT8_T *intArray, UINT8_T len)
int number convert to buff
tuya_data_reverse
void tuya_data_reverse(UINT8_T *dst, UINT8_T *src, UINT16_T srclen)
tuya_strlen
SIZE_T tuya_strlen(const CHAR_T *str)
string len
tuya_strcmp
INT_T tuya_strcmp(const CHAR_T *src, const CHAR_T *dst)
compare characters of two string
tuya_asc2hex
UCHAR_T tuya_asc2hex(CHAR_T asccode)
convert character to hex, if '0'-'f'/'F' -> 0-15, else 0
tuya_byte_sort
void tuya_byte_sort(UCHAR_T is_ascend, UCHAR_T *buf, INT_T len)
sort the CHAR_T in the buf according ascii value
tuya_strcat
CHAR_T * tuya_strcat(CHAR_T *dst, const CHAR_T *src)
string cat
制作者
1.9.4