Skip to content

Commit

Permalink
fix first start mode - handle webserver
Browse files Browse the repository at this point in the history
  • Loading branch information
ohAnd committed Jul 6, 2024
1 parent 27debee commit cd0b7f5
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/dtuGateway.ino
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ void handleUpdatePowerLimit()
globalData.powerLimitSet = gotLimit;

// Serial.print("got SetLimit: " + String(globalData.powerLimitSet) + " - current limit: " + String(globalData.powerLimit) + " %");

String JSON = "{";
JSON = JSON + "\"PowerLimitSet\": \"" + globalData.powerLimitSet + "\"";
JSON = JSON + "}";
Expand All @@ -544,14 +544,14 @@ void handleUpdatePowerLimit()
else
{
Serial.print("got wrong data for SetLimit: " + powerLimitSetNew);
server.send(400, "text/plain", "powerLimit out of range");
return;

server.send(400, "text/plain", "powerLimit out of range");
return;
}

// trigger new update info with changed release channel
// getUpdateInfo(AsyncWebServerRequest *request);
//updateInfoRequested = true;
// updateInfoRequested = true;
}

void handleUpdateOTASettings()
Expand Down Expand Up @@ -1482,13 +1482,14 @@ void loop()
if (updateRunning)
return;

// if (WiFi.status() == WL_CONNECTED)
// {
// web server runner
server.handleClient();
// serving domain name
MDNS.update();
if (WiFi.status() == WL_CONNECTED)
{
// web server runner
server.handleClient();
// serving domain name
MDNS.update();

// runner for mqttClient to hold a already etablished connection
if (userConfig.mqttActive)
{
Expand Down Expand Up @@ -1554,13 +1555,16 @@ void loop()

// -------->

if (globalControls.wifiSwitch && !userConfig.wifiAPstart)
checkWifiTask();
else
if (!userConfig.wifiAPstart)
{
// stopping connection to DTU before go wifi offline
dtuConnectionStop(&dtuClient, DTU_STATE_OFFLINE);
WiFi.disconnect();
if (globalControls.wifiSwitch)
checkWifiTask();
else
{
// stopping connection to DTU before go wifi offline
dtuConnectionStop(&dtuClient, DTU_STATE_OFFLINE);
WiFi.disconnect();
}
}

if (dtuConnection.preventCloudErrors)
Expand Down

0 comments on commit cd0b7f5

Please sign in to comment.