Skip to content

Commit b916545

Browse files
committed
🐛 Fix IOS 18 Safari webUI Bug
1 parent 9db1575 commit b916545

2 files changed

Lines changed: 32 additions & 40 deletions

File tree

platformio.ini

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ platform = espressif8266@4.2.1
1313
framework = arduino
1414
monitor_speed = 115200
1515
monitor_filters = esp8266_exception_decoder, default, time, printable, colorize
16-
custom_prog_version = 2.3.0A1
16+
custom_prog_version = 2.3.1
1717
build_flags =
1818
-DVERSION=${this.custom_prog_version}
1919
-DPIO_SRC_NAM="EPEver2MQTT"
@@ -26,14 +26,13 @@ lib_extra_dirs =
2626
lib_deps =
2727
knolleary/PubSubClient@^2.8
2828
bblanchon/ArduinoJson@^6.21.3
29-
ottowinter/ESPAsyncTCP-esphome@^1.2.3
30-
ottowinter/ESPAsyncWebServer-esphome@^3.0.0
29+
esphome/ESPAsyncTCP-esphome @ 2.0.0
30+
mathieucarbou/ESPAsyncWebServer @ 3.3.7
31+
mathieucarbou/WebSerialLite@^6.2.0
3132
alanswx/ESPAsyncWiFiManager@^0.31
3233
gyverlibs/UnixTime@^1.1
33-
asjdf/WebSerialLite@^2.2.0
3434
paulstoffregen/OneWire@^2.3.7
3535
milesburton/DallasTemperature@^3.11.0
36-
3736
bblanchon/StreamUtils@^1.8.0
3837

3938
[env:d1_mini]

src/main.cpp

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ DynamicJsonDocument liveJson(JSON_BUFFER);
5757
OneWire oneWire(TEMPSENS_PIN);
5858
DallasTemperature tempSens(&oneWire);
5959

60-
6160
#include "status-LED.h"
6261
ADC_MODE(ADC_VCC);
6362
//----------------------------------------------------------------------
@@ -318,16 +317,16 @@ void setup()
318317
server.on("/set", HTTP_GET, [](AsyncWebServerRequest *request)
319318
{
320319
if(strlen(_settings.data.httpUser) > 0 && !request->authenticate(_settings.data.httpUser, _settings.data.httpPass)) return request->requestAuthentication();
321-
AsyncWebParameter *p = request->getParam(0);
322-
String resultMsg = "message received";
323-
if (p->name() == "datetime")
324-
{
325-
uint8_t rtcSetY = atoi (request->getParam("datetime")->value().substring(0, 2).c_str ());
326-
uint8_t rtcSetM = atoi (request->getParam("datetime")->value().substring(2, 4).c_str ());
327-
uint8_t rtcSetD = atoi (request->getParam("datetime")->value().substring(4, 6).c_str ());
328-
uint8_t rtcSeth = atoi (request->getParam("datetime")->value().substring(6, 8).c_str ());
329-
uint8_t rtcSetm = atoi (request->getParam("datetime")->value().substring(8, 10).c_str ());
330-
uint8_t rtcSets = atoi (request->getParam("datetime")->value().substring(10, 12).c_str ());
320+
String message;
321+
String resultMsg = "message received";
322+
if (request->hasParam("datetime")) {
323+
message = request->getParam("datetime")->value();
324+
uint8_t rtcSetY = atoi (message.substring(0, 2).c_str ());
325+
uint8_t rtcSetM = atoi (message.substring(2, 4).c_str ());
326+
uint8_t rtcSetD = atoi (message.substring(4, 6).c_str ());
327+
uint8_t rtcSeth = atoi (message.substring(6, 8).c_str ());
328+
uint8_t rtcSetm = atoi (message.substring(8, 10).c_str ());
329+
uint8_t rtcSets = atoi (message.substring(10, 12).c_str ());
331330

332331
for (size_t i = 1; i <= ((size_t)_settings.data.deviceQuantity); i++)
333332
{
@@ -338,9 +337,9 @@ void setup()
338337
epnode.writeMultipleRegisters(0x9013, 3); //write registers
339338
delay(50);
340339
}
341-
}
342-
if (p->name() == "devid")
343-
{
340+
}
341+
if (request->hasParam("devid")) {
342+
message = request->getParam("devid")->value();
344343
digitalWrite(EPEVER_DE_RE, 1);
345344
delay(50);
346345

@@ -350,7 +349,7 @@ void setup()
350349
u8TransmitRaw[2] = 0x00;
351350
u8TransmitRaw[3] = 0x01;
352351
u8TransmitRaw[4] = 0x01;
353-
u8TransmitRaw[5] = p->value().toInt();
352+
u8TransmitRaw[5] = message.toInt();
354353

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

369-
if(result[2] == p->value().toInt()){
368+
if(result[2] == message.toInt()){
370369
resultMsg = "ID " + String(result[2], HEX) + " Successfull Set";
371370
} else {
372371
resultMsg = "ID set Fail... Actual id is: " + String(result[2], HEX);
373372
}
374-
}
375-
if (p->name() == "ha")
376-
{
377-
haDiscTrigger = true;
378-
}
373+
}
374+
if (request->hasParam("ha")) {
375+
haDiscTrigger = true;
376+
}
379377
request->send(200, "text/plain", resultMsg.c_str()); });
380378

381379
server.on(
@@ -863,20 +861,15 @@ bool sendtoMQTT()
863861
}
864862
else
865863
{
866-
/* mqttclient.beginPublish((topic + String("/DATA")).c_str(), measureJson(liveJson), false);
867-
serializeJson(liveJson, mqttclient);
868-
mqttclient.endPublish(); */
869-
870-
871-
872-
873-
874-
mqttclient.beginPublish((topic + String("/DATA")).c_str(), measureJson(liveJson), false);
875-
BufferingPrint bufferedClient(mqttclient, 32);
876-
serializeJson(liveJson, bufferedClient);
877-
bufferedClient.flush();
878-
mqttclient.endPublish();
879-
864+
/* mqttclient.beginPublish((topic + String("/DATA")).c_str(), measureJson(liveJson), false);
865+
serializeJson(liveJson, mqttclient);
866+
mqttclient.endPublish(); */
867+
868+
mqttclient.beginPublish((topic + String("/DATA")).c_str(), measureJson(liveJson), false);
869+
BufferingPrint bufferedClient(mqttclient, 32);
870+
serializeJson(liveJson, bufferedClient);
871+
bufferedClient.flush();
872+
mqttclient.endPublish();
880873
}
881874
return true;
882875
}

0 commit comments

Comments
 (0)