Skip to content

Commit

Permalink
20240525
Browse files Browse the repository at this point in the history
- Add support for all Tube's ZB gateways
- Rework board detecting mechanism - now supports more board configs and detects more accurate (need more tests on T-Internet-POE)
- Update de.json Thanks @Sn00kiT 🚀 #29
- Fix Error switching to USB mode Thanks @OlegBrailean #26
- Keep working on cz.json Thanks @leroyloren 🚀 #27, #28
  • Loading branch information
xyzroe committed May 25, 2024
1 parent 866df1b commit ad2769f
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 134 deletions.
9 changes: 4 additions & 5 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Preferences preferences;

extern struct SysVarsStruct vars;
extern struct BrdConfigStruct hwConfig;
extern struct ThisConfigStruct hwConfig;
extern BrdConfigStruct brdConfigs[BOARD_CFG_CNT];

extern struct SystemConfigStruct systemCfg;
Expand Down Expand Up @@ -44,10 +44,9 @@ void printNVSFreeSpace()
void eraseNVS()
{
LOGD("Going to erase NVS");
int timeDelay = 3;
for (int i = 0; i < timeDelay; i++)
for (uint8_t i = 0; i < TIMEOUT_FACTORY_RESET; i++)
{
LOGD("%d seconds left..", (timeDelay - i));
LOGD("%d seconds left..", (TIMEOUT_FACTORY_RESET - i));
delay(1000);
}
LOGD("Erasing NVS");
Expand Down Expand Up @@ -885,7 +884,7 @@ bool loadFileConfigHW()
{
searchId = config["searchId"];
}
BrdConfigStruct *newConfig = findBrdConfig(searchId);
ThisConfigStruct *newConfig = findBrdConfig(searchId);
if (newConfig)
{
LOGD("Find. Saving config");
Expand Down
71 changes: 42 additions & 29 deletions src/const/hw.cpp
Original file line number Diff line number Diff line change
@@ -1,33 +1,46 @@
#include "const/hw.h"

// 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 = -1, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT, .pwrAltPin = 5}, // 2 T-Internet-POE
};

// ZigBee configurations
// !!! Don't forget to edit ZB_CFG_CNT !!!
ZbConfig zbConfigs[] = {
{.txPin = 4, .rxPin = 36, .rstPin = 16, .bslPin = 32}, // 0
{.txPin = 17, .rxPin = 5, .rstPin = 33, .bslPin = 32}, // 1
{.txPin = 33, .rxPin = 32, .rstPin = 12, .bslPin = 14}, // 2
{.txPin = 4, .rxPin = 36, .rstPin = 5, .bslPin = 16}, // 3
{.txPin = 5, .rxPin = 17, .rstPin = 33, .bslPin = 32}, // 4
{.txPin = 16, .rxPin = 5, .rstPin = 33, .bslPin = 32}, // 5
{.txPin = 16, .rxPin = 5, .rstPin = 13, .bslPin = 4}, // 6
{.txPin = 4, .rxPin = 36, .rstPin = 5, .bslPin = 16}, // 7
};

// Mist configurations
// !!! Don't forget to edit MIST_CFG_CNT !!!
MistConfig mistConfigs[] = {
{.btnPin = -1, .btnPlr = 0, .uartSelPin = -1, .uartSelPlr = 0, .ledModePin = -1, .ledModePlr = 0, .ledPwrPin = -1, .ledPwrPlr = 0}, // 0
{.btnPin = 35, .btnPlr = 1, .uartSelPin = 33, .uartSelPlr = 1, .ledModePin = 12, .ledModePlr = 1, .ledPwrPin = 14, .ledPwrPlr = 1}, // 1
{.btnPin = 35, .btnPlr = 1, .uartSelPin = 4, .uartSelPlr = 1, .ledModePin = 12, .ledModePlr = 1, .ledPwrPin = 14, .ledPwrPlr = 1}, // 2
};

// Board configurations
// !!! Don't forget to edit BOARD_CFG_CNT !!!
BrdConfigStruct brdConfigs[] = {
// BOARD_CFG_CNT
{"UZG-01",
{.addr = 0, .pwrPin = -1, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT, .pwrAltPin = 5},
{.btnPin = 35, .btnPlr = 1, .uartSelPin = 33, .uartSelPlr = 1, .ledModePin = 12, .ledModePlr = 1, .ledPwrPin = 14, .ledPwrPlr = 1},
{.txPin = 4, .rxPin = 36, .rstPin = 16, .bslPin = 32}},
{"SLZB-06",
{.addr = 1, .pwrPin = 16, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO0_IN, .pwrAltPin = -1},
{.btnPin = 35, .btnPlr = 1, .uartSelPin = 4, .uartSelPlr = 1, .ledModePin = 12, .ledModePlr = 1, .ledPwrPin = 14, .ledPwrPlr = 1},
{.txPin = 17, .rxPin = 5, .rstPin = 33, .bslPin = 32}},
{"Olimex-ESP32-POE",
{.addr = 0, .pwrPin = 12, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT, .pwrAltPin = -1},
{.btnPin = -1, .btnPlr = 0, .uartSelPin = -1, .uartSelPlr = 0, .ledModePin = -1, .ledModePlr = 0, .ledPwrPin = -1, .ledPwrPlr = 0},
{.txPin = 4, .rxPin = 36, .rstPin = 16, .bslPin = 32}},
{"WT32-ETH01",
{.addr = 1, .pwrPin = 16, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO0_IN, .pwrAltPin = -1},
{.btnPin = -1, .btnPlr = 0, .uartSelPin = -1, .uartSelPlr = 0, .ledModePin = -1, .ledModePlr = 0, .ledPwrPin = -1, .ledPwrPlr = 0},
{.txPin = 17, .rxPin = 5, .rstPin = 33, .bslPin = 32}},
{"T-Internet-POE",
{.addr = 0, .pwrPin = -1, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT, .pwrAltPin = -1},
{.btnPin = -1, .btnPlr = 0, .uartSelPin = -1, .uartSelPlr = 0, .ledModePin = -1, .ledModePlr = 0, .ledPwrPin = -1, .ledPwrPlr = 0},
{.txPin = 4, .rxPin = 36, .rstPin = 16, .bslPin = 32}},
{"China-GW",
{.addr = 0, .pwrPin = 12, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT, .pwrAltPin = -1},
{.btnPin = -1, .btnPlr = 0, .uartSelPin = -1, .uartSelPlr = 0, .ledModePin = -1, .ledModePlr = 0, .ledPwrPin = -1, .ledPwrPlr = 0},
{.txPin = 33, .rxPin = 32, .rstPin = 12, .bslPin = 14}},
{"TubeZB - Olimex",
{.addr = 0, .pwrPin = 12, .mdcPin = 23, .mdiPin = 18, .phyType = ETH_PHY_LAN8720, .clkMode = ETH_CLOCK_GPIO17_OUT, .pwrAltPin = -1},
{.btnPin = -1, .btnPlr = 0, .uartSelPin = -1, .uartSelPlr = 0, .ledModePin = -1, .ledModePlr = 0, .ledPwrPin = -1, .ledPwrPlr = 0},
{.txPin = 4, .rxPin = 36, .rstPin = 5, .bslPin = 16}},
{"UZG-01", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 1},
{"SLZB-06", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 2},
{"WT32-ETH01", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 0},
{"T-Internet-POE", .ethConfigIndex = 2, .zbConfigIndex = 0, .mistConfigIndex = 0},
{"Olimex-ESP32-POE", .ethConfigIndex = 0, .zbConfigIndex = 0, .mistConfigIndex = 0},
{"China-GW", .ethConfigIndex = 0, .zbConfigIndex = 2, .mistConfigIndex = 0},
{"TubesZB-eth", .ethConfigIndex = 1, .zbConfigIndex = 1, .mistConfigIndex = 0},
{"TubesZB-eth_usb", .ethConfigIndex = 1, .zbConfigIndex = 4, .mistConfigIndex = 0},
{"TubesZB-poe", .ethConfigIndex = 0, .zbConfigIndex = 5, .mistConfigIndex = 0},
{"TubesZB-poe-2022", .ethConfigIndex = 0, .zbConfigIndex = 6, .mistConfigIndex = 0},
{"TubesZB-poe-2023", .ethConfigIndex = 0, .zbConfigIndex = 7, .mistConfigIndex = 0},
};
38 changes: 25 additions & 13 deletions src/const/hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ struct EthConfig
int pwrAltPin;
};

// ZigBee settings structure
struct ZbConfig
{
int txPin;
int rxPin;
int rstPin;
int bslPin;
};

// Miscellaneous settings structure
struct MistConfig {
struct MistConfig
{
int btnPin;
int btnPlr;
int uartSelPin;
Expand All @@ -24,22 +34,24 @@ struct MistConfig {
int ledPwrPlr;
};

// ZigBee settings structure
struct ZbConfig
// Root configuration structure that includes only configuration indices
struct BrdConfigStruct
{
int txPin;
int rxPin;
int rstPin;
int bslPin;
char board[50];
int ethConfigIndex;
int zbConfigIndex;
int mistConfigIndex;
};

// Root configuration structure that includes all substructures
struct BrdConfigStruct
#define ETH_CFG_CNT 3
#define ZB_CFG_CNT 8
#define MIST_CFG_CNT 3
#define BOARD_CFG_CNT 13

struct ThisConfigStruct
{
char board[50];
EthConfig eth;
MistConfig mist;
ZbConfig zb;
};

#define BOARD_CFG_CNT 6
MistConfig mist;
};
Loading

0 comments on commit ad2769f

Please sign in to comment.