{"id":38413,"date":"2025-05-20T09:21:06","date_gmt":"2025-05-20T01:21:06","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/38413.html"},"modified":"2025-05-20T09:21:06","modified_gmt":"2025-05-20T01:21:06","slug":"ubuntu%e5%ae%89%e8%a3%85mosquitto%ef%bc%8c%e5%81%9a%e4%b8%80%e4%b8%aa%e8%87%aa%e5%b7%b1%e7%9a%84%e7%89%a9%e8%81%94%e7%bd%91%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/38413.html","title":{"rendered":"Ubuntu\u5b89\u88c5Mosquitto\uff0c\u505a\u4e00\u4e2a\u81ea\u5df1\u7684\u7269\u8054\u7f51\u670d\u52a1\u5668"},"content":{"rendered":"<p>Ubuntu\u5b89\u88c5Mosquitto\u670d\u52a1\u5668\u5e76\u5bfc\u51fa\u8fd0\u884c\u65e5\u5fd7&#xff0c;web\u67e5\u770b\u8fd0\u884c\u65e5\u5fd7\u5e76\u5bfc\u51fa\u4e3aExcel&#xff08;\u672a\u5199&#xff09;&#xff0c;\u672c\u6587\u9700\u8981\u540c\u4e00\u5c40\u57df\u7f51\u73af\u5883&#xff0c;\u516c\u7f51\u8bbf\u95ee\u9700\u8981\u4f7f\u7528\u516c\u7f51IP\u6216\u7a7f\u900f<\/p>\n<p>\u6ce8\u610f&#xff1a;Linux\u4e0b\u521b\u5efa\u65b0\u6587\u4ef6\u8bf7\u5728\u4f7f\u7528\u524d\u786e\u8ba4\u6743\u9650<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u6240\u6709\u64cd\u4f5c\u8bf7\u6ce8\u610f\u8def\u5f84\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\u7b49<\/p>\n<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E4%B8%80%EF%BC%8C%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C-toc\" style=\"margin-left:0px\">\u4e00&#xff0c;\u51c6\u5907\u5de5\u4f5c<\/p>\n<p id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A01%20%E4%B8%80%E5%8F%B0%E8%BF%90%E8%A1%8CUbuntu%E7%9A%84%E4%B8%BB%E6%9C%BA%EF%BC%8C%E4%B8%BB%E6%9C%BA%E5%AE%8C%E6%88%90%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE%EF%BC%8Cssh%E7%AD%89%EF%BC%88%E6%9C%AC%E6%96%87%E4%BD%BF%E7%94%A8%E6%A0%91%E8%8E%93%E6%B4%BE5%EF%BC%89-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 \u00a0 \u00a01 \u4e00\u53f0\u8fd0\u884cUbuntu\u7684\u4e3b\u673a&#xff0c;\u4e3b\u673a\u5b8c\u6210\u57fa\u7840\u914d\u7f6e&#xff0c;ssh\u7b49&#xff08;\u672c\u6587\u4f7f\u7528\u6811\u8393\u6d3e5&#xff09;<\/p>\n<p id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A02%20%E4%B8%80%E5%8F%B0%E5%85%B6%E4%BB%96%E6%94%AF%E6%8C%81mqtt%E6%94%B6%E5%8F%91%E7%9A%84%E8%AE%BE%E5%A4%87%E7%94%A8%E6%9D%A5%E6%B5%8B%E8%AF%95-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 \u00a0 \u00a02 \u4e00\u53f0\u5176\u4ed6\u652f\u6301mqtt\u6536\u53d1\u7684\u8bbe\u5907\u7528\u6765\u6d4b\u8bd5<\/p>\n<p id=\"%E4%BA%8C%EF%BC%8C%E5%AE%89%E8%A3%85-toc\" style=\"margin-left:0px\">\u4e8c&#xff0c;\u5b89\u88c5<\/p>\n<p id=\"1%20%E7%A1%AE%E4%BF%9D%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E6%98%AF%E6%9C%80%E6%96%B0%E7%9A%84-toc\" style=\"margin-left:80px\">1 \u786e\u4fdd\u64cd\u4f5c\u7cfb\u7edf\u662f\u6700\u65b0\u7684<\/p>\n<p id=\"2%20%E5%AE%89%E8%A3%85Mosquitto-toc\" style=\"margin-left:80px\">2 \u5b89\u88c5Mosquitto<\/p>\n<p id=\"3%20%E6%B5%8B%E8%AF%95%EF%BC%88%E5%8F%AF%E8%B7%B3%E8%BF%87%EF%BC%89-toc\" style=\"margin-left:80px\">3 \u6d4b\u8bd5&#xff08;\u53ef\u8df3\u8fc7&#xff09;<\/p>\n<p id=\"4%20%E9%85%8D%E7%BD%AE%E9%98%B2%E7%81%AB%E5%A2%99%EF%BC%88%E9%BB%98%E8%AE%A41883%E7%AB%AF%E5%8F%A3%EF%BC%89-toc\" style=\"margin-left:80px\">4 \u914d\u7f6e\u9632\u706b\u5899&#xff08;\u9ed8\u8ba41883\u7aef\u53e3&#xff09;<\/p>\n<p id=\"5%C2%A0%E8%AE%BE%E7%BD%AEMosquitto%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8-toc\" style=\"margin-left:80px\">5\u00a0\u8bbe\u7f6eMosquitto\u5f00\u673a\u542f\u52a8<\/p>\n<p id=\"6%C2%A0%E8%AE%BE%E7%BD%AEMosquitto%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%EF%BC%88%E9%87%8D%E7%82%B9%EF%BC%89-toc\" style=\"margin-left:80px\">6\u00a0\u8bbe\u7f6eMosquitto\u914d\u7f6e\u6587\u4ef6&#xff08;\u91cd\u70b9&#xff09;<\/p>\n<p id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%206.1%E6%89%93%E5%BC%80%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6-toc\" style=\"margin-left:160px\">\u00a0 \u00a0 \u00a0 \u00a0 6.1\u6253\u5f00\u914d\u7f6e\u6587\u4ef6<\/p>\n<p id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%206.2%E4%BF%AE%E6%94%B9%E6%96%87%E4%BB%B6%E5%A6%82%E4%B8%8B-toc\" style=\"margin-left:160px\">\u00a0 \u00a0 \u00a0 \u00a0 6.2\u4fee\u6539\u6587\u4ef6\u5982\u4e0b<\/p>\n<p id=\"7%20%E5%88%9B%E5%BB%BA%E5%AF%86%E7%A0%81%E6%96%87%E4%BB%B6-toc\" style=\"margin-left:80px\">7 \u521b\u5efa\u5bc6\u7801\u6587\u4ef6<\/p>\n<p id=\"8%20%E9%87%8D%E5%90%AF%E6%9C%8D%E5%8A%A1%E4%BD%BF%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E7%94%9F%E6%95%88-toc\" style=\"margin-left:80px\">8 \u91cd\u542f\u670d\u52a1\u4f7f\u914d\u7f6e\u6587\u4ef6\u751f\u6548<\/p>\n<p id=\"%E4%B8%89%E3%80%81%E4%BD%BF%E7%94%A8-toc\" style=\"margin-left:0px\">\u4e09\u3001\u4f7f\u7528<\/p>\n<p id=\"1%20%E7%A1%AE%E8%AE%A4%E6%AD%A3%E5%B8%B8%E7%9B%91%E5%90%AC%E7%AB%AF%E5%8F%A3-toc\" style=\"margin-left:80px\">1 \u786e\u8ba4\u6b63\u5e38\u76d1\u542c\u7aef\u53e3<\/p>\n<p id=\"2%20%E7%A1%AE%E8%AE%A4%E8%BF%9E%E6%8E%A5%E7%8A%B6%E6%80%81%EF%BC%88windows%20powershell)-toc\" style=\"margin-left:80px\">2 \u786e\u8ba4\u8fde\u63a5\u72b6\u6001&#xff08;windows powershell)<\/p>\n<p id=\"3%20%E8%BF%9E%E6%8E%A5%E8%87%B3Linux%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%88%E6%9C%AC%E6%96%87%E4%BD%BF%E7%94%A8Windows%20MQTTX%EF%BC%89-toc\" style=\"margin-left:80px\">3 \u8fde\u63a5\u81f3Linux\u670d\u52a1\u5668&#xff08;\u672c\u6587\u4f7f\u7528Windows MQTTX&#xff09;<\/p>\n<p id=\"4%20%E6%8E%A5%E6%94%B6%E6%B5%8B%E8%AF%95-toc\" style=\"margin-left:80px\">4 \u63a5\u6536\u6d4b\u8bd5<\/p>\n<p id=\"5%20%E5%8F%91%E9%80%81%E6%B5%8B%E8%AF%95-toc\" style=\"margin-left:80px\">5 \u53d1\u9001\u6d4b\u8bd5<\/p>\n<p id=\"6%20%E6%8E%A5%E6%94%B6%E6%95%B0%E6%8D%AE%E5%B9%B6%E5%AF%BC%E5%87%BA%E6%96%87%E4%BB%B6-toc\" style=\"margin-left:80px\">6 \u63a5\u6536\u6570\u636e\u5e76\u5bfc\u51fa\u6587\u4ef6<\/p>\n<p id=\"%C2%A06.1%20%E5%AF%BC%E5%87%BA%E4%B8%BAJSON-toc\" style=\"margin-left:160px\">6.1 \u5bfc\u51fa\u4e3aJSON<\/p>\n<p id=\"6.2%20%E5%AF%BC%E5%87%BA%E4%B8%BAtxt-toc\" style=\"margin-left:160px\">6.2 \u5bfc\u51fa\u4e3atxt<\/p>\n<p id=\"%E5%9B%9B%E3%80%81%E8%BF%90%E8%A1%8C%E6%BC%94%E7%A4%BA-toc\" style=\"margin-left:0px\">\u56db\u3001\u8fd0\u884c\u6f14\u793a<\/p>\n<p id=\"%E4%BA%94%E3%80%81%E5%9B%BA%E5%AE%9ALinux%E8%AE%BE%E5%A4%87ip-toc\" style=\"margin-left:0px\">\u4e94\u3001\u56fa\u5b9aLinux\u8bbe\u5907ip<\/p>\n<p id=\"%E5%85%AD%E3%80%81ESP32%E8%BF%9E%E6%8E%A5%E7%AD%89%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9-toc\" style=\"margin-left:0px\">\u516d\u3001ESP32\u8fde\u63a5\u7b49\u6ce8\u610f\u4e8b\u9879<\/p>\n<p id=\"%E4%B8%83%E3%80%81Python%E8%A7%A3%E6%9E%90json%E5%B9%B6%E4%BB%8E%E7%BD%91%E9%A1%B5%E5%AF%BC%E5%87%BA%E6%97%A5%E5%BF%97-toc\" style=\"margin-left:0px\">\u4e03\u3001Python\u89e3\u6790json\u5e76\u4ece\u7f51\u9875\u5bfc\u51fa\u65e5\u5fd7<\/p>\n<p id=\"1%20%E5%AE%89%E8%A3%85%E6%89%80%E9%9C%80python%E5%BA%93-toc\" style=\"margin-left:80px\">1 \u5b89\u88c5\u6240\u9700python\u5e93<\/p>\n<p id=\"2%20%E9%80%89%E6%8B%A9%E4%B8%80%E4%B8%AA%E7%9B%AE%E5%BD%95%E5%88%9B%E5%BB%BA%E5%B9%B6%E5%86%99%E5%85%A5%E5%89%8D%E5%90%8E%E7%AB%AF%E4%BB%A3%E7%A0%81-toc\" style=\"margin-left:80px\">2 \u9009\u62e9\u4e00\u4e2a\u76ee\u5f55\u521b\u5efa\u5e76\u5199\u5165\u524d\u540e\u7aef\u4ee3\u7801<\/p>\n<p id=\"app.py-toc\" style=\"margin-left:160px\">app.py<\/p>\n<p id=\"index.html-toc\" style=\"margin-left:160px\">index.html<\/p>\n<p id=\"3%20%E8%BF%90%E8%A1%8C%E5%B9%B6%E8%AE%BF%E9%97%AE-toc\" style=\"margin-left:80px\">3 \u8fd0\u884c\u5e76\u8bbf\u95ee<\/p>\n<hr id=\"hr-toc\" \/>\n<h2 id=\"%E4%B8%80%EF%BC%8C%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C\">\u4e00&#xff0c;\u51c6\u5907\u5de5\u4f5c<\/h2>\n<h4 id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A01%20%E4%B8%80%E5%8F%B0%E8%BF%90%E8%A1%8CUbuntu%E7%9A%84%E4%B8%BB%E6%9C%BA%EF%BC%8C%E4%B8%BB%E6%9C%BA%E5%AE%8C%E6%88%90%E5%9F%BA%E7%A1%80%E9%85%8D%E7%BD%AE%EF%BC%8Cssh%E7%AD%89%EF%BC%88%E6%9C%AC%E6%96%87%E4%BD%BF%E7%94%A8%E6%A0%91%E8%8E%93%E6%B4%BE5%EF%BC%89\">\u00a0 \u00a0 \u00a0 \u00a01 \u4e00\u53f0\u8fd0\u884cUbuntu\u7684\u4e3b\u673a&#xff0c;\u4e3b\u673a\u5b8c\u6210\u57fa\u7840\u914d\u7f6e&#xff0c;ssh\u7b49&#xff08;\u672c\u6587\u4f7f\u7528\u6811\u8393\u6d3e5&#xff09;<\/h4>\n<h4 id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A02%20%E4%B8%80%E5%8F%B0%E5%85%B6%E4%BB%96%E6%94%AF%E6%8C%81mqtt%E6%94%B6%E5%8F%91%E7%9A%84%E8%AE%BE%E5%A4%87%E7%94%A8%E6%9D%A5%E6%B5%8B%E8%AF%95\">\u00a0 \u00a0 \u00a0 \u00a02 \u4e00\u53f0\u5176\u4ed6\u652f\u6301mqtt\u6536\u53d1\u7684\u8bbe\u5907\u7528\u6765\u6d4b\u8bd5<\/h4>\n<h2 id=\"%E4%BA%8C%EF%BC%8C%E5%AE%89%E8%A3%85\">\u4e8c&#xff0c;\u5b89\u88c5<\/h2>\n<h4 id=\"1%20%E7%A1%AE%E4%BF%9D%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E6%98%AF%E6%9C%80%E6%96%B0%E7%9A%84\">1 \u786e\u4fdd\u64cd\u4f5c\u7cfb\u7edf\u662f\u6700\u65b0\u7684<\/h4>\n<p>sudo apt update<\/p>\n<p>sudo apt upgrade -y <\/p>\n<h4 id=\"2%20%E5%AE%89%E8%A3%85Mosquitto\">2 \u5b89\u88c5Mosquitto<\/h4>\n<p>sudo apt install mosquitto mosquitto-clients -y <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5b89\u88c5\u5b8c\u6210\u540e\u67e5\u770b\u8fd0\u884c\u72b6\u6001\u4f1a\u663e\u793aruning<\/p>\n<p>sudo systemctl status mosquitto <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"193\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250520012104-682bd90002f0f.png\" width=\"379\" \/><\/p>\n<h4 id=\"3%20%E6%B5%8B%E8%AF%95%EF%BC%88%E5%8F%AF%E8%B7%B3%E8%BF%87%EF%BC%89\">3 \u6d4b\u8bd5&#xff08;\u53ef\u8df3\u8fc7&#xff09;<\/h4>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5206\u522b\u8fd0\u884c\u4ee5\u4e0b\u6307\u4ee4\u6d4b\u8bd5Mosquitto\u670d\u52a1\u5668<\/p>\n<p>mosquitto_pub -h localhost -t &#034;test\/topic&#034; -m &#034;Hello, MQTT&#034;<br \/>\nmosquitto_sub -h localhost -t &#034;test\/topic&#034; <\/p>\n<h4 id=\"4%20%E9%85%8D%E7%BD%AE%E9%98%B2%E7%81%AB%E5%A2%99%EF%BC%88%E9%BB%98%E8%AE%A41883%E7%AB%AF%E5%8F%A3%EF%BC%89\">4 \u914d\u7f6e\u9632\u706b\u5899&#xff08;\u9ed8\u8ba41883\u7aef\u53e3&#xff09;<\/h4>\n<p>sudo ufw allow 1883 <\/p>\n<h4 id=\"5%C2%A0%E8%AE%BE%E7%BD%AEMosquitto%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8\">5\u00a0\u8bbe\u7f6eMosquitto\u5f00\u673a\u542f\u52a8<\/h4>\n<p>sudo systemctl enable mosquitto <\/p>\n<h4 id=\"6%C2%A0%E8%AE%BE%E7%BD%AEMosquitto%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%EF%BC%88%E9%87%8D%E7%82%B9%EF%BC%89\">6\u00a0\u8bbe\u7f6eMosquitto\u914d\u7f6e\u6587\u4ef6&#xff08;\u91cd\u70b9&#xff09;<\/h4>\n<h6 id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%206.1%E6%89%93%E5%BC%80%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6\">\u00a0 \u00a0 \u00a0 \u00a0 6.1\u6253\u5f00\u914d\u7f6e\u6587\u4ef6<\/h6>\n<p>sudo nano \/etc\/mosquitto\/mosquitto.conf <\/p>\n<h6 id=\"%C2%A0%20%C2%A0%20%C2%A0%20%C2%A0%206.2%E4%BF%AE%E6%94%B9%E6%96%87%E4%BB%B6%E5%A6%82%E4%B8%8B\">\u00a0 \u00a0 \u00a0 \u00a0 6.2\u4fee\u6539\u6587\u4ef6\u5982\u4e0b<\/h6>\n<p>allow_anonymous false \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8bbe\u7f6e\u4e3a\u7981\u6b62\u533f\u540d\u8fde\u63a5&#xff08;\u90e8\u5206\u5e93\u533f\u540d\u8fde\u63a5\u5bb9\u6613\u5d29\u6e83&#xff09;<\/p>\n<p>password_file \/etc\/mosquitto\/pwfile \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u9009\u62e9\u5bc6\u7801\u6587\u4ef6&#xff08;\u7b49\u4f1a\u521b\u5efa&#xff09;<\/p>\n<p>bind_address 0.0.0.0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4e0d\u9650\u5236\u8bbe\u5907<\/p>\n<p># Place your local configuration in \/etc\/mosquitto\/conf.d\/<br \/>\n#<br \/>\n# A full description of the configuration file is at<br \/>\n# \/usr\/share\/doc\/mosquitto\/examples\/mosquitto.conf.example<\/p>\n<p>#pid_file \/run\/mosquitto\/mosquitto.pid<\/p>\n<p>persistence true<br \/>\npersistence_location \/var\/lib\/mosquitto\/<\/p>\n<p>log_dest file \/var\/log\/mosquitto\/mosquitto.log<\/p>\n<p>include_dir \/etc\/mosquitto\/conf.d<\/p>\n<p>allow_anonymous false<\/p>\n<p>password_file \/etc\/mosquitto\/pwfile<\/p>\n<p>bind_address 0.0.0.0 <\/p>\n<h4 id=\"7%20%E5%88%9B%E5%BB%BA%E5%AF%86%E7%A0%81%E6%96%87%E4%BB%B6\">7 \u521b\u5efa\u5bc6\u7801\u6587\u4ef6<\/h4>\n<p>\u7cfb\u7edf\u4f1a\u63d0\u793a\u8f93\u5165\u5bc6\u7801&#xff0c;your_username\u5c31\u662f\u7528\u6237\u540d<\/p>\n<p>\u521b\u5efa\u5bc6\u7801\u6587\u4ef6<br \/>\nsudo mosquitto_passwd -c \/etc\/mosquitto\/pwfile your_username<br \/>\n\u8bbe\u7f6e\u6587\u4ef6\u6743\u9650<br \/>\nsudo chown mosquitto:mosquitto \/etc\/mosquitto\/pwfile<br \/>\nsudo chmod 600 \/etc\/mosquitto\/pwfile<\/p>\n<h4 id=\"8%20%E9%87%8D%E5%90%AF%E6%9C%8D%E5%8A%A1%E4%BD%BF%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E7%94%9F%E6%95%88\">8 \u91cd\u542f\u670d\u52a1\u4f7f\u914d\u7f6e\u6587\u4ef6\u751f\u6548<\/h4>\n<p>sudo systemctl restart mosquitto <\/p>\n<h2 id=\"%E4%B8%89%E3%80%81%E4%BD%BF%E7%94%A8\">\u4e09\u3001\u4f7f\u7528<\/h2>\n<h4 id=\"1%20%E7%A1%AE%E8%AE%A4%E6%AD%A3%E5%B8%B8%E7%9B%91%E5%90%AC%E7%AB%AF%E5%8F%A3\">1 \u786e\u8ba4\u6b63\u5e38\u76d1\u542c\u7aef\u53e3<\/h4>\n<p>\u5b89\u88c5 net-tools \u5305<br \/>\nsudo apt install net-tools -y<br \/>\n\u8fd0\u884c netstat \u547d\u4ee4<br \/>\nsudo netstat -tuln | grep 1883<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"72\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250520012104-682bd9002de15.png\" width=\"933\" \/><\/p>\n<h4 id=\"2%20%E7%A1%AE%E8%AE%A4%E8%BF%9E%E6%8E%A5%E7%8A%B6%E6%80%81%EF%BC%88windows%20powershell)\">2 \u786e\u8ba4\u8fde\u63a5\u72b6\u6001&#xff08;windows powershell)<\/h4>\n<p>Test-NetConnection -ComputerName 192.168.66.161 -Port 1883<\/p>\n<h6 id=\"%E2%80%8B%E7%BC%96%E8%BE%91\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"226\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250520012104-682bd9003cb9f.png\" width=\"929\" \/><\/h6>\n<h4 id=\"3%20%E8%BF%9E%E6%8E%A5%E8%87%B3Linux%E6%9C%8D%E5%8A%A1%E5%99%A8%EF%BC%88%E6%9C%AC%E6%96%87%E4%BD%BF%E7%94%A8Windows%20MQTTX%EF%BC%89\">3 \u8fde\u63a5\u81f3Linux\u670d\u52a1\u5668&#xff08;\u672c\u6587\u4f7f\u7528Windows MQTTX&#xff09;<\/h4>\n<p>\u670d\u52a1\u5668\u5730\u5740\u586b\u5199Linux\u8bbe\u5907\u7684IP&#xff0c;\u7528\u6237\u540d\u548c\u5bc6\u7801\u4e3a\u5148\u524d\u8bbe\u7f6e&#xff0c;\u5f39\u51fa\u5df2\u8fde\u63a5\u5219\u6b63\u5e38<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"295\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250520012104-682bd90054582.png\" width=\"356\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"84\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250520012104-682bd9006dd33.png\" width=\"353\" \/><\/p>\n<h4 id=\"4%20%E6%8E%A5%E6%94%B6%E6%B5%8B%E8%AF%95\">4 \u63a5\u6536\u6d4b\u8bd5<\/h4>\n<p>mosquitto_sub \u8ba2\u9605\u00a0-p \u7aef\u53e3 -t &#034;\u8ba2\u9605\u8bdd\u9898&#034; -u &#034;\u7528\u6237\u540d&#034; -P &#034;\u5bc6\u7801&#034;<\/p>\n<p>mosquitto_sub -p 1883 -t &#034;test\/topic&#034; -u &#034;your_username&#034; -P &#034;password&#034; <\/p>\n<p>\u8bdd\u9898\u4e0e\u547d\u4ee4\u884c\u4e00\u81f4&#xff0c;\u547d\u4ee4\u884c\u4e2d\u53ef\u4ee5\u770b\u5230\u8ba2\u9605\u7684\u6d88\u606f<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"493\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250520012104-682bd9007a73d.png\" width=\"552\" \/><\/p>\n<h4 id=\"5%20%E5%8F%91%E9%80%81%E6%B5%8B%E8%AF%95\">5 \u53d1\u9001\u6d4b\u8bd5<\/h4>\n<p>mosquitto_pub \u53d1\u9001\u00a0-m &#034;\u5185\u5bb9&#034;<\/p>\n<p>mosquitto_pub -p 1883 -t &#034;test\/winrec&#034; -m &#034;HELLO&#034; -u &#034;your<br \/>\n_username&#034; -P &#034;password&#034; <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"272\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250520012104-682bd900aaf65.png\" width=\"671\" \/><\/p>\n<h4 id=\"6%20%E6%8E%A5%E6%94%B6%E6%95%B0%E6%8D%AE%E5%B9%B6%E5%AF%BC%E5%87%BA%E6%96%87%E4%BB%B6\">6 \u63a5\u6536\u6570\u636e\u5e76\u5bfc\u51fa\u6587\u4ef6<\/h4>\n<h6 id=\"%C2%A06.1%20%E5%AF%BC%E5%87%BA%E4%B8%BAJSON\" style=\"background-color:transparent\">6.1 \u5bfc\u51fa\u4e3aJSON<\/h6>\n<p>\u8def\u5f84\u7b49\u8bf7\u81ea\u884c\u66f4\u6362\u5e76\u8bbe\u7f6e\u597d\u6743\u9650<\/p>\n<p>mosquitto_sub -p 1883 -t &#034;collect\/updata&#034; -u &#034;pi5&#034; -P &#034;password&#034; | while read -r msg; do echo &#034;{\\\\&#034;timestamp\\\\&#034;: \\\\&#034;$(date &#043;&#039;%Y-%m-%dT%H:%M:%S&#039;)\\\\&#034;, \\\\&#034;message\\\\&#034;: \\\\&#034;$msg\\\\&#034;}&#034; &gt;&gt; &#034;\/home\/pi5\/mqtt\/data\/$(date &#043;&#039;%y_%m_%d&#039;).json&#034;; done<br \/>\n\u6587\u4ef6\u5939\u521b\u5efa\u53c2\u8003<br \/>\nsudo mkdir -p \/home\/mqtt\/data<br \/>\nsudo chmod -R 777 \/home\/mqtt\/data <\/p>\n<h6 id=\"6.2%20%E5%AF%BC%E5%87%BA%E4%B8%BAtxt\">6.2 \u5bfc\u51fa\u4e3atxt<\/h6>\n<p>mosquitto_sub -p 1883 -t &#034;test\/topic&#034; -u &#034;your_username&#034; -P &#034;password&#034; &gt;&gt; &#034;\/home\/mqtt\/data\/$(date &#043;&#039;%y_%m_%d&#039;).txt&#034; <\/p>\n<h2 id=\"%E5%9B%9B%E3%80%81%E8%BF%90%E8%A1%8C%E6%BC%94%E7%A4%BA\">\u56db\u3001\u8fd0\u884c\u6f14\u793a<\/h2>\n<p>\u8fd0\u884c\u5bfc\u51fa\u4e3aJSON\u547d\u4ee4\u5e76\u53d1\u9001\u4e00\u6bb5\u6570\u636e<\/p>\n<p>sudo nano \/home\/mqtt\/data\/25_02_22.json \u67e5\u770b\u8fd0\u884c\u7ed3\u679c<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"774\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250520012104-682bd900cdb13.png\" width=\"1225\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"669\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250520012105-682bd9012e9a5.png\" width=\"1141\" \/><\/p>\n<h2 id=\"%E4%BA%94%E3%80%81%E5%9B%BA%E5%AE%9ALinux%E8%AE%BE%E5%A4%87ip\">\u4e94\u3001\u56fa\u5b9aLinux\u8bbe\u5907ip<\/h2>\n<p>\u4f9d\u6b21\u8fd0\u884c\u5c06Xiaomi 13\u7f51\u7edc\u4e0b\u7684\u8bbe\u5907IP\u56fa\u5b9a\u4e3a192.168.66.66<br \/>\nsudo nmcli con mod &#034;Xiaomi 13&#034; ipv4.addresses 192.168.66.66\/24<br \/>\nsudo nmcli con mod &#034;Xiaomi 13&#034; ipv4.gateway 192.168.66.1<br \/>\nsudo nmcli con mod &#034;Xiaomi 13&#034; ipv4.dns &#034;8.8.8.8&#034;<br \/>\nsudo nmcli con mod &#034;Xiaomi 13&#034; ipv4.method manual<br \/>\n\u8bbe\u7f6e\u5b8c\u6210\u540e\u91cd\u8fdeWiFi<br \/>\nsudo nmcli con up &#034;Xiaomi 13&#034; <\/p>\n<h2 id=\"%E5%85%AD%E3%80%81ESP32%E8%BF%9E%E6%8E%A5%E7%AD%89%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9\">\u516d\u3001ESP32\u8fde\u63a5\u7b49\u6ce8\u610f\u4e8b\u9879<\/h2>\n<p>\u4f7f\u7528PubSubClient\u5e93\u65f6\u9700\u8981\u8bbe\u7f6e\u53c2\u6570&#xff0c;\u5426\u5219esp32\u4f1a\u5d29\u6e83&#xff0c;\u4ee5\u4e0b\u53c2\u6570\u6d4b\u8bd5\u53ef\u884c&#xff0c;\u4f8b\u7a0b\u5982\u4e0b<\/p>\n<p>\/\/PubSubClient ESP32-Linux<br \/>\n\/\/PubSubClient.h \u4e2d\u4fee\u6539MQTT_MAX_PACKET_SIZE 512 MQTT_KEEPALIVE 180<br \/>\n#include &lt;WiFi.h&gt;<br \/>\n#include &lt;PubSubClient.h&gt;<br \/>\n#include &#034;mqttserver.h&#034;<\/p>\n<p>\/\/ \u5e73\u53f0\u914d\u7f6e<br \/>\nconst char* mqttServer &#061; &#034;192.168.66.66&#034;;<br \/>\nconst int mqttPort &#061; 1883;<br \/>\nconst char* mqttClientId &#061; &#034;ESP32_1&#034;;<br \/>\nconst char* mqttUsername &#061; &#034;your_username&#034;;<br \/>\nconst char* mqttPassword &#061; &#034;password&#034;;<\/p>\n<p>\/\/ Topic\u914d\u7f6e<br \/>\nString topic_control &#061; &#034;test\/dowload&#034;;  \/\/ \u5c5e\u6027\u8bbe\u7f6eTopic<br \/>\nString topic_property_post &#061; &#034;test\/update&#034;;  \/\/ \u5c5e\u6027\u4e0a\u62a5Topic<\/p>\n<p>WiFiClient espClient; \/\/ \u521b\u5efa\u4e00\u4e2aWiFi\u5ba2\u6237\u7aef\u5b9e\u4f8b&#xff0c;\u7528\u4e8e\u4e0eWiFi\u7f51\u7edc\u8fde\u63a5<br \/>\nPubSubClient client(espClient); \/\/ \u521b\u5efa\u4e00\u4e2aPubSubClient\u5b9e\u4f8b&#xff0c;\u5c06WiFi\u5ba2\u6237\u7aef\u4f20\u9012\u7ed9\u5b83\u4ee5\u8fdb\u884cMQTT\u901a\u4fe1<\/p>\n<p>\/\/ \u7269\u8054\u7f51\u53c2\u6570<br \/>\nfloat depth_water;<br \/>\nfloat humi, temp;<\/p>\n<p>void mqtt_init(void) {<br \/>\n  \/\/ \u8bbe\u7f6eMQTT\u670d\u52a1\u5668\u5730\u5740\u548c\u7aef\u53e3&#xff08;\u544a\u8bc9\u5ba2\u6237\u7aef\u5728\u54ea\u91cc\u627e\u5230MQTT\u4ee3\u7406&#xff09;<br \/>\n  client.setServer(mqttServer, mqttPort);<br \/>\n  \/\/ \u8bbe\u7f6eMQTT\u6d88\u606f\u56de\u8c03\u51fd\u6570&#xff08;\u7528\u4e8e\u5904\u7406\u63a5\u6536\u5230\u7684MQTT\u6d88\u606f\u3002\u5f53\u5ba2\u6237\u7aef\u63a5\u6536\u5230\u6d88\u606f\u65f6&#xff0c;\u8fd9\u4e2a\u51fd\u6570\u4f1a\u88ab\u81ea\u52a8\u8c03\u7528&#xff09;<br \/>\n  client.setCallback(callback);<br \/>\n}<\/p>\n<p>\/\/MQTT\u72b6\u6001\u5224\u65ad&#xff0c;\u65ad\u8fde\u5219\u91cd\u8fde&#xff0c;\u8fde\u63a5\u6b63\u5e38\u5219\u4e0a\u62a5\u6570\u636e<br \/>\nvoid mqtt_server(void) {<br \/>\n  \/\/ \u68c0\u67e5MQTT\u8fde\u63a5\u72b6\u6001<br \/>\n  if (!client.connected()) {<br \/>\n    connectMQTT(); \/\/ \u5982\u679c\u672a\u8fde\u63a5&#xff0c;\u5219\u5c1d\u8bd5\u8fde\u63a5MQTT\u670d\u52a1\u5668<br \/>\n  }<br \/>\n  client.loop(); \/\/ \u5904\u7406MQTT\u6d88\u606f&#xff08;MQTT\u5ba2\u6237\u7aef\u7684\u6838\u5fc3\u5faa\u73af&#xff0c;\u5904\u7406\u6240\u6709\u5f85\u5904\u7406\u7684\u6d88\u606f\u548c\u56de\u8c03\u3002\u5982\u679c\u6ca1\u6709\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570&#xff0c;\u5ba2\u6237\u7aef\u5c06\u65e0\u6cd5\u63a5\u6536\u6d88\u606f\u3002&#xff09;<br \/>\n  reportDeviceStatus(); \/\/ \u62a5\u544a\u8bbe\u5907\u72b6\u6001<br \/>\n}<\/p>\n<p>\/\/ \u5904\u7406\u6536\u5230\u7684\u63a7\u5236\u547d\u4ee4<br \/>\nvoid callback(char* topic, byte* payload, unsigned int length) {<br \/>\n  \/\/ \u5c06payload\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32<br \/>\n  String message;<br \/>\n  for (int i &#061; 0; i &lt; length; i&#043;&#043;) {<br \/>\n    message &#043;&#061; (char)payload[i];<br \/>\n  }<\/p>\n<p>  Serial.print(&#034;Message received: &#034;);<br \/>\n  Serial.println(message);<br \/>\n}<\/p>\n<p>\/\/ MQTT\u670d\u52a1\u5668\u8fde\u63a5<br \/>\nvoid connectMQTT(void) {<br \/>\n  \/\/ \u53ea\u8981\u672a\u8fde\u63a5\u5230MQTT\u670d\u52a1\u5668&#xff0c;\u5c31\u6301\u7eed\u5c1d\u8bd5\u8fde\u63a5<br \/>\n  while (!client.connected()) {<br \/>\n    Serial.println(&#034;Reconnecting to MQTT&#8230;&#034;); \/\/ \u8f93\u51fa\u91cd\u65b0\u8fde\u63a5\u7684\u4fe1\u606f<br \/>\n    \/\/ \u5c1d\u8bd5\u8fde\u63a5\u5230MQTT\u670d\u52a1\u5668&#xff08;\u4f7f\u7528\u63d0\u4f9b\u7684\u5ba2\u6237\u7aefID\u3001\u7528\u6237\u540d\u548c\u5bc6\u7801&#xff09;<br \/>\n    if (client.connect(mqttClientId, mqttUsername, mqttPassword)) {<br \/>\n      Serial.println(&#034;Reconnected to MQTT server&#034;); \/\/ \u8f93\u51fa\u8fde\u63a5\u6210\u529f\u7684\u4fe1\u606f<br \/>\n      client.subscribe(topic_control.c_str());  \/\/ \u91cd\u65b0\u8ba2\u9605\u63a7\u5236\u547d\u4ee4\u4e3b\u9898<br \/>\n    } else {<br \/>\n      \/\/ \u5982\u679c\u8fde\u63a5\u5931\u8d25&#xff0c;\u8f93\u51fa\u9519\u8bef\u72b6\u6001<br \/>\n      Serial.print(&#034;MQTT reconnection failed, state: &#034;);<br \/>\n      Serial.println(client.state());<br \/>\n      delay(2000); \/\/ \u7b49\u5f852\u79d2\u518d\u5c1d\u8bd5\u91cd\u65b0\u8fde\u63a5<br \/>\n    }<br \/>\n  }<br \/>\n}<\/p>\n<p>\/\/ \u4e0a\u4f20\u6570\u636e<br \/>\nvoid reportDeviceStatus(void) {<br \/>\n  \/\/ \u6784\u9020JSON\u683c\u5f0f\u7684\u8d1f\u8f7d<br \/>\n  String payload &#061; &#034;{\\\\&#034;depth_water\\\\&#034;:&#034; &#043; String(depth_water) &#043; &#034;,\\\\&#034;humi\\\\&#034;:&#034; &#043; String(humi) &#043;&#034;,\\\\&#034;temp\\\\&#034;:&#034; &#043; String(temp) &#043;&#034;}&#034;;<\/p>\n<p>  \/\/ \u901a\u8fc7MQTT\u53d1\u5e03\u8d1f\u8f7d<br \/>\n  if (client.publish(topic_property_post.c_str(), payload.c_str())) {<br \/>\n    Serial.println(&#034;Device status reported successfully&#034;); \/\/ \u8f93\u51fa\u6210\u529f\u4fe1\u606f<br \/>\n  } else {<br \/>\n    Serial.println(&#034;Failed to report device status&#034;); \/\/ \u8f93\u51fa\u5931\u8d25\u4fe1\u606f<br \/>\n  }<br \/>\n}<\/p>\n<h2 id=\"%E4%B8%83%E3%80%81Python%E8%A7%A3%E6%9E%90json%E5%B9%B6%E4%BB%8E%E7%BD%91%E9%A1%B5%E5%AF%BC%E5%87%BA%E6%97%A5%E5%BF%97\">\u4e03\u3001Python\u89e3\u6790json\u5e76\u4ece\u7f51\u9875\u5bfc\u51fa\u65e5\u5fd7<\/h2>\n<h4 id=\"1%20%E5%AE%89%E8%A3%85%E6%89%80%E9%9C%80python%E5%BA%93\">1 \u5b89\u88c5\u6240\u9700python\u5e93<\/h4>\n<p>sudo apt install python3-pip python3-flask<\/p>\n<p>sudo apt install python3-pandas python3-openpyxl<\/p>\n<h4 id=\"2%20%E9%80%89%E6%8B%A9%E4%B8%80%E4%B8%AA%E7%9B%AE%E5%BD%95%E5%88%9B%E5%BB%BA%E5%B9%B6%E5%86%99%E5%85%A5%E5%89%8D%E5%90%8E%E7%AB%AF%E4%BB%A3%E7%A0%81\">2 \u9009\u62e9\u4e00\u4e2a\u76ee\u5f55\u521b\u5efa\u5e76\u5199\u5165\u524d\u540e\u7aef\u4ee3\u7801<\/h4>\n<p>cd \/home\/pi5<\/p>\n<p>touch app.py touch index.html<\/p>\n<h6 id=\"app.py\">app.py<\/h6>\n<p>from flask import Flask, request, jsonify, send_from_directory<br \/>\nimport os<br \/>\nimport json<br \/>\nimport re<br \/>\nimport pandas as pd<br \/>\nfrom datetime import datetime<\/p>\n<p>app &#061; Flask(__name__)<\/p>\n<p># \u8bbe\u7f6e\u5b58\u50a8 JSON \u6587\u4ef6\u7684\u76ee\u5f55<br \/>\nDATA_DIR &#061; &#039;\/home\/pi5\/mqtt\/data\/&#039;<\/p>\n<p># \u83b7\u53d6\u6240\u6709\u65e5\u671f\u7684\u6587\u4ef6\u540d<br \/>\ndef get_json_files():<br \/>\n    files &#061; [f for f in os.listdir(DATA_DIR) if f.endswith(&#039;.json&#039;)]<br \/>\n    return sorted(files)<\/p>\n<p># \u89e3\u6790\u6307\u5b9a\u65e5\u671f\u7684 JSON \u6587\u4ef6<br \/>\ndef parse_json_file(file_name):<br \/>\n    try:<br \/>\n        data_list &#061; []<br \/>\n        with open(os.path.join(DATA_DIR, file_name), &#039;r&#039;) as f:<br \/>\n            for line in f:<br \/>\n                line &#061; line.strip()<br \/>\n                if not line:<br \/>\n                    continue<br \/>\n                try:<br \/>\n                    # \u5c1d\u8bd5\u76f4\u63a5\u89e3\u6790\u884c\u6570\u636e<br \/>\n                    data &#061; json.loads(line)<br \/>\n                except json.JSONDecodeError:<br \/>\n                    # \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u4fee\u590d message \u5b57\u6bb5\u7684\u683c\u5f0f\u95ee\u9898<br \/>\n                    corrected_line &#061; re.sub(<br \/>\n                        r&#039;&#034;message&#034;:\\\\s*&#034;(\\\\{.*?\\\\})&#034;&#039;,<br \/>\n                        r&#039;&#034;message&#034;: \\\\1&#039;,<br \/>\n                        line,<br \/>\n                        flags&#061;re.DOTALL<br \/>\n                    )<br \/>\n                    try:<br \/>\n                        data &#061; json.loads(corrected_line)<br \/>\n                    except json.JSONDecodeError as e:<br \/>\n                        print(f&#034;Error decoding corrected line in {file_name}: {e}&#034;)<br \/>\n                        continue<br \/>\n                # \u68c0\u67e5 message \u5b57\u6bb5\u662f\u5426\u4e3a\u5b57\u7b26\u4e32&#xff0c;\u5c1d\u8bd5\u8fdb\u4e00\u6b65\u89e3\u6790<br \/>\n                if &#039;message&#039; in data and isinstance(data[&#039;message&#039;], str):<br \/>\n                    try:<br \/>\n                        data[&#039;message&#039;] &#061; json.loads(data[&#039;message&#039;])<br \/>\n                    except json.JSONDecodeError:<br \/>\n                        print(f&#034;Failed to parse message field in {file_name}&#034;)<br \/>\n                data_list.append(data)<br \/>\n        return data_list<br \/>\n    except Exception as e:<br \/>\n        print(f&#034;Error reading {file_name}: {e}&#034;)<br \/>\n        return None<\/p>\n<p># \u67e5\u8be2\u6307\u5b9a\u65e5\u671f\u8303\u56f4\u7684\u6570\u636e<br \/>\n&#064;app.route(&#039;\/query&#039;, methods&#061;[&#039;GET&#039;])<br \/>\ndef query_data():<br \/>\n    start_date &#061; request.args.get(&#039;start_date&#039;)  # \u83b7\u53d6\u67e5\u8be2\u7684\u5f00\u59cb\u65e5\u671f<br \/>\n    end_date &#061; request.args.get(&#039;end_date&#039;)      # \u83b7\u53d6\u67e5\u8be2\u7684\u7ed3\u675f\u65e5\u671f<\/p>\n<p>    # \u89e3\u6790\u65e5\u671f\u683c\u5f0f (yyyy-mm-dd)<br \/>\n    try:<br \/>\n        start_date &#061; datetime.strptime(start_date, &#039;%Y-%m-%d&#039;)<br \/>\n        end_date &#061; datetime.strptime(end_date, &#039;%Y-%m-%d&#039;)<br \/>\n    except ValueError:<br \/>\n        return jsonify({&#039;error&#039;: &#039;Invalid date format. Please use yyyy-mm-dd.&#039;}), 400<\/p>\n<p>    result &#061; []<\/p>\n<p>    # \u904d\u5386\u6240\u6709\u6587\u4ef6&#xff0c;\u6839\u636e\u65f6\u95f4\u8303\u56f4\u8fc7\u6ee4\u6587\u4ef6<br \/>\n    for file_name in get_json_files():<br \/>\n        # \u63d0\u53d6\u6587\u4ef6\u65e5\u671f&#xff08;\u5047\u8bbe\u6587\u4ef6\u540d\u662f\u7c7b\u4f3c &#034;25_02_22.json&#034;&#xff09;<br \/>\n        file_date_str &#061; file_name.split(&#039;.&#039;)[0]<br \/>\n        try:<br \/>\n            file_date &#061; datetime.strptime(file_date_str, &#039;%y_%m_%d&#039;)<br \/>\n        except ValueError:<br \/>\n            print(f&#034;Skipping invalid filename: {file_name}&#034;)<br \/>\n            continue<\/p>\n<p>        # \u5982\u679c\u6587\u4ef6\u65e5\u671f\u5728\u6307\u5b9a\u7684\u65f6\u95f4\u8303\u56f4\u5185&#xff0c;\u89e3\u6790\u5e76\u8fd4\u56de\u6570\u636e<br \/>\n        if start_date &lt;&#061; file_date &lt;&#061; end_date:<br \/>\n            parsed_data &#061; parse_json_file(file_name)<br \/>\n            if parsed_data:<br \/>\n                for entry in parsed_data:<br \/>\n                    # \u63d0\u53d6 timestamp \u5b57\u6bb5\u5e76\u4ec5\u4fdd\u7559\u65f6\u95f4\u90e8\u5206<br \/>\n                    timestamp &#061; entry.get(&#034;timestamp&#034;, &#034;&#034;)<br \/>\n                    time_part &#061; timestamp.split(&#039;T&#039;)[1] if &#039;T&#039; in timestamp else &#034;&#034;<\/p>\n<p>                    # \u63d0\u53d6 message \u5b57\u6bb5&#xff0c;\u5e76\u683c\u5f0f\u5316\u4e3a &#034;key: value | key: value&#034;<br \/>\n                    message &#061; entry.get(&#034;message&#034;, {})<br \/>\n                    message_str &#061; &#034; | &#034;.join([f&#034;{key}: {value}&#034; for key, value in message.items()])<\/p>\n<p>                    # \u5c06\u65f6\u95f4\u548c\u683c\u5f0f\u5316\u540e\u7684 message \u62fc\u63a5<br \/>\n                    result.append({<br \/>\n                        &#039;date&#039;: file_date.strftime(&#039;%Y-%m-%d&#039;),<br \/>\n                        &#039;data&#039;: f&#034;{time_part} {message_str}&#034;  # \u62fc\u63a5\u65f6\u95f4\u548c\u6d88\u606f\u5185\u5bb9<br \/>\n                    })<\/p>\n<p>    return jsonify(result)<\/p>\n<p># \u5bfc\u51fa\u6570\u636e\u4e3a Excel<br \/>\n&#064;app.route(&#039;\/export_excel&#039;, methods&#061;[&#039;GET&#039;])<br \/>\ndef export_excel():<br \/>\n    start_date &#061; request.args.get(&#039;start_date&#039;)  # \u83b7\u53d6\u67e5\u8be2\u7684\u5f00\u59cb\u65e5\u671f<br \/>\n    end_date &#061; request.args.get(&#039;end_date&#039;)      # \u83b7\u53d6\u67e5\u8be2\u7684\u7ed3\u675f\u65e5\u671f<\/p>\n<p>    # \u89e3\u6790\u65e5\u671f\u683c\u5f0f (yyyy-mm-dd)<br \/>\n    try:<br \/>\n        start_date &#061; datetime.strptime(start_date, &#039;%Y-%m-%d&#039;)<br \/>\n        end_date &#061; datetime.strptime(end_date, &#039;%Y-%m-%d&#039;)<br \/>\n    except ValueError:<br \/>\n        return jsonify({&#039;error&#039;: &#039;Invalid date format. Please use yyyy-mm-dd.&#039;}), 400<\/p>\n<p>    result &#061; []<\/p>\n<p>    # \u904d\u5386\u6240\u6709\u6587\u4ef6&#xff0c;\u6839\u636e\u65f6\u95f4\u8303\u56f4\u8fc7\u6ee4\u6587\u4ef6<br \/>\n    for file_name in get_json_files():<br \/>\n        # \u63d0\u53d6\u6587\u4ef6\u65e5\u671f&#xff08;\u5047\u8bbe\u6587\u4ef6\u540d\u662f\u7c7b\u4f3c &#034;25_02_22.json&#034;&#xff09;<br \/>\n        file_date_str &#061; file_name.split(&#039;.&#039;)[0]<br \/>\n        try:<br \/>\n            file_date &#061; datetime.strptime(file_date_str, &#039;%y_%m_%d&#039;)<br \/>\n        except ValueError:<br \/>\n            print(f&#034;Skipping invalid filename: {file_name}&#034;)<br \/>\n            continue<\/p>\n<p>        # \u5982\u679c\u6587\u4ef6\u65e5\u671f\u5728\u6307\u5b9a\u7684\u65f6\u95f4\u8303\u56f4\u5185&#xff0c;\u89e3\u6790\u5e76\u8fd4\u56de\u6570\u636e<br \/>\n        if start_date &lt;&#061; file_date &lt;&#061; end_date:<br \/>\n            parsed_data &#061; parse_json_file(file_name)<br \/>\n            if parsed_data:<br \/>\n                for entry in parsed_data:<br \/>\n                    result.append({<br \/>\n                        &#039;date&#039;: file_date.strftime(&#039;%Y-%m-%d&#039;),<br \/>\n                        &#039;data&#039;: entry<br \/>\n                    })<\/p>\n<p>    # \u5c06\u67e5\u8be2\u7ed3\u679c\u8f6c\u6362\u4e3a pandas DataFrame<br \/>\n    df_list &#061; []<br \/>\n    for item in result:<br \/>\n        date_str &#061; item[&#039;date&#039;]<br \/>\n        data &#061; item[&#039;data&#039;]<br \/>\n        # \u68c0\u67e5 &#039;message&#039; \u662f\u5426\u4e3a\u5b57\u7b26\u4e32&#xff0c;\u5982\u679c\u662f&#xff0c;\u5219\u89e3\u6790\u5b83\u4e3a\u5b57\u5178<br \/>\n        if isinstance(data.get(&#034;message&#034;, &#034;&#034;), str):<br \/>\n            try:<br \/>\n                data[&#039;message&#039;] &#061; json.loads(data[&#039;message&#039;])  # \u89e3\u6790\u4e3a\u5b57\u5178<br \/>\n            except json.JSONDecodeError:<br \/>\n                print(f&#034;Failed to parse message field in {item[&#039;date&#039;]}&#034;)<\/p>\n<p>        # \u63d0\u53d6 &#039;timestamp&#039; \u5e76\u53ea\u4fdd\u7559 &#039;T&#039; \u540e\u7684\u90e8\u5206&#xff0c;\u6539\u4e3a &#039;time&#039;<br \/>\n        timestamp &#061; data.get(&#034;timestamp&#034;, &#034;&#034;)<br \/>\n        time_part &#061; timestamp.split(&#039;T&#039;)[1] if &#039;T&#039; in timestamp else &#034;&#034;<\/p>\n<p>        # \u63d0\u53d6\u5b57\u6bb5&#xff0c;\u5e76\u786e\u4fdd\u83b7\u53d6\u6709\u6548\u7684\u6570\u636e<br \/>\n        df_list.append({<br \/>\n            &#039;date&#039;: date_str,<br \/>\n            &#039;time&#039;: time_part,  # \u53ea\u4fdd\u7559 &#039;T&#039; \u540e\u7684\u90e8\u5206<br \/>\n            &#039;humi1&#039;: data.get(&#034;message&#034;, {}).get(&#034;humi1&#034;, &#034;&#034;),<br \/>\n            &#039;temp2&#039;: data.get(&#034;message&#034;, {}).get(&#034;temp2&#034;, &#034;&#034;),<br \/>\n            #&#039;temp&#039;: data.get(&#034;message&#034;, {}).get(&#034;temp&#034;, &#034;&#034;),<br \/>\n        })<\/p>\n<p>    # \u5c06\u6570\u636e\u4fdd\u5b58\u5230 Excel \u6587\u4ef6<br \/>\n    df &#061; pd.DataFrame(df_list)<br \/>\n    file_path &#061; &#034;data.xlsx&#034;  # \u4f7f\u7528\u76f8\u5bf9\u8def\u5f84<br \/>\n    df.to_excel(file_path, index&#061;False, engine&#061;&#039;openpyxl&#039;)<\/p>\n<p>    # \u4f7f\u7528 send_from_directory \u53d1\u9001\u6587\u4ef6&#xff0c;\u786e\u4fdd\u6587\u4ef6\u4f4d\u4e8e\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55<br \/>\n    return send_from_directory(os.getcwd(), file_path, as_attachment&#061;True)<\/p>\n<p># \u8fd4\u56de\u9759\u6001\u6587\u4ef6&#xff08;index.html&#xff09;<br \/>\n&#064;app.route(&#039;\/&#039;)<br \/>\ndef serve_index():<br \/>\n    return send_from_directory(os.getcwd(), &#039;index.html&#039;)<\/p>\n<p>if __name__ &#061;&#061; &#039;__main__&#039;:<br \/>\n    app.run(debug&#061;True, host&#061;&#039;0.0.0.0&#039;)<\/p>\n<h6 id=\"index.html\">index.html<\/h6>\n<p>&lt;!DOCTYPE html&gt;<br \/>\n&lt;html lang&#061;&#034;en&#034;&gt;<br \/>\n&lt;head&gt;<br \/>\n    &lt;meta charset&#061;&#034;UTF-8&#034;&gt;<br \/>\n    &lt;meta name&#061;&#034;viewport&#034; content&#061;&#034;width&#061;device-width, initial-scale&#061;1.0&#034;&gt;<br \/>\n    &lt;title&gt;MQTT Data Query&lt;\/title&gt;<br \/>\n    &lt;style&gt;<br \/>\n        body {<br \/>\n            font-family: Arial, sans-serif;<br \/>\n            margin: 20px;<br \/>\n        }<br \/>\n        .container {<br \/>\n            max-width: 600px;<br \/>\n            margin: auto;<br \/>\n        }<br \/>\n        input, button {<br \/>\n            padding: 8px;<br \/>\n            margin: 5px;<br \/>\n        }<br \/>\n        .result {<br \/>\n            margin-top: 20px;<br \/>\n        }<br \/>\n        table {<br \/>\n            width: 100%;<br \/>\n            border-collapse: collapse;<br \/>\n        }<br \/>\n        table, th, td {<br \/>\n            border: 1px solid #ddd;<br \/>\n        }<br \/>\n        th, td {<br \/>\n            padding: 8px;<br \/>\n            text-align: left;<br \/>\n        }<br \/>\n    &lt;\/style&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<\/p>\n<p>    &lt;div class&#061;&#034;container&#034;&gt;<br \/>\n        &lt;h1&gt;Data Query&lt;\/h1&gt;<\/p>\n<p>        &lt;label for&#061;&#034;start_date&#034;&gt;Start Date:&lt;\/label&gt;<br \/>\n        &lt;input type&#061;&#034;date&#034; id&#061;&#034;start_date&#034; required&gt;<\/p>\n<p>        &lt;label for&#061;&#034;end_date&#034;&gt;End Date:&lt;\/label&gt;<br \/>\n        &lt;input type&#061;&#034;date&#034; id&#061;&#034;end_date&#034; required&gt;<br \/>\n        &lt;br&gt;<br \/>\n        &lt;button onclick&#061;&#034;fetchData()&#034;&gt;Query Data&lt;\/button&gt;<br \/>\n        &lt;button onclick&#061;&#034;exportExcel()&#034;&gt;Export to Excel&lt;\/button&gt;<\/p>\n<p>        &lt;div class&#061;&#034;result&#034;&gt;<br \/>\n            &lt;h3&gt;Results&lt;\/h3&gt;<br \/>\n            &lt;div id&#061;&#034;data-table&#034;&gt;&lt;\/div&gt;<br \/>\n        &lt;\/div&gt;<br \/>\n    &lt;\/div&gt;<\/p>\n<p>    &lt;script&gt;<br \/>\n        async function fetchData() {<br \/>\n            const start_date &#061; document.getElementById(&#039;start_date&#039;).value;<br \/>\n            const end_date &#061; document.getElementById(&#039;end_date&#039;).value;<\/p>\n<p>            if (!start_date || !end_date) {<br \/>\n                alert(&#034;Please select both start and end dates.&#034;);<br \/>\n                return;<br \/>\n            }<\/p>\n<p>            const response &#061; await fetch(&#096;\/query?start_date&#061;${start_date}&amp;end_date&#061;${end_date}&#096;);<br \/>\n            const data &#061; await response.json();<\/p>\n<p>            let tableHTML &#061; &#039;&lt;table&gt;&lt;tr&gt;&lt;th&gt;Date&lt;\/th&gt;&lt;th&gt;Data&lt;\/th&gt;&lt;\/tr&gt;&#039;;<\/p>\n<p>            data.forEach(item &#061;&gt; {<br \/>\n                tableHTML &#043;&#061; &#096;&lt;tr&gt;&lt;td&gt;${item.date}&lt;\/td&gt;&lt;td&gt;${JSON.stringify(item.data)}&lt;\/td&gt;&lt;\/tr&gt;&#096;;<br \/>\n            });<\/p>\n<p>            tableHTML &#043;&#061; &#039;&lt;\/table&gt;&#039;;<br \/>\n            document.getElementById(&#039;data-table&#039;).innerHTML &#061; tableHTML;<br \/>\n        }<\/p>\n<p>        function exportExcel() {<br \/>\n            const start_date &#061; document.getElementById(&#039;start_date&#039;).value;<br \/>\n            const end_date &#061; document.getElementById(&#039;end_date&#039;).value;<\/p>\n<p>            if (!start_date || !end_date) {<br \/>\n                alert(&#034;Please select both start and end dates.&#034;);<br \/>\n                return;<br \/>\n            }<\/p>\n<p>            window.location.href &#061; &#096;\/export_excel?start_date&#061;${start_date}&amp;end_date&#061;${end_date}&#096;;<br \/>\n        }<br \/>\n    &lt;\/script&gt;<\/p>\n<p>&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/p>\n<h4 id=\"3%20%E8%BF%90%E8%A1%8C%E5%B9%B6%E8%AE%BF%E9%97%AE\">3 \u8fd0\u884c\u5e76\u8bbf\u95ee<\/h4>\n<p>\u8fd0\u884c<\/p>\n<p>python app.py<\/p>\n<p>\u8bbf\u95ee<\/p>\n<p>\u8bbe\u5907IP:5000<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb535\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf10\u6b21\u3002Ubuntu\u5b89\u88c5Mosquitto\u670d\u52a1\u5668\u5e76\u5bfc\u51fa\u8fd0\u884c\u65e5\u5fd7\uff0cweb\u67e5\u770b\u8fd0\u884c\u65e5\u5fd7\u5e76\u5bfc\u51fa\u4e3aExcel\uff08\u672a\u5199\uff09\uff0c\u672c\u6587\u9700\u8981\u540c\u4e00\u5c40\u57df\u7f51\u73af\u5883\uff0c\u516c\u7f51\u8bbf\u95ee\u9700\u8981\u4f7f\u7528\u516c\u7f51IP\u6216\u7a7f\u900f\u6ce8\u610f\uff1aLinux\u4e0b\u521b\u5efa\u65b0\u6587\u4ef6\u8bf7\u5728\u4f7f\u7528\u524d\u786e\u8ba4\u6743\u9650\u3002_ubuntu mosquitto<\/p>\n","protected":false},"author":2,"featured_media":38404,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[43,44],"topic":[],"class_list":["post-38413","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Ubuntu\u5b89\u88c5Mosquitto\uff0c\u505a\u4e00\u4e2a\u81ea\u5df1\u7684\u7269\u8054\u7f51\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/38413.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ubuntu\u5b89\u88c5Mosquitto\uff0c\u505a\u4e00\u4e2a\u81ea\u5df1\u7684\u7269\u8054\u7f51\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb535\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf10\u6b21\u3002Ubuntu\u5b89\u88c5Mosquitto\u670d\u52a1\u5668\u5e76\u5bfc\u51fa\u8fd0\u884c\u65e5\u5fd7\uff0cweb\u67e5\u770b\u8fd0\u884c\u65e5\u5fd7\u5e76\u5bfc\u51fa\u4e3aExcel\uff08\u672a\u5199\uff09\uff0c\u672c\u6587\u9700\u8981\u540c\u4e00\u5c40\u57df\u7f51\u73af\u5883\uff0c\u516c\u7f51\u8bbf\u95ee\u9700\u8981\u4f7f\u7528\u516c\u7f51IP\u6216\u7a7f\u900f\u6ce8\u610f\uff1aLinux\u4e0b\u521b\u5efa\u65b0\u6587\u4ef6\u8bf7\u5728\u4f7f\u7528\u524d\u786e\u8ba4\u6743\u9650\u3002_ubuntu mosquitto\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/38413.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-20T01:21:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250520012104-682bd90002f0f.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/38413.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/38413.html\",\"name\":\"Ubuntu\u5b89\u88c5Mosquitto\uff0c\u505a\u4e00\u4e2a\u81ea\u5df1\u7684\u7269\u8054\u7f51\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-20T01:21:06+00:00\",\"dateModified\":\"2025-05-20T01:21:06+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/38413.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/38413.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/38413.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ubuntu\u5b89\u88c5Mosquitto\uff0c\u505a\u4e00\u4e2a\u81ea\u5df1\u7684\u7269\u8054\u7f51\u670d\u52a1\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ubuntu\u5b89\u88c5Mosquitto\uff0c\u505a\u4e00\u4e2a\u81ea\u5df1\u7684\u7269\u8054\u7f51\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/38413.html","og_locale":"zh_CN","og_type":"article","og_title":"Ubuntu\u5b89\u88c5Mosquitto\uff0c\u505a\u4e00\u4e2a\u81ea\u5df1\u7684\u7269\u8054\u7f51\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb535\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf10\u6b21\u3002Ubuntu\u5b89\u88c5Mosquitto\u670d\u52a1\u5668\u5e76\u5bfc\u51fa\u8fd0\u884c\u65e5\u5fd7\uff0cweb\u67e5\u770b\u8fd0\u884c\u65e5\u5fd7\u5e76\u5bfc\u51fa\u4e3aExcel\uff08\u672a\u5199\uff09\uff0c\u672c\u6587\u9700\u8981\u540c\u4e00\u5c40\u57df\u7f51\u73af\u5883\uff0c\u516c\u7f51\u8bbf\u95ee\u9700\u8981\u4f7f\u7528\u516c\u7f51IP\u6216\u7a7f\u900f\u6ce8\u610f\uff1aLinux\u4e0b\u521b\u5efa\u65b0\u6587\u4ef6\u8bf7\u5728\u4f7f\u7528\u524d\u786e\u8ba4\u6743\u9650\u3002_ubuntu mosquitto","og_url":"https:\/\/www.wsisp.com\/helps\/38413.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-20T01:21:06+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250520012104-682bd90002f0f.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/38413.html","url":"https:\/\/www.wsisp.com\/helps\/38413.html","name":"Ubuntu\u5b89\u88c5Mosquitto\uff0c\u505a\u4e00\u4e2a\u81ea\u5df1\u7684\u7269\u8054\u7f51\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-20T01:21:06+00:00","dateModified":"2025-05-20T01:21:06+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/38413.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/38413.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/38413.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Ubuntu\u5b89\u88c5Mosquitto\uff0c\u505a\u4e00\u4e2a\u81ea\u5df1\u7684\u7269\u8054\u7f51\u670d\u52a1\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/38413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=38413"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/38413\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/38404"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=38413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=38413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=38413"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=38413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}