tuya common api module
更多...
#include "tuya_cloud_types.h"
浏览源代码.
|
#define | BITMASK(bit) (1 << (bit)) |
|
#define | GETBIT(val, bit) (((val) & BITMASK(bit)) > 0) |
|
#define | RESETBIT(val, bit) ((val) &= ~BITMASK(bit)) |
|
#define | SETBIT(val, bit) ((val) |= BITMASK(bit)) |
|
|
unsigned char | asc2hex (char asccode) |
| convert character to hex, if '0'-'f'/'F' -> 0-15, else 0 更多...
|
|
void | ascs2hex (unsigned char *hex, unsigned char *ascs, int srclen) |
| convert the character array to hex array 更多...
|
|
void | byte2str (unsigned char *pbDest, unsigned char *pbSrc, int nLen, bool_t upper) |
|
void | byte_sort (unsigned char is_ascend, unsigned char *buf, int buf_cnt) |
| sort the char in the buf according ascii value 更多...
|
|
void | hex2str (unsigned char *pbDest, unsigned char *pbSrc, int nLen) |
| convert the input hex array to string array 更多...
|
|
int | is_valid_version (char *ver) |
| check the version input is valid 更多...
|
|
char * | mm_strdup (const char *str) |
| duplicate input string, will malloc a new block of memory 更多...
|
|
int | str_revr_find_ch (const char *str, const int revr_index, const char ch) |
| find <ch> in <str>, start find in index <revr_index>, find in reverse order. 更多...
|
|
int | string2mac (const char *str, char mac[6]) |
| convert mac address string to mac address array 更多...
|
|
int | tuya_isalpha (int c) |
|
int | tuya_strncasecmp (const char *s1, const char *s2, size_t n) |
| compare the first n characters of two string 更多...
|
|
int | tuya_tolower (int c) |
|
int | tuya_toupper (int c) |
|
int | versionString2int (const char *versionString) |
| convert version string to integer 更多...
|
|
tuya common api module
- 版本
- 1.0
- 日期
- 2019-10-30
- 版权所有
- Copyright (c) tuya.inc 2019
◆ asc2hex()
unsigned char asc2hex |
( |
char |
asccode | ) |
|
convert character to hex, if '0'-'f'/'F' -> 0-15, else 0
- 参数
-
[in] | asccode | the input character |
- 返回
- the hex value
◆ ascs2hex()
void ascs2hex |
( |
unsigned char * |
hex, |
|
|
unsigned char * |
ascs, |
|
|
int |
srclen |
|
) |
| |
convert the character array to hex array
- 参数
-
[out] | hex | the out hex array |
[in] | ascs | the input character array |
[in] | srclen | the length of input character array |
◆ byte_sort()
void byte_sort |
( |
unsigned char |
is_ascend, |
|
|
unsigned char * |
buf, |
|
|
int |
buf_cnt |
|
) |
| |
sort the char in the buf according ascii value
- 参数
-
[in] | is_ascend | sort in sacend order |
[in] | buf | the buffer need to sort |
[in] | buf_cnt | the character counts in buffer |
◆ hex2str()
void hex2str |
( |
unsigned char * |
pbDest, |
|
|
unsigned char * |
pbSrc, |
|
|
int |
nLen |
|
) |
| |
convert the input hex array to string array
- 参数
-
[out] | pbDest | the out string array |
[in] | pbSrc | the input hex array |
[in] | nLen | the length of input hex array |
- 注解
- the size of <pbDest> must >= nLen * 2, convert example 00-ff -> "00"-"FF"
◆ is_valid_version()
int is_valid_version |
( |
char * |
ver | ) |
|
check the version input is valid
- 参数
-
[in] | ver | the version string |
- 返回
- 1 on valid, 0 on invalid
◆ mm_strdup()
char * mm_strdup |
( |
const char * |
str | ) |
|
duplicate input string, will malloc a new block of memory
- 参数
-
[in] | str | the input string need to duplicate |
- 返回
- new string
◆ str_revr_find_ch()
int str_revr_find_ch |
( |
const char * |
str, |
|
|
const int |
revr_index, |
|
|
const char |
ch |
|
) |
| |
find <ch> in <str>, start find in index <revr_index>, find in reverse order.
- 参数
-
[in] | str | the string for find |
[in] | revr_index | the start index to find |
[in] | ch | the character to find |
- 返回
- -2 on not found, -1 on invalid parameter, >=0 on the position of the character to find
◆ string2mac()
int string2mac |
( |
const char * |
str, |
|
|
char |
mac[6] |
|
) |
| |
convert mac address string to mac address array
- 参数
-
[in] | str | the input mac address string |
[out] | mac | the mac address array |
- 返回
- 0 on success, others on failed.
- 警告
- now only support valid mac address string: xxxxxxxxxxxx / xx-xx-xx-xx-xx-xx
◆ tuya_strncasecmp()
int tuya_strncasecmp |
( |
const char * |
s1, |
|
|
const char * |
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 |
- 返回
- 0 one equal, 1 on s1 longer than s2, -1 on s2 longer than s1
◆ versionString2int()
int versionString2int |
( |
const char * |
versionString | ) |
|
convert version string to integer
- 参数
-
[in] | versionString | the input version string |
- 返回
- a integer version
- 注解
- can support version string format x.y.z or x.y, for example: "1.0.1" to 0x010001 and "40.00" t0 0x2800