Skip to content

Commit

Permalink
Merge pull request #56 from SQ2CPA/main
Browse files Browse the repository at this point in the history
TNC and few more changes and fixes
  • Loading branch information
richonguzman authored Mar 22, 2024
2 parents 6bd6cce + 0b40cb0 commit 0d11627
Show file tree
Hide file tree
Showing 28 changed files with 963 additions and 366 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ jobs:
- "ttgo-t-beam-v1"
- "ttgo-t-beam-v1_SX1268"
- "ttgo-t-beam-v1_2_SX1262"
# - "heltec_wireless_stick_lite" # NOT FULLY TESTED
- "heltec_wireless_stick"
- "heltec_wireless_stick_lite"
steps:
- uses: actions/checkout@v3

Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Commit Test Build

on:
push:
branches:
- '*'

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- "ttgo-lora32-v21"
- "heltec-lora32-v2"
- "heltec_wifi_lora_32_V3"
- "ESP32_DIY_LoRa"
- "ESP32_DIY_1W_LoRa"
- "ttgo-t-beam-v1_2"
- "ttgo-t-beam-v1"
- "ttgo-t-beam-v1_SX1268"
- "ttgo-t-beam-v1_2_SX1262"
- "heltec_wireless_stick"
- "heltec_wireless_stick_lite"
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: Install PlatformIO Core
run: pip install --upgrade platformio

- name: Build target
run: pio run -e ${{ matrix.target }}

- name: Build FS
run: pio run --target buildfs -e ${{ matrix.target }}
5 changes: 5 additions & 0 deletions data/igate_conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
"digi": {
"mode": 0
},
"tnc": {
"enableServer": false,
"enableSerial": false,
"acceptOwn": false
},
"aprs_is": {
"active": false,
"passcode": "XYZVW",
Expand Down
256 changes: 133 additions & 123 deletions data_embed/index.html

Large diffs are not rendered by default.

51 changes: 35 additions & 16 deletions data_embed/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function loadSettings(settings) {
document.querySelector(".list-networks").innerHTML = "";

// Networks
const wifiNetworks = settings.wifi.AP;
const wifiNetworks = settings.wifi.AP || [];
const networksContainer = document.querySelector(".list-networks");

let networkCount = 0;
Expand Down Expand Up @@ -150,6 +150,11 @@ function loadSettings(settings) {
// document.getElementById("digi.longitude").value = settings.digi.longitude;
document.getElementById("digi.mode").value = settings.digi.mode;

// TNC
document.getElementById("tnc.enableServer").checked = settings.tnc.enableServer;
document.getElementById("tnc.enableSerial").checked = settings.tnc.enableSerial;
document.getElementById("tnc.acceptOwn").checked = settings.tnc.acceptOwn;

// OTA
document.getElementById("ota.username").value = settings.ota.username;
document.getElementById("ota.password").value = settings.ota.password;
Expand All @@ -162,6 +167,7 @@ function loadSettings(settings) {
settings.other.sendBatteryVoltage;
document.getElementById("other.externalVoltageMeasurement").checked =
settings.other.externalVoltageMeasurement;

document.getElementById("other.externalVoltagePin").value =
settings.other.externalVoltagePin;
// document.getElementById("beacon.igateSendsLoRaBeacon").value =
Expand Down Expand Up @@ -207,8 +213,33 @@ function loadSettings(settings) {

updateImage();
refreshSpeedStandard();
toggleFields();
}

function showToast(message) {
const el = document.querySelector('#toast');

el.querySelector('.toast-body').innerHTML = message;

(new bootstrap.Toast(el)).show();
}

document.getElementById('send-beacon').addEventListener('click', function (e) {
e.preventDefault();

fetch("/action?type=send-beacon", { method: "POST" });

showToast("Your beacon will be sent in a moment. <br> <u>This action will be ignored if you have APRSIS and LoRa TX disabled!</u>");
});

document.getElementById('reboot').addEventListener('click', function (e) {
e.preventDefault();

fetch("/action?type=reboot", { method: "POST" });

showToast("Your device will be rebooted in a while");
});

const bmeCheckbox = document.querySelector("input[name='bme.active']");

const stationModeSelect = document.querySelector("select[name='stationMode']");
Expand Down Expand Up @@ -239,36 +270,26 @@ function updateImage() {
}

function toggleFields() {
const sendBatteryVoltageCheckbox = document.querySelector(
'input[name="other.sendBatteryVoltage"]'
);
const externalVoltageMeasurementCheckbox = document.querySelector(
'input[name="other.externalVoltageMeasurement"]'
);
const externalVoltagePinInput = document.querySelector(
'input[name="other.externalVoltagePin"]'
);

externalVoltageMeasurementCheckbox.disabled =
!sendBatteryVoltageCheckbox.checked;
externalVoltagePinInput.disabled =
!externalVoltageMeasurementCheckbox.checked;
}

const sendBatteryVoltageCheckbox = document.querySelector(
'input[name="other.sendBatteryVoltage"]'
);
const externalVoltageMeasurementCheckbox = document.querySelector(
'input[name="other.externalVoltageMeasurement"]'
);
const externalVoltagePinInput = document.querySelector(
'input[name="other.externalVoltagePin"]'
);

sendBatteryVoltageCheckbox.addEventListener("change", function () {
externalVoltageMeasurementCheckbox.disabled = !this.checked;
externalVoltagePinInput.disabled =
!externalVoltageMeasurementCheckbox.checked;
externalVoltageMeasurementCheckbox.addEventListener("change", function () {
externalVoltagePinInput.disabled = !this.checked;
});

document.querySelector(".new button").addEventListener("click", function () {
Expand Down Expand Up @@ -378,8 +399,6 @@ document.getElementById("action.speed").addEventListener("change", function () {
}
});

toggleFields();

const form = document.querySelector("form");

const saveModal = new bootstrap.Modal(document.getElementById("saveModal"), {
Expand Down Expand Up @@ -430,4 +449,4 @@ form.addEventListener("submit", async (event) => {
setTimeout(checkConnection, 2000);
});

fetchSettings();
fetchSettings();
8 changes: 8 additions & 0 deletions data_embed/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.alert-fixed {
position:fixed;
top: 0px;
left: 0px;
width: 100%;
z-index:9999;
border-radius:0px
}
9 changes: 4 additions & 5 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ board = heltec_wifi_lora_32_V3
board_build.mcu = esp32s3
build_flags = -Werror -Wall -DHELTEC_WS -DELEGANTOTA_USE_ASYNC_WEBSERVER=1

;[env:heltec_wireless_stick_lite]
;board = heltec_wireless_stick_lite
;board_build.mcu = esp32c3
;board_build.f_cpu = 240000000L
;build_flags = -Werror -Wall -DHELTEC_WSL -DELEGANTOTA_USE_ASYNC_WEBSERVER=1
[env:heltec_wireless_stick_lite]
board = heltec_wireless_stick_lite
board_build.mcu = esp32c3
build_flags = -Werror -Wall -DHELTEC_WSL -DELEGANTOTA_USE_ASYNC_WEBSERVER=1
34 changes: 27 additions & 7 deletions src/LoRa_APRS_iGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
#include "gps_utils.h"
#include "bme_utils.h"
#include "web_utils.h"
#include "tnc_utils.h"
#include "display.h"
#include "utils.h"
#include <ElegantOTA.h>

#include "battery_utils.h"

Configuration Config;
WiFiClient espClient;
Expand All @@ -41,6 +42,8 @@ bool WiFiConnected = false;
bool WiFiAutoAPStarted = false;
long WiFiAutoAPTime = false;

uint32_t lastBatteryCheck = 0;

uint32_t bmeLastReading = -60000;

String batteryVoltage;
Expand All @@ -55,7 +58,7 @@ String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seven
void setup() {
Serial.begin(115200);

#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2)
#if defined(TTGO_T_LORA32_V2_1) || defined(HELTEC_V2) || defined(HELTEC_WSL)
pinMode(batteryPin, INPUT);
#endif
#ifdef HAS_INTERNAL_LED
Expand All @@ -82,6 +85,7 @@ void setup() {
SYSLOG_Utils::setup();
BME_Utils::setup();
WEB_Utils::setup();
TNC_Utils::setup();
}

void loop() {
Expand All @@ -92,6 +96,10 @@ void loop() {
return; // Don't process IGate and Digi during OTA update
}

if (BATTERY_Utils::checkIfShouldSleep()) {
ESP.deepSleep(1800000000); // 30 min sleep (60s = 60e6)
}

thirdLine = Utils::getLocalIP();

WIFI_Utils::checkWiFi(); // Always use WiFi, not related to IGate/Digi mode
Expand All @@ -101,6 +109,8 @@ void loop() {
APRS_IS_Utils::connect();
}

TNC_Utils::loop();

Utils::checkDisplayInterval();
Utils::checkBeaconInterval();

Expand All @@ -112,12 +122,22 @@ void loop() {

APRS_IS_Utils::checkStatus(); // Need that to update display, maybe split this and send APRSIS status to display func?

if (Config.aprs_is.active) { // If APRSIS enabled
APRS_IS_Utils::loop(packet); // Send received packet to APRSIS
}
if (packet != "") {
if (Config.aprs_is.active) { // If APRSIS enabled
APRS_IS_Utils::loop(packet); // Send received packet to APRSIS
}

if (Config.digi.mode == 2) { // If Digi enabled
DIGI_Utils::loop(packet); // Send received packet to Digi
}

if (Config.tnc.enableServer) { // If TNC server enabled
TNC_Utils::sendToClients(packet); // Send received packet to TNC KISS
}

if (Config.digi.mode == 2) { // If Digi enabled
DIGI_Utils::loop(packet); // Send received packet to Digi
if (Config.tnc.enableSerial) { // If Serial KISS enabled
TNC_Utils::sendToSerial(packet); // Send received packet to Serial KISS
}
}

show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
Expand Down
Loading

0 comments on commit 0d11627

Please sign in to comment.