apply astylerc
This commit is contained in:
@@ -69,7 +69,8 @@ const String EthernetDevice::deviceName() const
|
||||
|
||||
void EthernetDevice::initialize()
|
||||
{
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK) {
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK)
|
||||
{
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
vTaskDelay(250 / portTICK_PERIOD_MS);
|
||||
@@ -79,7 +80,8 @@ void EthernetDevice::initialize()
|
||||
Log->println("Failed to initialize ethernet hardware");
|
||||
Log->println("Network device has a critical failure, enable fallback to Wi-Fi and reboot.");
|
||||
wifiFallback = true;
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK) {
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK)
|
||||
{
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||
@@ -108,11 +110,11 @@ void EthernetDevice::initialize()
|
||||
// https://github.com/arendst/Tasmota/commit/f8fbe153000591727e40b5007e0de78c33833131
|
||||
// https://github.com/arendst/Tasmota/commit/f8fbe153000591727e40b5007e0de78c33833131#diff-32fc0eefbf488dd507b3bef52189bbe37158737aba6f96fe98a8746dc5021955R417
|
||||
uint32_t pkg_version = bootloader_common_get_chip_ver_pkg();
|
||||
#if defined(CONFIG_SOC_SPIRAM_SUPPORTED) && defined(CONFIG_SPIRAM)
|
||||
#if defined(CONFIG_SOC_SPIRAM_SUPPORTED) && defined(CONFIG_SPIRAM)
|
||||
if(esp_psram_get_size() <= 0 && pkg_version <= 3)
|
||||
#else
|
||||
#else
|
||||
if(pkg_version <= 3)
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
esp_gpio_revoke(0xFFFFFFFFFFFFFFFF);
|
||||
}
|
||||
@@ -147,7 +149,8 @@ void EthernetDevice::initialize()
|
||||
Log->println("Failed to initialize ethernet hardware");
|
||||
Log->println("Network device has a critical failure, enable fallback to Wi-Fi and reboot.");
|
||||
wifiFallback = true;
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK) {
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK)
|
||||
{
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||
@@ -232,7 +235,8 @@ void EthernetDevice::onNetworkEvent(arduino_event_id_t event, arduino_event_info
|
||||
|
||||
void EthernetDevice::reconfigure()
|
||||
{
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK) {
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK)
|
||||
{
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||
|
||||
@@ -17,28 +17,28 @@ class EthernetDevice : public NetworkDevice
|
||||
|
||||
public:
|
||||
EthernetDevice(const String& hostname,
|
||||
Preferences* preferences,
|
||||
const IPConfiguration* ipConfiguration,
|
||||
const std::string& deviceName,
|
||||
uint8_t phy_addr = ETH_PHY_ADDR_LAN8720,
|
||||
int power = ETH_PHY_POWER_LAN8720,
|
||||
int mdc = ETH_PHY_MDC_LAN8720,
|
||||
int mdio = ETH_PHY_MDIO_LAN8720,
|
||||
eth_phy_type_t ethtype = ETH_PHY_TYPE_LAN8720,
|
||||
eth_clock_mode_t clock_mode = ETH_CLK_MODE_LAN8720);
|
||||
Preferences* preferences,
|
||||
const IPConfiguration* ipConfiguration,
|
||||
const std::string& deviceName,
|
||||
uint8_t phy_addr = ETH_PHY_ADDR_LAN8720,
|
||||
int power = ETH_PHY_POWER_LAN8720,
|
||||
int mdc = ETH_PHY_MDC_LAN8720,
|
||||
int mdio = ETH_PHY_MDIO_LAN8720,
|
||||
eth_phy_type_t ethtype = ETH_PHY_TYPE_LAN8720,
|
||||
eth_clock_mode_t clock_mode = ETH_CLK_MODE_LAN8720);
|
||||
|
||||
EthernetDevice(const String& hostname,
|
||||
Preferences* preferences,
|
||||
const IPConfiguration* ipConfiguration,
|
||||
const std::string& deviceName,
|
||||
uint8_t phy_addr,
|
||||
int cs,
|
||||
int irq,
|
||||
int rst,
|
||||
int spi_sck,
|
||||
int spi_miso,
|
||||
int spi_mosi,
|
||||
eth_phy_type_t ethtype);
|
||||
Preferences* preferences,
|
||||
const IPConfiguration* ipConfiguration,
|
||||
const std::string& deviceName,
|
||||
uint8_t phy_addr,
|
||||
int cs,
|
||||
int irq,
|
||||
int rst,
|
||||
int spi_sck,
|
||||
int spi_miso,
|
||||
int spi_mosi,
|
||||
eth_phy_type_t ethtype);
|
||||
|
||||
const String deviceName() const override;
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#if !defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32P4)
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
ETH_CLOCK_GPIO0_IN = 0,
|
||||
ETH_CLOCK_GPIO0_OUT = 1,
|
||||
ETH_CLOCK_GPIO0_OUT = 1,
|
||||
ETH_CLOCK_GPIO16_OUT = 2,
|
||||
ETH_CLOCK_GPIO17_OUT = 3
|
||||
} eth_clock_mode_t;
|
||||
|
||||
@@ -11,15 +11,18 @@
|
||||
void NetworkDevice::init()
|
||||
{
|
||||
_useEncryption = false;
|
||||
|
||||
if(_preferences->getBool(preference_mqtt_ssl_enabled, false)) {
|
||||
if (!SPIFFS.begin(true)) {
|
||||
|
||||
if(_preferences->getBool(preference_mqtt_ssl_enabled, false))
|
||||
{
|
||||
if (!SPIFFS.begin(true))
|
||||
{
|
||||
Log->println("SPIFFS Mount Failed");
|
||||
}
|
||||
else
|
||||
{
|
||||
File file = SPIFFS.open("/mqtt_ssl.ca");
|
||||
if (!file || file.isDirectory()) {
|
||||
if (!file || file.isDirectory())
|
||||
{
|
||||
Log->println("mqtt_ssl.ca not found");
|
||||
}
|
||||
else
|
||||
@@ -47,7 +50,8 @@ void NetworkDevice::init()
|
||||
|
||||
File file2 = SPIFFS.open("/mqtt_ssl.crt");
|
||||
File file3 = SPIFFS.open("/mqtt_ssl.key");
|
||||
if (!file2 || file2.isDirectory() || !file3 || file3.isDirectory()) {
|
||||
if (!file2 || file2.isDirectory() || !file3 || file3.isDirectory())
|
||||
{
|
||||
Log->println("mqtt_ssl.crt or mqtt_ssl.key not found");
|
||||
}
|
||||
else
|
||||
|
||||
@@ -9,9 +9,9 @@ class NetworkDevice
|
||||
{
|
||||
public:
|
||||
explicit NetworkDevice(const String& hostname, Preferences* preferences, const IPConfiguration* ipConfiguration)
|
||||
: _hostname(hostname),
|
||||
_preferences(preferences),
|
||||
_ipConfiguration(ipConfiguration)
|
||||
: _hostname(hostname),
|
||||
_preferences(preferences),
|
||||
_ipConfiguration(ipConfiguration)
|
||||
{}
|
||||
|
||||
virtual const String deviceName() const = 0;
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
virtual String localIP() = 0;
|
||||
virtual String BSSIDstr() = 0;
|
||||
|
||||
#ifndef NUKI_HUB_UPDATER
|
||||
#ifndef NUKI_HUB_UPDATER
|
||||
virtual bool isEncrypted();
|
||||
virtual bool mqttConnect();
|
||||
virtual bool mqttDisconnect(bool force);
|
||||
@@ -39,35 +39,35 @@ public:
|
||||
virtual uint16_t mqttPublish(const char* topic, uint8_t qos, bool retain, const char* payload);
|
||||
virtual uint16_t mqttPublish(const char* topic, uint8_t qos, bool retain, const uint8_t* payload, size_t length);
|
||||
virtual uint16_t mqttSubscribe(const char* topic, uint8_t qos);
|
||||
|
||||
|
||||
virtual void mqttSetServer(const char* host, uint16_t port);
|
||||
virtual void mqttSetClientId(const char* clientId);
|
||||
virtual void mqttSetCleanSession(bool cleanSession);
|
||||
virtual void mqttSetKeepAlive(uint16_t keepAlive);
|
||||
virtual void mqttSetWill(const char* topic, uint8_t qos, bool retain, const char* payload);
|
||||
virtual void mqttSetCredentials(const char* username, const char* password);
|
||||
|
||||
|
||||
virtual void mqttOnMessage(espMqttClientTypes::OnMessageCallback callback);
|
||||
virtual void mqttOnConnect(espMqttClientTypes::OnConnectCallback callback);
|
||||
virtual void mqttOnDisconnect(espMqttClientTypes::OnDisconnectCallback callback);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
protected:
|
||||
const IPConfiguration* _ipConfiguration = nullptr;
|
||||
Preferences* _preferences = nullptr;
|
||||
#ifndef NUKI_HUB_UPDATER
|
||||
#ifndef NUKI_HUB_UPDATER
|
||||
espMqttClient *_mqttClient = nullptr;
|
||||
espMqttClientSecure *_mqttClientSecure = nullptr;
|
||||
|
||||
void init();
|
||||
|
||||
|
||||
MqttClient *getMqttClient() const;
|
||||
|
||||
bool _useEncryption = false;
|
||||
bool _mqttEnabled = true;
|
||||
bool _mqttInternal = false;
|
||||
char* _path;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
const String _hostname;
|
||||
};
|
||||
@@ -21,7 +21,8 @@ const String WifiDevice::deviceName() const
|
||||
|
||||
void WifiDevice::initialize()
|
||||
{
|
||||
if (_hostname != "fakep4forhosted") {
|
||||
if (_hostname != "fakep4forhosted")
|
||||
{
|
||||
ssid = _preferences->getString(preference_wifi_ssid, "");
|
||||
ssid.trim();
|
||||
pass = _preferences->getString(preference_wifi_pass, "");
|
||||
@@ -61,8 +62,10 @@ void WifiDevice::initialize()
|
||||
WiFi.disconnect();
|
||||
|
||||
int loop = 0;
|
||||
while (!_wifiClientStarted && loop < 50) {
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK) {
|
||||
while (!_wifiClientStarted && loop < 50)
|
||||
{
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK)
|
||||
{
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
@@ -85,8 +88,10 @@ void WifiDevice::scan(bool passive, bool async)
|
||||
}
|
||||
|
||||
int loop = 0;
|
||||
while (!_wifiClientStarted && loop < 50) {
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK) {
|
||||
while (!_wifiClientStarted && loop < 50)
|
||||
{
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK)
|
||||
{
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
@@ -122,12 +127,14 @@ void WifiDevice::openAP()
|
||||
Log->println("Starting AP with SSID NukiHub and Password NukiHubESP32");
|
||||
_startAP = false;
|
||||
WiFi.mode(WIFI_AP);
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK) {
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK)
|
||||
{
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
WiFi.softAPsetHostname(_hostname.c_str());
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK) {
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK)
|
||||
{
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
@@ -142,8 +149,10 @@ void WifiDevice::openAP()
|
||||
bool WifiDevice::connect()
|
||||
{
|
||||
int loop = 0;
|
||||
while (!_wifiClientStarted && loop < 50) {
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK) {
|
||||
while (!_wifiClientStarted && loop < 50)
|
||||
{
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK)
|
||||
{
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
@@ -210,8 +219,9 @@ bool WifiDevice::connect()
|
||||
loop = 0;
|
||||
while(!isConnected() && loop < 600)
|
||||
{
|
||||
Log->print(".");
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK) {
|
||||
Log->print(".");
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK)
|
||||
{
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
vTaskDelay(25 / portTICK_PERIOD_MS);
|
||||
@@ -226,7 +236,8 @@ bool WifiDevice::connect()
|
||||
if(_preferences->getBool(preference_restart_on_disconnect, false) && (espMillis() > 60000))
|
||||
{
|
||||
Log->println("Restart on disconnect watchdog triggered, rebooting");
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK) {
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK)
|
||||
{
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
@@ -253,7 +264,8 @@ void WifiDevice::reconfigure()
|
||||
{
|
||||
_preferences->putString(preference_wifi_ssid, "");
|
||||
_preferences->putString(preference_wifi_pass, "");
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK) {
|
||||
if (esp_task_wdt_status(NULL) == ESP_OK)
|
||||
{
|
||||
esp_task_wdt_reset();
|
||||
}
|
||||
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||
@@ -305,9 +317,10 @@ bool WifiDevice::isApOpen()
|
||||
|
||||
void WifiDevice::onWifiEvent(const WiFiEvent_t &event, const WiFiEventInfo_t &info)
|
||||
{
|
||||
Log->printf("[WiFi-event] event: %d\n", event);
|
||||
Log->printf("[WiFi-event] event: %d\n", event);
|
||||
|
||||
switch (event) {
|
||||
switch (event)
|
||||
{
|
||||
case ARDUINO_EVENT_WIFI_READY:
|
||||
Log->println("WiFi interface ready");
|
||||
break;
|
||||
@@ -404,5 +417,5 @@ void WifiDevice::onWifiEvent(const WiFiEvent_t &event, const WiFiEventInfo_t &in
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
virtual bool isApOpen();
|
||||
|
||||
int8_t signalStrength() override;
|
||||
|
||||
|
||||
String localIP() override;
|
||||
String BSSIDstr() override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user