Skip to content

Commit

Permalink
20240421
Browse files Browse the repository at this point in the history
Web UI:
- Fix web install selected version
- Fix web install latest version

Code:
- Add fetch latest bin file link from Github on ESP32

Build and Development:
- Move manifest.json from release to mkdocs/assets/manifest/$VERSION$/manifest.json

Docs:

Hardware:
  • Loading branch information
xyzroe committed Apr 20, 2024
1 parent 9e562dd commit dc51005
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 18 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,23 @@ jobs:
files: |
bin/XZG_${{ steps.get_version.outputs.version }}.ota.bin
bin/XZG_${{ steps.get_version.outputs.version }}.full.bin
manifest.json
- name: Checkout mkdocs branch
uses: actions/checkout@v3
with:
ref: mkdocs
path: mkdocs

- name: Copy manifest.json to mkdocs branch
run: |
mkdir -p mkdocs/docs/assets/manifest/${{ steps.get_version.outputs.version }}
cp manifest.json mkdocs/docs/assets/manifest/${{ steps.get_version.outputs.version }}/manifest.json
- name: Commit and push manifest.json
run: |
cd mkdocs
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add docs/assets/manifest/${{ steps.get_version.outputs.version }}/manifest.json
git commit -m "Add manifest.json for version ${{ steps.get_version.outputs.version }}"
git push origin mkdocs
2 changes: 1 addition & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#define BUFFER_SIZE 256

#define UPD_FILE "https://github.com/mercenaruss/uzg-firmware/releases/latest/download/XZG.bin"
//#define UPD_FILE "https://github.com/mercenaruss/uzg-firmware/releases/latest/download/XZG.bin"

// CC2652 settings (FOR BSL VALIDATION!)
#define NEED_BSL_PIN 15 // CC2652 pin number (FOR BSL VALIDATION!)
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// AUTO GENERATED FILE
#ifndef VERSION
#define VERSION "20240420"
#define VERSION "20240421"
#endif
52 changes: 47 additions & 5 deletions src/web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,18 @@ void handleApi()
if (serverWeb.hasArg(argUrl))
getEspUpdate(serverWeb.arg(argUrl));
else
getEspUpdate(UPD_FILE);
{
String link = fetchGitHubReleaseInfo();
LOGD("%s", link.c_str());
if (link)
{
getEspUpdate(link);
}
else
{
LOGW("Error getting link");
}
}
break;
case CMD_ZB_CHK_FW:
zbFwCheck();
Expand Down Expand Up @@ -1909,11 +1920,11 @@ String getRootData(bool update)
const char *espFlashType = "espFlashType";
if (chip_info.features & CHIP_FEATURE_EMB_FLASH)
{
doc[espFlashType] = 1;
doc[espFlashType] = 1;
}
else
{
doc[espFlashType] = 2;
doc[espFlashType] = 2;
}

doc["espFlashSize"] = ESP.getFlashChipSize() / (1024 * 1024);
Expand Down Expand Up @@ -1988,7 +1999,7 @@ String getRootData(bool update)
doc[wifiDns] = networkCfg.wifiDhcp ? noConn : WiFi.dnsIP().toString();
}
}

if (vars.apStarted)
{ // AP active
String AP_NameString;
Expand All @@ -2000,7 +2011,7 @@ String getRootData(bool update)
doc[wifiMaskKey] = "255.255.255.0 (Access point)";
doc[wifiGateKey] = "192.168.1.1 (this device)";
doc[wifiDhcpKey] = "On (Access point)";
doc[wifiMode] = 2; //"AP";
doc[wifiMode] = 2; //"AP";
doc[wifiRssi] = noConn; //"N/A";
}

Expand Down Expand Up @@ -2249,3 +2260,34 @@ void runEspUpdateFirmware(uint8_t *data, size_t len)
// Restart ESP32 to see changes
ESP.restart();
}

