ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
Loading...
Searching...
No Matches
MicroSD

MicroSD interface for the esp32. More...

Functions

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.
 

Detailed Description

MicroSD interface for the esp32.

The MicroSDCommand message is used to control the microSD card connected to the esp32 module's SPI.

Function Documentation

◆ ControllerMicroSDLog()

uint32_t ControllerMicroSDLog ( const char *  msg,
const char *  base 
)

Append a line of plain text to the log file on the microSD card.

Unlike ControllerMicroSDSave(), the payload is not a Measurement, so no UserConfig has to be sent first to open a data file. The esp32 appends the line to a fixed log file.

Intended to back a microlog output handler, see ulog_output_add().

Parameters
msgNull terminated string. Truncated to fit MicroSDCommand.log.
baseBase filename that boot index and extension get appended.
Returns
MicroSDCommand_ReturnCode from the esp32. Returns MicroSDCommand_ReturnCode_ERROR_GENERAL if the i2c transaction failed.

Definition at line 155 of file microsd.c.

References CONTROLLER_SUCCESS, ControllerRx(), ControllerTransaction(), ControllerTx(), Buffer::data, DecodeEsp32Command(), EncodeMicroSDCommand(), Buffer::len, and Buffer::size.

◆ ControllerMicroSDSave()

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.

Parameters
dataAn array of data bytes. This data must be a protobuf-encoded (serialized) Measurement.
num_bytesThe number of bytes to be written.
Returns
File length in bytes (after saving data). Returns -1 on failure to save.

Definition at line 12 of file microsd.c.

References CONTROLLER_SUCCESS, ControllerRx(), ControllerTransaction(), ControllerTx(), data, Buffer::data, DecodeEsp32Command(), DecodeMeasurement(), EncodeMicroSDCommand(), Buffer::len, and Buffer::size.

Referenced by measure_sensor().

◆ ControllerMicroSDUserConfig()

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.

Parameters
ucUserConfig to be encoded and sent.
filenameFilename (limited to 256 characters)
Returns
File length in bytes (after saving data). Returns -1 on failure to save.

Definition at line 80 of file microsd.c.

References CONTROLLER_SUCCESS, ControllerRx(), ControllerTransaction(), ControllerTx(), Buffer::data, DecodeEsp32Command(), EncodeMicroSDCommand(), epoch(), filename, Buffer::len, and Buffer::size.