SYSTEM_EVENT.. to ARDUINO_EVENT_...

This commit is contained in:
MichaelDvP
2022-04-25 17:07:52 +02:00
parent 986b4df997
commit fa166483bb
7 changed files with 87 additions and 83 deletions

View File

@@ -47,7 +47,7 @@ void APSettingsService::manageAP() {
void APSettingsService::startAP() {
WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask);
esp_wifi_set_bandwidth(ESP_IF_WIFI_AP, WIFI_BW_HT20);
esp_wifi_set_bandwidth((wifi_interface_t)ESP_IF_WIFI_AP, WIFI_BW_HT20);
WiFi.softAP(_state.ssid.c_str(), _state.password.c_str(), _state.channel, _state.ssidHidden, _state.maxClients);
if (!_dnsServer) {
IPAddress apIp = WiFi.softAPIP();

View File

@@ -99,8 +99,8 @@ void MqttSettingsService::onConfigUpdated() {
void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
switch (event) {
case SYSTEM_EVENT_STA_GOT_IP:
case SYSTEM_EVENT_ETH_GOT_IP:
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
case ARDUINO_EVENT_ETH_GOT_IP:
emsesp::EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
if (!networkSettings.enableIPv6 && _state.enabled) {
// emsesp::EMSESP::logger().info(F("IPv4 Network connection found, starting MQTT client"));
@@ -108,14 +108,15 @@ void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
}
});
break;
case SYSTEM_EVENT_GOT_IP6:
case ARDUINO_EVENT_ETH_GOT_IP6:
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
if (_state.enabled) {
// emsesp::EMSESP::logger().info(F("IPv6 Network connection found, starting MQTT client"));
onConfigUpdated();
}
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
case SYSTEM_EVENT_ETH_DISCONNECTED:
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
case ARDUINO_EVENT_ETH_DISCONNECTED:
if (_state.enabled) {
// emsesp::EMSESP::logger().info(F("Network connection dropped, stopping MQTT client"));
_mqttClient.disconnect();

View File

@@ -25,15 +25,15 @@ void NTPSettingsService::begin() {
// handles both WiFI and Ethernet
void NTPSettingsService::WiFiEvent(WiFiEvent_t event) {
switch (event) {
case SYSTEM_EVENT_STA_DISCONNECTED:
case SYSTEM_EVENT_ETH_DISCONNECTED:
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
case ARDUINO_EVENT_ETH_DISCONNECTED:
emsesp::EMSESP::logger().info(F("WiFi connection dropped, stopping NTP"));
connected_ = false;
configureNTP();
break;
case SYSTEM_EVENT_STA_GOT_IP:
case SYSTEM_EVENT_ETH_GOT_IP:
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
case ARDUINO_EVENT_ETH_GOT_IP:
// emsesp::EMSESP::logger().info(F("Got IP address, starting NTP synchronization"));
connected_ = true;
configureNTP();

View File

@@ -58,7 +58,7 @@ void NetworkSettingsService::manageSTA() {
if (_state.staticIPConfig) {
WiFi.config(_state.localIP, _state.gatewayIP, _state.subnetMask, _state.dnsIP1, _state.dnsIP2); // configure for static IP
} else {
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); // configure for DHCP
WiFi.config(IPADDR_NONE, IPADDR_NONE, IPADDR_NONE); // configure for DHCP
}
WiFi.setHostname(_state.hostname.c_str()); // set hostname
@@ -66,9 +66,9 @@ void NetworkSettingsService::manageSTA() {
// www.esp32.com/viewtopic.php?t=12055
read([&](NetworkSettings & networkSettings) {
if (networkSettings.bandwidth20) {
esp_wifi_set_bandwidth(ESP_IF_WIFI_STA, WIFI_BW_HT20);
esp_wifi_set_bandwidth((wifi_interface_t)ESP_IF_WIFI_STA, WIFI_BW_HT20);
} else {
esp_wifi_set_bandwidth(ESP_IF_WIFI_STA, WIFI_BW_HT40);
esp_wifi_set_bandwidth((wifi_interface_t)ESP_IF_WIFI_STA, WIFI_BW_HT40);
}
esp_wifi_set_max_tx_power(networkSettings.tx_power * 4);
if (networkSettings.nosleep) {
@@ -82,7 +82,7 @@ void NetworkSettingsService::manageSTA() {
// handles if wifi stopped
void NetworkSettingsService::WiFiEvent(WiFiEvent_t event) {
if (event == SYSTEM_EVENT_STA_STOP) {
if (event == ARDUINO_EVENT_WIFI_STA_STOP) {
if (_stopping) {
_lastConnectionAttempt = 0;
_stopping = false;

View File

@@ -66,8 +66,8 @@ void OTASettingsService::configureArduinoOTA() {
void OTASettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
switch (event) {
case SYSTEM_EVENT_STA_GOT_IP:
case SYSTEM_EVENT_ETH_GOT_IP:
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
case ARDUINO_EVENT_ETH_GOT_IP:
configureArduinoOTA();
break;
default: