|
TuyaOS
|


结构体 | |
| struct | mqtt_subscribe_t |
| Definition of mqtt subscribe 更多... | |
类型定义 | |
| typedef VOID(* | CB_MQTT_CONNECT_DENY) (BYTE_T deny_times) |
| MQTT client is not permited to connect to broker 更多... | |
| typedef VOID(* | CB_MQTT_CONNECTED) (VOID) |
| MQTT client is connected to broker | |
| typedef VOID(* | CB_MQTT_DATA_RECV) (CHAR_T *topic, BYTE_T *data, UINT_T len) |
| Callback when recv msg from broker 更多... | |
| typedef VOID(* | CB_MQTT_DISCONNECTED) (VOID) |
| MQTT client is disconnected from broker | |
| typedef VOID(* | CB_MQTT_PUB_INFORM) (OPERATE_RET op_ret, VOID *ctx) |
| Async callback that indicates QOS1 publish success or not. 更多... | |
| typedef VOID * | MQTT_HANDLE |
枚举 | |
| enum | backoff_e { BACKOFF_RANDOM , BACKOFF_LOOP_CYCLE , BACKOFF_LOOP_LAST } |
| Backoff strategy for reconnection when broken | |
| enum | mqtt_cfg_e { MQTT_CFG_LINKAGE , MQTT_CFG_HEARTBEAT , MQTT_CFG_SLEEP_WITHOUT_PERMIT , MQTT_CFG_SOCKET_FD , MQTT_CFG_DISCONNECT_WHEN_STOP , MQTT_CFG_BACKOFF_STRATEGY , MQTT_CFG_MAX } |
| Definition of mqtt cfg type | |
函数 | |
| OPERATE_RET | tuya_svc_mqtt_client_create (mqtt_ctx_t *ctx, MQTT_HANDLE *handle) |
| Create mqtt client 更多... | |
| OPERATE_RET | tuya_svc_mqtt_client_destroy (MQTT_HANDLE handle) |
| Close and destroy mqtt client 更多... | |
| OPERATE_RET | tuya_svc_mqtt_client_get_cfg (MQTT_HANDLE handle, mqtt_cfg_e cfg, VOID *data) |
| Get cfg of mqtt client 更多... | |
| BOOL_T | tuya_svc_mqtt_client_is_connected (MQTT_HANDLE handle) |
| Mqtt broker is connected or not 更多... | |
| OPERATE_RET | tuya_svc_mqtt_client_pause (MQTT_HANDLE handle) |
| Pause mqtt client 更多... | |
| OPERATE_RET | tuya_svc_mqtt_client_publish (MQTT_HANDLE handle, mqtt_msg_t *msg) |
| Publish mqtt msg to broker 更多... | |
| OPERATE_RET | tuya_svc_mqtt_client_register_cb (MQTT_HANDLE handle, CB_MQTT_CONNECTED cb_connected, CB_MQTT_DISCONNECTED cb_disconnected, CB_MQTT_CONNECT_DENY cb_connect_deny) |
| Register event handers of MQTT client 更多... | |
| OPERATE_RET | tuya_svc_mqtt_client_restart (MQTT_HANDLE handle) |
| Restart mqtt client (or reconnect to broker when disconnected) 更多... | |
| OPERATE_RET | tuya_svc_mqtt_client_resume (MQTT_HANDLE handle) |
| Resume mqtt client 更多... | |
| OPERATE_RET | tuya_svc_mqtt_client_set_cfg (MQTT_HANDLE handle, mqtt_cfg_e cfg, VOID *data) |
| Get cfg of mqtt client 更多... | |
| OPERATE_RET | tuya_svc_mqtt_client_start (MQTT_HANDLE handle) |
| Start mqtt client (or reconnect to broker when disconnected) 更多... | |
| OPERATE_RET | tuya_svc_mqtt_client_stop (MQTT_HANDLE handle) |
| Stop mqtt client (disconnect from mqtt broker) 更多... | |
| OPERATE_RET | tuya_svc_mqtt_client_subscribe (MQTT_HANDLE handle, mqtt_subscribe_t *sub) |
| Subcribe topics within one mqtt request 更多... | |
| OPERATE_RET | tuya_svc_mqtt_client_unsubscribe (MQTT_HANDLE handle, mqtt_subscribe_t *sub) |
| Unsubcribe topics within one mqtt request 更多... | |
Permission is hereby granted, to any person obtaining a copy of this software and associated documentation files (the "Software"), Under the premise of complying with the license of the third-party open source software contained in the software, to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
| typedef VOID(* CB_MQTT_CONNECT_DENY) (BYTE_T deny_times) |
MQTT client is not permited to connect to broker
| [in] | deny_times | How many times this MQTT client is denied by broker |
| typedef VOID(* CB_MQTT_DATA_RECV) (CHAR_T *topic, BYTE_T *data, UINT_T len) |
Callback when recv msg from broker
| [in] | topic | Topic that msg is recved from |
| [in] | data | Buffer of msg content |
| [in] | len | Length of msg content |
| typedef VOID(* CB_MQTT_PUB_INFORM) (OPERATE_RET op_ret, VOID *ctx) |
Async callback that indicates QOS1 publish success or not.
| [in] | op_ret | OPRT_OK on success. Others on error, please refer to tuya_error_code.h |
| [in] | ctx | Private data |
| OPERATE_RET tuya_svc_mqtt_client_create | ( | mqtt_ctx_t * | ctx, |
| MQTT_HANDLE * | handle | ||
| ) |
Create mqtt client
| [in] | ctx | Context of mqtt client, see mqtt_ctx_t for details |
| [out] | handle | Handle of mqtt client |
| OPERATE_RET tuya_svc_mqtt_client_destroy | ( | MQTT_HANDLE | handle | ) |
Close and destroy mqtt client
| [in] | handle | Handle of mqtt client |
| OPERATE_RET tuya_svc_mqtt_client_get_cfg | ( | MQTT_HANDLE | handle, |
| mqtt_cfg_e | cfg, | ||
| VOID * | data | ||
| ) |
Get cfg of mqtt client
| [in] | handle | Handle of mqtt client |
| [in] | cfg | Cfg type, see mqtt_cfg_e for details |
| [out] | data | Cfg data |
| BOOL_T tuya_svc_mqtt_client_is_connected | ( | MQTT_HANDLE | handle | ) |
Mqtt broker is connected or not
| [in] | handle | Handle of mqtt client |
| OPERATE_RET tuya_svc_mqtt_client_pause | ( | MQTT_HANDLE | handle | ) |
Pause mqtt client
| [in] | handle | Handle of mqtt client |
| OPERATE_RET tuya_svc_mqtt_client_publish | ( | MQTT_HANDLE | handle, |
| mqtt_msg_t * | msg | ||
| ) |
Publish mqtt msg to broker
| [in] | handle | Handle of mqtt client |
| [in] | msg | see mqtt_msg_t for details |
| OPERATE_RET tuya_svc_mqtt_client_register_cb | ( | MQTT_HANDLE | handle, |
| CB_MQTT_CONNECTED | cb_connected, | ||
| CB_MQTT_DISCONNECTED | cb_disconnected, | ||
| CB_MQTT_CONNECT_DENY | cb_connect_deny | ||
| ) |
Register event handers of MQTT client
| [in] | handle | Handler of MQTT client |
| [in] | cb_connected | Hander when MQTT client is connected to broker |
| [in] | cb_disconnected | Hander when MQTT client is disconnected to broker |
| [in] | cb_connect_deny | Hander when MQTT client is not permited to connect to broker |
| OPERATE_RET tuya_svc_mqtt_client_restart | ( | MQTT_HANDLE | handle | ) |
Restart mqtt client (or reconnect to broker when disconnected)
| [in] | handle | Handle of mqtt client |
| OPERATE_RET tuya_svc_mqtt_client_resume | ( | MQTT_HANDLE | handle | ) |
Resume mqtt client
| [in] | handle | Handle of mqtt client |
| OPERATE_RET tuya_svc_mqtt_client_set_cfg | ( | MQTT_HANDLE | handle, |
| mqtt_cfg_e | cfg, | ||
| VOID * | data | ||
| ) |
Get cfg of mqtt client
| [in] | handle | Handle of mqtt client |
| [in] | cfg | Cfg type, see mqtt_cfg_e for details |
| [in] | data | Cfg data |
| OPERATE_RET tuya_svc_mqtt_client_start | ( | MQTT_HANDLE | handle | ) |
Start mqtt client (or reconnect to broker when disconnected)
| [in] | handle | Handle of mqtt client |
| OPERATE_RET tuya_svc_mqtt_client_stop | ( | MQTT_HANDLE | handle | ) |
Stop mqtt client (disconnect from mqtt broker)
| [in] | handle | Handle of mqtt client |
| OPERATE_RET tuya_svc_mqtt_client_subscribe | ( | MQTT_HANDLE | handle, |
| mqtt_subscribe_t * | sub | ||
| ) |
Subcribe topics within one mqtt request
| [in] | handle | Handle of mqtt client |
| [in] | sub | see mqtt_subscribe_t for details |
| OPERATE_RET tuya_svc_mqtt_client_unsubscribe | ( | MQTT_HANDLE | handle, |
| mqtt_subscribe_t * | sub | ||
| ) |
Unsubcribe topics within one mqtt request
| [in] | handle | Handle of mqtt client |
| [in] | sub | see mqtt_subscribe_t for details |