Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/BootstrapManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ void BootstrapManager::bootstrapSetup(void (*manageDisconnections)(), void (*man
launchWebServerForOTAConfig();
}
#if defined(ARDUINO_ARCH_ESP32)
esp_task_wdt_init(3000, true); //enable panic so ESP32 restarts
esp_task_wdt_config_t twdt_config = {
.timeout_ms = 3000, // TODO 3000
.trigger_panic = true,
};
esp_task_wdt_init(&twdt_config); //enable panic so ESP32 restarts
esp_task_wdt_add(NULL); //add current thread to WDT watch
#endif
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
Expand Down Expand Up @@ -110,7 +114,11 @@ void BootstrapManager::bootstrapSetup(void (*manageDisconnections)(), void (*man
#endif
}
#if defined(ARDUINO_ARCH_ESP32)
esp_task_wdt_init(3000, true); //enable panic so ESP32 restarts
esp_task_wdt_config_t twdt_config = {
.timeout_ms = 3000, // TODO 3000
.trigger_panic = true,
};
esp_task_wdt_init(&twdt_config); //enable panic so ESP32 restarts
esp_task_wdt_add(NULL); //add current thread to WDT watch
#endif
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
Expand Down
34 changes: 20 additions & 14 deletions src/EthManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const ethernet_config ethernetDevices[] = {
// No Ethernet
{
},
#if CONFIG_IDF_TARGET_ESP32
// QuinLed-ESP32-Ethernet
{

0,
5,
23,
Expand Down Expand Up @@ -102,39 +102,45 @@ const ethernet_config ethernetDevices[] = {
ETH_PHY_LAN8720,
ETH_CLOCK_GPIO0_OUT
}
#endif
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S3)

#endif

};

/**
* Connect to ethernet
* @param deviceNumber to use
*/
void EthManager::connectToEthernet(int8_t deviceNumber) {
#if CONFIG_IDF_TARGET_ESP32
ETH.begin(
ethernetDevices[deviceNumber].type,
ethernetDevices[deviceNumber].address,
ethernetDevices[deviceNumber].power,
ethernetDevices[deviceNumber].mdc,
ethernetDevices[deviceNumber].mdio,
ethernetDevices[deviceNumber].type,
ethernetDevices[deviceNumber].power,
ethernetDevices[deviceNumber].clk_mode
);
#else
// TODO fix this
#endif
}

/**
* Deallocate ethernet pins
* @param deviceNumber to deallocate
*/
void EthManager::deallocateEthernetPins(int8_t deviceNumber) {
const uint32_t MATRIX_DETACH_OUT_SIG = 0x100;
gpio_matrix_out(ethernetDevices[deviceNumber].address, MATRIX_DETACH_OUT_SIG, false, false);
gpio_matrix_out(ethernetDevices[deviceNumber].power, MATRIX_DETACH_OUT_SIG, false, false);
gpio_matrix_out(ethernetDevices[deviceNumber].mdc, MATRIX_DETACH_OUT_SIG, false, false);
gpio_matrix_out(ethernetDevices[deviceNumber].mdio, MATRIX_DETACH_OUT_SIG, false, false);
gpio_matrix_out(ethernetDevices[deviceNumber].clk_mode, MATRIX_DETACH_OUT_SIG, false, false);
pinMode(ethernetDevices[deviceNumber].address, INPUT);
pinMode(ethernetDevices[deviceNumber].power, INPUT);
pinMode(ethernetDevices[deviceNumber].mdc, INPUT);
pinMode(ethernetDevices[deviceNumber].mdio, INPUT);
pinMode(ethernetDevices[deviceNumber].clk_mode, INPUT);
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].address);
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].power);
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].mdc);
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].mdio);
#if CONFIG_IDF_TARGET_ESP32
gpio_reset_pin((gpio_num_t) ethernetDevices[deviceNumber].clk_mode);
#endif
delay(1);
}

#endif
2 changes: 2 additions & 0 deletions src/EthManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ typedef struct EthConfig {
int power;
int mdc;
int mdio;
#if CONFIG_IDF_TARGET_ESP32
eth_phy_type_t type;
eth_clock_mode_t clk_mode;
#endif
} ethernet_config;

extern const ethernet_config ethernetDevices[];
Expand Down
7 changes: 6 additions & 1 deletion src/WifiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void WifiManager::setupWiFi(void (*manageDisconnections)(), void (*manageHardwar
#if defined(ESP8266)
WiFi.setSleepMode(WIFI_NONE_SLEEP);
#endif
WiFi.setAutoConnect(true);
// WiFi.setAutoConnect(true); // TODO
WiFi.setAutoReconnect(true);
Serial.println(microcontrollerIP);
if (!microcontrollerIP.equals("DHCP")) {
Expand Down Expand Up @@ -109,7 +109,9 @@ void WifiManager::setupWiFi(void (*manageDisconnections)(), void (*manageHardwar
});
#elif defined(ARDUINO_ARCH_ESP32)
WiFi.setHostname(helper.string2char(deviceName));
#if !CONFIG_IDF_TARGET_ESP32S2
btStop();
#endif
#endif
// Start wifi connection
WiFi.begin(qsid.c_str(), qpass.c_str());
Expand Down Expand Up @@ -224,6 +226,9 @@ void WifiManager::setupOTAUpload() {
Serial.println(F("End"));
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
#if defined(ARDUINO_ARCH_ESP32)
esp_task_wdt_reset(); // TODO
# endif
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Expand Down
1 change: 1 addition & 0 deletions src/WifiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <HTTPClient.h>
#include <WiFiUdp.h>
#include <WebServer.h>
#include <esp_task_wdt.h>

#endif

Expand Down