diff --git a/data_embed/script.js b/data_embed/script.js
index 9251635..d1e3cc1 100644
--- a/data_embed/script.js
+++ b/data_embed/script.js
@@ -455,4 +455,59 @@ form.addEventListener("submit", async (event) => {
setTimeout(checkConnection, 2000);
});
-fetchSettings();
\ No newline at end of file
+fetchSettings();
+
+function loadReceivedPackets(packets) {
+ if (packets) {
+ document.querySelector('#received-packets tbody').innerHTML = '';
+
+ const container = document.querySelector("#received-packets tbody");
+
+ container.innerHTML = '';
+
+ const date = new Date();
+
+ packets.forEach((packet) => {
+ const element = document.createElement("tr");
+
+ date.setTime(packet.millis);
+
+ const p = date.toUTCString().split(' ')
+
+ element.innerHTML = `
+ ${p[p.length-2]}
+ ${packet.packet}
+ ${packet.RSSI}
+ ${packet.SNR}
+ `;
+
+ container.appendChild(element);
+ })
+ }
+
+ setTimeout(fetchReceivedPackets, 15000);
+}
+
+function fetchReceivedPackets() {
+ fetch("/received-packets.json")
+ .then((response) => response.json())
+ .then((packets) => {
+ loadReceivedPackets(packets);
+ })
+ .catch((err) => {
+ console.error(err);
+
+ console.error(`Failed to load received packets`);
+ });
+}
+
+document.querySelector('a[href="/received-packets"]').addEventListener('click', function (e) {
+ e.preventDefault();
+
+ document.getElementById('received-packets').classList.remove('d-none');
+ document.getElementById('configuration').classList.add('d-none');
+
+ document.querySelector('button[type=submit]').remove();
+
+ fetchReceivedPackets();
+})
\ No newline at end of file
diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp
index c1d9f4b..4a9b6f9 100644
--- a/src/LoRa_APRS_iGate.cpp
+++ b/src/LoRa_APRS_iGate.cpp
@@ -53,6 +53,8 @@ std::vector lastHeardStation_temp;
std::vector packetBuffer;
std::vector packetBuffer_temp;
+std::vector receivedPackets;
+
String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, iGateBeaconPacket, iGateLoRaBeaconPacket;
void setup() {
diff --git a/src/lora_utils.cpp b/src/lora_utils.cpp
index 80ae3c1..44ad704 100644
--- a/src/lora_utils.cpp
+++ b/src/lora_utils.cpp
@@ -9,6 +9,8 @@
extern Configuration Config;
+extern std::vector receivedPackets;
+
bool transmissionFlag = true;
bool ignorePacket = false;
bool operationDone = true;
@@ -169,6 +171,21 @@ namespace LoRa_Utils {
freqError = radio.getFrequencyError();
Utils::println("<--- LoRa Packet Rx : " + loraPacket);
Utils::println("(RSSI:" + String(rssi) + " / SNR:" + String(snr) + " / FreqErr:" + String(freqError) + ")");
+
+ if (!Config.lowPowerMode) {
+ ReceivedPacket receivedPacket;
+ receivedPacket.millis = millis();
+ receivedPacket.packet = loraPacket.substring(3);
+ receivedPacket.RSSI = rssi;
+ receivedPacket.SNR = snr;
+
+ if (receivedPackets.size() >= 20) {
+ receivedPackets.erase(receivedPackets.begin());
+ }
+
+ receivedPackets.push_back(receivedPacket);
+ }
+
if (Config.syslog.active && WiFi.status() == WL_CONNECTED) {
SYSLOG_Utils::log("Rx", loraPacket, rssi, snr, freqError);
}
diff --git a/src/utils.h b/src/utils.h
index ad741f2..0ff8e2f 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -3,6 +3,13 @@
#include
+class ReceivedPacket {
+public:
+ long millis;
+ String packet;
+ int RSSI;
+ float SNR;
+};
namespace Utils {
diff --git a/src/web_utils.cpp b/src/web_utils.cpp
index e71a27c..749fc4a 100644
--- a/src/web_utils.cpp
+++ b/src/web_utils.cpp
@@ -1,9 +1,13 @@
+#include
#include "configuration.h"
#include "ota_utils.h"
#include "web_utils.h"
+#include "utils.h"
-extern Configuration Config;
-extern uint32_t lastBeaconTx;
+extern Configuration Config;
+
+extern uint32_t lastBeaconTx;
+extern std::vector receivedPackets;
extern const char web_index_html[] asm("_binary_data_embed_index_html_gz_start");
extern const char web_index_html_end[] asm("_binary_data_embed_index_html_gz_end");
@@ -57,6 +61,23 @@ namespace WEB_Utils {
request->send(200, "application/json", fileContent);
}
+ void handleReceivedPackets(AsyncWebServerRequest *request) {
+ StaticJsonDocument<1536> data;
+
+ for (int i = 0; i < receivedPackets.size(); i++) {
+ data[i]["millis"] = receivedPackets[i].millis;
+ data[i]["packet"] = receivedPackets[i].packet;
+ data[i]["RSSI"] = receivedPackets[i].RSSI;
+ data[i]["SNR"] = receivedPackets[i].SNR;
+ }
+
+ String buffer;
+
+ serializeJson(data, buffer);
+
+ request->send(200, "application/json", buffer);
+ }
+
void handleWriteConfiguration(AsyncWebServerRequest *request) {
Serial.println("Got new config from www");
@@ -214,6 +235,7 @@ namespace WEB_Utils {
void setup() {
server.on("/", HTTP_GET, handleHome);
server.on("/status", HTTP_GET, handleStatus);
+ server.on("/received-packets.json", HTTP_GET, handleReceivedPackets);
server.on("/configuration.json", HTTP_GET, handleReadConfiguration);
server.on("/configuration.json", HTTP_POST, handleWriteConfiguration);
server.on("/action", HTTP_POST, handleAction);