add SD support

This commit is contained in:
theFeiter 2022-07-23 18:30:44 +02:00
parent 9e700ca315
commit f83e41da5a

View File

@ -294,10 +294,23 @@ void mqtt_callback(char* topic, byte * message, unsigned int length) {
void resendLog(){ void resendLog(){
#ifdef USE_SD_LOG #ifdef USE_SD_LOG
/*DBG("Releasing Log buffer to SD"); DBG("Resending logged values from SD card.");
File logfile = SD.open(SD_FILENAME, FILE_WRITE); File logfile = SD.open(SD_FILENAME, FILE_READ);
logfile.print(logBuffer); while(1){
logfile.close();*/ String line = logfile.readStringUntil('\n');
if (line.length() > 0){ // if line contains something
if (!client.publish(TOPIC_DATA, line.c_str())) {
break;
}else{
time(&last_mqtt_success);
}
}else{
logfile.close();
SD.remove(SD_FILENAME); // if all values are sent
break;
}
}
DBG(" Done");
#endif #endif
#ifdef USE_FS_LOG #ifdef USE_FS_LOG
DBG("Resending logged values from internal flash."); DBG("Resending logged values from internal flash.");
@ -311,11 +324,11 @@ void resendLog(){
time(&last_mqtt_success); time(&last_mqtt_success);
} }
}else{ }else{
logfile.close();
LittleFS.remove(FS_FILENAME); // if all values are sent LittleFS.remove(FS_FILENAME); // if all values are sent
break; break;
} }
} }
logfile.close();
DBG(" Done"); DBG(" Done");
#endif #endif