ESP32 fixes
This commit is contained in:
parent
0f4d574c4f
commit
3c4fb7c49c
5 changed files with 40 additions and 10 deletions
|
@ -24,6 +24,27 @@ disk_backend_esp32::~disk_backend_esp32()
|
|||
delete fh;
|
||||
}
|
||||
|
||||
JsonVariant disk_backend_esp32::serialize() const
|
||||
{
|
||||
JsonVariant j;
|
||||
|
||||
j["disk-backend-type"] = "esp32";
|
||||
|
||||
j["overlay"] = serialize_overlay();
|
||||
|
||||
// TODO store checksum of backend
|
||||
|
||||
j["filename"] = filename;
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
disk_backend_esp32 *disk_backend_esp32::deserialize(const JsonVariantConst j)
|
||||
{
|
||||
// TODO verify checksum of backend
|
||||
return new disk_backend_esp32(j["file"].as<std::string>());
|
||||
}
|
||||
|
||||
void disk_backend_esp32::emit_error()
|
||||
{
|
||||
DOLOG(ll_error, true, "SdFat error: %d/%d", sd.sdErrorCode(), sd.sdErrorData());
|
||||
|
|
|
@ -23,6 +23,9 @@ public:
|
|||
disk_backend_esp32(const std::string & filename);
|
||||
virtual ~disk_backend_esp32();
|
||||
|
||||
JsonVariant serialize() const override;
|
||||
static disk_backend_esp32 *deserialize(const JsonVariantConst j);
|
||||
|
||||
std::string get_identifier() const { return filename; }
|
||||
|
||||
bool begin(const bool dummy) override;
|
||||
|
|
4
bus.cpp
4
bus.cpp
|
@ -45,9 +45,9 @@ bus::~bus()
|
|||
delete dc11_;
|
||||
}
|
||||
|
||||
JsonDocument bus::serialize() const
|
||||
JsonVariant bus::serialize() const
|
||||
{
|
||||
JsonDocument j_out;
|
||||
JsonVariant j_out;
|
||||
|
||||
if (m)
|
||||
j_out["memory"] = m->serialize();
|
||||
|
|
4
bus.h
4
bus.h
|
@ -80,10 +80,8 @@ public:
|
|||
bus();
|
||||
~bus();
|
||||
|
||||
#if IS_POSIX
|
||||
JsonDocument serialize() const;
|
||||
JsonVariant serialize() const;
|
||||
static bus *deserialize(const JsonDocument j, console *const cnsl, std::atomic_uint32_t *const event);
|
||||
#endif
|
||||
|
||||
void reset() override;
|
||||
void init(); // invoked by 'RESET' command
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
|
||||
#include "disk_backend.h"
|
||||
#include "gen.h"
|
||||
#include "utils.h"
|
||||
#if IS_POSIX
|
||||
#include "disk_backend_file.h"
|
||||
#include "disk_backend_nbd.h"
|
||||
#else
|
||||
#include "disk_backend_esp32.h"
|
||||
#endif
|
||||
#include "disk_backend_nbd.h"
|
||||
|
||||
|
||||
disk_backend::disk_backend()
|
||||
|
@ -96,12 +99,17 @@ disk_backend *disk_backend::deserialize(const JsonVariantConst j)
|
|||
|
||||
disk_backend *d = nullptr;
|
||||
|
||||
if (type == "file")
|
||||
d = disk_backend_file::deserialize(j);
|
||||
|
||||
else if (type == "nbd")
|
||||
if (type == "nbd")
|
||||
d = disk_backend_nbd::deserialize(j);
|
||||
|
||||
#if IS_POSIX
|
||||
else if (type == "file")
|
||||
d = disk_backend_file::deserialize(j);
|
||||
#else
|
||||
else if (type == "esp32")
|
||||
d = disk_backend_esp32::deserialize(j);
|
||||
#endif
|
||||
|
||||
// should not be triggered
|
||||
assert(d);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue