mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
remove Serial.p*
This commit is contained in:
@@ -44,7 +44,7 @@ void APSettingsService::manageAP() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void APSettingsService::startAP() {
|
void APSettingsService::startAP() {
|
||||||
Serial.println(F("Starting software access point"));
|
// Serial.println(F("Starting software access point"));
|
||||||
IPAddress localIP(192, 168, 4, 1);
|
IPAddress localIP(192, 168, 4, 1);
|
||||||
IPAddress gateway(192, 168, 4, 1);
|
IPAddress gateway(192, 168, 4, 1);
|
||||||
IPAddress subnet(255, 255, 255, 0);
|
IPAddress subnet(255, 255, 255, 0);
|
||||||
@@ -52,8 +52,8 @@ void APSettingsService::startAP() {
|
|||||||
WiFi.softAP(_state.ssid.c_str(), _state.password.c_str());
|
WiFi.softAP(_state.ssid.c_str(), _state.password.c_str());
|
||||||
if (!_dnsServer) {
|
if (!_dnsServer) {
|
||||||
IPAddress apIp = WiFi.softAPIP();
|
IPAddress apIp = WiFi.softAPIP();
|
||||||
Serial.print(F("Starting captive portal on "));
|
// Serial.print(F("Starting captive portal on "));
|
||||||
Serial.println(apIp);
|
// Serial.println(apIp);
|
||||||
_dnsServer = new DNSServer;
|
_dnsServer = new DNSServer;
|
||||||
_dnsServer->start(DNS_PORT, "*", apIp);
|
_dnsServer->start(DNS_PORT, "*", apIp);
|
||||||
}
|
}
|
||||||
@@ -61,12 +61,12 @@ void APSettingsService::startAP() {
|
|||||||
|
|
||||||
void APSettingsService::stopAP() {
|
void APSettingsService::stopAP() {
|
||||||
if (_dnsServer) {
|
if (_dnsServer) {
|
||||||
Serial.println(F("Stopping captive portal"));
|
// Serial.println(F("Stopping captive portal"));
|
||||||
_dnsServer->stop();
|
_dnsServer->stop();
|
||||||
delete _dnsServer;
|
delete _dnsServer;
|
||||||
_dnsServer = nullptr;
|
_dnsServer = nullptr;
|
||||||
}
|
}
|
||||||
Serial.println(F("Stopping software access point"));
|
// Serial.println(F("Stopping software access point"));
|
||||||
WiFi.softAPdisconnect(true);
|
WiFi.softAPdisconnect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,17 +87,19 @@ AsyncMqttClient* MqttSettingsService::getMqttClient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MqttSettingsService::onMqttConnect(bool sessionPresent) {
|
void MqttSettingsService::onMqttConnect(bool sessionPresent) {
|
||||||
|
/*
|
||||||
Serial.print(F("Connected to MQTT, "));
|
Serial.print(F("Connected to MQTT, "));
|
||||||
if (sessionPresent) {
|
if (sessionPresent) {
|
||||||
Serial.println(F("with persistent session"));
|
Serial.println(F("with persistent session"));
|
||||||
} else {
|
} else {
|
||||||
Serial.println(F("without persistent session"));
|
Serial.println(F("without persistent session"));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqttSettingsService::onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
|
void MqttSettingsService::onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
|
||||||
Serial.print(F("Disconnected from MQTT reason: "));
|
// Serial.print(F("Disconnected from MQTT reason: "));
|
||||||
Serial.println((uint8_t)reason);
|
// Serial.println((uint8_t)reason);
|
||||||
_disconnectReason = reason;
|
_disconnectReason = reason;
|
||||||
_disconnectedAt = millis();
|
_disconnectedAt = millis();
|
||||||
}
|
}
|
||||||
@@ -110,28 +112,28 @@ void MqttSettingsService::onConfigUpdated() {
|
|||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
void MqttSettingsService::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
|
void MqttSettingsService::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
if (_state.enabled) {
|
if (_state.enabled) {
|
||||||
Serial.println(F("WiFi connection dropped, starting MQTT client."));
|
// Serial.println(F("WiFi connection dropped, starting MQTT client."));
|
||||||
onConfigUpdated();
|
onConfigUpdated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqttSettingsService::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) {
|
void MqttSettingsService::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
if (_state.enabled) {
|
if (_state.enabled) {
|
||||||
Serial.println(F("WiFi connection dropped, stopping MQTT client."));
|
// Serial.println(F("WiFi connection dropped, stopping MQTT client."));
|
||||||
onConfigUpdated();
|
onConfigUpdated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
void MqttSettingsService::onStationModeGotIP(const WiFiEventStationModeGotIP& event) {
|
void MqttSettingsService::onStationModeGotIP(const WiFiEventStationModeGotIP& event) {
|
||||||
if (_state.enabled) {
|
if (_state.enabled) {
|
||||||
Serial.println(F("WiFi connection dropped, starting MQTT client."));
|
// Serial.println(F("WiFi connection dropped, starting MQTT client."));
|
||||||
onConfigUpdated();
|
onConfigUpdated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MqttSettingsService::onStationModeDisconnected(const WiFiEventStationModeDisconnected& event) {
|
void MqttSettingsService::onStationModeDisconnected(const WiFiEventStationModeDisconnected& event) {
|
||||||
if (_state.enabled) {
|
if (_state.enabled) {
|
||||||
Serial.println(F("WiFi connection dropped, stopping MQTT client."));
|
// Serial.println(F("WiFi connection dropped, stopping MQTT client."));
|
||||||
onConfigUpdated();
|
onConfigUpdated();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +145,7 @@ void MqttSettingsService::configureMqtt() {
|
|||||||
|
|
||||||
// only connect if WiFi is connected and MQTT is enabled
|
// only connect if WiFi is connected and MQTT is enabled
|
||||||
if (_state.enabled && WiFi.isConnected()) {
|
if (_state.enabled && WiFi.isConnected()) {
|
||||||
Serial.println(F("Connecting to MQTT..."));
|
// Serial.println(F("Connecting to MQTT..."));
|
||||||
_mqttClient.setServer(retainCstr(_state.host.c_str(), &_retainedHost), _state.port);
|
_mqttClient.setServer(retainCstr(_state.host.c_str(), &_retainedHost), _state.port);
|
||||||
if (_state.username.length() > 0) {
|
if (_state.username.length() > 0) {
|
||||||
_mqttClient.setCredentials(
|
_mqttClient.setCredentials(
|
||||||
|
|||||||
@@ -32,22 +32,22 @@ void NTPSettingsService::begin() {
|
|||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
void NTPSettingsService::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
|
void NTPSettingsService::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
Serial.println(F("Got IP address, starting NTP Synchronization"));
|
// Serial.println(F("Got IP address, starting NTP Synchronization"));
|
||||||
configureNTP();
|
configureNTP();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NTPSettingsService::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) {
|
void NTPSettingsService::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
Serial.println(F("WiFi connection dropped, stopping NTP."));
|
// Serial.println(F("WiFi connection dropped, stopping NTP."));
|
||||||
configureNTP();
|
configureNTP();
|
||||||
}
|
}
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
void NTPSettingsService::onStationModeGotIP(const WiFiEventStationModeGotIP& event) {
|
void NTPSettingsService::onStationModeGotIP(const WiFiEventStationModeGotIP& event) {
|
||||||
Serial.println(F("Got IP address, starting NTP Synchronization"));
|
// Serial.println(F("Got IP address, starting NTP Synchronization"));
|
||||||
configureNTP();
|
configureNTP();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NTPSettingsService::onStationModeDisconnected(const WiFiEventStationModeDisconnected& event) {
|
void NTPSettingsService::onStationModeDisconnected(const WiFiEventStationModeDisconnected& event) {
|
||||||
Serial.println(F("WiFi connection dropped, stopping NTP."));
|
// Serial.println(F("WiFi connection dropped, stopping NTP."));
|
||||||
configureNTP();
|
configureNTP();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -34,10 +34,11 @@ void OTASettingsService::configureArduinoOTA() {
|
|||||||
_arduinoOTA = nullptr;
|
_arduinoOTA = nullptr;
|
||||||
}
|
}
|
||||||
if (_state.enabled) {
|
if (_state.enabled) {
|
||||||
Serial.println(F("Starting OTA Update Service..."));
|
// Serial.println(F("Starting OTA Update Service..."));
|
||||||
_arduinoOTA = new ArduinoOTAClass;
|
_arduinoOTA = new ArduinoOTAClass;
|
||||||
_arduinoOTA->setPort(_state.port);
|
_arduinoOTA->setPort(_state.port);
|
||||||
_arduinoOTA->setPassword(_state.password.c_str());
|
_arduinoOTA->setPassword(_state.password.c_str());
|
||||||
|
/*
|
||||||
_arduinoOTA->onStart([]() { Serial.println(F("Starting")); });
|
_arduinoOTA->onStart([]() { Serial.println(F("Starting")); });
|
||||||
_arduinoOTA->onEnd([]() { Serial.println(F("\r\nEnd")); });
|
_arduinoOTA->onEnd([]() { Serial.println(F("\r\nEnd")); });
|
||||||
_arduinoOTA->onProgress([](unsigned int progress, unsigned int total) {
|
_arduinoOTA->onProgress([](unsigned int progress, unsigned int total) {
|
||||||
@@ -56,6 +57,7 @@ void OTASettingsService::configureArduinoOTA() {
|
|||||||
else if (error == OTA_END_ERROR)
|
else if (error == OTA_END_ERROR)
|
||||||
Serial.println(F("End Failed"));
|
Serial.println(F("End Failed"));
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
_arduinoOTA->begin();
|
_arduinoOTA->begin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ void WiFiSettingsService::manageSTA() {
|
|||||||
}
|
}
|
||||||
// Connect or reconnect as required
|
// Connect or reconnect as required
|
||||||
if ((WiFi.getMode() & WIFI_STA) == 0) {
|
if ((WiFi.getMode() & WIFI_STA) == 0) {
|
||||||
Serial.println(F("Connecting to WiFi."));
|
// Serial.println(F("Connecting to WiFi."));
|
||||||
if (_state.staticIPConfig) {
|
if (_state.staticIPConfig) {
|
||||||
// configure for static IP
|
// configure for static IP
|
||||||
WiFi.config(_state.localIP, _state.gatewayIP, _state.subnetMask, _state.dnsIP1, _state.dnsIP2);
|
WiFi.config(_state.localIP, _state.gatewayIP, _state.subnetMask, _state.dnsIP1, _state.dnsIP2);
|
||||||
|
|||||||
@@ -18,32 +18,30 @@ WiFiStatus::WiFiStatus(AsyncWebServer* server, SecurityManager* securityManager)
|
|||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
void WiFiStatus::onStationModeConnected(WiFiEvent_t event, WiFiEventInfo_t info) {
|
void WiFiStatus::onStationModeConnected(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
Serial.println(F("WiFi Connected."));
|
// Serial.println(F("WiFi Connected."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiFiStatus::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) {
|
void WiFiStatus::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
Serial.print(F("WiFi Disconnected. Reason code="));
|
// Serial.print(F("WiFi Disconnected. Reason code="));
|
||||||
Serial.println(info.disconnected.reason);
|
// Serial.println(info.disconnected.reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiFiStatus::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
|
void WiFiStatus::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
Serial.printf_P(
|
// Serial.printf_P(PSTR("WiFi Got IP. localIP=%s, hostName=%s\r\n"), WiFi.localIP().toString().c_str(), WiFi.getHostname());
|
||||||
PSTR("WiFi Got IP. localIP=%s, hostName=%s\r\n"), WiFi.localIP().toString().c_str(), WiFi.getHostname());
|
|
||||||
}
|
}
|
||||||
#elif defined(ESP8266)
|
#elif defined(ESP8266)
|
||||||
void WiFiStatus::onStationModeConnected(const WiFiEventStationModeConnected& event) {
|
void WiFiStatus::onStationModeConnected(const WiFiEventStationModeConnected& event) {
|
||||||
Serial.print(F("WiFi Connected. SSID="));
|
// Serial.print(F("WiFi Connected. SSID="));
|
||||||
Serial.println(event.ssid);
|
// Serial.println(event.ssid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiFiStatus::onStationModeDisconnected(const WiFiEventStationModeDisconnected& event) {
|
void WiFiStatus::onStationModeDisconnected(const WiFiEventStationModeDisconnected& event) {
|
||||||
Serial.print(F("WiFi Disconnected. Reason code="));
|
// Serial.print(F("WiFi Disconnected. Reason code="));
|
||||||
Serial.println(event.reason);
|
// Serial.println(event.reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiFiStatus::onStationModeGotIP(const WiFiEventStationModeGotIP& event) {
|
void WiFiStatus::onStationModeGotIP(const WiFiEventStationModeGotIP& event) {
|
||||||
Serial.printf_P(
|
// Serial.printf_P(PSTR("WiFi Got IP. localIP=%s, hostName=%s\r\n"), event.ip.toString().c_str(), WiFi.hostname().c_str());
|
||||||
PSTR("WiFi Got IP. localIP=%s, hostName=%s\r\n"), event.ip.toString().c_str(), WiFi.hostname().c_str());
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user