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 a8b0bb6 commit e63cb0c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 68 deletions.
12 changes: 4 additions & 8 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
platform = espressif8266@4.2.1
framework = arduino
monitor_speed = 115200
custom_prog_version = 2.14.0
custom_prog_version = 2.14.1
build_flags =
-DVERSION=${this.custom_prog_version}
-DPIO_SRC_NAM="Daly2MQTT"
Expand All @@ -23,15 +23,11 @@ extra_scripts = pre:tools/mini_html.py
lib_deps =
knolleary/PubSubClient @ ^2.8
bblanchon/ArduinoJson @ ^6.21.3
;need replaced by this:
;https://github.com/mathieucarbou/ESPAsyncWebServer
;because this:
;https://github.com/esphome/ESPAsyncWebServer/issues/42
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.0
plerup/EspSoftwareSerial @ ^8.0.3
asjdf/WebSerialLite@^2.2.0
paulstoffregen/OneWire@^2.3.7
milesburton/DallasTemperature@^3.11.0

Expand Down
106 changes: 46 additions & 60 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ DeviceAddress tempDeviceAddress;

ADC_MODE(ADC_VCC);

const char *PARAM_MESSAGE PROGMEM = "message";

//----------------------------------------------------------------------
void saveConfigCallback()
{
Expand Down Expand Up @@ -509,67 +511,51 @@ 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);
if (p->name() == "chargefet")
{
writeLog("<WEBS> Webcall: charge fet to: %s", p->value());
if(p->value().toInt() == 1){
bms.setChargeMOS(true);
bms.get.chargeFetState = true;
}
if(p->value().toInt() == 0){
bms.setChargeMOS(false);
bms.get.chargeFetState = false;
}
}
if (p->name() == "dischargefet")
{
writeLog("<WEBS> Webcall: discharge fet to: %s", p->value());
if(p->value().toInt() == 1){
bms.setDischargeMOS(true);
bms.get.disChargeFetState = true;
}
if(p->value().toInt() == 0){
bms.setDischargeMOS(false);
bms.get.disChargeFetState = false;
}
}
if (p->name() == "soc")
{
writeLog("<WEBS> Webcall: setsoc SOC set to: %s", p->value());
if(p->value().toInt() >= 0 && p->value().toInt() <= 100 ){
bms.setSOC(p->value().toInt());
String message;

if (request->hasParam("chargefet")) {
message = request->getParam("chargefet")->value();
writeLog("<WEBS> Webcall: charge fet to: %s", message);
bms.setChargeMOS((message == "1") ? true:false);
bms.get.chargeFetState = (message == "1") ? true:false;
}
if (request->hasParam("dischargefet")) {
message = request->getParam("dischargefet")->value();
writeLog("<WEBS> Webcall: discharge fet to: %s", message);
bms.setDischargeMOS((message == "1") ? true:false);
bms.get.disChargeFetState = (message == "1") ? true:false;
}
if (request->hasParam("soc")) {
message = request->getParam("soc")->value();
writeLog("<WEBS> Webcall: setsoc SOC set to: %s", message);
if(message.toInt() >= 0 && message.toInt() <= 100 ){
bms.setSOC(message.toInt());
}
}
if (request->hasParam("relais")) {
message = request->getParam("relais")->value();
writeLog("<WEBS> Webcall: set relais to: %s", message);
relaisComparsionResult = (message == "1") ? true:false;
}
if (request->hasParam("bmsreset")) {
message = request->getParam("bmsreset")->value();
if(message.toInt() == 1){
writeLog("<WEBS> Webcall: reset BMS");
bms.setBmsReset();
}
if (p->name() == "relais")
{
writeLog("<WEBS> Webcall: set relais to: %s", p->value());
if(p->value().toInt() == 1){
relaisComparsionResult = true;
}
if(p->value().toInt() == 0){
relaisComparsionResult = false;
}
}
if (request->hasParam("bmswake")) {
message = request->getParam("bmswake")->value();
writeLog("<WEBS> wakeup manual from Web");
if(message.toInt() == 1){
wakeupHandler(true);
writeLog("<WEBS> wakeup manual from Web");
}
if (p->name() == "bmsreset")
{
writeLog("<WEBS> Webcall: reset BMS");
if(p->value().toInt() == 1){
bms.setBmsReset();
}
}
if (p->name() == "bmswake")
{
if(p->value().toInt() == 1){
wakeupHandler(true);
writeLog("<WEBS> wakeup manual from Web");
}
}
if (p->name() == "ha")
{
haDiscTrigger = true;
}
request->send(200, "text/plain", "message received"); });
}
if (request->hasParam("ha")) {
haDiscTrigger = true;
}
request->send(200, "text/plain", "message received"); });

server.on(
"/update", HTTP_POST, [](AsyncWebServerRequest *request)
Expand Down Expand Up @@ -622,7 +608,7 @@ void setup()
{ request->send(418, "text/plain", "418 I'm a teapot"); });

// set the device name

if (MDNS.begin(_settings.data.deviceName))
{
writeLog("<SYS > mDNS running...");
Expand Down Expand Up @@ -651,7 +637,7 @@ void setup()
// end void setup
void loop()
{
MDNS.update();
MDNS.update();
if (Update.isRunning())
{
workerCanRun = false; // lockout, atfer true need reboot
Expand Down

0 comments on commit e63cb0c

Please sign in to comment.