Update batch schema and add ACK handling
This commit is contained in:
@@ -11,7 +11,8 @@ enum class PayloadType : uint8_t {
|
||||
MeterData = 0,
|
||||
TestCode = 1,
|
||||
TimeSync = 2,
|
||||
MeterBatch = 3
|
||||
MeterBatch = 3,
|
||||
Ack = 4
|
||||
};
|
||||
|
||||
constexpr uint8_t PROTOCOL_VERSION = 1;
|
||||
@@ -59,6 +60,8 @@ constexpr uint32_t OLED_AUTO_OFF_MS = 10UL * 60UL * 1000UL;
|
||||
constexpr uint32_t SENDER_OLED_READ_MS = 10000;
|
||||
constexpr uint32_t METER_SAMPLE_INTERVAL_MS = 1000;
|
||||
constexpr uint32_t METER_SEND_INTERVAL_MS = 30000;
|
||||
constexpr uint32_t BATCH_ACK_TIMEOUT_MS = 3000;
|
||||
constexpr uint8_t BATCH_MAX_RETRIES = 2;
|
||||
constexpr uint8_t METER_BATCH_MAX_SAMPLES = 30;
|
||||
constexpr uint32_t WATCHDOG_TIMEOUT_SEC = 120;
|
||||
constexpr bool ENABLE_HA_DISCOVERY = true;
|
||||
|
||||
@@ -22,7 +22,6 @@ struct MeterData {
|
||||
float energy_total_kwh;
|
||||
float phase_power_w[3];
|
||||
float total_power_w;
|
||||
float phase_voltage_v[3];
|
||||
float battery_voltage_v;
|
||||
uint8_t battery_percent;
|
||||
bool valid;
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
|
||||
bool meterDataToJson(const MeterData &data, String &out_json);
|
||||
bool jsonToMeterData(const String &json, MeterData &data);
|
||||
bool meterBatchToJson(const MeterData *samples, size_t count, String &out_json, const FaultCounters *faults = nullptr, FaultType last_error = FaultType::None);
|
||||
bool meterBatchToJson(const MeterData *samples, size_t count, uint16_t batch_id, String &out_json,
|
||||
const FaultCounters *faults = nullptr, FaultType last_error = FaultType::None);
|
||||
bool jsonToMeterBatch(const String &json, MeterData *out_samples, size_t max_count, size_t &out_count);
|
||||
|
||||
Reference in New Issue
Block a user