commit
0695e6643e
|
|
@ -14,7 +14,7 @@
|
||||||
class="navbar bg-body-secondary shadow-sm border-bottom sticky-top navbar-expand-lg"
|
class="navbar bg-body-secondary shadow-sm border-bottom sticky-top navbar-expand-lg"
|
||||||
>
|
>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="navbar-brand"
|
<a class="navbar-brand" href=""
|
||||||
>CA2RXU's LoRa</a
|
>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">
|
<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>
|
</button>
|
||||||
<div class="collapse navbar-collapse" id="navbarColor01">
|
<div class="collapse navbar-collapse" id="navbarColor01">
|
||||||
<ul class="navbar-nav me-auto">
|
<ul class="navbar-nav me-auto">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="/">
|
||||||
|
Configuration
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/update">
|
<a class="nav-link" href="/update">
|
||||||
Update <small>OTA</small>
|
Update <small>OTA</small>
|
||||||
|
|
@ -40,11 +45,11 @@
|
||||||
<a class="dropdown-item" href="#" id="reboot">Reboot</a>
|
<a class="dropdown-item" href="#" id="reboot">Reboot</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<!-- <li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="#" id="received-packets">
|
<a class="nav-link" href="/received-packets">
|
||||||
Received packets
|
Received packets
|
||||||
</a>
|
</a>
|
||||||
</li> -->
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<button class="btn btn-success my-2 my-sm-0" type="submit">Save</button>
|
<button class="btn btn-success my-2 my-sm-0" type="submit">Save</button>
|
||||||
|
|
@ -52,7 +57,32 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</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>
|
<main>
|
||||||
<div class="col-10 my-5 mx-auto">
|
<div class="col-10 my-5 mx-auto">
|
||||||
<div class="row my-5 d-flex align-items-top">
|
<div class="row my-5 d-flex align-items-top">
|
||||||
|
|
|
||||||
|
|
@ -456,3 +456,58 @@ form.addEventListener("submit", async (event) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
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;
|
||||||
std::vector<String> packetBuffer_temp;
|
std::vector<String> packetBuffer_temp;
|
||||||
|
|
||||||
|
std::vector<ReceivedPacket> receivedPackets;
|
||||||
|
|
||||||
String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, iGateBeaconPacket, iGateLoRaBeaconPacket;
|
String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, iGateBeaconPacket, iGateLoRaBeaconPacket;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
extern Configuration Config;
|
extern Configuration Config;
|
||||||
|
|
||||||
|
extern std::vector<ReceivedPacket> receivedPackets;
|
||||||
|
|
||||||
bool transmissionFlag = true;
|
bool transmissionFlag = true;
|
||||||
bool ignorePacket = false;
|
bool ignorePacket = false;
|
||||||
bool operationDone = true;
|
bool operationDone = true;
|
||||||
|
|
@ -169,6 +171,21 @@ namespace LoRa_Utils {
|
||||||
freqError = radio.getFrequencyError();
|
freqError = radio.getFrequencyError();
|
||||||
Utils::println("<--- LoRa Packet Rx : " + loraPacket);
|
Utils::println("<--- LoRa Packet Rx : " + loraPacket);
|
||||||
Utils::println("(RSSI:" + String(rssi) + " / SNR:" + String(snr) + " / FreqErr:" + String(freqError) + ")");
|
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) {
|
if (Config.syslog.active && WiFi.status() == WL_CONNECTED) {
|
||||||
SYSLOG_Utils::log("Rx", loraPacket, rssi, snr, freqError);
|
SYSLOG_Utils::log("Rx", loraPacket, rssi, snr, freqError);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,13 @@
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
class ReceivedPacket {
|
||||||
|
public:
|
||||||
|
long millis;
|
||||||
|
String packet;
|
||||||
|
int RSSI;
|
||||||
|
float SNR;
|
||||||
|
};
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
|
#include <ArduinoJson.h>
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "ota_utils.h"
|
#include "ota_utils.h"
|
||||||
#include "web_utils.h"
|
#include "web_utils.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
extern Configuration Config;
|
extern Configuration Config;
|
||||||
|
|
||||||
extern uint32_t lastBeaconTx;
|
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[] asm("_binary_data_embed_index_html_gz_start");
|
||||||
extern const char web_index_html_end[] asm("_binary_data_embed_index_html_gz_end");
|
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);
|
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) {
|
void handleWriteConfiguration(AsyncWebServerRequest *request) {
|
||||||
Serial.println("Got new config from www");
|
Serial.println("Got new config from www");
|
||||||
|
|
||||||
|
|
@ -214,6 +235,7 @@ namespace WEB_Utils {
|
||||||
void setup() {
|
void setup() {
|
||||||
server.on("/", HTTP_GET, handleHome);
|
server.on("/", HTTP_GET, handleHome);
|
||||||
server.on("/status", HTTP_GET, handleStatus);
|
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_GET, handleReadConfiguration);
|
||||||
server.on("/configuration.json", HTTP_POST, handleWriteConfiguration);
|
server.on("/configuration.json", HTTP_POST, handleWriteConfiguration);
|
||||||
server.on("/action", HTTP_POST, handleAction);
|
server.on("/action", HTTP_POST, handleAction);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue