Skip to content

Commit

Permalink
20240508
Browse files Browse the repository at this point in the history
Web UI:
- Resolved issues with commands button failure states
- Fix ability to flash CC2652 if no revision design detected
- Add ESP restart after Zigbee flashing
- Add "Erase complete" message before Zigbee flashing

Code:
= Corrected errors with the trash ZB version
- Fixed ZB version detection during boot
- Ensured status returns for both ZB LED toggle and firmware check buttons
  • Loading branch information
xyzroe committed May 8, 2024
1 parent 07d2384 commit 8f260b9
Show file tree
Hide file tree
Showing 20 changed files with 86 additions and 60 deletions.
3 changes: 2 additions & 1 deletion lib/CCTools/src/CCTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ bool CommandInterface::_ledToggle(bool ledState)
CommandInterface::zbInfoStruct CommandInterface::_checkFwVer()
{
zbInfoStruct chip;
for (uint8_t i = 0; i < 6; i++)
for (uint8_t i = 0; i < 10; i++)
{
if (_stream.read() != cmdFrameStart || _stream.read() != 0x0a || _stream.read() != 0x61 || _stream.read() != cmdVer2)
{ // check for packet start
Expand Down Expand Up @@ -456,6 +456,7 @@ CommandInterface::zbInfoStruct CommandInterface::_checkFwVer()
return chip;
}
}
chip.fwRev = 0;
return chip;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/CCTools/src/CCTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class CommandInterface
}
else if (chip_id == 0x3202 && wafer_id == 0xBB41 && pg_rev == 0x3)
{
return "CC2652P2_?";
return "CC2652P2_";
}
else if (chip_id == 0x3102 && wafer_id == 0xBB41 && pg_rev == 0x3)
{
Expand Down
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ void startServers(bool usb = false)

startAP(false);

zbFwCheck();

if (!vars.apStarted)
{
if (vpnCfg.wgEnable)
Expand Down Expand Up @@ -575,11 +573,13 @@ void setup()
setupCoordinatorMode();
vars.connectedClients = 0;

LOGD("done");

xTaskCreate(updateWebTask, "update Web Task", 2048, NULL, 7, NULL);

printNVSFreeSpace();

zbFwCheck();

LOGD("done");
}

WiFiClient client[10];
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 "20240507"
#define VERSION "20240508"
#endif
18 changes: 16 additions & 2 deletions src/web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,27 @@ void handleApi()
}
break;
case CMD_ZB_CHK_FW:
zbFwCheck();
if (zbFwCheck())
{
serverWeb.send(HTTP_CODE_OK, contTypeText, result);
}
else
{
serverWeb.send(HTTP_CODE_INTERNAL_SERVER_ERROR, contTypeText, result);
}
break;
case CMD_ZB_CHK_HW:
zbHwCheck();
break;
case CMD_ZB_LED_TOG:
zbLedToggle();
if (zbLedToggle())
{
serverWeb.send(HTTP_CODE_OK, contTypeText, result);
}
else
{
serverWeb.send(HTTP_CODE_INTERNAL_SERVER_ERROR, contTypeText, result);
}
break;
case CMD_ESP_FAC_RES:
if (serverWeb.hasArg(argConf))
Expand Down
56 changes: 23 additions & 33 deletions src/websrc/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,15 +621,15 @@ function apiGetPage(page, doneCall, loader = true) {
if (cmd == 3) {
modalConstructor("restartWait");
}
}, 1000, jbtn);
}, 2000, jbtn);
}).fail(function () {
spiner.remove();
jbtn.prop("disabled", false);
statusFail.appendTo(jbtn);
setTimeout(function (jbtn) {
statusFail.remove();
}, 1000, jbtn);
alert(i18next.t('c.ercn'));
}, 2000, jbtn);
//alert(i18next.t('c.ercn'));
});
}
});
Expand Down Expand Up @@ -1319,6 +1319,10 @@ function updateRootEvents(callback) {
data = i18next.t('md.zg.fu.st');
}

