TuyaOS
宏定义 | 函数
tuya_tools.h 文件参考

tuya common api module 更多...

#include "tuya_cloud_types.h"
tuya_tools.h 的引用(Include)关系图:

浏览源代码.

宏定义

#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

版本
1.0
日期
2019-10-13

宏定义说明

◆ TUYA_PALIGN_DOWN

#define TUYA_PALIGN_DOWN (   x,
  align 
)    (x & ~(align-1))

align and round down

参数
[in]xnumber to be aligned
[in]alignalign size
返回

◆ TUYA_PALIGN_UP

#define TUYA_PALIGN_UP (   x,
  align 
)    ((x + (align-1)) & ~(align-1))

align and round up

参数
[in]xnumber to be aligned
[in]alignalign size
返回

函数说明

◆ tuya_asc2hex()

UCHAR_T tuya_asc2hex ( CHAR_T  asccode)

convert character to hex, if '0'-'f'/'F' -> 0-15, else 0

参数
[in]asccodethe input character
返回
the hex value

◆ tuya_ascs2hex()

void tuya_ascs2hex ( UCHAR_T *  hex,
UCHAR_T *  ascs,
INT_T  srclen 
)

convert the hex character array to hex array

参数
[out]hexthe out hex array
[in]ascsthe input hex character array
[in]srclenthe length of input character array
返回
none

◆ tuya_bit1_count()

UINT_T tuya_bit1_count ( UINT_T  num)

calculate the number of bits 1 in a number

参数
[in]numnumber
返回
number of bits 1

◆ tuya_buff_reverse()

void tuya_buff_reverse ( UINT8_T *  buf,
UINT16_T  len 
)
注解
buff reversal function
参数
[in/out]buf: the buff need to be reverse
[in]lenthe length of buff
返回
none

◆ 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

参数
[in]is_ascendsorting mode
[in]bufthe buffer need to sort
[in]lenthe length of character in buffer
返回
none

◆ tuya_check_sum16()

UINT16_T tuya_check_sum16 ( UINT8_T *  buf,
UINT32_T  len 
)

16-bit cumulative checksum calculation

参数
[in]bufthe buffer to calculate
[in]lenlength of the buffer
返回
16-bit cumulative checksum

◆ tuya_check_sum8()

UINT8_T tuya_check_sum8 ( UINT8_T *  buf,
UINT32_T  len 
)

8-bit cumulative checksum calculation

参数
[in]bufthe buffer to calculate
[in]lenlength of the buffer
返回
8-bit cumulative checksum

◆ tuya_data_reverse()

void tuya_data_reverse ( UINT8_T *  dst,
UINT8_T *  src,
UINT16_T  srclen 
)
注解
data reversal function
参数
[out]dstreversal dest data
[in]srcreversal source data
[in]srclenreversal data buffer length
返回
none

◆ 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.

参数
[in]strthe string for find
[in]indexthe reverse index start to find
[in]chthe character to find
返回
-2 on not found, -1 on invalid parameter, >=0 on the position of the character to find

◆ tuya_hex2str()

void tuya_hex2str ( UCHAR_T *  str,
UCHAR_T *  hex,
INT_T  hexlen 
)

convert the input hex array to string array

参数
[out]strthe out string array
[in]hexthe input hex array
[in]hexlenthe length of input hex array
返回
none
注解
the size of <str> must >= hexlen * 2, convert example 00-ff -> "00"-"FF"

◆ tuya_int2intArray()

UINT_T tuya_int2intArray ( UINT_T  num,
UINT8_T *  intArray,
UINT8_T  len 
)

int number convert to buff

参数
[in]numthe number need to convert
[out]intArraypoint to array
[in]lenthe length of array
返回
the arry length of converted

◆ tuya_intArray2int()

UINT_T tuya_intArray2int ( UINT8_T *  intArray,
UINT_T  index,
UINT8_T  len 
)

int array convert to a int number

参数
[in]intArraythe array need to convert
[in]indexarry start index
[in]lenthe length of array
返回
the number of converted

◆ tuya_leading_zeros_count()

UINT_T tuya_leading_zeros_count ( UINT_T  num)

the software calculates the number of leading zeros

参数
[in]numnumber
返回
number of leading zeros

◆ tuya_str2num()

BOOL_T tuya_str2num ( UINT_T *  number,
const CHAR_T *  str,
UINT8_T  strlen 
)

convert the input string to number

参数
[out]numberthe out number
[in]strthe input string
[in]strlenthe length of input hex array
返回
none
注解
the size of <pbDest> must >= nLen * 2, convert example 00-ff -> "00"-"FF"

◆ tuya_strcat()

CHAR_T * tuya_strcat ( CHAR_T *  dst,
const CHAR_T *  src 
)

string cat

参数
[in]dstpoint to target string array
[in]srcpoint to the string to append
返回
pointer to the final destination string dest

◆ tuya_strcmp()

INT_T tuya_strcmp ( const CHAR_T *  src,
const CHAR_T *  dst 
)

compare characters of two string

参数
[in]srcthe source string
[in]dstthe dest string
返回
0 one equal, 1 on s1 longer than s2, -1 on s2 longer than s1

◆ tuya_strcpy()

CHAR_T * tuya_strcpy ( CHAR_T *  dst,
const CHAR_T *  src 
)

string copy

参数
[in]dsttarget array used to store the copied content
[in]srcstring to copy
返回
pointer to the final destination string dest

◆ tuya_strlen()

SIZE_T tuya_strlen ( const CHAR_T *  str)

string len

参数
[in]strstring to calculate length
返回
length of string

◆ 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

参数
[in]s1the string 1
[in]s2the string 2
[in]nthe first n characters
返回
0 one equal, 1 on s1 longer than s2, -1 on s2 longer than s1