Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
SAOPP authored Jun 10, 2024
2 parents f90ecd0 + b08c13f commit d515d26
Show file tree
Hide file tree
Showing 25 changed files with 432 additions and 334 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/build_fw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ jobs:
echo "No changes to commit"
fi
notify:
runs-on: ubuntu-latest
needs: build_release_push
steps:
- name: Send Telegram Notification about release
uses: appleboy/telegram-action@master
with:
Expand All @@ -153,4 +149,4 @@ jobs:
json_payload=$(jq -n --arg content "https://github.com/${{ github.repository }}/releases/tag/${{ steps.get_tag.outputs.tag }}" '{content: $content}')
curl -H "Content-Type: application/json" \
-d "$json_payload" \
${{ secrets.DISCORD_WEBHOOK }}
${{ secrets.DISCORD_WEBHOOK }}
7 changes: 7 additions & 0 deletions XZG.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
"files.associations": {
"*.tpp": "cpp"
},
"i18n-ally.keysInUse": [
"p.lo.mlo",
"p.lo.mwc",
"p.lo.mnl",
"p.mq.disc.ph",
"p.mq.disc.n"
],
},
"extensions": {
"recommendations": [
Expand Down
2 changes: 2 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ struct SysVarsStruct
bool updateZbAvail;
IPAddress savedWifiDNS;
IPAddress savedEthDNS;

bool firstUpdCheck = false;
};

// Network configuration structure
Expand Down
3 changes: 1 addition & 2 deletions src/const/hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ EthConfig ethConfigs[] = {
{.addr = 0, .pwrPin = 12, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT}, // .pwrAltPin = -1}, // 0 Olimex-ESP32-POE
{.addr = 1, .pwrPin = 16, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO0_IN}, // .pwrAltPin = -1}, // 1 WT32-ETH01
{.addr = 0, .pwrPin = 5, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT}, // .pwrAltPin = -1}, // 2 T-Internet-POE / UZG01 / HamGeek POE Plus
// {.addr = 0, .pwrPin = 5, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT}, // .pwrAltPin = -1}, // 3 HamGeek POE Plus
};

// ZigBee configurations
Expand Down Expand Up @@ -47,5 +46,5 @@ BrdConfigStruct brdConfigs[] = {
{"TubesZB-poe-2023", .ethConfigIndex = 0, .zbConfigIndex = 6, .mistConfigIndex = 0}, // 10
{"CZC-1.0", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 11
{"SLS-classic", .ethConfigIndex = -1, .zbConfigIndex = 7, .mistConfigIndex = 3}, // 12
{"HG POE+", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 13
{"HG POE Plus", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 13
};
200 changes: 117 additions & 83 deletions src/etc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ void nmDeactivate()
setLedsDisable();
}

void checkDNS(bool setup)
bool checkDNS(bool setup)
{
const char *wifiKey = "WiFi";
const char *ethKey = "ETH";
Expand Down Expand Up @@ -482,6 +482,7 @@ void checkDNS(bool setup)
}
}
}
return true;
}

/*void reCheckDNS()
Expand All @@ -491,7 +492,7 @@ void checkDNS(bool setup)

void setupCron()
{
//Cron.create(const_cast<char *>("30 */1 * * * *"), reCheckDNS, false);
// Cron.create(const_cast<char *>("30 */1 * * * *"), reCheckDNS, false);

// const String time = systemCfg.updCheckTime;
static char formattedTime[16];
Expand Down Expand Up @@ -627,7 +628,7 @@ ThisConfigStruct *findBrdConfig(int searchId = 0)
bool zbOk = false;

static ThisConfigStruct bestConfig;
bestConfig.eth = {.addr = -1, .pwrPin = -1, .mdcPin = -1, .mdiPin = -1, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT};// .pwrAltPin = -1};
bestConfig.eth = {.addr = -1, .pwrPin = -1, .mdcPin = -1, .mdiPin = -1, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT}; // .pwrAltPin = -1};
bestConfig.zb = {.txPin = -1, .rxPin = -1, .rstPin = -1, .bslPin = -1};
memset(&bestConfig.mist, -1, sizeof(bestConfig.mist));
strlcpy(bestConfig.board, "Unknown", sizeof(bestConfig.board));
Expand All @@ -640,7 +641,7 @@ ThisConfigStruct *findBrdConfig(int searchId = 0)

LOGI("Try brd: %d - %s", brdIdx, brdConfigs[brdIdx].board);

if (brdIdx == 3) // T-Internet-POE
/*if (brdIdx == 3) // T-Internet-POE
{
pinMode(ethConfigs[ethIdx].pwrPin, OUTPUT);
delay(50);
Expand All @@ -654,69 +655,99 @@ ThisConfigStruct *findBrdConfig(int searchId = 0)
LOGW("%s", "Looks like not T-Internet-POE!");
continue;
}
}
}*/

if (ETH.begin(ethConfigs[ethIdx].addr, ethConfigs[ethIdx].pwrPin, ethConfigs[ethIdx].mdcPin, ethConfigs[ethIdx].mdiPin, ethConfigs[ethIdx].phyType, ethConfigs[ethIdx].clkMode))// ethConfigs[ethIdx].pwrAltPin))
if (ethIdx == -1)
{
ethOk = true;
LOGD("NO ethernet OK: %d", ethIdx);
}
else if (ETH.begin(ethConfigs[ethIdx].addr, ethConfigs[ethIdx].pwrPin, ethConfigs[ethIdx].mdcPin, ethConfigs[ethIdx].mdiPin, ethConfigs[ethIdx].phyType, ethConfigs[ethIdx].clkMode)) // ethConfigs[ethIdx].pwrAltPin))
{
ethOk = true;
LOGD("Ethernet config OK: %d", ethIdx);

bestConfig.eth = ethConfigs[ethIdx];
LOGD("Ethernet config OK: %d", ethIdx);
}

if (mistConfigs[mistIdx].btnPin > 0)
if (mistConfigs[mistIdx].btnPin > 0)
{
pinMode(mistConfigs[mistIdx].btnPin, INPUT);
int press = 0;
for (int y = 0; y < 10; y++)
{
pinMode(mistConfigs[mistIdx].btnPin, INPUT);
int press = 0;
for (int y = 0; y < 10; y++)
int state = digitalRead(mistConfigs[mistIdx].btnPin);
if (state != mistConfigs[mistIdx].btnPlr)
{
int state = digitalRead(mistConfigs[mistIdx].btnPin);
if (state != mistConfigs[mistIdx].btnPlr)
{
press++;
}
delay(100);
press++;
}
btnOk = (press <= 5);
delay(100);
}
btnOk = (press <= 5);

if (!btnOk)
{
LOGD("Button pin ERROR");
ethOk = false;
}
else
{
LOGD("Button pin OK");
}
if (!btnOk)
{
LOGD("Button pin ERROR");
ethOk = false;
}
else
{
btnOk = true;
LOGD("Button pin OK");
}
}
else
{
btnOk = true;
}

