Skip to content

Commit

Permalink
Fixes reboot when viewing status page from IOS 15
Browse files Browse the repository at this point in the history
  • Loading branch information
mstegen committed Mar 23, 2022
1 parent a1ddf50 commit c035e57
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion SmartEVSE-3/include/evse.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#define LOG_EVSE LOG_INFO // Default: LOG_INFO
#define LOG_MODBUS LOG_WARN // Default: LOG_WARN

#define VERSION "3.00" // SmartEVSE software version
#define VERSION "3.0.1" // SmartEVSE software version
#define TRANSFORMER_COMP 100


Expand Down
12 changes: 6 additions & 6 deletions SmartEVSE-3/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ board_build.f_flash = 80000000L
board_build.flash_mode = dio
lib_ignore =
AsyncTCP
ESPAsyncTCP-esphome
LittleFS_esp32
lib_deps =
https://github.com/esphome/AsyncTCP.git
lib_deps =
esphome/AsyncTCP-esphome @ ^1.2.2
esphome/ESPAsyncWebServer-esphome @ ^2.1.0
khoih-prog/[email protected]
miq19/[email protected]
Expand All @@ -35,8 +34,9 @@ monitor_filters = esp32_exception_decoder
board_build.partitions = partitions_custom.csv

[env:release]
platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.2
platformio/tool-esptoolpy @ https://github.com/tasmota/esptool/releases/download/v3.2/esptool-v3.2.zip
platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
platform_packages =
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32#master

build_flags =
-DLOG_LEVEL=5
16 changes: 8 additions & 8 deletions SmartEVSE-3/src/evse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "utils.h"
#include "OneWire.h"
#include "modbus.h"
#include "wifi.h"

#include <nvs_flash.h> // nvs initialisation code (can be removed?)

Expand Down Expand Up @@ -468,8 +467,8 @@ uint8_t Pilot() {
for (n=0 ; n<25 ;n++) {
sample = ADCsamples[n];
voltage = esp_adc_cal_raw_to_voltage( sample, adc_chars_CP); // convert adc reading to voltage
if (sample < Min) Min = voltage; // store lowest value
if (sample > Max) Max = voltage; // store highest value
if (voltage < Min) Min = voltage; // store lowest value
if (voltage > Max) Max = voltage; // store highest value
}
//Serial.printf("min:%u max:%u\n",Min ,Max);

Expand Down Expand Up @@ -1189,6 +1188,7 @@ uint8_t setItemValue(uint8_t nav, uint16_t val) {
break;
case STATUS_CURRENT:
OverrideCurrent = val;
timeout = 10; // reset timeout when register is written
break;
case STATUS_SOLAR_TIMER:
setSolarStopTimer(val);
Expand Down Expand Up @@ -2657,18 +2657,17 @@ void WiFiStationGotIp(WiFiEvent_t event, WiFiEventInfo_t info) {
// WebSockets event handler
//
void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len){
static uint8_t led = 0;

if (type == WS_EVT_CONNECT) {
Serial.printf("ws[%s][%u] connect\n", server->url(), client->id());
client->printf("Hello Client %u\n", client->id());
client->ping();
//client->printf("Hello Client %u\n", client->id());
//client->ping(); // this will crash the ESP on IOS 15.3.1 / Safari
//client->text("Hello from ESP32 Server");

} else if (type == WS_EVT_DISCONNECT) {
Serial.printf("ws[%s][%u] disconnect\n", server->url(), client->id());
} else if(type == WS_EVT_PONG){
Serial.printf("ws[%s][%u] pong[%u]: %s\n", server->url(), client->id(), len, (len)?(char*)data:"");
// Serial.printf("ws[%s][%u] pong[%u]: %s\n", server->url(), client->id(), len, (len)?(char*)data:"");
} else if (type == WS_EVT_DATA){

Serial.println("Data received: ");
Expand Down Expand Up @@ -2977,7 +2976,8 @@ void setup() {

// attach the channels to the GPIO to be controlled
ledcAttachPin(PIN_CP_OUT, CP_CHANNEL);
pinMode(PIN_CP_OUT, OUTPUT); // Re-init the pin to output, required in order for attachInterrupt to work (2.0.2)
//pinMode(PIN_CP_OUT, OUTPUT); // Re-init the pin to output, required in order for attachInterrupt to work (2.0.2)
// not required/working on master branch..
// see https://github.com/espressif/arduino-esp32/issues/6140
ledcAttachPin(PIN_LEDR, RED_CHANNEL);
ledcAttachPin(PIN_LEDG, GREEN_CHANNEL);
Expand Down

0 comments on commit c035e57

Please sign in to comment.