KW11-L new serialization

This commit is contained in:
folkert van heusden 2024-05-14 07:57:33 +02:00
parent e0e0e93b20
commit 798d69fc7a
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
2 changed files with 7 additions and 10 deletions

View file

@ -216,19 +216,18 @@ uint8_t kw11_l::get_lf_crs()
return rc;
}
#if IS_POSIX
json_t *kw11_l::serialize()
JsonDocument kw11_l::serialize()
{
json_t *j = json_object();
JsonDocument j;
json_object_set(j, "CSR", json_integer(lf_csr));
j["CSR"] = lf_csr;
return j;
}
kw11_l *kw11_l::deserialize(const json_t *const j, bus *const b, console *const cnsl)
{
uint16_t CSR = json_integer_value(json_object_get(j, "CSR"));
uint16_t CSR = j["CSR"];
kw11_l *out = new kw11_l(b);
out->lf_csr = CSR;
@ -236,4 +235,3 @@ kw11_l *kw11_l::deserialize(const json_t *const j, bus *const b, console *const
return out;
}
#endif

View file

@ -1,6 +1,7 @@
// (C) 2018-2024 by Folkert van Heusden
// Released under MIT license
#include <ArduinoJson.h>
#include <atomic>
#include <thread>
@ -42,10 +43,8 @@ public:
void show_state(console *const cnsl) const override;
#if IS_POSIX
json_t *serialize();
static kw11_l *deserialize(const json_t *const j, bus *const b, console *const cnsl);
#endif
JsonDocument serialize();
static kw11_l *deserialize(const JsonDocument j, bus *const b, console *const cnsl);
void begin(console *const cnsl);
void operator()();