if (btnOk)
{
LOGD("Trying Zigbee: %d", zbIdx);
esp_task_wdt_reset();
Serial2.begin(systemCfg.serialSpeed, SERIAL_8N1, zbConfigs[zbIdx].rxPin, zbConfigs[zbIdx].txPin);
if (btnOk)
{
LOGD("Trying Zigbee: %d", zbIdx);
esp_task_wdt_reset();
Serial2.begin(systemCfg.serialSpeed, SERIAL_8N1, zbConfigs[zbIdx].rxPin, zbConfigs[zbIdx].txPin);

int BSL_PIN_MODE = 0;
if (CCTool.begin(zbConfigs[zbIdx].rstPin, zbConfigs[zbIdx].bslPin, BSL_PIN_MODE))
int BSL_PIN_MODE = 0;
if (CCTool.begin(zbConfigs[zbIdx].rstPin, zbConfigs[zbIdx].bslPin, BSL_PIN_MODE))
{
if (CCTool.detectChipInfo())
{
if (CCTool.detectChipInfo())
{
zbOk = true;
LOGD("Zigbee config OK: %d", zbIdx);
zbOk = true;
LOGD("Zigbee config OK: %d", zbIdx);

bestConfig.zb = zbConfigs[zbIdx];
bestConfig.mist = mistConfigs[mistIdx];

bestConfig.zb = zbConfigs[zbIdx];
bestConfig.mist = mistConfigs[mistIdx];
strlcpy(bestConfig.board, brdConfigs[brdIdx].board, sizeof(bestConfig.board));
return &bestConfig;
bool multiCfg = false;
int brdNewId = -1;
for (int brdNewIdx = 0; brdNewIdx < BOARD_CFG_CNT; brdNewIdx++)
{
LOGD("%d %d", brdIdx, brdNewIdx);
if (brdIdx != brdNewIdx && brdConfigs[brdNewIdx].ethConfigIndex == ethIdx && brdConfigs[brdNewIdx].zbConfigIndex == zbIdx && brdConfigs[brdNewIdx].mistConfigIndex == mistIdx)
{
multiCfg = true;
brdNewId = brdNewIdx;
break;
}
}
const char *nameBrd;
if (!multiCfg)
{
nameBrd = brdConfigs[brdIdx].board;
strlcpy(bestConfig.board, nameBrd, sizeof(bestConfig.board));
}
else
{
zbOk = false;
LOGD("Zigbee config ERROR");
String nameBrdStr = ("Multi_" + String(brdNewId));
nameBrd = nameBrdStr.c_str();
// LOGW("%s", nameBrdStr);
strlcpy(bestConfig.board, nameBrd, sizeof(bestConfig.board));
}

return &bestConfig;
}
else
{
zbOk = false;
LOGD("Zigbee config ERROR");
}
}
}
Expand Down Expand Up @@ -960,47 +991,50 @@ int compareVersions(String v1, String v2)

void checkUpdateAvail()
{
const char *ESPkey = "ESP";
const char *ZBkey = "ZB";
const char *FoundKey = "Found ";
const char *NewFwKey = " new fw: ";
const char *TryKey = "try to install";
String latestReleaseUrlEsp = fetchLatestEspFw();
String latestReleaseUrlZb = fetchLatestZbFw();
String latestVersionEsp = extractVersionFromURL(latestReleaseUrlEsp);
String latestVersionZb = extractVersionFromURL(latestReleaseUrlZb);

LOGD("%s %s", ESPkey, latestVersionEsp.c_str());
LOGD("%s %s", ZBkey, latestVersionZb.c_str());

if (latestVersionEsp.length() > 0 && compareVersions(latestVersionEsp, VERSION) > 0)
{
vars.updateEspAvail = true;
printLogMsg(String(FoundKey) + String(ESPkey) + String(NewFwKey) + latestVersionEsp);
if (systemCfg.updAutoInst)
if (!vars.apStarted)
{
const char *ESPkey = "ESP";
const char *ZBkey = "ZB";
const char *FoundKey = "Found ";
const char *NewFwKey = " new fw: ";
const char *TryKey = "try to install";
String latestReleaseUrlEsp = fetchLatestEspFw();
String latestReleaseUrlZb = fetchLatestZbFw();
String latestVersionEsp = extractVersionFromURL(latestReleaseUrlEsp);
String latestVersionZb = extractVersionFromURL(latestReleaseUrlZb);

LOGD("%s %s", ESPkey, latestVersionEsp.c_str());
LOGD("%s %s", ZBkey, latestVersionZb.c_str());

if (latestVersionEsp.length() > 0 && compareVersions(latestVersionEsp, VERSION) > 0)
{
printLogMsg(String(TryKey));
getEspUpdate(latestReleaseUrlEsp);
vars.updateEspAvail = true;
printLogMsg(String(FoundKey) + String(ESPkey) + String(NewFwKey) + latestVersionEsp);
if (systemCfg.updAutoInst)
{
printLogMsg(String(TryKey));
getEspUpdate(latestReleaseUrlEsp);
}
}
else
{
vars.updateEspAvail = false;
}
}
else
{
vars.updateEspAvail = false;
}

if (CCTool.chip.fwRev > 0 && latestVersionZb.length() > 0 && compareVersions(latestVersionZb, String(CCTool.chip.fwRev)) > 0)
{
vars.updateZbAvail = true;
printLogMsg(String(FoundKey) + String(ZBkey) + String(NewFwKey) + latestVersionZb);
if (systemCfg.updAutoInst)
if (CCTool.chip.fwRev > 0 && latestVersionZb.length() > 0 && compareVersions(latestVersionZb, String(CCTool.chip.fwRev)) > 0)
{
printLogMsg(String(TryKey));
flashZbUrl(latestReleaseUrlZb);
ESP.restart();
vars.updateZbAvail = true;
printLogMsg(String(FoundKey) + String(ZBkey) + String(NewFwKey) + latestVersionZb);
if (systemCfg.updAutoInst)
{
printLogMsg(String(TryKey));
flashZbUrl(latestReleaseUrlZb);
ESP.restart();
}
}
else
{
vars.updateZbAvail = false;
}
}
else
{
vars.updateZbAvail = false;
}
}
2 changes: 1 addition & 1 deletion src/etc.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void factoryReset();
void setLedsDisable(bool all = false);
void cronTest();
void nmActivate();
void checkDNS(bool setup = false);
bool checkDNS(bool setup = false);
void setupCron();

void setClock(void *pvParameters);
Expand Down
Loading

0 comments on commit d515d26

Please sign in to comment.