commit
0695e6643e
|
|
@ -14,7 +14,7 @@
|
|||
class="navbar bg-body-secondary shadow-sm border-bottom sticky-top navbar-expand-lg"
|
||||
>
|
||||
<div class="container">
|
||||
<a class="navbar-brand"
|
||||
<a class="navbar-brand" href=""
|
||||
>CA2RXU's LoRa</a
|
||||
>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
|
||||
|
|
@ -22,6 +22,11 @@
|
|||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarColor01">
|
||||
<ul class="navbar-nav me-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/">
|
||||
Configuration
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/update">
|
||||
Update <small>OTA</small>
|
||||
|
|
@ -40,11 +45,11 @@
|
|||
<a class="dropdown-item" href="#" id="reboot">Reboot</a>
|
||||
</div>
|
||||
</li>
|
||||
<!-- <li class="nav-item">
|
||||
<a class="nav-link" href="#" id="received-packets">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/received-packets">
|
||||
Received packets
|
||||
</a>
|
||||
</li> -->
|
||||
</li>
|
||||
</ul>
|
||||
<div class="d-flex">
|
||||
<button class="btn btn-success my-2 my-sm-0" type="submit">Save</button>
|
||||
|
|
@ -52,7 +57,32 @@
|
|||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container">
|
||||
|
||||
<div class="container d-none" id="received-packets">
|
||||
<div class="row my-5 d-flex align-items-top">
|
||||
<div class="col-12">
|
||||
<h3>Last 20 received packets list</h3>
|
||||
<table class="table mt-4">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Time*</th>
|
||||
<th scope="col">Frame</th>
|
||||
<th scope="col">RSSI</th>
|
||||
<th scope="col">SNR</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<span>List refresh automatically every 15 seconds.</span><br>
|
||||
<small>* - For now time is measured from board boot up.</small>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<div class="container" id="configuration">
|
||||
<main>
|
||||
<div class="col-10 my-5 mx-auto">
|
||||
<div class="row my-5 d-flex align-items-top">
|
||||
|
|
|
|||
|
|
@ -455,4 +455,59 @@ form.addEventListener("submit", async (event) => {
|
|||
setTimeout(checkConnection, 2000);
|
||||
});
|
||||
|
||||
fetchSettings();
|
||||
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 = `
|
||||
<td>${p[p.length-2]}</td>
|
||||
<td>${packet.packet}</td>
|
||||
<td>${packet.RSSI}</td>
|
||||
<td>${packet.SNR}</td>
|
||||
`;
|
||||
|
||||
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();
|
||||
})
|
||||
|
|
@ -53,6 +53,8 @@ std::vector<String> lastHeardStation_temp;
|
|||
std::vector<String> packetBuffer;
|
||||
std::vector<String> packetBuffer_temp;
|
||||
|
||||
std::vector<ReceivedPacket> receivedPackets;
|
||||
|
||||
String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, iGateBeaconPacket, iGateLoRaBeaconPacket;
|
||||
|
||||
void setup() {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
extern Configuration Config;
|
||||
|
||||
extern std::vector<ReceivedPacket> 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,13 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
|
||||
class ReceivedPacket {
|
||||
public:
|
||||
long millis;
|
||||
String packet;
|
||||
int RSSI;
|
||||
float SNR;
|
||||
};
|
||||
|
||||
namespace Utils {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
#include <ArduinoJson.h>
|
||||
#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<ReceivedPacket> 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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue