xLibEsp32Rtos3

所属分类:uCOS/RTOS
开发工具:C
文件大小:87KB
下载次数:0
上传日期:2019-04-25 12:06:05
上 传 者sh-1993
说明:  【支持esp8266和esp32】基于乐鑫idf框架,研究出超稳定、掉线重连、解决内存泄露问题的Mqtt框架!
([Support esp8266 and esp32] Based on the Lexin idf framework, we have developed an Mqtt framework that is ultra stable, disconnected and reconnected, and solves the memory leak problem!)

文件列表:
CMakeLists.txt (234, 2019-04-25)
LICENSE (11323, 2019-04-25)
Makefile (177, 2019-04-25)
components (0, 2019-04-25)
components\xmqtt (0, 2019-04-25)
components\xmqtt\component.mk (507, 2019-04-25)
components\xmqtt\include (0, 2019-04-25)
components\xmqtt\include\MQTTConnect.h (4747, 2019-04-25)
components\xmqtt\include\MQTTFormat.h (2028, 2019-04-25)
components\xmqtt\include\MQTTPacket.h (3997, 2019-04-25)
components\xmqtt\include\MQTTPublish.h (1690, 2019-04-25)
components\xmqtt\include\MQTTSubscribe.h (1601, 2019-04-25)
components\xmqtt\include\MQTTUnsubscribe.h (1499, 2019-04-25)
components\xmqtt\include\StackTrace.h (3160, 2019-04-25)
components\xmqtt\include\xmqtt.h (2919, 2019-04-25)
components\xmqtt\lib (0, 2019-04-25)
components\xmqtt\lib\libxmqtt.a (209362, 2019-04-25)
main (0, 2019-04-25)
main\Kconfig (545, 2019-04-25)
main\component.mk (146, 2019-04-25)
main\user_main.c (6155, 2019-04-25)
sdkconfig (15575, 2019-04-25)
sdkconfig.defaults (3, 2019-04-25)
sdkconfig.old (14038, 2019-04-25)

## `xMqttEsp32Rtos3.2Lib` - 本仓库为 `esp32 rtos 3.2` 环境的代码使用,如需拉取`esp38266`代码请访问 https://github.com/xuhongv/xLibEsp8266Rtos3.1Mqtt ---------- ## 维护日志 ---------- | 版本 | 更新日志 | 更新时间 | | --- | --- | --- | | v1.0 | 初次提交 | 2019.04.10 | | v1.1 | 修复接收数据流程bug | 2019.04.23 | | v2.0 | 全新的 API 接口,使用更清晰! | 2019.04.25 | ### 一、简介; ---------- - 本人半颗心脏在总结一些以往 `esp8266`的开发经验,把 这个 `MQTT`连接的断线重连不泄露内存等问题的框架弄好了!**下面是这个框架的一周多运行时间的状态上报的可视化界面!** 具体的上报看使用demo代码! - 如有问题技术或者讨论,请加付费QQ群:434878850 - 本仓库的核心代码是以静态库存在,**但不影响使用!** 如需此库的源码联系:870189248@qq.com - 本库支持 `esp8266 rtos3.1` 和 `esp32 rtos3.2`使用,**其使用提供的 API接口说明方法一样**,但具体细节使用有所不一样,链接如下: - `esp8266 ` : https://github.com/xuhongv/xLibEsp8266Rtos3.1Mqtt - `esp32 `:https://github.com/xuhongv/xLibEsp32Rtos3.2Mqtt ---------- ### 二、如何使用; - 第一步 先初始化连接参数 ``` xMQTT_CONFIG xMqttConfig = { .MQTTVersion = 4, .borkerHost = "193.112.51.78", //服务器地址 .borkerPort = 1883, //端口号 .mqttCommandTimeout = 6000, // 超时 .username = "admin", //用户名 .password = "xuhongv2019", //用户密码 .clientID = "521331497", //设备Id .keepAliveInterval = 60, //心跳 .cleansession = true, //清理会话 }; xMqttInit(&xMqttConfig); ``` - 第二步 创建接收任务,死循环读取 ```xMqttReceiveMsg```接口 ,此方法在 ```xmqtt.h``` 已经提供!请提供足够大的任务栈创建不断死循环读取,方法使用见代码示范的```TaskXMqttRecieve```方法! - 第三步 创建 ```TaskMainMqtt``` 任务,此方法在 ```xmqtt.h``` 已经提供!请提供足够大的任务栈创建! - 其他使用: - 发布消息: ``` strcpy((char *)sMsg.topic, MQTT_DATA_PUBLISH); sprintf((char *)sMsg.payload, "{\"xMqttVersion\":%s,\"freeHeap\":%d}", getXMqttVersion(), esp_get_free_heap_size()); sMsg.payloadlen = strlen((char *)sMsg.payload); sMsg.qos = 1; sMsg.retained = 0; sMsg.dup = 0; xMqttPublicMsg(&sMsg); ``` - 订阅主题,请在连接成功后开始订阅主题: ``` strcpy((char *)rMsg.topic, MQTT_DATA_SUBLISH); rMsg.qos = 1; xMqttSubTopic(&rMsg); ``` - 切记当宿主程序网络发生改变,请调用 ```xMqttConnectWifiNotify()``` 方法通知 ```xmqtt``` ,以便迅捷地重连服务器! ``` xMqttConnectWifiNotify(WIFI_CONNECTED); //通知wifi连接AP成功 xMqttConnectWifiNotify(WIFI_DISCONNECTED);//通知wifi断开AP成功 ``` ----------

近期下载者

相关文件


收藏者