{"id":36768,"date":"2025-05-12T13:16:04","date_gmt":"2025-05-12T05:16:04","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/36768.html"},"modified":"2025-05-12T13:16:04","modified_gmt":"2025-05-12T05:16:04","slug":"stm32esp8266%e5%ae%9e%e7%8e%b0%e5%8d%95%e7%89%87%e6%9c%ba%e4%b8%8e%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%9a%84wifi%e9%80%9a%e4%bf%a1","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/36768.html","title":{"rendered":"STM32+esp8266\u5b9e\u73b0\u5355\u7247\u673a\u4e0e\u670d\u52a1\u5668\u7684WiFi\u901a\u4fe1"},"content":{"rendered":"<h3>\u8bbe\u8ba1\u6982\u8ff0&#xff1a;\u00a0 \u00a0 \u00a0 \u00a0\u00a0<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u672c\u5b9e\u9a8c\u91c7\u7528STM32F1\u7cfb\u5217&#043;esp8266 01s\u6a21\u5757&#xff0c;\u91c7\u7528HAL\u5e93\u5f00\u53d1\u3002\u4e3b\u63a7\u82af\u7247\u54ea\u4e2a\u7cfb\u5217\u548c\u578b\u53f7\u90fd\u53ef\u4ee5&#xff0c;\u53ea\u8981\u6709\u4e24\u4e2a\u4e32\u53e3&#xff08;UART\u6216\u8005USART&#xff0c;\u4ee5\u4e0b\u7edf\u79f0\u4e32\u53e3&#xff09;\u5c31\u884c\u3002\u628a\u4e32\u53e3\u914d\u7f6e\u597d&#xff0c;\u00a0 \u53ef\u4ee5\u76f4\u63a5\u79fb\u690d\u4f7f\u7528\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"444\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512051602-6821841295ceb.png\" width=\"450\" \/><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5f88\u591a\u535a\u4e3b\u90fd\u5199\u8fc7STM32&#043;esp8266\u7684\u6587\u7ae0&#xff0c;\u4f46\u5927\u90e8\u5206\u90fd\u53ea\u8bb2\u4e00\u79cd\u7528\u6cd5\u6216\u8005\u4ecb\u7ecd\u7684\u6bd4\u8f83\u6a21\u7cca&#xff0c;\u7ffb\u4e86\u5f88\u591a\u90fd\u6ca1\u770b\u61c2\u5230\u5e95\u8981\u600e\u4e48\u64cd\u4f5c\u8fd9\u4e2aWiFi\u6a21\u5757&#xff0c;\u4e8e\u662f\u5c31\u81ea\u5df1\u57cb\u5934\u6252\u4e86\u51e0\u5929\u5b98\u65b9\u6587\u6863&#xff0c;\u5927\u81f4\u7406\u4e86\u4e00\u4e2a\u901a\u7528\u6a21\u578b&#xff0c;\u628a\u6a21\u5757\u7684\u5de5\u4f5c\u6a21\u5f0f\u5206\u4e3a5\u4e2a&#xff0c;WiFi\u72b6\u6001\u5206\u4e3a3\u4e2a\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"153\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512051602-68218412c0437.png\" width=\"413\" \/><\/p>\n<\/p>\n<p>\u00a0\u81f3\u4e8e\u4e3a\u4ec0\u4e48\u5206\u4e3a5\u79cd\u6a21\u5f0f&#xff0c;\u662f\u53c2\u8003\u4e86\u5b98\u65b9\u7684\u6d4b\u8bd5\u6587\u6863&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"172\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512051602-68218412cd84c.png\" width=\"244\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"550\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512051602-68218412d7b96.png\" width=\"594\" \/><\/p>\n<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728\u5f00\u59cb\u5199\u4ee3\u7801\u524d&#xff0c;\u6211\u5efa\u8bae\u5404\u4f4d\u5148\u7528esp-link&#xff08;\u56fa\u4ef6\u70e7\u5f55\u5668&#xff0c;\u6ca1\u6709\u5c31\u4e70\u4e00\u4e2a&#xff0c;\u4fbf\u5b9c&#xff0c;\u5b9e\u5728\u4e0d\u60f3\u8981\u4e5f\u884c&#xff0c;\u7528TTL\u8f6c\u4e32\u53e3&#xff09;\u63a5\u4e0a\u6a21\u5757&#xff0c;\u8fde\u63a5\u7535\u8111&#xff0c;\u7528\u4e32\u53e3\u628a\u6307\u4ee4\u719f\u6089\u4e00\u4e0b&#xff0c;\u628a\u8fd95\u79cd\u6a21\u5f0f\u8fc7\u4e00\u904d&#xff0c;\u6587\u6863\u5730\u5740&#xff1a;<\/p>\n<p><span class=\"link-card-box\"><span class=\"link-title\">4B-ESP8266__AT Command Examples__CN (espressif.com.cn)<\/span><span class=\"link-link\"><img decoding=\"async\" class=\"link-link-icon\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512051602-68218412ec01e.png\" \/>https:\/\/www.espressif.com.cn\/sites\/default\/files\/documentation\/4b-esp8266_at_command_examples_cn.pdf<\/span><\/span>\u8fd9\u6837\u6a21\u5757\u7684\u5927\u81f4\u5de5\u4f5c\u6d41\u7a0b\u5c31\u6e05\u695a\u4e86&#xff0c;\u4ee3\u7801\u5199\u8d77\u6765\u624d\u6761\u7406\u6e05\u6670\u3002<\/p>\n<h4><\/h4>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u56e0\u4e3a\u8981\u4f7f\u7528\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef&#xff0c;\u7535\u8111\u53ef\u4ee5\u4f7f\u7528NetAssist&#xff0c;\u8f6f\u4ef6\u5f88\u597d\u627e&#xff1b;\u624b\u673a\u7aef\u5e94\u7528\u5546\u5e97\u641cTCP&#xff0c;\u5927\u90e8\u5206\u90fd\u80fd\u7528&#xff0c;\u6700\u597d\u662f\u67094\u4e2a\u9009\u9879&#xff0c;TCP\u7684\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef&#xff0c;UDP\u7684\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5efa\u8bae\u5927\u5bb6\u7535\u8111\u7aef\u548c\u624b\u673a\u7aef\u914d\u5408\u4f7f\u7528&#xff0c;\u7535\u8111\u7aef\u5efa\u670d\u52a1\u5668&#xff0c;\u624b\u673a\u548cesp\u8fde&#xff1b;\u624b\u673a\u5efa\u670d\u52a1\u5668&#xff0c;\u7535\u8111\u548cesp\u8fde&#xff1b;esp\u5efa\u670d\u52a1\u5668&#xff0c;\u7535\u8111\u548c\u624b\u673a\u8fde\u3002<\/p>\n<\/p>\n<h3>\u4ee3\u7801\u8bbe\u8ba1\u6846\u67b6&#xff1a;<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4ee3\u7801\u6574\u4f53\u9700\u8981\u5bf93\u4e2a\u90e8\u5206\u8fdb\u884c\u7f16\u5199&#xff0c;\u4e32\u53e31&#xff0c;\u4e32\u53e32&#xff0c;esp\u6a21\u5757\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"31\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512051602-68218412f177d.png\" width=\"843\" \/><\/p>\n<h4>\u00a0\u4e32\u53e3&#xff1a;<\/h4>\n<p>\u7531\u4e8eHAL\u5e93\u6709\u56de\u8c03\u673a\u5236&#xff0c;\u4e32\u53e32\u7684\u4e2d\u65ad\u56de\u8c03\u51fd\u6570\u5c31\u653e\u5728\u4e86\u4e32\u53e31<\/p>\n<p>\u4e32\u53e31\u548c2\u5927\u81f4\u76f8\u540c&#xff0c;\u91c7\u7528\u6b63\u70b9\u539f\u5b50\u7684\u8bbe\u8ba1&#xff0c;\u6709\u7f13\u51b2\u6570\u7ec4\u548c\u63a5\u6536\u5b8c\u6210\u6807\u5fd7\u4f4d\u3002<\/p>\n<p>\u4e32\u53e32\u8981\u505a\u4e00\u70b9\u8c03\u6574&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"202\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512051603-6821841307f6e.png\" width=\"590\" \/><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5c06\u539f\u6765\u7684\u90e8\u5206\u6ce8\u91ca&#xff0c;\u589e\u52a0\u65b0\u7684\u63a5\u6536\u6761\u4ef6\u3002\u8fd9\u4e2a\u4e3b\u8981\u662f\u56e0\u4e3aesp\u7684AT\u6307\u4ee4\u5728\u672b\u5c3e\u8981\u52a0\u4e0a\u56de\u8f66\u6362\u884c\u624d\u80fd\u751f\u6548&#xff0c;\u6bcf\u6b21\u6a21\u5757\u8fd4\u56de\u7684\u6570\u636e\u4e0d\u77e5\u4e3a\u5565\u53c8\u4ee5\u56de\u8f66\u6362\u884c\u5f00\u59cb&#xff0c;\u7d22\u6027\u6211\u5c31\u76f4\u63a5\u4e22\u5f03\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u4e32\u53e3\u7684\u4ee3\u7801\u53ef\u4ee5\u4ece\u6b63\u70b9\u539f\u5b50\u7684\u4f8b\u7a0b\u4e2d\u62f7\u8d1d&#xff0c;\u90fd\u4e00\u6837\u3002\u6ce8\u610f\u8981\u7406\u89e3\u6e05\u695a\u63a5\u6536\u5b8c\u6210\u6807\u5fd7\u4f4d\u7684\u542b\u4e49&#xff0c;\u8fd9\u4e2a\u6807\u5fd7\u4f4d\u7684\u4e0d\u540cbit\u8bbe\u8ba1\u5f88\u5de7\u5999&#xff0c;\u7528\u597d\u4e86\u4e8b\u534a\u529f\u500d\u3002<\/p>\n<\/p>\n<h4>esp8266&#xff1a;<\/h4>\n<h5>\u521d\u59cb\u5316\u51fd\u6570&#xff1a;<\/h5>\n<p>\/**<br \/>\n * &#064;brief       esp8266wifi\u6a21\u5757\u521d\u59cb\u5316<br \/>\n * &#064;param       RUNmode&#xff1a;1\u4e3a\u5355\u8fde\u63a5TCP&#xff0c;esp\u505a\u5ba2\u6237\u7aef;<br \/>\n *                       2\u4e3aUDP\u4f20\u8f93;<br \/>\n *                       3\u4e3aTCP\u900f\u4f20;<br \/>\n *                       4\u4e3aUDP\u900f\u4f20;<br \/>\n *                       5\u4e3a\u591a\u8fde\u63a5TCP&#xff0c;esp\u505a\u670d\u52a1\u5668;<br \/>\n * &#064;param       wifi_mode: 1\u4e3aStation \u6a21\u5f0f&#xff0c;\u8fde\u63a5\u5916\u90e8wifi<br \/>\n *                         2\u4e3aSoftAP \u6a21\u5f0f&#xff0c;\u5f00\u542f\u70ed\u70b9<br \/>\n *                         3\u4e3aSoftAP&#043;Station \u53cc\u6a21\u5f0f<br \/>\n * &#064;note        \u68c0\u6d4bIP\u662f\u5426\u83b7\u5f97&#xff1a;AT&#043;CIFSR<br \/>\n *              \u82e5\u8981\u66f4\u6362\u6a21\u5757\u4f7f\u7528\u65b9\u5f0f&#xff0c;\u91cd\u65b0\u8c03\u7528\u521d\u59cb\u5316\u5373\u53ef<br \/>\n *              \u6a21\u5757\u53ea\u6709\u5728RUNmode\u4e3a\u6a21\u5f0f5\u5f00\u542f\u670d\u52a1\u5668\u540e\u624d\u80fd\u4f5c\u4e3a\u670d\u52a1\u5668&#xff0c;\u5176\u4f59\u5747\u4e3aStation\u5ba2\u6237\u7aef<br \/>\n *<br \/>\n * &#064;retval      0\u4e3a\u9519\u8bef&#xff0c;1\u4e3a\u521d\u59cb\u5316\u5b8c\u6210<br \/>\n *\/<br \/>\nuint8_t esp8266_Init(uint8_t RUNmode,uint8_t wifi_mode) <\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a01\u3001\u5c31\u4ece\u521d\u59cb\u5316\u51fd\u6570\u5f00\u59cb&#xff0c;\u8fd9\u662f\u8fd9\u4e2aproject\u96c6\u6210\u5ea6\u6700\u9ad8\u7684\u51fd\u6570&#xff0c;\u8c03\u7528\u4e86\u6240\u6709\u5e95\u5c42\u51fd\u6570\u3002\u8fd9\u4e2a\u51fd\u6570\u7684\u903b\u8f91\u5c31\u662f\u6309\u7167\u53c2\u8003\u624b\u518c\u7ed9\u7684\u6307\u4ee4\u96c6&#xff0c;\u6839\u636e\u4f20\u53c2RUNmode\u7684\u503c&#xff0c;\u5206\u522b\u5bf9\u5e945\u79cd\u8fd0\u884c\u6a21\u5f0f\u8fdb\u884c\u521d\u59cb\u5316\u3002<\/p>\n<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 2\u3001 \u5f00\u5934\u5b9a\u4e49\u53d8\u91cf&#xff0c;\u8fdb\u884c\u5e38\u89c4\u914d\u7f6e&#xff0c;\u56e0\u4e3a\u53ef\u80fd\u6bcf\u6b21\u7528\u5230\u7684\u6a21\u5f0f\u4e0d\u540c&#xff0c;\u6240\u4ee5\u5728\u5f00\u5934\u52a0\u4e86\u6062\u590d\u51fa\u5382\u8bbe\u7f6e&#xff08;\u590d\u4f4d\u6a21\u5757&#xff0c;\u8fd9\u91cc\u7528\u7684\u51fd\u6570\u8c03\u7528&#xff09;&#xff0c;\u5173\u95ed\u56de\u663e\u548cIP\u663e\u793a\u770b\u4e2a\u4eba\u559c\u597d&#xff0c;\u56de\u663e\u5c31\u662f\u53d1\u9001\u6307\u4ee4\u540e&#xff0c;\u6a21\u5757\u4f1a\u5148\u8fd4\u56de\u6536\u5230\u7684\u6307\u4ee4&#xff0c;\u518d\u8fd4\u56de\u54cd\u5e94\u503c\u3002<\/p>\n<p>uint8_t ERROR_count&#061;0;\/\/ERROR_count\u7528\u4e8e\u8ba1\u6570\u9519\u8bef\u65f6\u7684\u5c1d\u8bd5\u6b21\u6570<br \/>\n    uint8_t esp_state&#061;esp8266_OK;\/\/\u83b7\u53d6\u5f53\u524d\u7684\u5de5\u4f5c\u6a21\u5f0f<br \/>\n    char temp1[MAX_temp_array];\/\/\u7528\u4e8e\u5b57\u7b26\u4e32\u8fde\u63a5<\/p>\n<p>    esp8266wifi_working_mode&#061;RUNmode;\/\/\u4fdd\u5b58\u5168\u5c40\u5de5\u4f5c\u6a21\u5f0f<br \/>\n    printf(&#034;\\\\r\\\\nESP8266wifi\u6a21\u5757\u6b63\u5728\u521d\u59cb\u5316\\\\r\\\\n&#034;);<br \/>\n    esp8266wifi_reset();\/\/\u590d\u4f4d\u6a21\u5757       <\/p>\n<p>esp8266wifi_send_cmd(&#034;ATE0&#034;,0,normal_waittime);\/\/\u5173\u95ed\u56de\u663e<br \/>\n    esp8266wifi_send_cmd(&#034;AT&#043;CIPDINFO&#061;0&#034;,0,normal_waittime);\/\/\u5173\u95ed\u663e\u793aIP\u548c\u7aef\u53e3<\/p>\n<p>    esp8266wifi_set_wifi_mode(wifi_mode);\/\/\u8bbe\u7f6ewifi\u6a21\u5f0f <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0esp8266wifi_working_mode\u662f\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf&#xff0c;\u6709\u7684\u51fd\u6570\u9700\u8981\u7528\u5230\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8fd9\u91cc\u7684esp8266wifi_send_cmd\u51fd\u6570\u5148\u7b80\u5355\u4ecb\u7ecd\u4e00\u4e0b&#xff0c;\u4f5c\u7528\u662f\u901a\u8fc7\u4e32\u53e3\u53d1\u9001\u6570\u636e&#xff0c;\u653e\u5230\u540e\u9762\u7684\u5e95\u5c42\u8c03\u7528\u6765\u8bb2\u3002\u7b2c\u4e00\u4e2a\u4f20\u53c2\u662f\u8981\u53d1\u9001\u7684\u5b57\u7b26\u4e32&#xff1b;\u7b2c\u4e8c\u4e2a\u662f\u8981\u68c0\u67e5\u7684\u5b57\u7b26\u4e32&#xff0c;\u68c0\u67e5\u6a21\u5757\u6709\u6ca1\u6709\u53cd\u56de\u8fd9\u4e2a\u5b50\u4e32&#xff0c;\u8fd9\u91cc\u7ed90\u662f\u4e0d\u68c0\u67e5\u8fd4\u56de&#xff1b;\u7b2c\u4e09\u4e2a\u662f\u7b49\u5f85\u65f6\u95f4\u3002\u00a0<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u590d\u4f4d\u51fd\u6570&#xff1a;<\/p>\n<p>\/**<br \/>\n * &#064;brief       \u6062\u590d\u51fa\u5382\u8bbe\u7f6e<br \/>\n * &#064;param       \u65e0<br \/>\n * &#064;retval      \u65e0<br \/>\n *\/<br \/>\nvoid esp8266wifi_reset(void)<br \/>\n{<br \/>\n    printf(&#034;\u6b63\u5728\u590d\u4f4d&#8230;\\\\n&#034;);<br \/>\nesp8266wifi_send_cmd(&#034;AT&#043;RESTORE&#034;,0,normal_waittime);<br \/>\n    delay_ms(1000);<br \/>\n    printf(&#034;\u590d\u4f4d\u5b8c\u6210\\\\n&#034;);<br \/>\n} <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0esp8266wifi_set_wifi_mode(wifi_mode);\/\/\u8bbe\u7f6ewifi\u6a21\u5f0f\u662f\u4e00\u4e2a\u81ea\u5b9a\u4e49\u51fd\u6570&#xff0c;\u53d1\u9001AT&#043;CWMODE\u6307\u4ee4\u3002<\/p>\n<p>\/**<br \/>\n * &#064;brief       \u8bbe\u7f6eWi-Fi\u6a21\u5f0f<br \/>\n * &#064;param       mode: 1\u4e3aStation \u6a21\u5f0f&#xff0c;\u5ba2\u6237\u7aef<br \/>\n *                    2\u4e3aSoftAP \u6a21\u5f0f&#xff0c;\u5f00\u542f\u70ed\u70b9<br \/>\n *                    3\u4e3aSoftAP&#043;Station \u53cc\u6a21\u5f0f<br \/>\n * &#064;retval      \u65e0<br \/>\n *\/<br \/>\nvoid esp8266wifi_set_wifi_mode(uint8_t mode)<br \/>\n{<br \/>\n    switch (mode)<br \/>\n    {<br \/>\n        case 1:<br \/>\n            esp8266wifi_send_cmd(&#034;AT&#043;CWMODE&#061;1&#034;,0,normal_waittime);<br \/>\n            break;<br \/>\n        case 2:<br \/>\n            esp8266wifi_send_cmd(&#034;AT&#043;CWMODE&#061;2&#034;,0,normal_waittime);<br \/>\n            break;<br \/>\n        case 3:<br \/>\n            esp8266wifi_send_cmd(&#034;AT&#043;CWMODE&#061;3&#034;,0,normal_waittime);<br \/>\n            break;<br \/>\n        default:<br \/>\n            break;<br \/>\n    }<br \/>\n} <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u00a0<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 3\u3001\u63a5\u4e0b\u6765\u5c31\u662f\u5224\u65adWIFI\u6a21\u5f0f&#xff0c;\u5f00\u542f\u70ed\u70b9\u8fd8\u662f\u8fde\u63a5WIFI&#xff0c;sprintf\u7684\u4f5c\u7528\u662f\u5408\u5e76\u5b57\u7b26\u4e32&#xff0c;\u53ef\u4ee5\u767e\u5ea6\u7528\u6cd5&#xff0c;\u4f20\u53c2\u7528\u5230\u7684\u4e24\u4e2a\u5b8f\u5b9a\u4e49&#xff0c;\u5c31\u662fWiFi\u540d\u5b57\u548c\u5bc6\u7801\u3002<\/p>\n<p>if(wifi_mode&#061;&#061;wifi_mode_Station)\/\/\u8fde\u63a5WIFI<br \/>\n    {<br \/>\n        sprintf(temp1,&#034;AT&#043;CWJAP&#061;\\\\&#034;%s\\\\&#034;,\\\\&#034;%s\\\\&#034;&#034;,SoftAP_WIFI_SSID,SoftAP_WIFI_PASSWORD);<br \/>\n        ERROR_count&#061;0;<br \/>\n        printf(&#034;\\\\r\\\\n\u6b63\u5728\u8fde\u63a5WIFI&#8230;\\\\r\\\\n&#034;);<br \/>\n        do\/\/\u8fde\u63a5WIFI<br \/>\n        {<br \/>\n            esp_state&#061;esp8266wifi_send_cmd(temp1,&#034;OK&#034;,MAX_waittime);<br \/>\n            if(esp_state&#061;&#061;esp8266_ERROR)<br \/>\n            {<br \/>\n                ERROR_count&#043;&#043;;<br \/>\n                delay_ms(1000);\/\/\u5ef6\u65f61s<br \/>\n                if(ERROR_count&#061;&#061;esp8266_Init_Try_Time)<br \/>\n                {<br \/>\n                    printf(&#034;\\\\r\\\\n\u8fde\u63a5WIFI\u5931\u8d25\\\\r\\\\n&#034;);<br \/>\n                    return esp8266_ERROR;<br \/>\n                }<br \/>\n            }<br \/>\n        }while(esp_state!&#061;esp8266_OK);<br \/>\n        printf(&#034;\\\\r\\\\nWIFI\u8fde\u63a5\u6210\u529f\\\\r\\\\n&#034;);<br \/>\n    } <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8fd9\u91cc\u7528\u4e86\u4e00\u4e2ado-while\u8bed\u53e5\u7528\u6765\u5728\u8fde\u63a5\u5931\u8d25\u65f6\u5c1d\u8bd5\u91cd\u65b0\u8fde\u63a5&#xff0c;\u4e00\u5b9a\u6b21\u6570&#xff08;esp8266_Init_Try_Time&#xff0c;\u6211\u7528\u76845\u6b21&#xff09;\u540e\u653e\u5f03\u5e76\u7ed3\u675f\u521d\u59cb\u5316\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8fd8\u6709\u4e0b\u9762\u7684else\u90e8\u5206\u6ca1\u6709\u653e&#xff0c;\u4ee3\u7801\u903b\u8f91\u540c\u7406&#xff0c;\u7528\u4e8e\u8bbe\u7f6eesp\u7684WiFi\u540d\u5b57\u548c\u5bc6\u7801&#xff0c;\u53ea\u8981\u4fee\u6539\u5bf9\u5e94\u7684sprintf\u5c31\u884c&#xff0c;\u4e0d\u505a\u8bb2\u89e3\u3002<\/p>\n<\/p>\n<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a04\u3001\u63a5\u4e0b\u6765\u5c31\u662f\u6a21\u5f0f1&#xff0c;\u6839\u636e\u624b\u518c\u6307\u4ee4&#xff0c;\u7b2c\u4e00\u6b65<span style=\"color:#404040\">\u914d\u7f6e<\/span><span style=\"color:#404040\"> WiFi <\/span><span style=\"color:#404040\">\u6a21\u5f0f\u6211\u653e\u5230\u4e86\u521d\u59cb\u5316\u51fd\u6570\u7684\u5f00\u5934&#xff0c;\u56e0\u4e3a\u6bcf\u4e2a\u6a21\u5f0f\u90fd\u9700\u8981\u8bbe\u7f6e&#xff1b;\u7b2c\u4e8c\u90e8\u8fde\u63a5\u8def\u7531\u5668\u5728\u4e0a\u4e00\u5f20\u56fe\u505a\u4e86\u8bb2\u89e3&#xff1b;\u7b2c\u4e09\u6b65\u67e5\u8be2\u5730\u5740\u8fd9\u91cc\u4e0d\u9700\u8981&#xff1b;\u7b2c\u56db\u6b65\u8fde\u63a5\u670d\u52a1\u5668&#xff0c;\u4e5f\u5c31\u662f\u8fd9\u91cc\u4ee3\u7801\u6240\u5c55\u793a\u7684\u3002<\/span><\/p>\n<p>if(RUNmode&#061;&#061;mode_1_TCP_Client)\/\/\u5355\u8fde\u63a5TCP,esp\u505aStation\u5ba2\u6237\u7aef<br \/>\n    {<br \/>\n        esp8266wifi_set_trans_mode(0);\/\/\u8bbe\u7f6e\u4e3a\u666e\u901a\u4f20\u8f93\u6a21\u5f0f&#xff0c;\u975e\u900f\u4f20<br \/>\n        esp8266wifi_send_cmd(&#034;AT&#043;CIPMUX&#061;0&#034;,0,normal_waittime);\/\/\u5355\u8fde\u63a5\u6a21\u5f0f<br \/>\n        sprintf(temp1,&#034;AT&#043;CIPSTART&#061;\\\\&#034;TCP\\\\&#034;,\\\\&#034;%s\\\\&#034;,%s&#034;,esp8266wifi_TCP_IP,esp8266wifi_TCP_PORT);<br \/>\n        ERROR_count&#061;0;<br \/>\n        printf(&#034;\\\\r\\\\n\u6b63\u5728\u8fde\u63a5\u670d\u52a1\u5668&#8230;\\\\r\\\\n&#034;);<br \/>\n        do\/\/esp\u4f5c\u4e3a\u5ba2\u6237\u7aef\u8fde\u63a5\u5230\u670d\u52a1\u5668<br \/>\n        {<br \/>\n            esp_state&#061;esp8266wifi_send_cmd(temp1,&#034;CONNECTED&#034;,MAX_waittime);<br \/>\n            if(esp_state&#061;&#061;esp8266_ERROR)<br \/>\n            {<br \/>\n                ERROR_count&#043;&#043;;<br \/>\n                delay_ms(1000);<br \/>\n                if(ERROR_count&#061;&#061;esp8266_Init_Try_Time)<br \/>\n                {<br \/>\n                    printf(&#034;\\\\r\\\\n\u8fde\u63a5\u5230\u670d\u52a1\u5668\u5931\u8d25\\\\r\\\\n&#034;);<br \/>\n                    return esp8266_ERROR;<br \/>\n                }<br \/>\n            }<br \/>\n        }while(esp_state!&#061;esp8266_OK);<br \/>\n        printf(&#034;\\\\r\\\\n\u6210\u529f\u8fde\u63a5\u5230\u670d\u52a1\u5668\\\\r\\\\n&#034;);<br \/>\n    } <\/p>\n<p><span style=\"color:#404040\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5176\u4e2desp8266wifi_set_trans_mode(0);\/\/\u8bbe\u7f6e\u4e3a\u666e\u901a\u4f20\u8f93\u6a21\u5f0f\u662f\u4e00\u4e2a\u81ea\u5b9a\u4e49\u51fd\u6570&#xff1a;<\/span><\/p>\n<p>\/**<br \/>\n * &#064;brief       \u8bbe\u7f6e\u4f20\u8f93\u6a21\u5f0f<br \/>\n * &#064;param       mode: 0\u4e3a\u666e\u901a\u4f20\u8f93\u6a21\u5f0f<br \/>\n  *                  1\u4e3a\u900f\u4f20\u6a21\u5f0f&#xff0c;\u4ec5\u2f40\u6301 TCP \u5355\u8fde\u63a5\u548c UDP \u56fa\u5b9a\u901a\u4fe1\u5bf9\u7aef\u7684\u60c5\u51b5<br \/>\n * &#064;retval      \u65e0<br \/>\n *\/<br \/>\nvoid esp8266wifi_set_trans_mode(uint8_t mode)<br \/>\n{<br \/>\n    switch (mode)<br \/>\n    {<br \/>\n        case 0:<br \/>\n            esp8266wifi_send_cmd(&#034;AT&#043;CIPMODE&#061;0&#034;,0,normal_waittime);<br \/>\n            break;<br \/>\n        case 1:<br \/>\n            esp8266wifi_send_cmd(&#034;AT&#043;CIPMODE&#061;1&#034;,0,normal_waittime);<br \/>\n            break;<br \/>\n        default:<br \/>\n            break;<br \/>\n    }<br \/>\n} <\/p>\n<p><span style=\"color:#404040\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728\u7535\u8111\u4e32\u53e3\u6d4b\u8bd5\u8fc7\u7a0b\u4e2d&#xff0c;\u7ecf\u5e38\u4f1a\u9047\u5230\u67d0\u4e00\u914d\u7f6e\u672a\u66f4\u6539&#xff0c;\u4ee5\u81f3\u4e8e\u5f53\u524d\u914d\u7f6e\u5931\u8d25\u7684\u95ee\u9898&#xff0c;\u56e0\u4e3a\u5355\u7247\u673a\u60f3\u8981\u52a0\u5165\u8fd9\u4e00\u8bc6\u522b\u80fd\u529b\u6bd4\u8f83\u7e41\u7410&#xff0c;\u6240\u4ee5\u6211\u5728\u6bcf\u79cd\u6a21\u5f0f\u914d\u7f6e\u65f6\u90fd\u52a0\u5165\u4e86\u5bf9\u5e94\u7684\u524d\u7f6e\u6761\u4ef6&#xff0c;\u624b\u518c\u6ca1\u5199&#xff0c;\u6211\u8fd9\u91cc\u8bbe\u7f6e\u4e00\u904d\u4ee5\u9632\u4e07\u4e00\u3002<\/span><\/p>\n<p><span style=\"color:#404040\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u540e\u9762\u76844\u79cd\u6a21\u5f0f\u539f\u7406\u4e5f\u90fd\u662f\u4e00\u6837&#xff0c;\u53ef\u4ee5\u6309\u7740\u6211\u7684\u65b9\u6cd5&#xff0c;\u6839\u636e\u624b\u518c\u7684\u914d\u7f6e\u6307\u5bfc\u6765\u5199\u3002\u521d\u59cb\u5316\u65f6\u53ea\u9700\u8981\u914d\u7f6e\u5230\u8fde\u63a5\u670d\u52a1\u5668&#xff0c;\u8fd9\u6837esp\u5c31\u53ef\u4ee5\u63a5\u6536\u6570\u636e\u4e86&#xff0c;\u53d1\u9001\u6570\u636e\u548c\u63a5\u6536\u6570\u636e\u4f5c\u4e3a\u4e00\u4e2a\u5355\u72ec\u7684\u6a21\u5757\u53bb\u8c03\u7528\u3002<\/span><\/p>\n<\/p>\n<h5><span style=\"color:#404040\">esp\u53d1\u9001\u6570\u636e&#xff1a;<\/span><\/h5>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u624b\u518c\u4e2d\u6bcf\u79cd\u6a21\u5f0f\u7684\u53d1\u9001\u6570\u636e\u90e8\u5206&#xff0c;\u9664\u4e86\u900f\u4f20&#xff0c;\u90fd\u662f\u8981\u5148\u6307\u5b9a\u6570\u636e\u957f\u5ea6&#xff0c;\u518d\u53d1\u9001\u6570\u636e\u3002\u4f46\u662f\u5355\u8fde\u63a5\u548c\u591a\u8fde\u63a5\u7684\u6307\u4ee4\u4e5f\u4e0d\u592a\u4e00\u6837&#xff0c;\u6240\u4ee5\u6211\u5199\u4e865\u79cd\u6a21\u5f0f\u7684\u53d1\u9001\u51fd\u6570&#xff0c;\u518d\u7528\u4e00\u4e2a\u5c01\u88c5\u540e\u7684\u53d1\u9001\u51fd\u6570&#xff0c;\u6839\u636e\u521d\u59cb\u5316\u65f6\u7684\u8bbe\u7f6e\u81ea\u52a8\u8c03\u7528\u5bf9\u5e94\u7684\u51fd\u6570\u3002<\/p>\n<p>1\u3001\u6a21\u5f0f2UDP\u6bd4\u8f83\u6709\u4ee3\u8868\u6027&#xff1a;<\/p>\n<p>\/\/\u6a21\u5f0f2<br \/>\n\/**<br \/>\n * &#064;brief       UDP&#xff0c;esp\u53d1\u9001\u6570\u636e\u5230\u8fdc\u7aef<br \/>\n * &#064;param       *data: \u8981\u53d1\u9001\u7684\u6570\u636e<br \/>\n * &#064;retval      state&#xff1a;\u8fd4\u56de1\u53d1\u9001\u6210\u529f&#xff0c;0\u5219\u5931\u8d25<br \/>\n *\/<br \/>\nuint8_t mode_2_send_date(char *Data)<br \/>\n{<br \/>\n    uint8_t state &#061; esp8266_OK;\/\/\u53d1\u9001\u6210\u529f\u72b6\u6001<br \/>\n    char str1[MAX_temp_array];  <\/p>\n<p>    \/\/\u53d1\u9001\u6570\u636e<br \/>\n    if(esp8266wifi_UDP_mode&#061;&#061;0)\/\/\u8fdc\u7aef\u56fa\u5b9a<br \/>\n    {<br \/>\n        sprintf(str1,&#034;AT&#043;CIPSEND&#061;%d,%d&#034;,esp8266wifi_UDP_Link_ID,strlen(Data)&#043;2);<br \/>\n    }<br \/>\n    else if(esp8266wifi_UDP_mode&#061;&#061;2)\/\/\u8fdc\u7aef\u53ef\u53d8<br \/>\n    {<br \/>\n        sprintf(str1,&#034;AT&#043;CIPSEND&#061;%d&#034;,strlen(Data)&#043;2);<br \/>\n    }<\/p>\n<p>    esp8266wifi_send_cmd(str1,&#034;&gt;&#034;,normal_waittime);<br \/>\n    state&#061;esp8266wifi_send_cmd(Data,&#034;SEND OK&#034;,MAX_waittime);<br \/>\n    return state;<br \/>\n} <\/p>\n<p>\u00a02\u3001\u5c01\u88c5\u51fd\u6570&#xff1a;<\/p>\n<p>\/**<br \/>\n * &#064;brief       esp8266\u6a21\u5757\u53d1\u9001\u6570\u636e<br \/>\n * &#064;param       *data&#xff1a;\u8981\u53d1\u9001\u7684\u6570\u636e<br \/>\n * &#064;param       ID&#xff1a;\u8981\u6536\u5230\u6570\u636e\u7684ID\u53f7<br \/>\n * &#064;retval      result&#xff1a;\u8fd4\u56de1\u53d1\u9001\u6210\u529f&#xff0c;0\u5219\u5931\u8d25<br \/>\n *\/<br \/>\nuint8_t esp8266_send_data(char *data,uint8_t ID)<br \/>\n{<br \/>\nuint8_t result&#061;esp8266_OK, mode &#061; esp8266wifi_working_mode;<br \/>\n    switch (mode)<br \/>\n    {<br \/>\n        case 1:<br \/>\n            result &#061; mode_1_send_date(data);<br \/>\n            break;<br \/>\n        case 2:<br \/>\n            result &#061; mode_2_send_date(data);<br \/>\n            break;<br \/>\n        case 3:<br \/>\n        case 4:<br \/>\n            mode_3_and_4_send_date(data);<br \/>\n            break;<br \/>\n        case 5:<br \/>\n            result &#061; mode_5_send_date(data,ID);<br \/>\n            break;<br \/>\n        default:<br \/>\n            break;<br \/>\n    }<br \/>\nreturn result;<br \/>\n} <\/p>\n<p>\u00a03\u3001\u900f\u4f20\u6a21\u5f0f\u7684\u53d1\u9001\u4e0d\u592a\u4e00\u6837&#xff0c;\u9700\u8981\u8fdb\u5165\u900f\u4f20\u53d1\u9001\u72b6\u6001&#xff0c;\u53d1\u9001AT&#043;CIPSEND\u540e&#xff0c;\u6a21\u5757\u4f1a\u8fd4\u56de\u4e00\u4e2a\u7b26\u53f7\u201c&gt;\u201d&#xff0c;\u8fd9\u65f6\u4e0d\u9700\u8981\u6307\u5b9a\u957f\u5ea6&#xff0c;\u76f4\u63a5\u8f93\u5165\u8981\u53d1\u9001\u7684\u6570\u636e\u3002\u60f3\u8981\u9000\u51fa\u900f\u4f20\u72b6\u6001&#xff0c;\u9700\u8981\u53d1\u9001\u201c&#043;&#043;&#043;\u201d&#xff0c;\u5177\u4f53\u7ec6\u8282\u67e5\u770b\u624b\u518c\u3002\u8981\u4f7f\u7528\u8fd9\u4e24\u4e2a\u51fd\u6570\u65f6&#xff0c;\u5728\u900f\u4f20\u6a21\u5f0f\u521d\u59cb\u5316\u7ed3\u675f\u540e&#xff0c;\u4e3b\u51fd\u6570\u8c03\u7528\u5373\u53ef\u3002<\/p>\n<p>\/**<br \/>\n * &#064;brief       \u5f00\u542f\u900f\u4f20\u53d1\u9001<br \/>\n * &#064;param       \u65e0<br \/>\n * &#064;note        \u4ec5\u2f40\u6301 TCP \u5355\u8fde\u63a5\u548c UDP \u56fa\u5b9a\u901a\u4fe1\u5bf9\u7aef\u7684\u60c5\u51b5<br \/>\n * &#064;retval      state&#xff1a;\u8fd4\u56de1\u6210\u529f&#xff0c;0\u5219\u5931\u8d25<br \/>\n *\/<br \/>\nvoid esp8266_start_trans(void)<br \/>\n{<br \/>\nesp8266wifi_send_cmd(&#034;AT&#043;CIPSEND&#034;,&#034;&gt;&#034;,MAX_waittime);<br \/>\n}<\/p>\n<p>\/**<br \/>\n * &#064;brief       \u9000\u51fa\u900f\u4f20\u53d1\u9001<br \/>\n * &#064;param       \u65e0<br \/>\n * &#064;retval      result&#xff1a;\u8fd4\u56de1\u53d1\u9001\u6210\u529f&#xff0c;0\u5219\u5931\u8d25<br \/>\n *\/<br \/>\nuint8_t esp8266_quit_trans(void)<br \/>\n{<br \/>\nuint8_t result&#061;esp8266_OK;<br \/>\nesp8266wifi_send_string(&#034;&#043;&#043;&#043;&#034;);<br \/>\ndelay_ms(1000);<br \/>\nresult&#061;esp8266wifi_send_cmd(&#034;AT&#034;,&#034;OK&#034;,MAX_waittime);<br \/>\nif(!result)<br \/>\nprintf(&#034;quit_trans failed!&#034;);<br \/>\nelse<br \/>\nprintf(&#034;quit_trans success!&#034;);<br \/>\nreturn result;<br \/>\n} <\/p>\n<h5>esp\u63a5\u6536\u6570\u636e&#xff1a;<\/h5>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5728\u4e32\u53e3\u53d1\u9001\u6570\u636e\u65f6\u53ef\u4ee5\u770b\u5230&#xff0c;\u4f7f\u7528\u975e\u900f\u4f20\u6a21\u5f0f\u4e0b\u7684\u4fe1\u606f\u4f20\u8f93&#xff0c;esp\u5728\u63a5\u6536\u5230\u6570\u636e\u540e\u4f1a\u5411\u4e32\u53e3\u8fd4\u56de&#043;IPD&#xff0c;<span style=\"color:#404040\">&lt;link ID&gt;&#xff0c;\u6570\u636e\u957f\u5ea6&#xff1a;\u6570\u636e\u3002\u5728\u591a\u8fde\u63a5\u4e0b\u624d\u6709&lt;link ID&gt;\u3002\u5728\u900f\u4f20\u6a21\u5f0f\u4e0b\u76f4\u63a5\u53d6\u51fa\u4e32\u53e3\u7f13\u51b2\u6570\u7ec4&#xff0c;\u5728\u5176\u4ed6\u6a21\u5f0f\u4e0b\u505a\u76f8\u5e94\u7684\u6570\u636e\u622a\u53d6\u3002<\/span><\/p>\n<p>\/**<br \/>\n * &#064;brief       \u63a5\u6536\u6570\u636e\u5904\u7406&#xff0c;\u5bf9esp8266\u8fd4\u56de\u7684\u6570\u636e\u8fdb\u884c\u89e3\u7801,\u5e76\u6e05\u9664\u4e32\u53e3\u63a5\u6536\u5b8c\u6210\u6807\u5fd7\u4f4d<br \/>\n * &#064;param       *true_data&#xff1a;\u63a5\u6536\u5230\u7684\u6709\u6548\u6570\u636e<br \/>\n * &#064;note        \u4ee5\u4e0b\u662fesp8266\u8fd4\u56de\u6570\u636e\u7684HEX\u663e\u793a\u4e0e16\u8fdb\u5236\u663e\u793a,\u4e32\u53e3\u63a5\u6536\u6570\u636e\u65f6&#xff0c;\u5df2\u5728\u4e32\u53e3\u63a5\u6536\u4e2d\u65ad\u4e2d\u6ee4\u9664\u5f00\u5934\u76840D 0A<br \/>\n *<br \/>\n *              &#043;IPD,4:qq<br \/>\n *              0D 0A      2B 49 50 44 2C(,) 34 3A(:) 71 71      0D 0A<br \/>\n *<br \/>\n *              &#043;IPD,0,4:qq<br \/>\n *              0D 0A      2B 49 50 44 2C(,) 30 2C(,) 34 3A(:) 71 71       0D 0A<br \/>\n *<br \/>\n * &#064;retval      ID:\u53d1\u9001\u6570\u636e\u7684ID<br \/>\n *\/<br \/>\nuint8_t esp8266_receive_data(char *true_data,uint8_t old_date[])<br \/>\n{<br \/>\n    uint8_t ID&#061;0;\/\/\u591a\u8fde\u63a5\u6a21\u5f0f\u7684ID\u53f7<br \/>\n    uint8_t date_byte&#061;5;\/\/\u9ed8\u8ba4\u4ece\u7b2c\u4e00\u4e2a\u9017\u53f7\u540e\u4e00\u4f4d\u5f00\u59cb&#xff0c;\u9017\u53f7\u4ee5\u524d\u7684\u201c&#043;IPD\u201d\u548c\u9017\u53f7\u90fd\u4e0d\u8981&#xff08;&#043;IPD,&#xff09;<br \/>\n    uint8_t j,mode &#061; esp8266wifi_working_mode;<br \/>\n    char temp[MAX_temp_array];<\/p>\n<p>    if((mode&#061;&#061;mode_3_TCP_transparent)||(mode&#061;&#061;mode_4_UDP_transparent))<br \/>\n    {<br \/>\n        sprintf(true_data,&#034;%s&#034;,(char *)old_date);<br \/>\n    }<br \/>\n    else<br \/>\n    {<br \/>\n        if(mode&#061;&#061;mode_5_TCP_Server)\/\/\u591a\u8fde\u63a5\u6a21\u5f0f<br \/>\n        {<br \/>\n            ID &#061; old_date[5];<br \/>\n        }<br \/>\n        while(old_date[date_byte]!&#061;0x3A)\/\/\u5192\u53f7(:)<br \/>\n        {<br \/>\n            date_byte&#043;&#043;;<br \/>\n        }<br \/>\n        date_byte&#043;&#043;;\/\/\u8df3\u8fc7\u5192\u53f7(:)<br \/>\n        while(old_date[date_byte]!&#061;&#039;\\\\0&#039;)<br \/>\n        {<br \/>\n            temp[j] &#061; old_date[date_byte];<br \/>\n            date_byte&#043;&#043;;<br \/>\n            j&#043;&#043;;<br \/>\n        }<br \/>\n        temp[j] &#061; &#039;\\\\0&#039;;\/\/\u7ed3\u675f\u7b26<br \/>\n        sprintf(true_data,&#034;%s&#034;,temp);<br \/>\n    }<br \/>\n    return ID;<br \/>\n} <\/p>\n<h5>\u5e95\u5c42\u51fd\u6570&#xff1a;<\/h5>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 1\u3001\u9996\u5148\u662f\u8c03\u7528\u7387\u6700\u9ad8\u7684stm32\u901a\u8fc7\u4e32\u53e3\u5411esp8266\u53d1\u9001\u6570\u636e\u51fd\u6570&#xff0c;\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u7684\u662f\u6709\u8fd4\u56de\u503c\u6821\u9a8c\u90e8\u5206&#xff0c;\u5982\u679c\u5f62\u53c2\u4f20\u503c0&#xff0c;\u5219\u4e0d\u8fdb\u884c\u6821\u9a8c\u3002waittime\u53c2\u6570\u7528\u4e8e\u7b49\u5f85\u6a21\u5757\u8fd4\u56de\u7684\u65f6\u95f4&#xff0c;\u6709\u65b0\u6570\u636e\u8fd4\u56de\u5219\u5237\u65b0\u7b49\u5f85\u65f6\u95f4\u3002<\/p>\n<p>\/**<br \/>\n * &#064;brief       \u5411esp8266wifi\u53d1\u9001\u6307\u4ee4,\u81ea\u52a8\u52a0\u4e0a\u56de\u8f66\u6362\u884c<br \/>\n * &#064;param       *cmd: \u8981\u53d1\u9001\u7684\u6307\u4ee4<br \/>\n *              *expect: \u671f\u671b\u6307\u4ee4&#xff0c;\u68c0\u67e5\u6a21\u5757\u8fd4\u56de\u503c&#xff0c;\u67e5\u770b\u6307\u4ee4\u6267\u884c\u60c5\u51b5,\u82e5\u4e0d\u68c0\u67e5&#xff0c;\u8c03\u7528\u65f6\u7ed90&#xff08;\u4e0d\u5e26\u5f15\u53f7&#xff09;<br \/>\n *              waittime: \u7b49\u5f85\u6570\u636e\u63a5\u6536\u65f6\u5e38(ms)&#xff0c;\u7b49\u5f85\u6a21\u5757\u56de\u5e94\u7684\u6700\u5927\u65f6\u95f4<br \/>\n * &#064;retval      state&#xff1a;\u5e94\u7b54\u6b63\u786e\u8fd4\u56de1&#xff0c;0\u5219\u5931\u8d25<br \/>\n *\/<br \/>\nuint8_t esp8266wifi_send_cmd(char *cmd,uint8_t *expect,int waittime)<br \/>\n{<br \/>\nuint8_t state&#061;0;<br \/>\n    int waittime_old&#061;waittime;<br \/>\n    char esp8_rx_data[MAX_temp_array];<br \/>\n    char temp[MAX_temp_array];         <\/p>\n<p>    esp8266wifi_rx_sta&#061;0;<br \/>\n    sprintf(temp,&#034;%s\\\\r\\\\n&#034;,cmd);<br \/>\nesp8266wifi_send_string(temp);<br \/>\n    while ((esp8266wifi_USART-&gt;SR &amp; 0X40) &#061;&#061; 0);<br \/>\nif(waittime)<br \/>\n{<br \/>\nwhile(&#8211;waittime)<br \/>\n{<br \/>\ndelay_ms(1);<br \/>\nif(esp8266wifi_rx_sta&amp;0X8000)<br \/>\n{<br \/>\n                waittime&#061;waittime_old;<br \/>\n                sprintf(esp8_rx_data,&#034;%s&#034;,(char *)esp8266wifi_rx_buf);<br \/>\n                \/\/ printf(&#034;\u6a21\u5757\u8fd4\u56de:%s\\\\n&#034;,esp8_rx_data);<br \/>\n                if(expect)<br \/>\n                {<br \/>\n                    if(esp8266wifi_check_cmd(expect,esp8_rx_data))<br \/>\n                    {<br \/>\n                        state&#061;esp8266_OK;<br \/>\n                        printf(&#034;\u6a21\u5757\u5e94\u7b54\u6b63\u786e: %s\\\\n&#034;,expect);<br \/>\n                    }<br \/>\n                }<br \/>\nesp8266wifi_rx_sta&#061;0;\/\/\u6e05\u7a7a\u63a5\u6536\u5b8c\u6210\u6807\u5fd7\u4f4d<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>return state;<br \/>\n}  <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02\u3001\u5b57\u7b26\u4e32\u6821\u9a8c<\/p>\n<p>\/**<br \/>\n * &#064;brief       \u68c0\u6d4b\u5e94\u7b54\u6307\u4ee4<br \/>\n * &#064;param       *str: \u8981\u9a8c\u8bc1\u7684\u9884\u671f\u7ed3\u679c<br \/>\n * &#064;retval      *strx&#xff1a;\u4e0e\u9884\u671f\u76f8\u540c\u8fd4\u56de\u539f\u5b57\u7b26\u4e32&#xff0c;\u4e0d\u540c\u5219\u8fd4\u56deNULL<br \/>\n *\/<br \/>\nuint8_t* esp8266wifi_check_cmd(uint8_t *str_target,char *str_rx)<br \/>\n{<\/p>\n<p>    str_rx&#061;strstr((const char*)str_rx,(const char*)str_target);<\/p>\n<p>    return (uint8_t *)str_rx;<br \/>\n} <\/p>\n<p>3\u3001\u5173\u95ed\u8fde\u63a5\u51fd\u6570<\/p>\n<p>\/**<br \/>\n * &#064;brief       \u5173\u95ed\u5f53\u524d\u7684\u8fde\u63a5<br \/>\n * &#064;param       ID&#xff1a;\u591a\u8fde\u63a5\u5173\u95ed\u7684ID,\u9700\u8981\u5173\u95ed\u7684\u8fde\u63a5 ID \u53f7\u3002\u5f53 ID \u4e3a 5 \u65f6&#xff0c;\u5173\u95ed\u6240\u6709\u8fde\u63a5\u3002<br \/>\n *                  &#xff08;\u5f00\u542f server \u540e ID \u4e3a 5 \u2f46\u6548&#xff09;<br \/>\n *\/<br \/>\nvoid esp8266wifi_close_connect(uint8_t ID)<br \/>\n{<br \/>\n    uint8_t num&#061;esp8266wifi_working_mode;\/\/\u83b7\u53d6\u5f53\u524d\u7684\u5de5\u4f5c\u6a21\u5f0f<br \/>\n    if(num&#061;&#061;1)\/\/\u5173\u95ed\u5355\u8fde\u63a5<br \/>\n    {<br \/>\n        esp8266wifi_send_cmd(&#034;AT&#043;CIPCLOSE&#034;,0,MAX_waittime);\/\/\u5173\u95ed\u5355\u8fde\u63a5<br \/>\n    }<br \/>\n    else if(num&#061;&#061;2)\/\/\u5173\u95ed\u591a\u8fde\u63a5<br \/>\n    {<br \/>\n        char str1[20];<br \/>\n        sprintf(str1,&#034;AT&#043;CIPCLOSE&#061;%d&#034;,ID);<br \/>\n        esp8266wifi_send_cmd(str1,0,MAX_waittime);<br \/>\n    }<\/p>\n<p>} <\/p>\n<h4>esp8266.h&#xff1a;<\/h4>\n<p>#ifndef _8266wifi_H<br \/>\n#define _8266wifi_H<br \/>\n#include &#034;sys.h&#034;<br \/>\n#include &#034;usart2.h&#034;<\/p>\n<p>\/******************************************************************************************\/<br \/>\n\/* \u4e32\u53e3\u66f4\u6539&#xff0c;\u53ef\u4ee5\u6539\u4e3a\u4efb\u610f\u914d\u7f6e\u597d\u7684USART *\/<br \/>\n\/*\u4e32\u53e3&#xff0c;\u63a5\u6536\u5b8c\u6210\u6807\u5fd7\u4f4d&#xff0c;\u63a5\u6536\u7f13\u51b2&#xff0c;\u4e32\u53e3\u53d1\u9001\u51fd\u6570*\/<br \/>\n#define esp8266wifi_USART               USART2_UX<br \/>\n#define esp8266wifi_rx_sta              g_usart2_rx_sta<br \/>\n#define esp8266wifi_rx_buf              g_usart2_rx_buf<br \/>\n#define esp8266wifi_send_string         usart2_send_string<\/p>\n<p>\/******************************************************************************************\/<br \/>\n\/*\u670d\u52a1\u5668wifi \u4fe1\u606f*\/<br \/>\n\/*\u540d\u79f0&#xff0c;\u5bc6\u7801*\/<br \/>\n#define SoftAP_WIFI_SSID           &#034;1111111&#034;<br \/>\n#define SoftAP_WIFI_PASSWORD       &#034;11111111&#034;<\/p>\n<p>\/*esp8266\u4f5c\u4e3aStation\u5ba2\u6237\u7aefwifi \u4fe1\u606f*\/<br \/>\n\/*\u540d\u79f0&#xff0c;\u5bc6\u7801&#xff0c;\u901a\u9053&#xff0c;\u52a0\u5bc6\u65b9\u5f0f*\/<\/p>\n<p>\/*\u52a0\u5bc6\u65b9\u5f0f<br \/>\n0&#xff1a;OPEN<br \/>\n2&#xff1a;WPA_PSK<br \/>\n3&#xff1a;WPA2_PSK<br \/>\n4&#xff1a;WPA_WPA2_PSK<br \/>\n*\/<br \/>\n#define esp8266wifi_WIFI_SSID           &#034;NiDie&#034;<br \/>\n#define esp8266wifi_WIFI_PASSWORD       &#034;12345678&#034;<br \/>\n#define esp8266wifi_WIFI_channal        1<br \/>\n#define esp8266wifi_WIFI_encoding       4<\/p>\n<p>\/******************************************************************************************\/<br \/>\n\/*TCP\u4f20\u8f93\u4fe1\u606f*\/ <\/p>\n<p>\/*esp\u4f5c\u4e3aSoftAP\u670d\u52a1\u5668\u7684IP\u548c\u7aef\u53e3\u4fe1\u606f*\/<br \/>\n#define esp8266wifi_SoftAP_IP           &#034;192.168.4.1&#034;<br \/>\n#define esp8266wifi_SoftAP_PORT         &#034;8080&#034;<\/p>\n<p>\/*esp\u4f5c\u4e3aStation\u5ba2\u6237\u7aef&#xff0c;\u8981\u63a5\u5165\u7684\u670d\u52a1\u5668IP\u548c\u7aef\u53e3\u4fe1\u606f*\/<br \/>\n#define esp8266wifi_TCP_IP          &#034;192.168.1.111&#034;<br \/>\n#define esp8266wifi_TCP_PORT        &#034;8081&#034;<\/p>\n<p>\/******************************************************************************************\/<br \/>\n\/*UDP\u4f20\u8f93\u4fe1\u606f*\/<br \/>\n\/*UDP\u8fdc\u7aef\u548cTCP\u7684\u670d\u52a1\u5668\u4f7f\u7528\u540c\u4e00\u7ec4IP\u548c\u7aef\u53e3&#xff0c;\u65b9\u4fbf\u8c03\u8bd5*\/<br \/>\n\/*IP&#xff0c;\u8fdc\u7a0b\u7aef\u53e3&#xff0c;\u8fde\u63a5ID&#xff0c;\u672c\u5730\u7aef\u53e3&#xff0c;\u7aef\u53e3\u4fdd\u6301*\/<br \/>\n#define esp8266wifi_UDP_IP              &#034;192.168.1.113&#034;<br \/>\n#define esp8266wifi_UDP_SoftAP_PORT     &#034;8081&#034;<br \/>\n#define esp8266wifi_UDP_Link_ID          4<br \/>\n#define esp8266wifi_UDP_Local_PORT       &#034;1112&#034;<\/p>\n<p>#define esp8266wifi_UDP_mode             2<br \/>\n\/*<br \/>\n\u2023 0&#xff1a;\u6536\u5230\u6570\u636e\u540e&#xff0c;\u4e0d\u66f4\u6539\u8fdc\u7aef\u2f6c\u6807&#xff0c;\u9ed8\u8ba4\u503c\u4e3a 0<br \/>\n\u2023 1&#xff1a;\u6536\u5230\u6570\u636e\u540e&#xff0c;\u6539\u53d8\u2f00\u6b21\u8fdc\u7aef\u2f6c\u6807<br \/>\n\u2023 2&#xff1a;\u6536\u5230\u6570\u636e\u540e&#xff0c;\u6539\u53d8\u8fdc\u7aef\u2f6c\u6807<br \/>\n*\/<br \/>\n\/*0 \u8868\u793a\u5f53\u524d UDP \u4f20\u8f93\u5efa\u2f74\u540e&#xff0c;UDP \u8fdc\u7aef\u4e0d\u4f1a\u88ab\u5176\u4ed6\u8bbe\u5907\u66f4\u6539&#xff1b;\u5373\u4f7f\u6709\u5176\u4ed6\u8bbe\u5907\u901a\u8fc7 UDP \u534f\u8bae\u53d1\u6570\u636e\u5230<br \/>\nESP8266 UDP \u7aef\u2f1d 1112&#xff0c;ESP8266 \u7684\u7b2c 4 \u53f7 UDP \u4f20\u8f93\u7684\u8fdc\u7aef\u4e5f\u4e0d\u4f1a\u88ab\u66ff\u6362&#xff0c;\u4f7f\u2f64\u6307\u4ee4<br \/>\n\u201cAT&#043;CIPSEND&#061;4, X\u201d \u53d1\u9001\u6570\u636e&#xff0c;\u4ecd\u7136\u662f\u5f53\u524d\u56fa\u5b9a\u7684 PC \u7aef\u6536\u5230\u3002*\/<br \/>\n\/*2 \u8868\u793a\u5f53\u524d UDP \u4f20\u8f93\u5efa\u2f74\u540e&#xff0c;UDP \u4f20\u8f93\u8fdc\u7aef\u4ecd\u7136\u4f1a\u66f4\u6539&#xff1b;UDP \u4f20\u8f93\u8fdc\u7aef\u4f1a\u2f83\u52a8\u66f4\u6539\u4e3a\u6700\u8fd1\u2f00\u4e2a\u4e0e<br \/>\nESP8266 UDP \u901a\u4fe1\u7684\u8fdc\u7aef\u3002*\/<\/p>\n<p>\/*********************************************************************************************\/<br \/>\n\/*\u53d8\u91cf\u5b9a\u4e49*\/<br \/>\n\/*\u6570\u7ec4\u6700\u5927\u503c&#xff0c;\u7b49\u5f85\u56de\u590d\u65f6\u95f4,\u4e0d\u6821\u9a8c\u65f6\u7684\u7b49\u5f85\u65f6\u95f4*\/<br \/>\n#define MAX_temp_array 200<br \/>\n#define MAX_waittime 3000<br \/>\n#define normal_waittime 200<\/p>\n<p>\/*\u5de5\u4f5c\u6a21\u5f0f*\/<br \/>\nextern uint8_t esp8266wifi_working_mode;<\/p>\n<p>\/*\u521d\u59cb\u5316\u9519\u8bef\u65f6\u7684\u5c1d\u8bd5\u6b21\u6570*\/<br \/>\n#define esp8266_Init_Try_Time 5<br \/>\n\/*********************************************************************************************\/<br \/>\n\/*\u5e95\u5c42\u51fd\u6570*\/<\/p>\n<p>uint8_t* esp8266wifi_check_cmd(uint8_t *str_target,char *str_rx);<br \/>\nvoid esp8266wifi_reset(void);<br \/>\nvoid esp8266wifi_set_trans_mode(uint8_t mode);<br \/>\nvoid esp8266wifi_set_wifi_mode(uint8_t mode);<br \/>\nuint8_t esp8266wifi_send_cmd(char *cmd,uint8_t *expect,int waittime);<br \/>\nvoid esp8266wifi_close_connect(uint8_t ID);<\/p>\n<p>\/*5\u79cd\u6a21\u5f0f\u53d1\u9001\u6570\u636e,\u53ef\u5355\u72ec\u8c03\u7528*\/<br \/>\nuint8_t mode_1_send_date(char *data);<br \/>\nuint8_t mode_2_send_date(char *Data);<br \/>\nuint8_t mode_2_send_date_IP(char *Data,char *SendIP,uint16_t SendPort);<br \/>\nvoid mode_3_and_4_send_date(char *data);<br \/>\nuint8_t mode_5_send_date(char *Data,uint8_t Link_ID);<\/p>\n<p>\/*********************************************************************************************\/<br \/>\n\/*\u7528\u6237\u8c03\u7528\u51fd\u6570*\/<br \/>\nvoid esp8266_start_trans(void);<br \/>\nuint8_t esp8266_quit_trans(void);<br \/>\nuint8_t esp8266_Init(uint8_t RUNmode,uint8_t wifi_mode);<br \/>\nuint8_t esp8266_send_data(char *data,uint8_t ID);<br \/>\nuint8_t esp8266_receive_data(char *true_data,uint8_t old_date[]);<\/p>\n<p>\/*********************************************************************************************\/<br \/>\n\/*\u521d\u59cb\u5316\u51fd\u6570\u4f20\u53c2\u5b9a\u4e49*\/<\/p>\n<p>\/*\u5de5\u4f5c\u6a21\u5f0f\u5b9a\u4e49*\/<br \/>\n#define mode_1_TCP_Client 1<br \/>\n#define mode_2_UDP 2<br \/>\n#define mode_3_TCP_transparent 3<br \/>\n#define mode_4_UDP_transparent 4<br \/>\n#define mode_5_TCP_Server 5<\/p>\n<p>\/*wifi\u6a21\u5f0f:1\u4e3a\u8fde\u63a5\u6a21\u5f0f&#xff0c;2\u4e3a\u70ed\u70b9\u6a21\u5f0f&#xff0c;3\u4e3a\u53cc\u5f00*\/<br \/>\n#define wifi_mode_Station 1<br \/>\n#define wifi_mode_SoftAP 2<br \/>\n#define wifi_mode_SoftAP_Station 3<\/p>\n<p>\/*\u8fd4\u56de\u503c\u72b6\u6001*\/<br \/>\n#define esp8266_OK 1<br \/>\n#define esp8266_ERROR 0<\/p>\n<p>#endif<\/p>\n<h4><\/h4>\n<h4>\u4e3b\u51fd\u6570main.c&#xff1a;<\/h4>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u76ee\u7684\u662f\u5728\u4e8e\u68c0\u67e5\u4fe1\u606f\u7684\u53d1\u9001\u662f\u5426\u6b63\u786e&#xff0c;\u7535\u8111\u4e32\u53e3\u63a7\u5236esp\u8fdb\u884c\u6570\u636e\u7684\u53d1\u9001\u548c\u8bfb\u53d6\u3002<\/p>\n<p>int main(void)<br \/>\n{<\/p>\n<p>    HAL_Init();                                             \/* \u521d\u59cb\u5316HAL\u5e93 *\/<br \/>\n    sys_stm32_clock_init(RCC_PLL_MUL9);                     \/* \u8bbe\u7f6e\u65f6\u949f, 72Mhz *\/<br \/>\n    delay_init(72);                                         \/* \u5ef6\u65f6\u521d\u59cb\u5316 *\/<br \/>\n    usart_init(115200);                                     \/* \u521d\u59cb\u5316\u4e32\u53e3 *\/<br \/>\n    led_init();                                             \/* \u521d\u59cb\u5316LED *\/<br \/>\n\/\/ OLED_Init();<br \/>\n    usart2_init(115200);<\/p>\n<p>    if(esp8266_Init(mode_1_TCP_Client,wifi_mode_Station)&#061;&#061;esp8266_OK)<br \/>\n    {<br \/>\n        printf(&#034;\\\\r\\\\nesp8266 \u6a21\u5f0f %d \u521d\u59cb\u5316\u5b8c\u6210!\\\\r\\\\n&#034;,mode_1_TCP_Client);<br \/>\n    }<br \/>\n    else<br \/>\n    {<br \/>\n        printf(&#034;\\\\r\\\\nesp8266\u521d\u59cb\u5316\u5931\u8d25\\\\r\\\\n&#034;);<br \/>\n        while(1)<br \/>\n        {<br \/>\n            LED0_TOGGLE();<br \/>\n            delay_ms(200);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    char rx_data[128];<br \/>\n    uint8_t ID&#061;0;<br \/>\n    while (1)<br \/>\n    {<br \/>\n        if(esp8266wifi_rx_sta&amp;0X8000)\/\/esp\u6536\u5230\u7684\u4fe1\u606f\u901a\u8fc7\u4e32\u53e3\u4e00\u6253\u5370<br \/>\n        {<br \/>\n            printf(&#034;\\\\nGot Date!\\\\n&#034;);<br \/>\n            ID &#061; esp8266_receive_data(rx_data,esp8266wifi_rx_buf);<br \/>\n            if(ID)<br \/>\n            {<br \/>\n                printf(&#034;ID :%d,\u6536\u5230\u7684\u4fe1\u606f: %s\\\\n&#034;,ID,rx_data);<br \/>\n            }<br \/>\n            else<br \/>\n            {<br \/>\n                printf(&#034;\u6536\u5230\u7684\u4fe1\u606f: %s\\\\n&#034;,rx_data);<br \/>\n            }<br \/>\n            esp8266wifi_rx_sta&#061;0;<br \/>\n        }<br \/>\n        if(g_usart_rx_sta&amp;0X8000)   \/\/\u4e32\u53e3\u4e00\u6536\u5230\u7684\u4fe1\u606f\u53d1\u9001\u5230esp<br \/>\n        {<br \/>\n            while ((USART_UX-&gt;SR &amp; 0X40) &#061;&#061; 0);     \/* \u7b49\u5f85\u4e0a\u4e00\u4e2a\u5b57\u7b26\u53d1\u9001\u5b8c\u6210 *\/<br \/>\n            esp8266_send_data((char *)g_usart_rx_buf,ID);<br \/>\n            \/\/ printf(&#034;%s\\\\n&#034;,g_usart_rx_buf);<br \/>\n            g_usart_rx_sta &#061; 0;<br \/>\n        }<\/p>\n<p>        LED0_TOGGLE();<br \/>\n        delay_ms(500);<br \/>\n    }<br \/>\n} <\/p>\n<h3>\u5b9e\u9a8c\u73b0\u8c61&#xff1a;<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5f00\u59cb\u5b9e\u9a8c\u524d\u8981\u6253\u5f00\u7535\u8111\u7aef\u7684\u670d\u52a1\u5668&#xff0c;\u8fd9\u91cc\u521d\u59cb\u5316\u7528\u7684\u6a21\u5f0f1\u3002\u7b49\u5f85\u521d\u59cb\u5316\u5b8c\u6210\u5373\u53ef\u53d1\u9001\u4fe1\u606f\u3002\u7f51\u7edc\u52a9\u624b\u548cesp\u8fdb\u884c\u6570\u636e\u901a\u4fe1\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"806\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512051603-6821841315ecf.png\" width=\"934\" \/><\/p>\n<p>\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"558\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512051603-6821841349e57.png\" width=\"653\" \/><\/p>\n<h3><\/h3>\n<h3>\u00a0\u603b\u7ed3&#xff1a;<\/h3>\n<p>\u672c\u6b21\u5b9e\u9a8c\u6709\u5f88\u591a\u53ef\u4ee5\u6539\u8fdb\u7684\u5730\u65b9&#xff0c;\u6bd4\u5982\u7b49\u5f85\u65f6\u95f4\u957f&#xff0c;\u521d\u59cb\u5316\u65f6\u95f4\u4e5f\u957f\u3002\u4f46\u662f\u6709\u70b9\u61d2&#xff0c;\u5c31\u653e\u7740\u5427\u3002\u8bfb\u8005\u6709\u4ec0\u4e48\u5efa\u8bae\u90fd\u53ef\u4ee5\u627e\u6211&#xff0c;\u6709\u95ee\u9898\u7684\u8fd8\u8bf7\u6307\u6b63\u3002<\/p>\n<\/p>\n<h3 style=\"background-color:transparent\">\u66f4\u65b0\u6e90\u7801&#xff1a;<\/h3>\n<p>GitCode&#xff1a;<\/p>\n<p>\u9879\u76ee\u9996\u9875 &#8211; ESP8266_wifi_module:The C language function encapsulation of the AP instructions of the ESP8266 module &#8211; GitCode<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2w\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf200\u6b21\u3002stm32\u4e32\u53e3\u8fde\u63a5esp8266WiFi\u6a21\u5757\uff0c\u901a\u8fc7AT\u6307\u4ee4\u63a7\u5236\u6a21\u5757\u8fdb\u884c\u6570\u636e\u6536\u53d1\uff0c\u548c\u670d\u52a1\u5668\u8fdb\u884c\u901a\u8baf\u3002\u53ef\u4ee5\u7528\u4e8e\u5355\u7247\u673a\u76f4\u63a5\u7684\u901a\u4fe1\uff0c\u624b\u673a\u548c\u5355\u7247\u673a\u901a\u8baf\u7b49\u3002_\u57fa\u4e8estm32\u3001esp8266\u53caov7670\u7684\u65e0\u7ebf\u56fe\u4f20\u4e0b\u4f4d\u673a\u6e90\u7801<\/p>\n","protected":false},"author":2,"featured_media":36759,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3170,217,270,269],"topic":[],"class_list":["post-36768","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-stm32mcu","tag-stm32","tag-270","tag-269"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>STM32+esp8266\u5b9e\u73b0\u5355\u7247\u673a\u4e0e\u670d\u52a1\u5668\u7684WiFi\u901a\u4fe1 - \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\/36768.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"STM32+esp8266\u5b9e\u73b0\u5355\u7247\u673a\u4e0e\u670d\u52a1\u5668\u7684WiFi\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2w\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf200\u6b21\u3002stm32\u4e32\u53e3\u8fde\u63a5esp8266WiFi\u6a21\u5757\uff0c\u901a\u8fc7AT\u6307\u4ee4\u63a7\u5236\u6a21\u5757\u8fdb\u884c\u6570\u636e\u6536\u53d1\uff0c\u548c\u670d\u52a1\u5668\u8fdb\u884c\u901a\u8baf\u3002\u53ef\u4ee5\u7528\u4e8e\u5355\u7247\u673a\u76f4\u63a5\u7684\u901a\u4fe1\uff0c\u624b\u673a\u548c\u5355\u7247\u673a\u901a\u8baf\u7b49\u3002_\u57fa\u4e8estm32\u3001esp8266\u53caov7670\u7684\u65e0\u7ebf\u56fe\u4f20\u4e0b\u4f4d\u673a\u6e90\u7801\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/36768.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-12T05:16:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512051602-6821841295ceb.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=\"10 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/36768.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/36768.html\",\"name\":\"STM32+esp8266\u5b9e\u73b0\u5355\u7247\u673a\u4e0e\u670d\u52a1\u5668\u7684WiFi\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-12T05:16:04+00:00\",\"dateModified\":\"2025-05-12T05:16:04+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/36768.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/36768.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/36768.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"STM32+esp8266\u5b9e\u73b0\u5355\u7247\u673a\u4e0e\u670d\u52a1\u5668\u7684WiFi\u901a\u4fe1\"}]},{\"@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":"STM32+esp8266\u5b9e\u73b0\u5355\u7247\u673a\u4e0e\u670d\u52a1\u5668\u7684WiFi\u901a\u4fe1 - \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\/36768.html","og_locale":"zh_CN","og_type":"article","og_title":"STM32+esp8266\u5b9e\u73b0\u5355\u7247\u673a\u4e0e\u670d\u52a1\u5668\u7684WiFi\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2w\u6b21\uff0c\u70b9\u8d5e13\u6b21\uff0c\u6536\u85cf200\u6b21\u3002stm32\u4e32\u53e3\u8fde\u63a5esp8266WiFi\u6a21\u5757\uff0c\u901a\u8fc7AT\u6307\u4ee4\u63a7\u5236\u6a21\u5757\u8fdb\u884c\u6570\u636e\u6536\u53d1\uff0c\u548c\u670d\u52a1\u5668\u8fdb\u884c\u901a\u8baf\u3002\u53ef\u4ee5\u7528\u4e8e\u5355\u7247\u673a\u76f4\u63a5\u7684\u901a\u4fe1\uff0c\u624b\u673a\u548c\u5355\u7247\u673a\u901a\u8baf\u7b49\u3002_\u57fa\u4e8estm32\u3001esp8266\u53caov7670\u7684\u65e0\u7ebf\u56fe\u4f20\u4e0b\u4f4d\u673a\u6e90\u7801","og_url":"https:\/\/www.wsisp.com\/helps\/36768.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-12T05:16:04+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250512051602-6821841295ceb.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"10 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/36768.html","url":"https:\/\/www.wsisp.com\/helps\/36768.html","name":"STM32+esp8266\u5b9e\u73b0\u5355\u7247\u673a\u4e0e\u670d\u52a1\u5668\u7684WiFi\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-12T05:16:04+00:00","dateModified":"2025-05-12T05:16:04+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/36768.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/36768.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/36768.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"STM32+esp8266\u5b9e\u73b0\u5355\u7247\u673a\u4e0e\u670d\u52a1\u5668\u7684WiFi\u901a\u4fe1"}]},{"@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\/36768","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=36768"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/36768\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/36759"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=36768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=36768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=36768"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=36768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}