{"id":19484393,"url":"https://github.com/funnygeeker/micropython-easyota","last_synced_at":"2025-04-15T11:50:37.138Z","repository":{"id":113375059,"uuid":"605988521","full_name":"funnygeeker/micropython-easyota","owner":"funnygeeker","description":"OTA update library for MicroPython.  适用于 MicroPython 的 OTA 更新库  ","archived":false,"fork":false,"pushed_at":"2024-04-06T14:47:24.000Z","size":40,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T19:44:47.555Z","etag":null,"topics":["esp01s","esp32","esp8266","github","micropython","ota","requests","rp2040","update"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/funnygeeker.png","metadata":{"files":{"readme":"README.ZH-CN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-24T10:46:36.000Z","updated_at":"2024-10-16T05:41:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc385e48-3094-4ea4-a87a-18f51c2f675b","html_url":"https://github.com/funnygeeker/micropython-easyota","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnygeeker%2Fmicropython-easyota","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnygeeker%2Fmicropython-easyota/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnygeeker%2Fmicropython-easyota/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funnygeeker%2Fmicropython-easyota/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funnygeeker","download_url":"https://codeload.github.com/funnygeeker/micropython-easyota/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249067153,"owners_count":21207392,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esp01s","esp32","esp8266","github","micropython","ota","requests","rp2040","update"],"created_at":"2024-11-10T20:21:17.410Z","updated_at":"2025-04-15T11:50:37.116Z","avatar_url":"https://github.com/funnygeeker.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[English (英语)](./README.md)\n# micropython-easyota\n- 适用于 `micropython` 的 OTA 更新库，高效，易用，拥有一定的可靠性\n\n### 特点\n- 支持 `Github` / `Gitee` 存储库\n- 使用单独的缓存目录来缓存文件，最后进行安装，由于安装速度很快，可以极大概率避免更新时断电造成的程序不完整\n- 可以指定本地路径和远程路径，支持自动扫描所有文件，也可以手动指定需要更新的文件，自动扫描时也可以忽略指定文件\n- 将 `cached_files` 参数设为 `False` 则不会于检查更新时下载文件，只校验哈希，之后更新时会下载文件并进行校验，拥有更高的可靠性，但是更新速度较慢\n### 兼容性\n- 通过测试的硬件：`ESP32-C3 RAM-400KB Flash-4MB`\n- 其他硬件尚未进行测试\n\n### 使用示例\n```python\n# import machine\nfrom lib.easyota import EasyOTA\nfrom lib.easynetwork import Client\n\n# 连接网络\nclient = Client()\nclient.connect('ssid', 'password')\nwhile not client.isconnected():\n    pass\nprint(\"IP Address: \", client.ifconfig()[0])\n\n\n# 用于表示更新进度的回调函数\ndef callback(msg, done, total):\n    if msg == \"preparation\":\n        print(\"准备中:\", \"{}/{}\".format(done, total), \"({}%)\".format(int(done / total * 100)))\n    elif msg == \"fetch\":\n        print(\"检查更新:\", \"{}/{}\".format(done, total), \"({}%)\".format(int(done / total * 100)))\n    elif msg == \"update\":\n        print(\"安装更新:\", \"{}/{}\".format(done, total), \"({}%)\".format(int(done / total * 100)))\n\n\n# 初始化实例\neo = EasyOTA('funnygeeker', 'micropython-easyota', 'main',\n             git_raw=EasyOTA.GITHUB_RAW, git_api=EasyOTA.GITHUB_API,\n             ignore=['/lib/easynetwork.py', '/lib/urequests.py', '/lib/easyota.py', '/main.py'],\n             callback=callback)  # 更多使用方法详见注释，您可以用 AI 将注释翻译为您所使用的语言\n\n\n# 在检查更新之前，请确保您的开发板已经连接到互联网，否则可能会报错。\n# 如果您使用的是 Thonny IDE 进行调试，拷贝文件后，别忘记切换到设备的根目录，否则路径可能不正确，无法正常进行更新\nresult = eo.fetch()  # 检查更新\nif result:\n    print(\"\"\"===【检查更新】===\n更改的文件：\\n{}\n删除的文件：\\n{}\n新增的目录：\\n{}\n删除的目录：\\n{}\n\"\"\".format(result[0], result[1], result[2], result[3]))\n\n\nresult = eo.update()  # 更新文件\nif result is True:\n    result = '更新成功'\n    # machine.reset()  # 重启开发板\nelif result is False:\n    result = '无需更新'\nelif result is None:\n    result = '更新失败'\nif result:\n    print(\"===【更新结果】===\\n{}\".format(result))\n# 记得在 Thonny IDE 中点击 刷新，以刷新文件列表\n\n# machine.reset()  # 重新启动开发板，以应用更新\n```\n### 注意事项\n- 更新过程中下载的文件会缓存到缓存目录，更新前请注意开发板的可用存储空间是否足够\n- 更新成功后建议及时重启开发板，以避免现有的程序被更改，在 `import` 时引发一些 `BUG`\n- 该程序不适用于文件非常多的情况检查更新，若文件列表过大，在低性能开发板上可能会引发内存分配错误\n- 使用时需要连接网络，您可以使用 [https://github.com/funnygeeker/micropython-easynetwork](https://github.com/funnygeeker/micropython-easynetwork) 连接无线网络，也可以用其他的方式完成网络的连接。\n- `Github` 仓库在国内使用时如果经常出现网络问题，请使用 `EasyOTA.GITHUB_RAW2` 进行测试，或者更换为 `Gitee` 存储库进行测试\n- 您仍然需要留意正好处于两次版本切换之间进行更新的用户，可以试着将版本文件与程序分开进行更新，先更新版本文件，版本文件里的更新选项设为禁用更新，2-6小时后再更新程序，将版本说明文件里的更新选项设为启用更新，以达到最佳的可靠性\n\n### 灵感来源\nSenko：[https://github.com/RangerDigital/senko](https://github.com/RangerDigital/senko)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunnygeeker%2Fmicropython-easyota","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunnygeeker%2Fmicropython-easyota","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunnygeeker%2Fmicropython-easyota/lists"}