if (e.data == "erase") {
data = i18next.t('md.zg.fu.er');
}

if (e.data == "finish") {
data = i18next.t('md.zg.fu.fn');
$(".progress").addClass(classHide);
Expand All @@ -1340,7 +1344,15 @@ function updateRootEvents(callback) {
data = i18next.t('md.zg.fu.f', { file: fileName });
}
else {
data = i18next.t('md.zg.fu.nv', { ver: e.data });
let ver = "Unknown";
if (e.data != 0) {
ver = e.data;
}
data = i18next.t('md.zg.fu.nv', { ver: ver });
setTimeout(function () {
espReboot();
restartWait();
}, 2000);
}
$("#zbFlshPgsTxt").html(data);
}, false);
Expand Down Expand Up @@ -1490,45 +1502,23 @@ function updateProgressBar(id, current, min, max) {
//progressBar.textContent = width.toFixed(0) + '%'; // Отображаем проценты внутри прогресс бара
}

function findLatestVersions(data, deviceName) {
const categories = ['router', 'coordinator'];
const result = {};

categories.forEach(category => {
if (data[category]) {
Object.keys(data[category]).forEach(subCategory => {
if (subCategory.startsWith(deviceName)) {
Object.keys(data[category][subCategory]).forEach(file => {
const fileInfo = data[category][subCategory][file];
if (!result[category] || result[category].ver < fileInfo.ver) {
result[category] = {
file: file,
ver: fileInfo.ver,
link: fileInfo.link,
notes: fileInfo.notes
};
}
});
}
});
}
});

return result;
}

