Skip to content

Commit 8506c17

Browse files
committed
attempt fix sd for pico target
1 parent 8cd12df commit 8506c17

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/provisioning/sdcard/ws_sdcard.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ void ws_sdcard::BuildJSONDoc(JsonDocument &doc, uint8_t pin, bool value,
10321032
/**************************************************************************/
10331033
bool ws_sdcard::LogJSONDoc(JsonDocument &doc) {
10341034
size_t szJson;
1035-
// Serialize the JSON document
1035+
10361036
#ifndef OFFLINE_MODE_DEBUG
10371037
File32 file;
10381038
file = _sd.open(_log_filename, O_RDWR | O_CREAT | O_AT_END);
@@ -1046,22 +1046,23 @@ bool ws_sdcard::LogJSONDoc(JsonDocument &doc) {
10461046
doc, file); // Serialize the JSON to the file in 64-byte chunks
10471047
bufferedFile.print("\n"); // JSONL format specifier
10481048
bufferedFile.flush(); // Send the remaining bytes
1049+
file.close();
1050+
// Update log file's size
1051+
_sz_cur_log_file = szJson + 2; // +2 bytes for "\n"
10491052
// print the doc to the serial
10501053
serializeJson(doc, Serial);
10511054
Serial.print("\n");
10521055
#else
10531056
szJson = serializeJson(doc, Serial);
10541057
Serial.print("\n"); // Required JSONL format specifier
10551058
#endif
1056-
_sz_cur_log_file = szJson + 2; // +2 bytes for "\n"
10571059

1060+
// Do we need a new log file?
10581061
if (_sz_cur_log_file >= _max_sz_log_file) {
10591062
WS_DEBUG_PRINTLN(
10601063
"[SD] NOTE: Log file has exceeded maximum size! Attempting to "
10611064
"create a new file...");
1062-
if (!CreateNewLogFile())
1063-
return false;
1064-
return false;
1065+
return CreateNewLogFile();
10651066
}
10661067

10671068
return true;

0 commit comments

Comments
 (0)