Rework test mode to use normal LoRa batching and ACK flow
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "display_ui.h"
|
||||
#include "json_codec.h"
|
||||
#include "lora_transport.h"
|
||||
#include "mqtt_client.h"
|
||||
#include "payload_codec.h"
|
||||
@@ -77,6 +78,18 @@ static uint8_t bit_count32(uint32_t value) {
|
||||
return count;
|
||||
}
|
||||
|
||||
static bool mqtt_publish_sample(const MeterData &data) {
|
||||
#ifdef ENABLE_TEST_MODE
|
||||
String payload;
|
||||
if (!meterDataToJson(data, payload)) {
|
||||
return false;
|
||||
}
|
||||
return mqtt_publish_test(data.device_id, payload);
|
||||
#else
|
||||
return mqtt_publish_state(data);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct BatchRxState {
|
||||
bool active;
|
||||
uint16_t batch_id;
|
||||
@@ -470,7 +483,7 @@ static void receiver_loop() {
|
||||
|
||||
web_server_set_last_batch(static_cast<uint8_t>(sender_idx), samples, count);
|
||||
for (size_t s = 0; s < count; ++s) {
|
||||
mqtt_publish_state(samples[s]);
|
||||
mqtt_publish_sample(samples[s]);
|
||||
}
|
||||
g_sender_statuses[sender_idx].last_data = samples[count - 1];
|
||||
g_sender_statuses[sender_idx].last_update_ts_utc = samples[count - 1].ts_utc;
|
||||
|
||||
Reference in New Issue
Block a user