TuyaOS
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
48SIZE_T tuya_strlen(const CHAR_T *str);
49
58CHAR_T *tuya_strcpy(CHAR_T *dst, const CHAR_T *src);
59
68CHAR_T *tuya_strcat(CHAR_T* dst, const CHAR_T* src);
69
79INT_T tuya_strncasecmp(const CHAR_T *s1, const CHAR_T *s2, SIZE_T n);
80
89INT_T tuya_strcmp(const CHAR_T *src, const CHAR_T *dst);
90
98UCHAR_T tuya_asc2hex(CHAR_T asccode);
99
109VOID_T tuya_ascs2hex(UCHAR_T *hex, UCHAR_T *ascs, INT_T srclen);
110
121VOID_T tuya_hex2str(UCHAR_T *str, UCHAR_T *hex, INT_T hexlen);
122
133BOOL_T tuya_str2num(UINT_T *number, const CHAR_T *str, UINT8_T strlen);
134
144UINT_T tuya_int2intArray(UINT_T num, UINT8_T *intArray, UINT8_T len);
145
155UINT_T tuya_intArray2int(UINT8_T *intArray, UINT_T index, UINT8_T len);
156
164VOID_T tuya_buff_reverse(UINT8_T *buf, UINT16_T len);
165
174VOID_T tuya_data_reverse(UINT8_T *dst, UINT8_T *src, UINT16_T srclen);
175
185VOID_T tuya_byte_sort(UCHAR_T is_ascend, UCHAR_T *buf, INT_T len);
186
196INT_T tuya_find_char_with_reverse_idx(const CHAR_T *str, const INT_T index, const CHAR_T ch);
197
205UINT_T tuya_bit1_count(UINT_T num);
206
214UINT_T tuya_leading_zeros_count(UINT_T num);
215
224UINT8_T tuya_check_sum8(UINT8_T *buf, UINT32_T len);
225
234UINT16_T tuya_check_sum16(UINT8_T *buf, UINT32_T len);
235
236
237#ifdef __cplusplus
238}
239#endif
240#endif
241
UINT8_T tuya_check_sum8(UINT8_T *buf, UINT32_T len)
8-bit cumulative checksum calculation
INT_T tuya_strncasecmp(const CHAR_T *s1, const CHAR_T *s2, SIZE_T n)
compare the first n characters of two string
UINT_T tuya_leading_zeros_count(UINT_T num)
the software calculates the number of leading zeros
void tuya_buff_reverse(UINT8_T *buf, UINT16_T len)
UINT_T tuya_bit1_count(UINT_T num)
calculate the number of bits 1 in a number
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.
void tuya_hex2str(UCHAR_T *str, UCHAR_T *hex, INT_T hexlen)
convert the input hex array to string array
UINT16_T tuya_check_sum16(UINT8_T *buf, UINT32_T len)
16-bit cumulative checksum calculation
CHAR_T * tuya_strcpy(CHAR_T *dst, const CHAR_T *src)
string copy
BOOL_T tuya_str2num(UINT_T *number, const CHAR_T *str, UINT8_T strlen)
convert the input string to number
UINT_T tuya_intArray2int(UINT8_T *intArray, UINT_T index, UINT8_T len)
int array convert to a int number
void tuya_ascs2hex(UCHAR_T *hex, UCHAR_T *ascs, INT_T srclen)
convert the hex character array to hex array
UINT_T tuya_int2intArray(UINT_T num, UINT8_T *intArray, UINT8_T len)
int number convert to buff
void tuya_data_reverse(UINT8_T *dst, UINT8_T *src, UINT16_T srclen)
SIZE_T tuya_strlen(const CHAR_T *str)
string len
INT_T tuya_strcmp(const CHAR_T *src, const CHAR_T *dst)
compare characters of two string
UCHAR_T tuya_asc2hex(CHAR_T asccode)
convert character to hex, if '0'-'f'/'F' -> 0-15, else 0
void tuya_byte_sort(UCHAR_T is_ascend, UCHAR_T *buf, INT_T len)
sort the CHAR_T in the buf according ascii value
CHAR_T * tuya_strcat(CHAR_T *dst, const CHAR_T *src)
string cat