|
TuyaOS
|
tuya common api module 更多...
#include "tuya_cloud_types.h"
宏定义 | |
| #define | TUYA_PALIGN_DOWN(x, align) (x & ~(align-1)) |
| align and round down 更多... | |
| #define | TUYA_PALIGN_UP(x, align) ((x + (align-1)) & ~(align-1)) |
| align and round up 更多... | |
函数 | |
| UCHAR_T | tuya_asc2hex (CHAR_T asccode) |
| convert character to hex, if '0'-'f'/'F' -> 0-15, else 0 更多... | |
| void | tuya_ascs2hex (UCHAR_T *hex, UCHAR_T *ascs, INT_T srclen) |
| convert the hex character array to hex array 更多... | |
| UINT_T | tuya_bit1_count (UINT_T num) |
| calculate the number of bits 1 in a number 更多... | |
| void | tuya_buff_reverse (UINT8_T *buf, UINT16_T len) |
| void | tuya_byte_sort (UCHAR_T is_ascend, UCHAR_T *buf, INT_T len) |
| sort the CHAR_T in the buf according ascii value 更多... | |
| UINT16_T | tuya_check_sum16 (UINT8_T *buf, UINT32_T len) |
| 16-bit cumulative checksum calculation 更多... | |
| UINT8_T | tuya_check_sum8 (UINT8_T *buf, UINT32_T len) |
| 8-bit cumulative checksum calculation 更多... | |
| void | tuya_data_reverse (UINT8_T *dst, UINT8_T *src, UINT16_T srclen) |
| 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 更多... | |
| UINT_T | tuya_int2intArray (UINT_T num, UINT8_T *intArray, UINT8_T len) |
| int number convert to buff 更多... | |
| UINT_T | tuya_intArray2int (UINT8_T *intArray, UINT_T index, UINT8_T len) |
| int array convert to a int number 更多... | |
| UINT_T | tuya_leading_zeros_count (UINT_T num) |
| the software calculates the number of leading zeros 更多... | |
| BOOL_T | tuya_str2num (UINT_T *number, const CHAR_T *str, UINT8_T strlen) |
| convert the input string to number 更多... | |
| CHAR_T * | tuya_strcat (CHAR_T *dst, const CHAR_T *src) |
| string cat 更多... | |
| INT_T | tuya_strcmp (const CHAR_T *src, const CHAR_T *dst) |
| compare characters of two string 更多... | |
| CHAR_T * | tuya_strcpy (CHAR_T *dst, const CHAR_T *src) |
| string copy 更多... | |
| SIZE_T | tuya_strlen (const CHAR_T *str) |
| string len 更多... | |
| INT_T | tuya_strncasecmp (const CHAR_T *s1, const CHAR_T *s2, SIZE_T n) |
| compare the first n characters of two string 更多... | |
tuya common api module
| #define TUYA_PALIGN_DOWN | ( | x, | |
| align | |||
| ) | (x & ~(align-1)) |
align and round down
| [in] | x | number to be aligned |
| [in] | align | align size |
| #define TUYA_PALIGN_UP | ( | x, | |
| align | |||
| ) | ((x + (align-1)) & ~(align-1)) |
align and round up
| [in] | x | number to be aligned |
| [in] | align | align size |
| UCHAR_T tuya_asc2hex | ( | CHAR_T | asccode | ) |
convert character to hex, if '0'-'f'/'F' -> 0-15, else 0
| [in] | asccode | the input character |
| void tuya_ascs2hex | ( | UCHAR_T * | hex, |
| UCHAR_T * | ascs, | ||
| INT_T | srclen | ||
| ) |
convert the hex character array to hex array
| [out] | hex | the out hex array |
| [in] | ascs | the input hex character array |
| [in] | srclen | the length of input character array |
| UINT_T tuya_bit1_count | ( | UINT_T | num | ) |
calculate the number of bits 1 in a number
| [in] | num | number |
| void tuya_buff_reverse | ( | UINT8_T * | buf, |
| UINT16_T | len | ||
| ) |
| [in/out] | buf: the buff need to be reverse | |
| [in] | len | the length of buff |
| void tuya_byte_sort | ( | UCHAR_T | is_ascend, |
| UCHAR_T * | buf, | ||
| INT_T | len | ||
| ) |
sort the CHAR_T in the buf according ascii value
| [in] | is_ascend | sorting mode |
| [in] | buf | the buffer need to sort |
| [in] | len | the length of character in buffer |
| UINT16_T tuya_check_sum16 | ( | UINT8_T * | buf, |
| UINT32_T | len | ||
| ) |
16-bit cumulative checksum calculation
| [in] | buf | the buffer to calculate |
| [in] | len | length of the buffer |
| UINT8_T tuya_check_sum8 | ( | UINT8_T * | buf, |
| UINT32_T | len | ||
| ) |
8-bit cumulative checksum calculation
| [in] | buf | the buffer to calculate |
| [in] | len | length of the buffer |
| void tuya_data_reverse | ( | UINT8_T * | dst, |
| UINT8_T * | src, | ||
| UINT16_T | srclen | ||
| ) |
| [out] | dst | reversal dest data |
| [in] | src | reversal source data |
| [in] | srclen | reversal data buffer length |
| 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.
| [in] | str | the string for find |
| [in] | index | the reverse index start to find |
| [in] | ch | the character to find |
| void tuya_hex2str | ( | UCHAR_T * | str, |
| UCHAR_T * | hex, | ||
| INT_T | hexlen | ||
| ) |
convert the input hex array to string array
| [out] | str | the out string array |
| [in] | hex | the input hex array |
| [in] | hexlen | the length of input hex array |
| UINT_T tuya_int2intArray | ( | UINT_T | num, |
| UINT8_T * | intArray, | ||
| UINT8_T | len | ||
| ) |
int number convert to buff
| [in] | num | the number need to convert |
| [out] | intArray | point to array |
| [in] | len | the length of array |
| UINT_T tuya_intArray2int | ( | UINT8_T * | intArray, |
| UINT_T | index, | ||
| UINT8_T | len | ||
| ) |
int array convert to a int number
| [in] | intArray | the array need to convert |
| [in] | index | arry start index |
| [in] | len | the length of array |
| UINT_T tuya_leading_zeros_count | ( | UINT_T | num | ) |
the software calculates the number of leading zeros
| [in] | num | number |
| BOOL_T tuya_str2num | ( | UINT_T * | number, |
| const CHAR_T * | str, | ||
| UINT8_T | strlen | ||
| ) |
convert the input string to number
| [out] | number | the out number |
| [in] | str | the input string |
| [in] | strlen | the length of input hex array |
| CHAR_T * tuya_strcat | ( | CHAR_T * | dst, |
| const CHAR_T * | src | ||
| ) |
string cat
| [in] | dst | point to target string array |
| [in] | src | point to the string to append |
| INT_T tuya_strcmp | ( | const CHAR_T * | src, |
| const CHAR_T * | dst | ||
| ) |
compare characters of two string
| [in] | src | the source string |
| [in] | dst | the dest string |
| CHAR_T * tuya_strcpy | ( | CHAR_T * | dst, |
| const CHAR_T * | src | ||
| ) |
string copy
| [in] | dst | target array used to store the copied content |
| [in] | src | string to copy |
| SIZE_T tuya_strlen | ( | const CHAR_T * | str | ) |
string len
| [in] | str | string to calculate length |
| INT_T tuya_strncasecmp | ( | const CHAR_T * | s1, |
| const CHAR_T * | s2, | ||
| SIZE_T | n | ||
| ) |
compare the first n characters of two string
| [in] | s1 | the string 1 |
| [in] | s2 | the string 2 |
| [in] | n | the first n characters |