ESP_IDF ESP8266RTOS V3.0 MQTT

编辑器:VSCode
记录日常学习 备忘

一、关于ESP_IDF的菜单配置
在终端调用make menuconfig后会弹出如下界面:
ESP_IDF ESP8266RTOS V3.0 MQTT_第1张图片键盘方向键+回车键选择:component config->MQTT(Paho) 会跳出以下界面
ESP_IDF ESP8266RTOS V3.0 MQTT_第2张图片MQTT version 百度 这里选3.1.1
MQTT client ID 服务器客户端ID要填写的内容–随便
MQTT keep-alive(seconds) 心跳时间
ESP8266 RTOS V3.0 SDK原文:
MQTT keep alive interval, Recommended value: 30s - 60s.
The last MQTT packet timestamp will be recorded,
a PING request will be sent if (current_timestamp - last_mqtt_packet_timestamp) > MQTT_KEEP_ALIVE.

MQTT username 用户名
MQTT password 密码
MQTT send cycle(ms) MQTT包必须在设定周期内发送,否则会返回超时
ESP8266 RTOS V3.0 SDK原文:
Recommended value: 30000 - 60000.
MQTT send interval in every cycle.
A MQTT packet should be sent out in MQTT_SEND_CYCLE,
will block for MQTT_SEND_CYCLE if weak network, and return timeout.
MQTT recv cycle(ms) MQTT包必须在设定周期内接收,否则会返回超时
ESP8266 RTOS V3.0 SDK原文:
Recommended value: 0ms - 500ms.
MQTT receive interval in every cycle.
a MQTT packet should be received in MQTT_RECV_CYCLE,
will block for MQTT_RECV_CYCLE if weak network , and return timeout.

MQTT ping timeout(ms) ESP8266发送心跳包(ping request)后,如何没有在设定的时间内收到应答(ping response),将会断开与MQTT的连接。
ESP8266 RTOS V3.0 SDK原文:
Recommended value: 3000ms - 10000ms.
MQTT ping timeout.
When MQTT_KEEP_ALIVE expired, it will start sending ping request.
If the ESP device does not receive any ping response within MQTT_PING_TIMEOUT,
it will terminate the MQTT connection.

二、关于MQTT服务器搭建
1.去官网下载压缩包http://emqtt.com/downloads 我下载的是V2.3.0
2.解压:注意路径不要带中文
3.打开cmd 跳到解压后的bin目录 我解压的路径是 E:\MQTT\emqttd\bin
ESP_IDF ESP8266RTOS V3.0 MQTT_第3张图片(1)E: (回车)
(2)cd MQTT\emqttd\bin(回车)
(3)emqttd console (回车)
一般一次都不行,关掉cmd窗口,多来几次。如果跳出。额,我找个别人的图,就表示安装成功了。
ESP_IDF ESP8266RTOS V3.0 MQTT_第4张图片
.http://127.0.0.1:18083 控制台地址 用户名:admin 密码:public
ESP_IDF ESP8266RTOS V3.0 MQTT_第5张图片这里就搭建成功了,用通信猫调试软件测试一下
ESP_IDF ESP8266RTOS V3.0 MQTT_第6张图片5.命令
emqttd start 启动EMQ
emqttd stop 停止EMQ
emqttd_ctl statuc 查询EMQ状态
要用EMQ控制台的话要启动EMQ,否则网页有时能进去有时进不去,更新EMQ版本后,控制台页面要手动刷新几下才会弹出新版本的界面,否则他会一直保持老版的控制台界面。

你可能感兴趣的:(ESP8266)