Skip to content

Commit

Permalink
20240610
Browse files Browse the repository at this point in the history
- Stops: socket connection, MQTT, cron and WG while Zigbee flashing and NVRAM erasing
- Fix RSSI bar direction
- Try to make SLS config works
- Fix AP turn OFF after LAN connected
- Update en.json #72 Thanks @SAOPP 🏆
- Update cz.json #71 Thanks @leroyloren 🏆
- Clean up the translations by removing unused entries and adding any missing ones
  • Loading branch information
xyzroe committed Jun 10, 2024
1 parent 0b7c82d commit 529442d
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 143 deletions.
39 changes: 25 additions & 14 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ void serializeSysVarsToJson(const SysVarsStruct &vars, JsonObject obj)

obj[disableLedsKey] = vars.disableLeds;
// obj[zbLedStateKey] = vars.zbLedState;
// obj[zbFlashingKey] = vars.zbFlashing;
obj[zbFlashingKey] = vars.zbFlashing;

obj[deviceIdKey] = vars.deviceId;

Expand Down Expand Up @@ -899,6 +899,10 @@ bool loadFileConfigHW()

if (!configFile)
{
if (!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED, "/lfs2", 10))
{
LOGD("Error with LITTLEFS");
}
DynamicJsonDocument config(300);
config[board] = "";
writeDefaultConfig(configFileHw, config);
Expand All @@ -917,10 +921,11 @@ bool loadFileConfigHW()
hwConfig.eth.mdiPin = config[mdiPin];
hwConfig.eth.phyType = config[phyType];
hwConfig.eth.clkMode = config[clkMode];
if (hwConfig.eth.pwrPin == -1) {
if (hwConfig.eth.pwrPin == -1)
{
hwConfig.eth.pwrPin = config[pwrAltPin];
}
//hwConfig.eth.pwrAltPin = config[pwrAltPin];
// hwConfig.eth.pwrAltPin = config[pwrAltPin];
hwConfig.mist.btnPin = config[btnPin];
hwConfig.mist.btnPlr = config[btnPlr];
hwConfig.mist.uartSelPin = config[uartSelPin];
Expand All @@ -936,18 +941,24 @@ bool loadFileConfigHW()

if (hwConfig.board[0] != '\0' && strlen(hwConfig.board) > 0)
{
LOGD("LOAD - OK");
LOGD("Load HW - OK");
return true;
}
else
{
LOGI("LOAD - ERROR");
LOGI("Load HW - ERROR");

int searchId = 0;
if (config["searchId"])
{
searchId = config["searchId"];
}
String chipId = ESP.getChipModel();
LOGW("%s", chipId);
//if (chipId == "ESP32-D0WDQ6")
//{
// searchId = 12;
//}
ThisConfigStruct *newConfig = findBrdConfig(searchId);
if (newConfig)
{
Expand All @@ -961,7 +972,7 @@ bool loadFileConfigHW()
config[mdiPin] = newConfig->eth.mdiPin;
config[phyType] = newConfig->eth.phyType;
config[clkMode] = newConfig->eth.clkMode;
//config[pwrAltPin] = newConfig->eth.pwrAltPin;
// config[pwrAltPin] = newConfig->eth.pwrAltPin;
config[btnPin] = newConfig->mist.btnPin;
config[btnPlr] = newConfig->mist.btnPlr;
config[uartSelPin] = newConfig->mist.uartSelPin;
Expand Down Expand Up @@ -1020,7 +1031,7 @@ bool loadFileSystemVar()
File configFile = LittleFS.open(configFileSystem, FILE_READ);
if (!configFile)
{
LOGD("%s %s", configFileSystem, msg_open_f);
// LOGD("%s %s", configFileSystem, msg_open_f);
return false;
}

Expand Down Expand Up @@ -1055,7 +1066,7 @@ bool loadFileConfigWifi()
File configFile = LittleFS.open(configFileWifi, FILE_READ);
if (!configFile)
{
LOGD("%s %s", configFileWifi, msg_open_f);
// LOGD("%s %s", configFileWifi, msg_open_f);
return false;
}

Expand Down Expand Up @@ -1094,7 +1105,7 @@ bool loadFileConfigEther()
File configFile = LittleFS.open(configFileEther, FILE_READ);
if (!configFile)
{
LOGD("%s %s", configFileEther, msg_open_f);
// LOGD("%s %s", configFileEther, msg_open_f);
return false;
}

Expand Down Expand Up @@ -1125,7 +1136,7 @@ bool loadFileConfigGeneral()
File configFile = LittleFS.open(configFileGeneral, FILE_READ);
if (!configFile)
{
LOGD("%s %s", configFileGeneral, msg_open_f);
// LOGD("%s %s", configFileGeneral, msg_open_f);
return false;
}

Expand Down Expand Up @@ -1170,7 +1181,7 @@ bool loadFileConfigSecurity()
File configFile = LittleFS.open(configFileSecurity, FILE_READ);
if (!configFile)
{
LOGD("%s %s", configFileSecurity, msg_open_f);
// LOGD("%s %s", configFileSecurity, msg_open_f);
return false;
}

Expand Down Expand Up @@ -1205,7 +1216,7 @@ bool loadFileConfigSerial()
File configFile = LittleFS.open(configFileSerial, FILE_READ);
if (!configFile)
{
LOGD("%s %s", configFileSerial, msg_open_f);
// LOGD("%s %s", configFileSerial, msg_open_f);
return false;
}

Expand Down Expand Up @@ -1234,7 +1245,7 @@ bool loadFileConfigMqtt()
File configFile = LittleFS.open(configFileMqtt, FILE_READ);
if (!configFile)
{
LOGD("%s %s", configFileMqtt, msg_open_f);
// LOGD("%s %s", configFileMqtt, msg_open_f);
return false;
}

Expand Down Expand Up @@ -1276,7 +1287,7 @@ bool loadFileConfigWg()
File configFile = LittleFS.open(configFileWg, FILE_READ);
if (!configFile)
{
LOGD("%s %s", configFileWg, msg_open_f);
// LOGD("%s %s", configFileWg, msg_open_f);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct SysVarsStruct

bool disableLeds;
// bool zbLedState;
// bool zbFlashing;
bool zbFlashing;

char deviceId[MAX_DEV_ID_LONG];

Expand Down
34 changes: 17 additions & 17 deletions src/const/hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// Ethernet configurations
// !!! Don't forget to edit ETH_CFG_CNT !!!
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 = 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
};

// ZigBee configurations
Expand Down Expand Up @@ -33,18 +33,18 @@ MistConfig mistConfigs[] = {
// Board configurations
// !!! Don't forget to edit BOARD_CFG_CNT !!!
BrdConfigStruct brdConfigs[] = {
{"UZG-01", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 0
{"SLZB-06", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 2}, // 1
{"WT32-ETH01", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 0}, // 2
{"T-Internet-POE", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 0}, // 3
{"Olimex-ESP32-POE", .ethConfigIndex = 0, .zbConfigIndex = 0, .mistConfigIndex = 0}, // 4
{"China-GW", .ethConfigIndex = 0, .zbConfigIndex = 2, .mistConfigIndex = 0}, // 5
{"TubesZB-eth", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 0}, // 6
{"TubesZB-eth_usb", .ethConfigIndex = 1, .zbConfigIndex = 3, .mistConfigIndex = 0}, // 7
{"TubesZB-poe", .ethConfigIndex = 0, .zbConfigIndex = 4, .mistConfigIndex = 0}, // 8
{"TubesZB-poe-2022", .ethConfigIndex = 0, .zbConfigIndex = 5, .mistConfigIndex = 0}, // 9
{"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 Plus", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 13
{"SLS-classic", .ethConfigIndex = -1, .zbConfigIndex = 7, .mistConfigIndex = 3}, // 0
{"UZG-01", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 1
{"SLZB-06", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 2}, // 2
{"WT32-ETH01", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 0}, // 3
{"T-Internet-POE", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 0}, // 4 DON'T MOVE
{"Olimex-ESP32-POE", .ethConfigIndex = 0, .zbConfigIndex = 0, .mistConfigIndex = 0}, // 5
{"China-GW", .ethConfigIndex = 0, .zbConfigIndex = 2, .mistConfigIndex = 0}, // 6
{"TubesZB-eth", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 0}, // 7
{"TubesZB-eth_usb", .ethConfigIndex = 1, .zbConfigIndex = 3, .mistConfigIndex = 0}, // 8
{"TubesZB-poe", .ethConfigIndex = 0, .zbConfigIndex = 4, .mistConfigIndex = 0}, // 9
{"TubesZB-poe-2022", .ethConfigIndex = 0, .zbConfigIndex = 5, .mistConfigIndex = 0}, // 10
{"TubesZB-poe-2023", .ethConfigIndex = 0, .zbConfigIndex = 6, .mistConfigIndex = 0}, // 11
{"CZC-1.0", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 12
{"HG POE Plus", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1}, // 13
};
2 changes: 1 addition & 1 deletion src/const/keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const char *mqttConnKey = "mqttConn";
const char *mqttReconnectTimeKey = "mqttReconnectTime";
const char *mqttHeartbeatTimeKey = "mqttHeartbeatTime";
// const char *zbLedStateKey = "zbLedState";
// const char *zbFlashingKey = "zbFlashing";
const char *zbFlashingKey = "zbFlashing";
const char *deviceIdKey = "deviceId";
const char *timeZoneNameKey = "timeZoneName";
const char *zbRoleKey = "zbRole";
Expand Down
6 changes: 4 additions & 2 deletions src/etc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,12 @@ void factoryReset()
delay(1000);
}

LittleFS.format();
if (!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED, "/lfs2", 10)) // change to format anyway
{
LOGD("Error with LITTLEFS");
}

LittleFS.remove(configFileSerial);
LittleFS.remove(configFileSecurity);
LittleFS.remove(configFileGeneral);
Expand Down Expand Up @@ -641,7 +643,7 @@ ThisConfigStruct *findBrdConfig(int searchId = 0)

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

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

if (ethIdx == -1)
{
Expand Down
Loading

0 comments on commit 529442d

Please sign in to comment.