mirror of
https://github.com/timmbogner/Farm-Data-Relay-System
synced 2024-11-10 07:10:42 +00:00
add SD support
This commit is contained in:
parent
9e700ca315
commit
f83e41da5a
@ -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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user