Skip to content

Commit

Permalink
🐛 Fix IOS 18 Safari webUI Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
softwarecrash committed Oct 2, 2024
1 parent 9db1575 commit b916545
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 40 deletions.
9 changes: 4 additions & 5 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ platform = espressif8266@4.2.1
framework = arduino
monitor_speed = 115200
monitor_filters = esp8266_exception_decoder, default, time, printable, colorize
custom_prog_version = 2.3.0A1
custom_prog_version = 2.3.1
build_flags =
-DVERSION=${this.custom_prog_version}
-DPIO_SRC_NAM="EPEver2MQTT"
Expand All @@ -26,14 +26,13 @@ lib_extra_dirs =
lib_deps =
knolleary/PubSubClient@^2.8
bblanchon/ArduinoJson@^6.21.3
ottowinter/ESPAsyncTCP-esphome@^1.2.3
ottowinter/ESPAsyncWebServer-esphome@^3.0.0
esphome/ESPAsyncTCP-esphome @ 2.0.0
mathieucarbou/ESPAsyncWebServer @ 3.3.7
mathieucarbou/WebSerialLite@^6.2.0
alanswx/ESPAsyncWiFiManager@^0.31
gyverlibs/UnixTime@^1.1
asjdf/WebSerialLite@^2.2.0
paulstoffregen/OneWire@^2.3.7
milesburton/DallasTemperature@^3.11.0

bblanchon/StreamUtils@^1.8.0

[env:d1_mini]
Expand Down
63 changes: 28 additions & 35 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ DynamicJsonDocument liveJson(JSON_BUFFER);
OneWire oneWire(TEMPSENS_PIN);
DallasTemperature tempSens(&oneWire);


#include "status-LED.h"
ADC_MODE(ADC_VCC);
//----------------------------------------------------------------------
Expand Down Expand Up @@ -318,16 +317,16 @@ void setup()
server.on("/set", HTTP_GET, [](AsyncWebServerRequest *request)
{
if(strlen(_settings.data.httpUser) > 0 && !request->authenticate(_settings.data.httpUser, _settings.data.httpPass)) return request->requestAuthentication();
AsyncWebParameter *p = request->getParam(0);
String resultMsg = "message received";
if (p->name() == "datetime")
{
uint8_t rtcSetY = atoi (request->getParam("datetime")->value().substring(0, 2).c_str ());
uint8_t rtcSetM = atoi (request->getParam("datetime")->value().substring(2, 4).c_str ());
uint8_t rtcSetD = atoi (request->getParam("datetime")->value().substring(4, 6).c_str ());
uint8_t rtcSeth = atoi (request->getParam("datetime")->value().substring(6, 8).c_str ());
uint8_t rtcSetm = atoi (request->getParam("datetime")->value().substring(8, 10).c_str ());
uint8_t rtcSets = atoi (request->getParam("datetime")->value().substring(10, 12).c_str ());
String message;
String resultMsg = "message received";
if (request->hasParam("datetime")) {
message = request->getParam("datetime")->value();
uint8_t rtcSetY = atoi (message.substring(0, 2).c_str ());
uint8_t rtcSetM = atoi (message.substring(2, 4).c_str ());
uint8_t rtcSetD = atoi (message.substring(4, 6).c_str ());
uint8_t rtcSeth = atoi (message.substring(6, 8).c_str ());
uint8_t rtcSetm = atoi (message.substring(8, 10).c_str ());
uint8_t rtcSets = atoi (message.substring(10, 12).c_str ());

for (size_t i = 1; i <= ((size_t)_settings.data.deviceQuantity); i++)
{
Expand All @@ -338,9 +337,9 @@ void setup()
epnode.writeMultipleRegisters(0x9013, 3); //write registers
delay(50);
}
}
if (p->name() == "devid")
{
}
if (request->hasParam("devid")) {
message = request->getParam("devid")->value();
digitalWrite(EPEVER_DE_RE, 1);
delay(50);

Expand All @@ -350,7 +349,7 @@ void setup()
u8TransmitRaw[2] = 0x00;
u8TransmitRaw[3] = 0x01;
u8TransmitRaw[4] = 0x01;
u8TransmitRaw[5] = p->value().toInt();
u8TransmitRaw[5] = message.toInt();

uint16_t crcBuff = 0xFFFF;
for (i = 0; i < 6; i++)
Expand All @@ -366,16 +365,15 @@ void setup()
char result[4];
EPEVER_SERIAL.readBytes(result, 4);

if(result[2] == p->value().toInt()){
if(result[2] == message.toInt()){
resultMsg = "ID " + String(result[2], HEX) + " Successfull Set";
} else {
resultMsg = "ID set Fail... Actual id is: " + String(result[2], HEX);
}
}
if (p->name() == "ha")
{
haDiscTrigger = true;
}
}
if (request->hasParam("ha")) {
haDiscTrigger = true;
}
request->send(200, "text/plain", resultMsg.c_str()); });

server.on(
Expand Down Expand Up @@ -863,20 +861,15 @@ bool sendtoMQTT()
}
else
{
/* mqttclient.beginPublish((topic + String("/DATA")).c_str(), measureJson(liveJson), false);
serializeJson(liveJson, mqttclient);
mqttclient.endPublish(); */





mqttclient.beginPublish((topic + String("/DATA")).c_str(), measureJson(liveJson), false);
BufferingPrint bufferedClient(mqttclient, 32);
serializeJson(liveJson, bufferedClient);
bufferedClient.flush();
mqttclient.endPublish();

/* mqttclient.beginPublish((topic + String("/DATA")).c_str(), measureJson(liveJson), false);
serializeJson(liveJson, mqttclient);
mqttclient.endPublish(); */

mqttclient.beginPublish((topic + String("/DATA")).c_str(), measureJson(liveJson), false);
BufferingPrint bufferedClient(mqttclient, 32);
serializeJson(liveJson, bufferedClient);
bufferedClient.flush();
mqttclient.endPublish();
}
return true;
}
Expand Down

0 comments on commit b916545

Please sign in to comment.