Files
DD3-LoRa-Bridge-MultiSender/src/payload_codec.h
acidburns 06847a9da4 Add RX reject reasons to telemetry and UI
BACKWARD-INCOMPATIBLE: MeterBatch schema bumped to v2 with err_rx_reject.
- Track and log RX reject reasons (CRC/protocol/role/payload/length/id/batch)
- Include rx_reject in sender telemetry JSON and receiver web UI
- Add lora_receive reject reason logging under SERIAL_DEBUG_MODE
2026-02-13 23:57:34 +01:00

38 lines
920 B
C

#pragma once
#include <Arduino.h>
struct BatchInput {
uint16_t sender_id;
uint16_t batch_id;
uint32_t t_last;
uint8_t dt_s;
uint8_t n;
uint16_t battery_mV;
uint8_t err_m;
uint8_t err_d;
uint8_t err_tx;
uint8_t err_last;
uint8_t err_rx_reject;
uint32_t energy_wh[30];
int16_t p1_w[30];
int16_t p2_w[30];
int16_t p3_w[30];
};
bool encode_batch(const BatchInput &in, uint8_t *out, size_t out_cap, size_t *out_len);
bool decode_batch(const uint8_t *buf, size_t len, BatchInput *out);
size_t uleb128_encode(uint32_t v, uint8_t *out, size_t cap);
bool uleb128_decode(const uint8_t *in, size_t len, size_t *pos, uint32_t *v);
uint32_t zigzag32(int32_t x);
int32_t unzigzag32(uint32_t u);
size_t svarint_encode(int32_t x, uint8_t *out, size_t cap);
bool svarint_decode(const uint8_t *in, size_t len, size_t *pos, int32_t *x);
#ifdef PAYLOAD_CODEC_TEST
bool payload_codec_self_test();
#endif