MCPcopy Create free account
hub / github.com/OpenEarable/open-earable / data_callback

Method data_callback

src/sd_logger/SD_Logger.cpp:29–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29void SD_Logger::data_callback(int id, unsigned int timestamp, const String & data_string) {
30 if (id == -1) {
31 dump_to_sd();
32 _file.close();
33 _opened = false;
34 return;
35 };
36
37 String text = String(id);
38 text += ", " + String(timestamp);
39 text += ", " + data_string;
40 text += "\r\n";
41
42 if (text.length() + _index > LOGGER_BUFFER_SIZE) {
43 dump_to_sd();
44 }
45
46 text.toCharArray(&(_buffer[_index]), text.length());
47 _index += text.length() - 1; // -1 to remove null terminator
48}
49
50void SD_Logger::dump_to_sd() {
51 if (!open_file()) return;

Callers

nothing calls this directly

Calls 1

closeMethod · 0.80

Tested by

no test coverage detected