5#include "../../proto/transcoder.h"
6#include "../../util/time.h"
7#include "../communication.h"
17 MicroSDCommand microsd_cmd = MicroSDCommand_init_zero;
18 microsd_cmd.type = MicroSDCommand_Type_SAVE;
20 microsd_cmd.which_data = MicroSDCommand_meas_tag;
43 Esp32Command cmd = Esp32Command_init_default;
77 return cmd.command.microsd_command.rc;
86 MicroSDCommand microsd_cmd = MicroSDCommand_init_zero;
87 microsd_cmd.type = MicroSDCommand_Type_USERCONFIG;
94 snprintf(microsd_cmd.filename,
sizeof(microsd_cmd.filename),
"/%lu_%s",
97 microsd_cmd.which_data = MicroSDCommand_uc_tag;
98 memcpy(µsd_cmd.data.uc, uc,
sizeof(UserConfiguration));
116 Esp32Command cmd = Esp32Command_init_default;
152 return cmd.command.microsd_command.rc;
160 MicroSDCommand microsd_cmd = MicroSDCommand_init_zero;
161 microsd_cmd.type = MicroSDCommand_Type_LOG;
163 microsd_cmd.which_data = MicroSDCommand_log_tag;
166 strncpy(microsd_cmd.data.log, msg,
sizeof(microsd_cmd.data.log) - 1);
167 microsd_cmd.data.log[
sizeof(microsd_cmd.data.log) - 1] =
'\0';
170 strncpy(microsd_cmd.filename, base,
sizeof(microsd_cmd.filename) - 1);
171 microsd_cmd.filename[
sizeof(microsd_cmd.filename) - 1] =
'\0';
179 return MicroSDCommand_ReturnCode_ERROR_GENERAL;
184 return MicroSDCommand_ReturnCode_ERROR_GENERAL;
188 Esp32Command cmd = Esp32Command_init_default;
191 return cmd.command.microsd_command.rc;
Buffer * ControllerTx(void)
Get reference to transmit buffer.
Buffer * ControllerRx(void)
Get reference to receive buffer.
ControllerStatus ControllerTransaction(void)
Send message and receive response from esp32.
uint32_t ControllerMicroSDSave(const uint8_t *data, const uint16_t num_bytes)
Save data to the microSD card. Appends data to already-created files, otherwise creates a new file.
uint32_t ControllerMicroSDUserConfig(UserConfiguration *uc, const char *filename)
Send the UserConfig to the ESP32 and saves a file on the microSD with the UserConfig contents.
uint32_t ControllerMicroSDLog(const char *msg, const char *base)
Append a line of plain text to the log file on the microSD card.
Esp32Command DecodeEsp32Command(const uint8_t *data, const size_t len)
Decodes an Esp32Command message.
size_t EncodeMicroSDCommand(const MicroSDCommand *microsd_cmd, uint8_t *buffer, size_t size)
Encodes a MicroSDCommand.
int DecodeMeasurement(Measurement *meas, const uint8_t *buffer, const size_t len)
Decodes a measurement.
uint32_t epoch(void)
Gets the current unix epoch timestamp.
unsigned int g_controller_i2c_timeout
MicroSD interface implementation with the esp32.