function findAllVersionsSorted(data, chip) {
const categories = ['router', 'coordinator', 'thread'];
const result = {};

const chipMap = { "CC2652P2_launchpad": "CC2652P2_launchpad", "CC2652P2_other": "CC2652P2_other", "CC2652P7": "CC2652P7", "CC2652RB": "CC2652RB" };
const deviceName = chipMap[chip];
if (!deviceName) throw new Error("Unsupported chip type or deviceName not set.");
let deviceName = chipMap[chip];
if (!deviceName) {
//throw new Error("Unsupported chip type or deviceName not set.");
console.error("error with ZB chip detect");
deviceName = chip;
}

categories.forEach(category => {
if (data[category]) {
Object.keys(data[category]).forEach(subCategory => {
if (subCategory == deviceName) {
if (subCategory.startsWith(deviceName)) {
Object.keys(data[category][subCategory]).forEach(file => {
const fileInfo = data[category][subCategory][file];
if (!result[category]) {
Expand Down
3 changes: 2 additions & 1 deletion src/websrc/json/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"f": "Wird geflasht: {{file}}",
"fn": "Erfolgreich geflasht!",
"nv": "Neue Version: {{ver}}",
"st": "CC2652-Blitz startet..."
"st": "CC2652-Blitz startet...",
"er": "Löschen beendet"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/websrc/json/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@
"f": "Going to flash: {{file}}",
"fn": "The firmware was successfully installed!",
"nv": "New version: {{ver}}",
"st": "CC2652 flash is starting..."
"st": "CC2652 flash is starting...",
"er": "Erase finished"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/websrc/json/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"f": "Va a flashear: {{archivo}}",
"fn": "¡Flasheado exitosamente!",
"nv": "Nueva versión: {{ver}}",
"st": "CC2652 flash iniciando..."
"st": "CC2652 flash iniciando...",
"er": "Borrar terminado"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/websrc/json/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"f": "Va flasher : {{file}}",
"fn": "Flashé avec succès !",
"nv": "Nouvelle version : {{ver}}",
"st": "Démarrage du flash CC2652..."
"st": "Démarrage du flash CC2652...",
"er": "Effacement terminé"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/websrc/json/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"f": "Flash: {{file}}",
"fn": "Flashato con successo!",
"nv": "Nuova versione: {{ver}}",
"st": "Avvio flash CC2652..."
"st": "Avvio flash CC2652...",
"er": "Cancellazione terminata"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/websrc/json/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"f": "フラッシュに移動します: {{file}}",
"fn": "無事フラッシュされました!",
"nv": "新しいバージョン: {{ver}}",
"st": "CC2652 フラッシュが起動しています..."
"st": "CC2652 フラッシュが起動しています...",
"er": "消去完了"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/websrc/json/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"f": "Zamierzam flashować: {{file}}",
"fn": "Flashowanie pomyślnie!",
"nv": "Nowa wersja: {{ver}}",
"st": "Uruchamianie lampy błyskowej CC2652..."
"st": "Uruchamianie lampy błyskowej CC2652...",
"er": "Wymazywanie zakończone"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/websrc/json/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"f": "Indo piscar: {{file}}",
"fn": "Piscou com sucesso!",
"nv": "Nova versão: {{ver}}",
"st": "Flash CC2652 iniciando..."
"st": "Flash CC2652 iniciando...",
"er": "Apagar concluído"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/websrc/json/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"f": "Прошивка: {{file}}",
"fn": "Прошивка прошла успешно!",
"nv": "Новая версия: {{ver}}",
"st": "Начинается прошивка CC2652..."
"st": "Начинается прошивка CC2652...",
"er": "Стирание завершено"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/websrc/json/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"f": "Flash'a gidiyor: {{file}}",
"fn": "Başarıyla yanıp söndü!",
"nv": "Yeni sürüm: {{ver}}",
"st": "CC2652 flaş başlangıç..."
"st": "CC2652 flaş başlangıç...",
"er": "Silme tamamlandı"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/websrc/json/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@
"f": "Прошивка: {{файл}}",
"fn": "Прошивку успішно встановлено!",
"nv": "Нова версія: {{ver}}",
"st": "Починається прошивка CC2652..."
"st": "Починається прошивка CC2652...",
"er": "Стирання завершено"
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/websrc/json/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"f": "即将闪现:{{file}}",
"fn": "刷机成功!",
"nv": "新版本:{{ver}}",
"st": "CC2652闪存启动..."
"st": "CC2652闪存启动...",
"er": "擦除完毕"
}
}
},
Expand Down
17 changes: 13 additions & 4 deletions src/zb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ String tag_ZB = "[ZB]";

extern CCTools CCTool;

void zbFwCheck()
bool zbFwCheck()
{
if (CCTool.checkFirmwareVersion())
{
printLogMsg(tag_ZB + " fw: " + String(CCTool.chip.fwRev));
return true;
}
else
{
printLogMsg(tag_ZB + " fw: unknown!");
return false;
}
}

Expand All @@ -65,24 +71,26 @@ void zbHwCheck()
CCTool.restart();
}

void zbLedToggle()
bool zbLedToggle()
{
if (CCTool.ledToggle())
{
if (CCTool.ledState == 1)
{
printLogMsg("[ZB] LED toggle ON");
//vars.zbLedState = 1;
// vars.zbLedState = 1;
}
else
{
printLogMsg("[ZB] LED toggle OFF");
//vars.zbLedState = 0;
// vars.zbLedState = 0;
}
return true;
}
else
{
printLogMsg("[ZB] LED toggle ERROR");
return false;
}
}

Expand Down Expand Up @@ -187,6 +195,7 @@ bool eraseWriteZbUrl(const char *url, std::function<void(float)> progressShow, C
}

CCTool.eraseFlash();
sendEvent("ZB_FW_info", 11, String("erase"));
printLogMsg("Erase completed!");

int totalSize = http.getSize();
Expand Down
4 changes: 2 additions & 2 deletions src/zb.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
void zbFwCheck();
bool zbFwCheck();
void zbHwCheck();
void zbLedToggle();
bool zbLedToggle();
bool zigbeeErase();
void flashZbUrl(String url);
bool eraseWriteZbUrl(const char *url, std::function<void(float)> progressShow, CCTools &CCTool);
Expand Down

0 comments on commit 8f260b9

Please sign in to comment.