String fetchGitHubReleaseInfo()
{
HTTPClient http;
http.begin("https://api.github.com/repos/xyzroe/xzg/releases");
int httpCode = http.GET();

String browser_download_url = "";

if (httpCode > 0)
{
String payload = http.getString();
LOGD("payload: %s", payload);

DynamicJsonDocument doc(8192);
deserializeJson(doc, payload);
JsonArray releases = doc.as<JsonArray>();

if (releases.size() > 0 && releases[0]["assets"].size() > 1)
{
browser_download_url = releases[0]["assets"][1]["browser_download_url"].as<String>();
}
}
else
{
LOGD("Error on HTTP request");
}

http.end();
return browser_download_url;
}
1 change: 1 addition & 0 deletions src/web.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void progressFunc(unsigned int progress, unsigned int total);

void getEspUpdate(String esp_fw_url);
void runEspUpdateFirmware(uint8_t *data, size_t len);
String fetchGitHubReleaseInfo();

void updateWebTask(void *parameter);

Expand Down
4 changes: 2 additions & 2 deletions src/websrc/html/PAGE_ABOUT.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h4 class="fw-bold mb-0" data-i18n="p.ab.w.t"></h4>
<h4 class="fw-bold mb-0" data-i18n="p.ab.cm.t"></h4>
<p data-i18n="p.ab.cm.m"></p>
<p class="text-center">
<a class="about_link" href="https://t.me/XZG_firmware" target="_blank" data-i18n="p.ab.cm.l"></a>
<a class="about_link" href="https://t.me/xzg_fw" target="_blank" data-i18n="p.ab.cm.l"></a>
</p>
</div>
</div>
Expand All @@ -61,7 +61,7 @@ <h4 class="fw-bold mb-0" data-i18n="p.ab.r.t"></h4>
<h4 class="fw-bold mb-0" data-i18n="p.ab.c.t"></h4>
<p data-i18n="p.ab.c.m"></p>
<p class="text-center">
<a class="about_link" href="https://github.com/xyzroe/xzg/" target="_blank" data-i18n="p.ab.c.l"></a>
<a class="about_link" href="https://github.com/xyzroe/xzg" target="_blank" data-i18n="p.ab.c.l"></a>
</p>
</div>
</div>
Expand Down
16 changes: 9 additions & 7 deletions src/websrc/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1530,10 +1530,10 @@ function modalConstructor(type, params) {
action = 1
$(modalBody).html(i18next.t("md.esp.fu.lfm"));
}
else if (typeof params === 'string' && /^https?:\/\//.test(params)) {
console.log("URL received:", params);
action = 2
$(modalBody).html(i18next.t("md.esp.fu.gvm"));
else if (params && 'link' in params && typeof params.link === 'string' && /^https?:\/\/.*/.test(params.link)) {
console.log("URL received:", params.link);
action = 2;
$(modalBody).html(i18next.t("md.esp.fu.gvm", { ver: params.ver }));
} else {
action = 3
console.log("Else ? received:", params);
Expand Down Expand Up @@ -1750,12 +1750,14 @@ function modalConstructor(type, params) {
}).appendTo(buttonAndDownloadsContainer);

if (release.assets.length > 0) {
const downloadLink = release.assets[0].browser_download_url;
const downloadLink = release.assets[1].browser_download_url;
$('<a>', {
"class": "btn btn-outline-warning",
click: function () {
//closeModal();
modalConstructor("flashESP", downloadLink);
var params = {};
params['link'] = downloadLink;
params['ver'] = release.tag_name;
modalConstructor("flashESP", params);
},
"data-bs-toggle": "tooltip",
"title": i18next.t('c.inst') + " " + release.tag_name,
Expand Down
2 changes: 1 addition & 1 deletion src/websrc/js/ota.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function sub_zb(t) {
}

async function fetchReleaseData() {
var t = await fetch("https://api.github.com/repos/xyzroe/ZigStarGW-FW/releases");
var t = await fetch("https://api.github.com/repos/xyzroe/xzg/releases");
if (t.ok) return await t.json();
throw new Error("GitHub API request failed: " + t.statusText)
}
Expand Down

0 comments on commit dc51005

Please sign in to comment.