2022-11-12 22:21:23 +08:00
|
|
|
|
#include "_mqtt__MQTT.h"
|
2022-11-13 14:52:39 +08:00
|
|
|
|
#include "mqttclient.h"
|
2022-12-18 00:41:57 +08:00
|
|
|
|
#include "PikaStdData_List.h"
|
2022-11-12 22:21:23 +08:00
|
|
|
|
|
2022-11-23 21:16:20 +08:00
|
|
|
|
PikaEventListener* g_mqtt_event_listener = NULL;
|
|
|
|
|
|
|
|
|
|
void Subscribe_Handler(void* client, message_data_t* msg);
|
2022-11-22 22:08:58 +08:00
|
|
|
|
|
2022-11-20 19:01:05 +08:00
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT___init__
|
|
|
|
|
// 功能说明:对象初始化
|
|
|
|
|
// 输入参数:
|
|
|
|
|
// 返 回 值:无
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-12 22:21:23 +08:00
|
|
|
|
void _mqtt__MQTT___init__(PikaObj* self,
|
|
|
|
|
char* ip,
|
|
|
|
|
int port,
|
|
|
|
|
char* clinetID,
|
|
|
|
|
char* username,
|
|
|
|
|
char* password,
|
|
|
|
|
char* version,
|
|
|
|
|
char* ca,
|
|
|
|
|
int keepalive) {
|
2022-11-22 22:08:18 +08:00
|
|
|
|
obj_setInt(self, "_connected", 0);
|
2022-11-13 15:16:08 +08:00
|
|
|
|
mqtt_client_t* _client = mqtt_lease();
|
2022-11-23 21:16:20 +08:00
|
|
|
|
_client->user_data = self;
|
2022-11-22 22:08:18 +08:00
|
|
|
|
// obj_setPtr(self, "_client", _client);
|
2022-11-13 15:16:08 +08:00
|
|
|
|
/* port to str, and cache to object */
|
|
|
|
|
char port_str[10] = {0};
|
2022-11-22 22:08:18 +08:00
|
|
|
|
int tmp = 0;
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (strlen(ip) > 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
obj_setStr(self, "host_str", ip);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
mqtt_set_host(_client, obj_getStr(self, "host_str"));
|
2022-11-20 19:01:05 +08:00
|
|
|
|
}
|
2022-12-11 14:54:56 +08:00
|
|
|
|
else {
|
|
|
|
|
__platform_printf("mqtt_init input ip none\r\n");
|
|
|
|
|
}
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
2022-11-22 22:08:18 +08:00
|
|
|
|
memset(port_str, 0, sizeof(port_str));
|
2022-11-13 15:16:08 +08:00
|
|
|
|
__platform_sprintf(port_str, "%d", port);
|
|
|
|
|
obj_setStr(self, "port", port_str);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
mqtt_set_port(_client, obj_getStr(self, "port"));
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (strlen(clinetID) > 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
obj_setStr(self, "id_str", clinetID);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
mqtt_set_client_id(_client, obj_getStr(self, "id_str"));
|
2022-11-20 19:01:05 +08:00
|
|
|
|
}
|
2022-12-11 14:54:56 +08:00
|
|
|
|
else {
|
|
|
|
|
__platform_printf("mqtt_init input clinetID none\r\n");
|
|
|
|
|
}
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (strlen(username) > 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
obj_setStr(self, "username_str", username);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
mqtt_set_user_name(_client, obj_getStr(self, "username_str"));
|
2022-11-20 19:01:05 +08:00
|
|
|
|
}
|
2022-12-11 14:54:56 +08:00
|
|
|
|
else {
|
|
|
|
|
__platform_printf("mqtt_init input username none\r\n");
|
|
|
|
|
}
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (strlen(password) > 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
obj_setStr(self, "password_str", password);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
mqtt_set_password(_client, obj_getStr(self, "password_str"));
|
2022-11-20 19:01:05 +08:00
|
|
|
|
}
|
2022-12-11 14:54:56 +08:00
|
|
|
|
else {
|
|
|
|
|
__platform_printf("mqtt_init input password none\r\n");
|
|
|
|
|
}
|
2022-11-22 22:08:18 +08:00
|
|
|
|
|
2022-11-20 19:01:05 +08:00
|
|
|
|
tmp = atoi(version);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (tmp > 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
mqtt_set_version(_client, tmp);
|
|
|
|
|
}
|
2022-12-11 14:54:56 +08:00
|
|
|
|
else {
|
|
|
|
|
__platform_printf("mqtt_init input version none\r\n");
|
|
|
|
|
}
|
2022-11-22 22:08:18 +08:00
|
|
|
|
|
|
|
|
|
if (strlen(ca) > 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
obj_setStr(self, "ca_str", ca);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
mqtt_set_ca(_client, obj_getStr(self, "ca_str"));
|
2022-11-20 19:01:05 +08:00
|
|
|
|
}
|
2022-12-11 14:54:56 +08:00
|
|
|
|
else {
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("mqtt_init input ca none\r\n");
|
2022-12-11 14:54:56 +08:00
|
|
|
|
}
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (keepalive > 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
mqtt_set_keep_alive_interval(_client, keepalive);
|
|
|
|
|
}
|
2022-12-11 14:54:56 +08:00
|
|
|
|
else {
|
|
|
|
|
__platform_printf("mqtt_init input keepalive none\r\n");
|
|
|
|
|
}
|
2022-11-13 15:16:08 +08:00
|
|
|
|
|
|
|
|
|
mqtt_set_clean_session(_client, 1);
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
2022-11-22 22:08:18 +08:00
|
|
|
|
obj_setPtr(self, "_client",
|
|
|
|
|
_client); //这里要再保存一次mqtt结构体的内容到python环境
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("Mqtt_Lib buildtime:%s-%s\r\n", __DATE__, __TIME__);
|
2022-11-13 15:16:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-20 19:01:05 +08:00
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT___del__
|
|
|
|
|
// 功能说明:释放对象资源
|
|
|
|
|
// 输入参数:
|
|
|
|
|
// 返 回 值:无
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-13 15:16:08 +08:00
|
|
|
|
void _mqtt__MQTT___del__(PikaObj* self) {
|
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (NULL == _client) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/* disconnect autoly if not disconnected */
|
|
|
|
|
int _connected = obj_getInt(self, "_connected");
|
|
|
|
|
if (_connected) {
|
|
|
|
|
_mqtt__MQTT_disconnect(self);
|
2022-11-13 15:16:08 +08:00
|
|
|
|
}
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// MQTT_LOG_E("%s:%d %s() >_<", __FILE__, __LINE__, __FUNCTION__);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
mqtt_release_free(_client);
|
2022-11-12 23:28:55 +08:00
|
|
|
|
}
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_connect
|
|
|
|
|
// 功能说明:连接mqtt的服务端
|
|
|
|
|
// 输入参数:无
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-22 22:08:18 +08:00
|
|
|
|
int _mqtt__MQTT_connect(PikaObj* self) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
int ret;
|
2022-11-22 22:08:18 +08:00
|
|
|
|
obj_setInt(self, "_connected", 1);
|
2022-11-20 19:01:05 +08:00
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
|
|
|
|
|
|
|
|
|
ret = mqtt_connect(_client);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (ret != 0)
|
|
|
|
|
__platform_printf("mqtt connect ERROR! :%d\r\n", ret);
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// if (ret == 0)
|
|
|
|
|
// __platform_printf("mqtt connect OK\r\n");
|
2022-11-20 19:01:05 +08:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_disconnect
|
|
|
|
|
// 功能说明:断开 mqtt的连接
|
|
|
|
|
// 输入参数:无
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-22 22:08:18 +08:00
|
|
|
|
int _mqtt__MQTT_disconnect(PikaObj* self) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
int ret;
|
2022-11-22 22:08:18 +08:00
|
|
|
|
obj_setInt(self, "_connected", 0);
|
2022-11-20 19:01:05 +08:00
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
|
|
|
|
|
|
|
|
|
ret = mqtt_disconnect(_client);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (ret != 0)
|
|
|
|
|
__platform_printf("mqtt disconnect ERROR! :%d\r\n", ret);
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// if (ret == 0)
|
|
|
|
|
// __platform_printf("mqtt disconnect OK\r\n");
|
2022-11-20 19:01:05 +08:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_listSubscribrTopic
|
|
|
|
|
// 功能说明:罗列出当前订阅的主题
|
|
|
|
|
// 输入参数:无
|
|
|
|
|
// 返 回 值:对象指针
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-22 22:08:18 +08:00
|
|
|
|
PikaObj* _mqtt__MQTT_listSubscribrTopic(PikaObj* self) {
|
2022-11-23 10:14:48 +08:00
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// int i = 0;
|
|
|
|
|
mqtt_list_t *curr, *next;
|
|
|
|
|
message_handlers_t* msg_handler;
|
|
|
|
|
PikaObj* list = NULL;
|
|
|
|
|
|
|
|
|
|
if (NULL == _client)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mqtt_list_is_empty(&_client->mqtt_msg_handler_list)) {
|
|
|
|
|
MQTT_LOG_I("%s:%d %s()... there are no subscribed topics...", __FILE__,
|
|
|
|
|
__LINE__, __FUNCTION__);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 创建 list 对象 */
|
|
|
|
|
list = newNormalObj(New_PikaStdData_List);
|
|
|
|
|
/* 初始化 list */
|
|
|
|
|
PikaStdData_List___init__(list);
|
|
|
|
|
|
|
|
|
|
LIST_FOR_EACH_SAFE(curr, next, &_client->mqtt_msg_handler_list) {
|
|
|
|
|
msg_handler = LIST_ENTRY(curr, message_handlers_t, list);
|
|
|
|
|
/* determine whether a node already exists by mqtt topic, but wildcards
|
|
|
|
|
* are not supported */
|
|
|
|
|
if (NULL != msg_handler->topic_filter) {
|
|
|
|
|
// MQTT_LOG_I("%s:%d %s()...[%d] subscribe topic: %s", __FILE__,
|
|
|
|
|
// __LINE__, __FUNCTION__, ++i, msg_handler->topic_filter);
|
|
|
|
|
|
|
|
|
|
/* 用 arg_new<type> 的 api 创建 arg */
|
|
|
|
|
Arg* str_arg1 = arg_newStr((char*)msg_handler->topic_filter);
|
|
|
|
|
/* 添加到 list 对象 */
|
|
|
|
|
PikaStdData_List_append(list, str_arg1);
|
|
|
|
|
}
|
2022-12-11 20:09:29 +08:00
|
|
|
|
}
|
2022-12-18 00:41:57 +08:00
|
|
|
|
return list;
|
2022-11-20 19:01:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_publish
|
|
|
|
|
// 功能说明:发布主题消息
|
|
|
|
|
// 输入参数:主题名称,有效数据
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-12-18 00:41:57 +08:00
|
|
|
|
int _mqtt__MQTT_publish(PikaObj *self, char* topic, int qos, char* payload) {
|
2022-11-23 10:14:48 +08:00
|
|
|
|
int ret;
|
|
|
|
|
mqtt_message_t msg;
|
|
|
|
|
|
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
2022-11-23 21:16:20 +08:00
|
|
|
|
memset(&msg, 0, sizeof(msg));
|
2022-11-23 10:14:48 +08:00
|
|
|
|
|
2022-12-11 14:54:56 +08:00
|
|
|
|
if((qos < 0) || (qos > 2)) {
|
|
|
|
|
__platform_printf("input qos error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2022-11-23 21:16:20 +08:00
|
|
|
|
if (strlen(topic) <= 0) {
|
2022-11-23 10:14:48 +08:00
|
|
|
|
__platform_printf("input topic error\r\n");
|
2022-12-11 14:54:56 +08:00
|
|
|
|
return -2;
|
2022-11-23 10:14:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-23 21:16:20 +08:00
|
|
|
|
if (strlen(payload) <= 0) {
|
2022-11-23 10:14:48 +08:00
|
|
|
|
__platform_printf("input payload error\r\n");
|
2022-12-11 14:54:56 +08:00
|
|
|
|
return -3;
|
2022-11-23 10:14:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-23 21:16:20 +08:00
|
|
|
|
msg.payload = (void*)payload;
|
2022-12-11 14:54:56 +08:00
|
|
|
|
msg.qos = qos;
|
2022-12-18 00:41:57 +08:00
|
|
|
|
__platform_printf("msg.qos:%d\r\n",msg.qos);//这里为了防止被优化,导致运行异常
|
2022-11-23 21:16:20 +08:00
|
|
|
|
ret = mqtt_publish(_client, topic, &msg);
|
2022-12-18 00:41:57 +08:00
|
|
|
|
if (ret == 0) {
|
|
|
|
|
// __platform_printf("MQTT_publish OK\r\n");
|
|
|
|
|
}
|
2022-11-23 21:16:20 +08:00
|
|
|
|
else
|
2022-12-11 14:54:56 +08:00
|
|
|
|
__platform_printf("MQTT_publish ERROR\r\n");
|
2022-11-23 10:14:48 +08:00
|
|
|
|
return ret;
|
2022-11-20 19:01:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_setCa
|
|
|
|
|
// 功能说明:设置ca值
|
|
|
|
|
// 输入参数:ca值
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-22 22:08:18 +08:00
|
|
|
|
int _mqtt__MQTT_setCa(PikaObj* self, char* ca) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
2022-11-22 22:08:18 +08:00
|
|
|
|
|
|
|
|
|
if (ca == NULL) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
__platform_printf("input ca error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (strlen(ca) <= 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
__platform_printf("input ca data error\r\n");
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
2022-12-11 14:54:56 +08:00
|
|
|
|
//__platform_printf("ca_str:%s\r\n",ca);
|
2022-11-20 19:01:05 +08:00
|
|
|
|
obj_setStr(self, "ca_str", ca);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
mqtt_set_ca(_client, obj_getStr(self, "ca_str"));
|
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("MQTT_setCa len:%d\r\n", strlen(ca));
|
2022-11-20 19:01:05 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_setClientID
|
|
|
|
|
// 功能说明:设置mqtt客户端的id
|
|
|
|
|
// 输入参数:id 字符串格式
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-22 22:08:18 +08:00
|
|
|
|
int _mqtt__MQTT_setClientID(PikaObj* self, char* id) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
2022-11-22 22:08:18 +08:00
|
|
|
|
|
|
|
|
|
if (id == NULL) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
__platform_printf("input id error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (strlen(id) <= 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
__platform_printf("input id data error\r\n");
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj_setStr(self, "id_str", id);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
mqtt_set_client_id(_client, obj_getStr(self, "id_str"));
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("MQTT_setClientID :%s\r\n", id);
|
2022-11-20 19:01:05 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_setHost
|
|
|
|
|
// 功能说明:设置mqtt客户端,连接主机的ip或者url
|
|
|
|
|
// 输入参数:字符串格式
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-22 22:08:18 +08:00
|
|
|
|
int _mqtt__MQTT_setHost(PikaObj* self, char* host_url) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
2022-11-22 22:08:18 +08:00
|
|
|
|
|
|
|
|
|
if (host_url == NULL) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
__platform_printf("input host_url error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (strlen(host_url) <= 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
__platform_printf("input host_url data error\r\n");
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-11 14:54:56 +08:00
|
|
|
|
obj_setStr(self, "host_str",host_url); // python 环境创建一个全局变量存放 host
|
|
|
|
|
mqtt_set_host(_client,obj_getStr(self,"host_str")); //从python环境中取出 host的指针 赋值给结构体
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("MQTT_setHost :%s\r\n", host_url);
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_setKeepAlive
|
|
|
|
|
// 功能说明:设置mqtt客户端的 心跳包发送间隔
|
|
|
|
|
// 输入参数:字符串格式
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-12-18 00:41:57 +08:00
|
|
|
|
int _mqtt__MQTT_setKeepAlive(PikaObj *self, int time) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
|
|
|
|
int tmp;
|
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// tmp = atoi(time);
|
|
|
|
|
tmp = time;
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (tmp > 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
mqtt_set_keep_alive_interval(_client, tmp);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
} else {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
__platform_printf("input keepalive data error \r\n");
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("MQTT_setKeepAlive :%d\r\n", tmp);
|
2022-11-20 19:01:05 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_setPassword
|
|
|
|
|
// 功能说明:设置mqtt客户端的 密码
|
|
|
|
|
// 输入参数:字符串格式
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-22 22:08:18 +08:00
|
|
|
|
int _mqtt__MQTT_setPassword(PikaObj* self, char* passwd) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
2022-11-22 22:08:18 +08:00
|
|
|
|
|
|
|
|
|
if (passwd == NULL) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
__platform_printf("input passwd error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (strlen(passwd) <= 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
__platform_printf("input passwd data error\r\n");
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj_setStr(self, "password_str", passwd);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
mqtt_set_password(_client, obj_getStr(self, "password_str"));
|
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("MQTT_setPassword :%s\r\n", passwd);
|
2022-11-20 19:01:05 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_setPort
|
|
|
|
|
// 功能说明:设置mqtt客户端,连接主机的端口号
|
|
|
|
|
// 输入参数:字符串格式
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-22 22:08:18 +08:00
|
|
|
|
int _mqtt__MQTT_setPort(PikaObj* self, int port) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
char port_str[10] = {0};
|
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
|
|
|
|
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (port <= 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
__platform_printf("input port error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__platform_sprintf(port_str, "%d", port);
|
|
|
|
|
obj_setStr(self, "port", port_str);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
|
|
|
|
|
mqtt_set_port(_client, obj_getStr(self, "port"));
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("MQTT_setPort :%s\r\n", port_str);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
|
2022-11-20 19:01:05 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_setUsername
|
|
|
|
|
// 功能说明:设置mqtt客户端的用户名
|
|
|
|
|
// 输入参数:字符串格式
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-22 22:08:18 +08:00
|
|
|
|
int _mqtt__MQTT_setUsername(PikaObj* self, char* name) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
2022-11-22 22:08:18 +08:00
|
|
|
|
|
|
|
|
|
if (name == NULL) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
__platform_printf("input name error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (strlen(name) <= 0) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
__platform_printf("input name data error\r\n");
|
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obj_setStr(self, "username_str", name);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
mqtt_set_user_name(_client, obj_getStr(self, "username_str"));
|
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("MQTT_setUsername :%s\r\n", name);
|
2022-11-20 19:01:05 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_setVersion
|
|
|
|
|
// 功能说明:设置mqtt 协议版本
|
|
|
|
|
// 输入参数:字符串格式
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-22 22:08:18 +08:00
|
|
|
|
int _mqtt__MQTT_setVersion(PikaObj* self, char* version) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// int tmp;
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
if(version == NULL) {
|
|
|
|
|
__platform_printf("input version str error\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if((strcmp(version,"3.1") == 0) || (strcmp(version,"3.1.1") == 0)) {
|
|
|
|
|
mqtt_set_version(_client, 3);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
__platform_printf("input version data error\n");
|
2022-11-20 19:01:05 +08:00
|
|
|
|
return -2;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("MQTT_setVersion :%d\r\n", tmp);
|
2022-11-20 19:01:05 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_setWill
|
2022-12-11 14:54:56 +08:00
|
|
|
|
// 功能说明:设置遗嘱消息,异常断连时会发送这个消息
|
2022-11-20 19:01:05 +08:00
|
|
|
|
// 输入参数:
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-12-18 00:41:57 +08:00
|
|
|
|
int _mqtt__MQTT_setWill(PikaObj *self, char* topic, char* payload, int qos, int retain) {
|
2022-11-23 09:28:31 +08:00
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
|
|
|
|
int ret;
|
2022-12-11 21:42:55 +08:00
|
|
|
|
char topic_str[MQTT_TOPIC_LEN_MAX];
|
2022-11-23 09:28:31 +08:00
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("\r\n");
|
2022-12-11 21:42:55 +08:00
|
|
|
|
if(topic == NULL) {
|
|
|
|
|
__platform_printf("input topic error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strlen(topic) <= 0) {
|
2022-11-23 09:28:31 +08:00
|
|
|
|
__platform_printf("input topic error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((qos < 0) || (qos > 2)) {
|
|
|
|
|
__platform_printf("input qos error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-11 21:42:55 +08:00
|
|
|
|
if(payload == NULL) {
|
|
|
|
|
__platform_printf("input payload error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-23 09:28:31 +08:00
|
|
|
|
if (strlen(payload) <= 0) {
|
|
|
|
|
__platform_printf("input payload error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("input retain :%d\r\n", (uint8_t)retain);
|
2022-11-23 09:28:31 +08:00
|
|
|
|
|
2022-12-11 21:42:55 +08:00
|
|
|
|
//必须转换成python环境的变量,否则函数退出后,topic里的是个空指针
|
|
|
|
|
memset(topic_str,0,sizeof(topic_str));
|
|
|
|
|
sprintf(topic_str,"%s",topic);
|
|
|
|
|
obj_setStr(self, topic_str, topic);
|
|
|
|
|
obj_setStr(self, "Will_payload", payload);
|
|
|
|
|
|
|
|
|
|
ret = mqtt_set_will_options(_client, obj_getStr(self, topic_str), qos, (uint8_t)retain, obj_getStr(self, "Will_payload"));
|
2022-11-23 09:28:31 +08:00
|
|
|
|
|
|
|
|
|
if (ret == 0) {
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("MQTT_setWill OK\r\n", topic);
|
2022-11-23 09:28:31 +08:00
|
|
|
|
} else
|
2022-12-11 14:54:56 +08:00
|
|
|
|
__platform_printf("MQTT_setWill ERROR\r\n");
|
2022-11-23 09:28:31 +08:00
|
|
|
|
|
2022-11-20 19:01:05 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_subscribe
|
|
|
|
|
// 功能说明:设置mqtt 订阅主题
|
|
|
|
|
// 输入参数:
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-12-18 00:41:57 +08:00
|
|
|
|
int _mqtt__MQTT_subscribe(PikaObj *self, char* topic, int qos, Arg* cb) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
|
|
|
|
int ret;
|
2022-12-11 21:42:55 +08:00
|
|
|
|
char topic_str[MQTT_TOPIC_LEN_MAX+24];
|
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("topic_str:%s \r\n",topic_str);
|
2022-12-11 21:42:55 +08:00
|
|
|
|
if(topic == NULL) {
|
|
|
|
|
__platform_printf("input topic error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
2022-12-11 19:08:16 +08:00
|
|
|
|
if ((strlen(topic) > MQTT_TOPIC_LEN_MAX)||(strlen(topic) <= 0)) {
|
2022-12-18 00:41:57 +08:00
|
|
|
|
__platform_printf("input topic data error strlen(topic):%d\r\n",strlen(topic));
|
|
|
|
|
return -2;
|
2022-11-20 19:01:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if ((qos < 0) || (qos > 2)) {
|
2022-11-20 19:01:05 +08:00
|
|
|
|
__platform_printf("input qos error\r\n");
|
2022-12-18 00:41:57 +08:00
|
|
|
|
return -3;
|
2022-11-20 19:01:05 +08:00
|
|
|
|
}
|
2022-12-11 14:54:56 +08:00
|
|
|
|
|
2022-12-11 19:08:16 +08:00
|
|
|
|
//必须转换成python环境的变量,否则函数退出后,topic里的是个空指针
|
|
|
|
|
memset(topic_str,0,sizeof(topic_str));
|
|
|
|
|
sprintf(topic_str,"%s",topic);
|
2022-12-11 20:09:29 +08:00
|
|
|
|
obj_setStr(self, topic_str, topic);
|
2022-11-20 19:01:05 +08:00
|
|
|
|
|
2022-12-11 20:09:29 +08:00
|
|
|
|
ret = mqtt_subscribe(_client, obj_getStr(self, topic_str), qos, Subscribe_Handler);
|
2022-11-22 22:08:18 +08:00
|
|
|
|
if (ret == 0) {
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("MQTT_subscribe Topic :%s Qos:%d OK\r\n", topic,qos);
|
2022-12-11 21:42:55 +08:00
|
|
|
|
//注册mqtt订阅主题的 回调函数
|
|
|
|
|
if(cb != NULL) {
|
|
|
|
|
memset(topic_str,0,sizeof(topic_str));
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// sprintf(topic_str,"eventCallBack_%s",topic);
|
|
|
|
|
sprintf(topic_str,"eventCallBack");
|
|
|
|
|
// __platform_printf("topic_str:%s \r\n",topic_str);
|
2022-12-11 21:42:55 +08:00
|
|
|
|
obj_setArg(self, topic_str, cb);
|
|
|
|
|
/* init event_listener for the first time */
|
|
|
|
|
if (NULL == g_mqtt_event_listener) {
|
|
|
|
|
pks_eventLisener_init(&g_mqtt_event_listener);
|
|
|
|
|
}
|
2022-12-18 00:41:57 +08:00
|
|
|
|
uint32_t eventId = hash_time33(topic_str);
|
|
|
|
|
// __platform_printf("hash_time33(topic_str):%d \r\n",hash_time33(topic_str));
|
2022-12-11 21:42:55 +08:00
|
|
|
|
pks_eventLicener_registEvent(g_mqtt_event_listener, eventId, self);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-22 22:08:18 +08:00
|
|
|
|
} else
|
2022-12-11 14:54:56 +08:00
|
|
|
|
__platform_printf("MQTT_subscribe Topic ERROR\r\n");
|
2022-12-11 20:09:29 +08:00
|
|
|
|
|
2022-12-11 19:08:16 +08:00
|
|
|
|
return ret;
|
2022-11-20 19:01:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_unsubscribe
|
|
|
|
|
// 功能说明:取消mqtt 订阅主题
|
|
|
|
|
// 输入参数:
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-22 22:08:18 +08:00
|
|
|
|
int _mqtt__MQTT_unsubscribe(PikaObj* self, char* topic) {
|
2022-11-23 09:28:31 +08:00
|
|
|
|
mqtt_client_t* _client = obj_getPtr(self, "_client");
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
if (strlen(topic) <= 0) {
|
|
|
|
|
__platform_printf("input topic error\r\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-23 21:16:20 +08:00
|
|
|
|
ret = mqtt_unsubscribe(_client, topic);
|
2022-11-23 09:28:31 +08:00
|
|
|
|
if (ret == 0) {
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// __platform_printf("MQTT_unsubscribe :%s OK\r\n", topic);
|
2022-11-23 09:28:31 +08:00
|
|
|
|
} else
|
2022-12-11 14:54:56 +08:00
|
|
|
|
__platform_printf("MQTT_unsubscribe :%s ERROR\r\n", topic);
|
2022-11-23 09:28:31 +08:00
|
|
|
|
|
2022-11-20 19:01:05 +08:00
|
|
|
|
return 0;
|
2022-11-22 22:08:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
2022-12-11 14:54:56 +08:00
|
|
|
|
// 函 数 名:Subscribe_Handler
|
|
|
|
|
// 功能说明:mqtt 订阅主题 的回调函数
|
2022-11-22 22:08:58 +08:00
|
|
|
|
// 输入参数:
|
|
|
|
|
// 返 回 值:0=成功;非0=错误码
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
2022-11-23 21:16:20 +08:00
|
|
|
|
void Subscribe_Handler(void* client, message_data_t* msg) {
|
2022-12-11 21:42:55 +08:00
|
|
|
|
char topic_str[MQTT_TOPIC_LEN_MAX+24];
|
|
|
|
|
PikaObj* self = ((mqtt_client_t*)client)->user_data;
|
2022-12-18 00:41:57 +08:00
|
|
|
|
char hash_str[32] = {0};
|
2022-12-11 21:42:55 +08:00
|
|
|
|
|
2022-12-18 00:41:57 +08:00
|
|
|
|
//防止数组越界
|
2022-12-11 21:42:55 +08:00
|
|
|
|
memset(topic_str,0,sizeof(topic_str));
|
|
|
|
|
if(strlen(msg->topic_name) <= MQTT_TOPIC_LEN_MAX)
|
2022-12-18 00:41:57 +08:00
|
|
|
|
// sprintf(topic_str,"eventCallBack_%s",msg->topic_name);
|
|
|
|
|
sprintf(topic_str,"eventCallBack");
|
2022-12-11 21:42:55 +08:00
|
|
|
|
else {
|
|
|
|
|
sprintf(topic_str,"eventCallBack_");
|
|
|
|
|
memcpy((topic_str+strlen("eventCallBack_")),msg->topic_name,MQTT_TOPIC_LEN_MAX);
|
|
|
|
|
}
|
2022-12-18 00:41:57 +08:00
|
|
|
|
|
2022-12-11 21:42:55 +08:00
|
|
|
|
pks_eventLisener_sendSignal(g_mqtt_event_listener,
|
2022-12-18 00:41:57 +08:00
|
|
|
|
hash_time33(topic_str), hash_time33(msg->topic_name));
|
|
|
|
|
|
|
|
|
|
memset(hash_str,0,sizeof(hash_str));
|
|
|
|
|
sprintf(hash_str,"M%d",hash_time33(msg->topic_name));
|
|
|
|
|
obj_setStr(self, hash_str, (char*)msg->message->payload);
|
|
|
|
|
|
|
|
|
|
memset(hash_str,0,sizeof(hash_str));
|
|
|
|
|
sprintf(hash_str,"T%d",hash_time33(msg->topic_name));
|
|
|
|
|
obj_setStr(self, hash_str, (char*)msg->topic_name);
|
|
|
|
|
|
|
|
|
|
// MQTT_LOG_I("\n>>>------------------");
|
|
|
|
|
// MQTT_LOG_I("Topic:%s \nlen:%d,message: %s", msg->topic_name,
|
|
|
|
|
// (int)msg->message->payloadlen, (char*)msg->message->payload);
|
|
|
|
|
// MQTT_LOG_I("------------------<<<");
|
2022-11-23 21:16:20 +08:00
|
|
|
|
}
|
2022-11-23 21:39:59 +08:00
|
|
|
|
|
|
|
|
|
void _mqtt___del__(PikaObj* self) {
|
|
|
|
|
if (NULL != g_mqtt_event_listener) {
|
|
|
|
|
pks_eventLisener_deinit(&g_mqtt_event_listener);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-18 00:41:57 +08:00
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_getMsg
|
|
|
|
|
// 功能说明:在回调函数中取出返回的数据
|
|
|
|
|
// 输入参数:
|
|
|
|
|
// 返 回 值:
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
char* _mqtt__MQTT_getMsg(PikaObj *self, int signal) {
|
|
|
|
|
// mqtt_client_t* _client = obj_getPtr(self, "_client");
|
|
|
|
|
char hash_str[32];
|
|
|
|
|
|
|
|
|
|
memset(hash_str,0,sizeof(hash_str));
|
|
|
|
|
sprintf(hash_str,"M%d",signal);
|
|
|
|
|
return (obj_getStr(self, hash_str));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_getTopic
|
|
|
|
|
// 功能说明:在回调函数中取出返回的数据
|
|
|
|
|
// 输入参数:
|
|
|
|
|
// 返 回 值:
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
char* _mqtt__MQTT_getTopic(PikaObj *self, int signal) {
|
|
|
|
|
char hash_str[32];
|
|
|
|
|
|
|
|
|
|
memset(hash_str,0,sizeof(hash_str));
|
|
|
|
|
sprintf(hash_str,"T%d",signal);
|
|
|
|
|
return (obj_getStr(self, hash_str));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
// 函 数 名:_mqtt__MQTT_setDisconnectHandler
|
|
|
|
|
// 功能说明:设置断开连接的回调函数
|
|
|
|
|
// 输入参数:
|
|
|
|
|
// 返 回 值:
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
int _mqtt__MQTT_setDisconnectHandler(PikaObj *self, Arg* cb) {
|
|
|
|
|
// mqtt_client_t* _client = obj_getPtr(self, "_client");
|
|
|
|
|
|
|
|
|
|
__platform_printf("_mqtt__MQTT_setDisconnectHandler\r\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|