Update ESP32 platform and LoRa batching

This commit is contained in:
2026-02-01 17:03:08 +01:00
parent 16c65744e3
commit 430b0d7054
5 changed files with 213 additions and 92 deletions

View File

@@ -15,6 +15,11 @@ enum class PayloadType : uint8_t {
Ack = 4
};
enum class BatchRetryPolicy : uint8_t {
Keep = 0,
Drop = 1
};
constexpr uint8_t PROTOCOL_VERSION = 1;
// Pin definitions
@@ -48,6 +53,7 @@ constexpr uint8_t LORA_SPREADING_FACTOR = 12;
constexpr long LORA_BANDWIDTH = 125E3;
constexpr uint8_t LORA_CODING_RATE = 5;
constexpr uint8_t LORA_SYNC_WORD = 0x34;
constexpr uint8_t LORA_PREAMBLE_LEN = 8;
// Timing
constexpr uint32_t SENDER_WAKE_INTERVAL_SEC = 30;
@@ -63,6 +69,8 @@ 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 uint8_t BATCH_QUEUE_DEPTH = 10;
constexpr BatchRetryPolicy BATCH_RETRY_POLICY = BatchRetryPolicy::Keep;
constexpr uint32_t WATCHDOG_TIMEOUT_SEC = 120;
constexpr bool ENABLE_HA_DISCOVERY = true;

View File

@@ -3,7 +3,7 @@
#include <Arduino.h>
#include "config.h"
constexpr size_t LORA_MAX_PAYLOAD = 200;
constexpr size_t LORA_MAX_PAYLOAD = 230;
struct LoraPacket {
uint8_t protocol_version;
@@ -20,3 +20,4 @@ void lora_init();
bool lora_send(const LoraPacket &pkt);
bool lora_receive(LoraPacket &pkt, uint32_t timeout_ms);
void lora_sleep();
uint32_t lora_airtime_ms(size_t packet_len);