Skip to content

Commit

Permalink
Fix for overflow when transferring files off the SD card over wifi
Browse files Browse the repository at this point in the history
  • Loading branch information
noisymime committed Oct 6, 2024
1 parent fc6213f commit 4914d24
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void initConfig()
{
config.begin("air-bear", false);

if(config.getUChar("connection_type", 0) == 0) { config.putUChar("connection_type", CONNECTION_TYPE_WIFI); } //Default to WIFI mode
if(config.getUChar("connection_type", 0) == 0) { config.putUChar("connection_type", CONNECTION_TYPE_DASH); } //Default to WIFI mode

Serial.println("Config Initialised");
}
2 changes: 1 addition & 1 deletion src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#define BIT_TIMER_1KHZ 7U

#define CONNECTION_TYPE_NONE 0
#define CONNECTION_TYPE_WIFI 1
#define CONNECTION_TYPE_DASH 1
#define CONNECTION_TYPE_BLE 2
#define CONNECTION_TYPE_TUNERSTUDIO 3

Expand Down
18 changes: 8 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void setup()
}
);

if( (config.getUChar("connection_type") == CONNECTION_TYPE_WIFI) && (updatesPending() == false) )
if( (config.getUChar("connection_type") == CONNECTION_TYPE_DASH) && (updatesPending() == false) )
{
//Init file system
if (!SPIFFS.begin(true)) {
Expand Down Expand Up @@ -147,7 +147,10 @@ void setup()
esp_efuse_set_rom_log_scheme(ESP_EFUSE_ROM_LOG_ALWAYS_OFF); //New eFuse value will be 3
}

if(config.getUChar("connection_type") == CONNECTION_TYPE_TUNERSTUDIO) { Serial_ECU.setRxBufferSize(2048+3); } //Maximum buffer size is 4x SD sectors (512) + 3 bytes over overhead
else { Serial_ECU.setRxBufferSize(257); } //Maximum buffer sent by the ECU
Serial_ECU.begin(115200);

delay(500);
while(Serial_ECU.available()) { Serial_ECU.read(); } //In case unit has restarted and ECU is still sending data over UART
}
Expand All @@ -163,7 +166,7 @@ void loop()
{
BIT_CLEAR(TIMER_mask, BIT_TIMER_30HZ);

if(config.getUChar("connection_type") == CONNECTION_TYPE_WIFI)
if(config.getUChar("connection_type") == CONNECTION_TYPE_DASH)
{
if(Serial_ECU.available())
{
Expand Down Expand Up @@ -197,23 +200,18 @@ void loop()

if(Serial_ECU)
{
if(config.getUChar("connection_type") == CONNECTION_TYPE_WIFI)
if(config.getUChar("connection_type") == CONNECTION_TYPE_DASH)
{
sendPing();
Serial.print("Notifications Sent: ");
Serial.println(notificationsSent);

if(serialECURequestQueueSize > 3)
if(serialECURequestQueueSize >= 2) { serialECURequestQueueSize++;} //Wait 1 additional second to allow ECU to timeout false data
if(serialECURequestQueueSize == 10)
{
//Not getting responses from ECU
sendNoDataMessage(); //Alert clients that no data is available
/* Serial_ECU.flush();
Serial_ECU.end();
Serial.println("Serial connection lost. Reconnecting");
Serial_ECU.begin(115200);
serialECURequestQueueSize = 0;
*/

}
}
else if(config.getUChar("connection_type") == CONNECTION_TYPE_TUNERSTUDIO)
Expand Down
2 changes: 1 addition & 1 deletion src/web_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ String webConfigRequest(AsyncWebServerRequest *request)
response += "<form action=\"" + String(WEB_CONFIG_URL) + "\" method=\"post\">";
response += "<h2>Connection Type</h2>";
response += "<select name=\"connection_type\" />";
response += "<option value=\"1\" " + (config.getUChar("connection_type") == CONNECTION_TYPE_WIFI ? String("selected") : String("")) + ">Web Dash</option>";
response += "<option value=\"1\" " + (config.getUChar("connection_type") == CONNECTION_TYPE_DASH ? String("selected") : String("")) + ">Web Dash</option>";
response += "<option value=\"2\" " + (config.getUChar("connection_type") == CONNECTION_TYPE_BLE ? String("selected") : String("")) + ">Bluetooth</option>";
response += "<option value=\"3\" " + (config.getUChar("connection_type") == CONNECTION_TYPE_TUNERSTUDIO ? String("selected") : String("")) + ">TunerStudio (TCP)</option>";
response += "</select><br/>";
Expand Down

0 comments on commit 4914d24

Please sign in to comment.