1#ifndef SDCard_Updater_h
2#define SDCard_Updater_h
10constexpr char OPEN_FILE_FAILED[] =
"Failed to open file (%s), ensure path is correct and SD card exist and is initalized";
16template <
typename Logger = DefaultLogger>
42 bool begin(
size_t const & firmware_size)
override {
43 FILE* file = fopen(m_path,
"w");
44 if (file ==
nullptr) {
52 size_t write(
uint8_t * payload,
size_t const & total_bytes)
override {
53 FILE* file = fopen(m_path,
"a");
54 if (file ==
nullptr) {
58 auto const bytes_written = fwrite(payload, 1, total_bytes, file);
68 return remove(m_path) == 0;
72 char const * m_path = {};
constexpr char OPEN_FILE_FAILED[]
Definition: SDCard_Updater.h:10
Updater interface that contains the method that a class that can be used to flash given binary data o...
Definition: IUpdater.h:14
IUpdater implementation that uses the c fopen function (https://cplusplus.com/reference/cstdio/fopen/...
Definition: SDCard_Updater.h:17
bool end() override
Ends the update and returns wheter it was successfully completed.
Definition: SDCard_Updater.h:67
size_t write(uint8_t *payload, size_t const &total_bytes) override
Writes the given amount of bytes of the packet data.
Definition: SDCard_Updater.h:52
void operator=(SDCard_Updater const &other)=delete
Deleted copy assignment operator.
SDCard_Updater(SDCard_Updater const &other)=delete
Deleted copy constructor.
void reset() override
Resets the writing of the given data so it can be restarted with begin.
Definition: SDCard_Updater.h:63
SDCard_Updater(char const *file_path)
Constructor.
Definition: SDCard_Updater.h:22
bool begin(size_t const &firmware_size) override
Initalizes the writing of the given data.
Definition: SDCard_Updater.h:42
~SDCard_Updater() override
Definition: SDCard_Updater.h:38