{"id":14971040,"url":"https://github.com/hsun1031/esp_git_ota","last_synced_at":"2025-10-26T14:30:58.216Z","repository":{"id":250893634,"uuid":"835707754","full_name":"Hsun1031/ESP_Git_OTA","owner":"Hsun1031","description":"This is Over The Air update library for ESP32 that uses GitHub releases as the firmware or SPIFFS source.","archived":false,"fork":false,"pushed_at":"2025-01-01T06:22:59.000Z","size":22,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-31T20:16:07.392Z","etag":null,"topics":["esp32","github","github-releases","ota-firmware-updates"],"latest_commit_sha":null,"homepage":"https://registry.platformio.org/libraries/hsun/ESP_Git_OTA","language":"C++","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/Hsun1031.png","metadata":{"files":{"readme":"README.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":"2024-07-30T11:27:00.000Z","updated_at":"2025-01-01T06:23:03.000Z","dependencies_parsed_at":"2024-07-30T18:10:26.626Z","dependency_job_id":null,"html_url":"https://github.com/Hsun1031/ESP_Git_OTA","commit_stats":null,"previous_names":["hsun1031/esp32_git_ota"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hsun1031%2FESP_Git_OTA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hsun1031%2FESP_Git_OTA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hsun1031%2FESP_Git_OTA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hsun1031%2FESP_Git_OTA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hsun1031","download_url":"https://codeload.github.com/Hsun1031/ESP_Git_OTA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238347477,"owners_count":19456941,"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":["esp32","github","github-releases","ota-firmware-updates"],"created_at":"2024-09-24T13:44:38.044Z","updated_at":"2025-10-26T14:30:57.897Z","avatar_url":"https://github.com/Hsun1031.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ESP Git OTA\n\nThis is Over The Air update library for `ESP32` that uses `GitHub` releases as the `firmware` or `SPIFFS` source.\n\n## 📄Table of Contents\n\n- 🏗️ [Installation](#%EF%B8%8Finstallation)\n- 📝 [Usage](#usage)\n- ➕ [Methods](#methods)\n  - 🎉 [init GithubReleaseOTA Object](#init-githubreleaseota-object)\n    - 🚨[Token hint](#token-hint)\n  - 🔒️ [Setup CA Certificate](#%EF%B8%8Fsetup-ca-certificate)\n  - 🏷️ [Get Tag](#%EF%B8%8Fget-tag)\n  - 🔖 [Get Release](#get-release-githubrelease-object)\n  - 📦️ [Get Asset](#%EF%B8%8Fget-asset-githubreleaseasset-object)\n  - ⚡️ [Flash Firmware or SPIFFS](#%EF%B8%8Fflash-firmware-or-spiffs)\n  - ♻️ [Free Memory](#%EF%B8%8Ffree-memory)\n- 👽️ [Object](#%EF%B8%8Fobject)\n  - [GithubRelease](#githubrelease)\n  - [GithubReleaseAsset](#githubreleaseasset)\n  - [GithubAuthor](#githubauthor)\n\n## 🏗️Installation\n\n- For PlatformIO:  \n\nAdd the following line to your `platformio.ini` file:\n\n```ini\n; Use PlatformIO repository\nlib_deps =\n    hsun/ESP_Git_OTA\n  ; hsun/ESP32_Git_OTA ; For Old version\n\n; Use GitHub repository\nlib_deps =\n    https://github.com/Hsun1031/ESP_Git_OTA.git\n```\n\n## 📝Usage\n\n```cpp\n#include \u003cArduino.h\u003e\n#include \u003cESP_Git_OTA.h\u003e\n\n#define ESP_VERSION \"v1.0.0\"\n\nGithubRelease release;\nbool readyForUpdate = false;\n\n// Public repository\nGithubReleaseOTA ota(\"username\", \"repository\");\n// Private repository See Token hint https://github.com/Hsun1031/ESP32_Git_OTA?tab=readme-ov-file#token-hint\n// GithubReleaseOTA ota(\"username\", \"repository\", \"token\");\n\nvoid setup() {\n    Serial.begin(115200);\n\n    // Setup WiFi connection...\n\n    // Setup CA certificate for HTTPS connection or use empty string\n    // ota.setCACert(PEM_CA_CERT);\n\n    // Get the latest release from GitHub\n    release = ota.getLatestRelease();\n\n    // Check if the latest release is newer than the current version\n    if (release.tag_name != NULL) {\n        if (strcmp(release.tag_name, ESP_VERSION) == 0) {\n            Serial.println(\"Already up to date\");\n            readyForUpdate = false;\n\n            ota.freeRelease(release);\n        } else {\n            Serial.println(\"New version available: \" + String(release.tag_name));\n            readyForUpdate = true;\n        }\n    }\n}\n\nvoid loop() {\n    if (readyForUpdate) {\n        int result = ota.flashFirmware(release, \"firmware.bin\");\n        Serial.println(\"Flash firmware result: \" + String(result));\n\n        if (result == 0) {\n            Serial.println(\"Firmware updated successfully\");\n\n            ESP.restart();\n        } else {\n            Serial.println(\"Firmware update failed: \" + String(result));\n            ota.freeRelease(release);\n            readyForUpdate = false;\n        }\n    } else {\n        Serial.println(\"Failed to get latest release\");\n        readyForUpdate = false;\n    }\n}\n\n```\n\n## ➕Methods\n\n### 🎉init GithubReleaseOTA Object\n\n#### ✨`GithubReleaseOTA(const char* username, const char* repository)` Initialize GithubReleaseOTA object with public repository\n\n- `Parameters`:\n  - `username` - `const char*`: GitHub username\n  - `repository` - `const char*`: GitHub repository\n\n#### ✨`GithubReleaseOTA(const char* username, const char* repository, const char* token)` Initialize GithubReleaseOTA object with private repository\n\n- `Parameters`:\n  - `username` - `const char*`: GitHub username\n  - `repository` - `const char*`: GitHub repository\n  - `token` - `const char*`: GitHub token\n\n#### 🚨`token` hint\n\nToken need `Contents` repository permissions (read), see Github API: [Get a release asset](https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#get-a-release-asset)\n\n### 🔒️Setup CA Certificate\n\n#### ✨`void setCACert(const char* ca)` Set website CA (Certificate Authority)\n\n- `Parameters`:\n  - `ca` - `const char*`: Certificate Authority\n\nexample:\n\n```cpp\nconst char* PEM_CA_CERT = \\\n    \"-----BEGIN CERTIFICATE-----\\n\" \\\n    ...\n    ...\n    \"-----END CERTIFICATE-----\\n\";\n\nota.setCACert(PEM_CA_CERT);\n```\n\n### 🏷️Get Tag\n\n#### ✨`String getLatestRelease()` Get Latest release tag\n\n- `Returns`:\n  - `String`: Latest release\n\n#### ✨`std::vector\u003cString\u003e getReleaseTagList()` Get all release tags\n\n- `Returns`:\n  - `std::vector\u003cString\u003e`: List of release tags\n\nexample:\n\n```cpp\nstd::vector\u003cString\u003e tags = ota.getReleaseTagList()\nfor (String tag : tags) {\n    Serial.println(tag);\n}\n```\n\n### 🔖Get Release ([`GithubRelease`](#githubrelease) Object)\n\n#### ✨`GithubRelease getLatestRelease()` Get Latest release\n\n- `Returns`:\n  - [`GithubRelease`](#githubrelease): Latest release\n\n#### ✨`GithubRelease getReleaseByTagName(const char* tagName)` Get release by tag name\n\n- `Parameters`:\n  - `tagName` - `const char*`: Tag name\n- `Returns`:\n  - [`GithubRelease`](#githubrelease): Release\n\n### 📦️Get Asset ([`GithubReleaseAsset`](#githubreleaseasset) Object)\n\n#### ✨`GithubReleaseAsset getAssetByname(GithubRelease release, const char* name)` Get asset by asset name\n\n- `Parameters`:\n  - `release` - [`GithubRelease`](#githubrelease): Release\n  - `name` - `const char*`: Asset name\n- `Returns`:\n  - [`GithubReleaseAsset`](#githubreleaseasset): Asset\n\n### ⚡️Flash Firmware or SPIFFS\n\nTo Flash Firmware or SPIFFS, Use on `Loop` function\n\n- Returns `int`:\n  - `0`: Success\n  - `1`: Null URL\n  - `2`: Connect error\n  - `3`: Begin error\n  - `4`: Write error\n  - `5`: End error\n\n#### ✨`int flashFirmware(GithubReleaseAsset asset);` Flash firmware by asset\n\n- `Parameters`:\n  - `asset` - [`GithubReleaseAsset`](#githubreleaseasset): Asset\n\n#### ✨`int flashFirmware(GithubRelease release, const char* name)` Flash firmware by release and asset name\n\n- `Parameters`:\n  - `release` - [`GithubRelease`](#githubrelease): Release\n  - `name` - `const char*`: Asset name\n\n#### ✨`int flashSpiffs(GithubReleaseAsset asset)` Flash SPIFFS by asset\n\n- `Parameters`:\n  - `asset` - [`GithubReleaseAsset`](#githubreleaseasset): Asset\n\n#### ✨`int flashSpiffs(GithubRelease release, const char* name)` Flash SPIFFS by release and asset name\n\n- `Parameters`:\n  - `release` - [`GithubRelease`](#githubrelease): Release\n  - `name` - `const char*`: Asset name\n\n#### ✨`int GithubReleaseOTA::flashByAssetId(int assetId, int flashType)` Flash by asset id\n\n- `Parameters`:\n  - `assetId` - `int`: Asset id\n  - `flashType` - `int`: Flash type (`Firmware`: U_FLASH, `SPIFFS`: U_SPIFFS)\n\n### ♻️Free Memory\n\n- ✨`void freeRelease(GithubRelease\u0026 release)` Free release object\n- ✨`void freeReleaseAsset(GithubReleaseAsset\u0026 asset)` Free asset object\n- ✨`void freeAuthor(GithubAuthor\u0026 author)` Free author object\n\n## 👽️Object\n\nSee Github API for more information: [GitHub API](https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28)\n\n### GithubRelease\n\n- `url`: const char*\n- `assets_url`: const char*\n- `upload_url`: const char*\n- `html_url`: const char*\n- `id`: int\n- `node_id`: const char*\n- `tag_name`: const char*\n- `target_commitish`: const char*\n- `name`: const char*\n- `draft`: bool\n- `prerelease`: bool\n- `created_at`: const char*\n- `published_at`: const char*\n- `author`: std::vector\\\u003c[GithubAuthor](#githubauthor)\\\u003e\n- `assets`: std::vector\\\u003c[GithubReleaseAsset](#githubreleaseasset)\\\u003e\n\n### GithubReleaseAsset\n\n- `url`: const char*\n- `browser_download_url`: const char*\n- `id`: int\n- `node_id`: const char*\n- `name`: const char*\n- `label`: const char*\n- `content_type`: const char*\n- `state`: const char*\n- `size`: int\n- `download_count`: int\n- `created_at`: const char*\n- `updated_at`: const char*\n- `author`: std::vector\\\u003c[GithubAuthor](#githubauthor)\\\u003e\n\n### GithubAuthor\n\n- `login`: const char*\n- `id`: int\n- `node_id`: const char*\n- `avatar_url`: const char*\n- `gravatar_id`: const char*\n- `url`: const char*\n- `html_url`: const char*\n- `followers_url`: const char*\n- `following_url`: const char*\n- `gists_url`: const char*\n- `starred_url`: const char*\n- `subscriptions_url`: const char*\n- `organizations_url`: const char*\n- `repos_url`: const char*\n- `events_url`: const char*\n- `received_events_url`: const char*\n- `type`: const char*\n- `site_admin`: bool\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhsun1031%2Fesp_git_ota","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhsun1031%2Fesp_git_ota","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhsun1031%2Fesp_git_ota/lists"}