{"id":632,"date":"2022-11-22T18:18:58","date_gmt":"2022-11-22T10:18:58","guid":{"rendered":"http:\/\/wordpress.loc\/?p=632"},"modified":"2022-11-22T18:32:52","modified_gmt":"2022-11-22T10:32:52","slug":"esp32_ch1-19","status":"publish","type":"post","link":"https:\/\/www.nmking.io\/index.php\/2022\/11\/22\/632\/","title":{"rendered":"ESP32 OTA\u7121\u7dda\u66f4\u65b0\u7cfb\u52171 Basic OTA"},"content":{"rendered":"\n<figure class=\"wp-block-pullquote\"><blockquote><p>OTA\u70baOverTheAir\u7684\u7e2e\u5beb\uff0c\u610f\u601d\u5c31\u662f\u7a7a\u4e2d\u66f4\u65b0\u7a0b\u5f0f\u78bc\uff0c\u5982\u679c\u4eca\u5929\u4f60\u7684\u88dd\u7f6e\u652f\u63f4OTA\uff0c\u90a3\u4f60\u5728\u5bb6\u88e1\u5c31\u53ef\u4ee5\u76f4\u63a5\u66f4\u65b0\u5ba2\u6236\u7aef\u88dd\u7f6e\u7684\u7a0b\u5f0f\uff0c\u662f\u4e0d\u662f\u5f88\u65b9\u4fbf\u3002<\/p><\/blockquote><\/figure>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-ht-block-toc is-style-rounded htoc htoc--position-wide toc-list-style-plain\" data-htoc-state=\"expanded\"><span class=\"htoc__title\"><span class=\"ht_toc_title\">Table of Contents<\/span><span class=\"htoc__toggle\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"16\" height=\"16\"><g fill=\"#444\"><path d=\"M15 7H1c-.6 0-1 .4-1 1s.4 1 1 1h14c.6 0 1-.4 1-1s-.4-1-1-1z\"><\/path><path d=\"M15 1H1c-.6 0-1 .4-1 1s.4 1 1 1h14c.6 0 1-.4 1-1s-.4-1-1-1zM15 13H1c-.6 0-1 .4-1 1s.4 1 1 1h14c.6 0 1-.4 1-1s-.4-1-1-1z\"><\/path><\/g><\/svg><\/span><\/span><div class=\"htoc__itemswrap\"><ul class=\"ht_toc_list\"><li class=\"\"><a href=\"#htoc-\">\u5be6\u4f5c\u8aaa\u660e<\/a><\/li><li class=\"\"><a href=\"#htoc-ota\">OTA\u6709\u54ea\u4e9b\u6a21\u5f0f\uff1f<\/a><\/li><li class=\"\"><a href=\"#htoc-basic-ota\">Basic OTA\u6a21\u5f0f<\/a><\/li><li class=\"\"><a href=\"#htoc-1\">\u6ce8\u610f\u4e8b\u9805<\/a><\/li><\/ul><\/div><\/div>\n\n\n\n<p>\u6211\u7684ESP32\u5be6\u505a\u66f8\u7c4d\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/www.nmking.io\/index.php\/2022\/11\/10\/esp32_ch1-2\/\" target=\"_blank\">\u6211\u51fa\u66f8\u4e86 ESP32 \u7269\u806f\u7db2\u5c08\u984c<\/a><br>\u535a\u5ba2\u4f86\u7db2\u5740\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/www.books.com.tw\/products\/0010901195\" target=\"_blank\">https:\/\/www.books.com.tw\/products\/0010901195<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"htoc-\">\u5be6\u4f5c\u8aaa\u660e<\/h2>\n\n\n\n<p>\u4eca\u5929\u4f86\u4ecb\u7d39ESP32 OTA\u9060\u7aef\u66f4\u65b0<\/p>\n\n\n\n<p>OTA\u70baOverTheAir\u7684\u7e2e\u5beb\uff0c\u610f\u601d\u5c31\u662f\u7a7a\u4e2d\u66f4\u65b0\u7a0b\u5f0f\u78bc\uff0c\u500b\u4eba\u8a8d\u70ba\u9019\u500bIoT\u7522\u696d\u975e\u5e38\u91cd\u8981\u7684\u4e00\u74b0\uff0c\u7562\u7adf\u7576\u4f60\u7684\u88dd\u7f6e\u5f9e\u5be6\u9a57\u5ba4\u8d70\u5230\u5be6\u969b\u5834\u57df\u5f8c\uff0c\u4e00\u5b9a\u6703\u9047\u5230\u5f88\u591a\u554f\u984c\uff0c\u5982\u679c\u5834\u57df\u5206\u6563\u5728\u5f88\u591a\u4e0d\u540c\u7684\u5730\u65b9\uff0c\u5149\u7a0b\u5f0f\u6539\u7248\u5c31\u6703\u8b93\u4f60\u75b2\u65bc\u5954\u6ce2\uff0c\u5e36\u8457USB\u7dda\u5230\u8655\u66f4\u65b0\u4f60\u7684ESP32\uff0c\u60f3\u60f3\u5c31\u5f88\u7d2f\uff0c\u5982\u679c\u4eca\u5929\u4f60\u7684\u88dd\u7f6e\u652f\u63f4OTA\uff0c\u90a3\u4f60\u5728\u5bb6\u88e1\u5c31\u53ef\u4ee5\u76f4\u63a5\u66f4\u65b0\u5ba2\u6236\u7aef\u88dd\u7f6e\u7684\u7a0b\u5f0f\uff0c\u662f\u4e0d\u662f\u5f88\u65b9\u4fbf\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"htoc-ota\">OTA\u6709\u54ea\u4e9b\u6a21\u5f0f\uff1f<\/h2>\n\n\n\n<p>OTA\u4e26\u975e\u662fESP32\u7684\u5c08\u5c6c\u529f\u80fd\uff0c\u5f88\u591aArduino\u7cfb\u5217\u4e5f\u90fd\u652f\u63f4\uff0c\u4ee5\u76ee\u524d\u7b46\u8005\u6240\u89c0\u5bdf\u5230\u7684OTA\u76ee\u524d\u4f86\u8aaa\u4e3b\u8981\u5206\u6210\u4ee5\u4e0b\u56db\u7a2e\u6a21\u5f0f<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Basic OTA\uff1a\u5728Arduino IDE\u4e2d\u5f62\u6210\u4e00\u500b\u865b\u64ec\u7684Port\uff0c\u9078\u64c7\u8a72Port\u5373\u53ef\u4e0a\u50b3\u65b0\u7684\u7a0b\u5f0f\u78bc<\/li>\n\n\n\n<li>OTAWebUpload\uff1aESP32\u6703\u8b8a\u6210\u4e00\u53f0Webserver\uff0c\u900f\u904eESP32\u7684\u7db2\u9801\u4e0a\u50b3ArduinoIDE\u7de8\u8b6f\u904e\u5f97bin(binary)\u6a94<\/li>\n\n\n\n<li>HTTP Update\uff1a\u5c07\u7de8\u8b6f\u597d\u7684bin\u6a94\u653e\u5728\u4e00\u500b\u516c\u958b\u7684\u7db2\u7ad9\u4e0a\uff0c\u8b93ESP32\u4e3b\u52d5\u4e0b\u8f09<\/li>\n\n\n\n<li>Stream Update\uff1a\u900f\u904eMQTT\u5c07\u7de8\u8b6f\u597d\u7684bin\u6a94\u76f4\u63a5\u4e0a\u50b3\u5230ESP32\u4e2d<\/li>\n<\/ol>\n\n\n\n<p>\u9664\u4e864\u4e4b\u5916\uff0c\u76ee\u524d\u6211\u90fd\u5be6\u505a\u904e\uff0c\u672c\u7bc7\u5148\u5f9e\u6700\u7c21\u55ae\u76841. Basic OTA\u958b\u59cb\u5427\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"htoc-basic-ota\">Basic OTA\u6a21\u5f0f<\/h2>\n\n\n\n<p>Basic OTA\u662f\u5167\u5efa\u7684\u529f\u80fd\uff0c\u53ea\u8981\u6a94\u6848\/\u7bc4\u4f8bArduinoOTA\/BasicOTA\u5c31\u53ef\u4ee5\u627e\u5230\uff0c\u7bc4\u4f8b\u7a0b\u5f0f\u9019\u88e1\u5c31\u4e0d\u5217\u51fa\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1633881987-683620687-g_n.png?resize=842%2C462&#038;ssl=1\" alt=\"\" width=\"842\" height=\"462\"\/><figcaption class=\"wp-element-caption\">\u9078\u64c7BasicOTA\u7a0b\u5f0f\u5eab<\/figcaption><\/figure>\n\n\n\n<p>\u4e0a\u50b3\u6642\u9078\u64c7Partition Scheme\u70baDefault 4MB wiht spiffs(1.2MM APP\/1.5M SPIFFS)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1633884003-2839300530-g_n.png?resize=839%2C316&#038;ssl=1\" alt=\"\" width=\"839\" height=\"316\"\/><figcaption class=\"wp-element-caption\">\u66f4\u6539Partition Scheme\u6a21\u5f0f<\/figcaption><\/figure>\n\n\n\n<p>\u4fee\u6539\u597d\u7a0b\u5f0f\u6700\u4e0a\u9762\u7684WiFi\u8a2d\u5b9a\u5f8c\uff0c\u4e0a\u50b3\u5373\u53ef<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1633882472-4090367455-g_n.png?resize=841%2C479&#038;ssl=1\" alt=\"\" width=\"841\" height=\"479\"\/><figcaption class=\"wp-element-caption\">\u7a0b\u5f0f\u4e2dWIFI\u8a2d\u5b9a\u4f4d\u7f6e<\/figcaption><\/figure>\n\n\n\n<p>BasicOTA\u7531\u65bc\u7b46\u8005\u5f88\u5c11\u7528\uff0c\u7a0b\u5f0f\u5167\u5bb9\u6211\u5c31\u4e0d\u4e00\u4e00\u8aaa\u660e<\/p>\n\n\n\n<p>\u7a0b\u5f0f\u4e0a\u50b3\u5f8c\uff0c\u5982\u679c\u7db2\u8def\u6709\u9023\u4e0a\uff0c\u7406\u8ad6\u4e0a\u5c31\u53ef\u4ee5\u5728ArduinoIDE\u4e2d\u627e\u5230\u88dd\u7f6e<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1633884339-322793149-g_n.png?resize=839%2C292&#038;ssl=1\" alt=\"\" width=\"839\" height=\"292\"\/><figcaption class=\"wp-element-caption\">\u9023\u4e0a\u7db2\u8def\u756b\u9762<\/figcaption><\/figure>\n\n\n\n<p>\u627e\u5230\u7684\u756b\u9762\u6703\u5411\u4e0b\u9762\u9019\u6a23\uff0c\u5728\u539f\u672c\u5e8f\u5217\u57e0\u4e0b\u65b9\u6703\u51fa\u73fe\u4e00\u500bESP32\u865b\u64ec\u7684Port\uff0c\u5f8c\u65b9\u5247\u70baESP32\u7684IP\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1633892047-1359633129-g_n.png?resize=841%2C228&#038;ssl=1\" alt=\"\" width=\"841\" height=\"228\"\/><figcaption class=\"wp-element-caption\">ESP32\u865b\u64ec\u7684Port<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"htoc-1\">\u6ce8\u610f\u4e8b\u9805<\/h2>\n\n\n\n<p>\u4e0d\u904e\u7d93\u904e\u53cd\u8986\u6e2c\u8a66\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u72c0\u6cc1<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u96fb\u8166\u8207ESP32\u5fc5\u9808\u4f7f\u7528\u540c\u4e00\u500b\u5340\u57df\u7db2\u8def\uff0c\u5207\u5fc5\u9808\u95dc\u9589\u9632\u706b\u7246<\/li>\n\n\n\n<li>\u7121\u6cd5\u4f7f\u7528\u624b\u6a5fAP\u5206\u4eab\u7db2\u8def\uff1a\u6211\u5c07\u96fb\u8166\u53caESP32\u90fd\u9078\u7528\u624b\u6a5f\u5206\u4eab\u7684\u7db2\u8def\uff0c\u4f46\u662f\u7121\u8ad6\u5982\u4f55\u6e2c\u8a66\u5c31\u662f\u627e\u4e0d\u5230\u2026..<\/li>\n\n\n\n<li>\u96fb\u8166\u53ef\u80fd\u9700\u8981\u91cd\u65b0\u958b\u6a5f<\/li>\n\n\n\n<li>\u7d50\u8ad6\u5c31\u662f\u9019\u7a2e\u6a21\u5f0f\u4f3c\u4e4e\u4e0d\u662f\u5f88\u7a69\u5b9a(\u4e5f\u53ef\u80fd\u662f\u6211\u5bb6\u7db2\u8def\u7684\u554f\u984c\u5427\u2026.)<\/li>\n<\/ol>\n\n\n\n<p>\u4e0d\u904e\u7db2\u8def\u7a0b\u5f0f\u78bc\u66f4\u65b0\uff0c\u53ea\u8981\u9078\u64c7\u4e0a\u9762\u7684\u865b\u64ecPort\u4e0d\u7528\u518d\u63d2USB\u5c31\u53ef\u4ee5\u66f4\u65b0\u4e86\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1633892455-4228847612-g_n.png?resize=841%2C248&#038;ssl=1\" alt=\"\" width=\"841\" height=\"248\"\/><figcaption class=\"wp-element-caption\">\u4f7f\u7528OTA\u7a0b\u5f0f\u66f4\u65b0\u4e2d<\/figcaption><\/figure>\n\n\n\n<p>\u9019\u88e1\u518d\u9644\u8a3b\u5169\u9ede\u8aaa\u660e\u4e00\u4e0b<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>delay\u554f\u984c\uff1a\u7576\u4f7f\u7528OTA\u6642\uff0c\u592a\u9577\u7684delay\u5c31\u6703\u5c0e\u81f4\u9001\u51fa\u9700\u6c42\u6642\u6c92\u88abESP32\u6536\u5230\uff0c\u56e0\u6b64\u5efa\u8b70\u7a0b\u5f0f\u6709delay\u7684\u5730\u65b9\u4fee\u6539\u70ba\u6aa2\u6e2c\u6642\u9593\uff0c\u8207\u4e4b\u524d\u4ecb\u7d39MQTT\u6642\u985e\u4f3c\uff0c\u5176\u65b9\u5f0f\u5982\u4e0b\uff1a<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/pic.pimg.tw\/youyouyou\/1633892301-4222857233-g_n.png?resize=840%2C608&#038;ssl=1\" alt=\"\" width=\"840\" height=\"608\"\/><figcaption class=\"wp-element-caption\">\u4fee\u6539delay\u7a0b\u5f0f<\/figcaption><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>\u70ba\u4e86\u80fd\u6301\u7e8c\u4f7f\u7528OTA\u529f\u80fd\uff0c\u65b0\u4e00\u7248\u7684\u7a0b\u5f0f\u78bc\u4e5f\u5fc5\u9808\u5305\u542bOTA\u529f\u80fd\uff0c\u5426\u5247\u9019\u7248\u71d2\u4e0a\u53bb\uff0c\u5c31\u6c92\u6709OTA\u4e86<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>OTA\u70baOverTheAir\u7684\u7e2e\u5beb\uff0c\u610f\u601d\u5c31\u662f\u7a7a\u4e2d\u66f4\u65b0\u7a0b\u5f0f\u78bc\uff0c\u5982\u679c\u4eca\u5929\u4f60\u7684\u88dd\u7f6e\u652f\u63f4OTA\uff0c\u90a3\u4f60\u5728\u5bb6\u88e1\u5c31\u53ef\u4ee5\u76f4\u63a5\u66f4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-632","post","type-post","status-publish","format-standard","hentry","category-esp32"],"blocksy_meta":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/posts\/632","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/comments?post=632"}],"version-history":[{"count":1,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/posts\/632\/revisions"}],"predecessor-version":[{"id":633,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/posts\/632\/revisions\/633"}],"wp:attachment":[{"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/media?parent=632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/categories?post=632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nmking.io\/index.php\/wp-json\/wp\/v2\/tags?post=632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}