Skip to content

Commit

Permalink
passcode verified
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed Dec 6, 2024
1 parent 9801545 commit 62107a5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
3 changes: 3 additions & 0 deletions include/aprs_is_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace APRS_IS_Utils {

void upload(const String& line);
void connect();

void checkStatus();
String checkForStartingBytes(const String& packet);

Expand All @@ -19,6 +20,8 @@ namespace APRS_IS_Utils {
void processAPRSISPacket(const String& packet);
void listenAPRSIS();

void firstConnection();

}

#endif
12 changes: 6 additions & 6 deletions src/LoRa_APRS_iGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ___________________________________________________________________*/
#include "A7670_utils.h"
#endif

String versionDate = "2024.12.04";
String versionDate = "2024.12.06";
Configuration Config;
WiFiClient espClient;
#ifdef HAS_GPS
Expand Down Expand Up @@ -136,6 +136,7 @@ void setup() {
A7670_Utils::setup();
#endif
Utils::checkRebootMode();
APRS_IS_Utils::firstConnection();
}

void loop() {
Expand All @@ -149,14 +150,13 @@ void loop() {
if (Config.lowVoltageCutOff > 0) {
BATTERY_Utils::checkIfShouldSleep();
}

thirdLine = Utils::getLocalIP();

WIFI_Utils::checkWiFi();

#ifdef HAS_A7670
if (Config.aprs_is.active && !modemLoggedToAPRSIS) A7670_Utils::APRS_IS_connect();
#else
WIFI_Utils::checkWiFi();
if (Config.aprs_is.active && (WiFi.status() == WL_CONNECTED) && !espClient.connected()) APRS_IS_Utils::connect();
#endif

Expand Down Expand Up @@ -191,10 +191,10 @@ void loop() {
}
}

if (Config.aprs_is.active) { // If APRSIS enabled
if (Config.aprs_is.active) {
APRS_IS_Utils::listenAPRSIS(); // listen received packet from APRSIS
}

STATION_Utils::processOutputPacketBuffer();

displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
Expand Down
32 changes: 24 additions & 8 deletions src/aprs_is_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ extern String seventhLine;
extern bool modemLoggedToAPRSIS;
extern bool backUpDigiMode;

uint32_t lastRxTime = millis();
uint32_t lastRxTime = millis();
bool passcodeValid = false;

#ifdef HAS_A7670
extern bool stationBeacon;
Expand Down Expand Up @@ -50,19 +51,16 @@ namespace APRS_IS_Utils {
}
if (count == 20) {
Serial.println("Tried: " + String(count) + " FAILED!");
}
else {
} else {
Serial.println("Connected!\n(Server: " + String(Config.aprs_is.server) + " / Port: " + String(Config.aprs_is.port) + ")");
// String filter = "t/m/" + Config.callsign + "/" + (String)Config.aprs_is.reportingDistance;

String aprsAuth = "user ";
aprsAuth += Config.callsign;
aprsAuth += " pass ";
aprsAuth += Config.aprs_is.passcode;
aprsAuth += " vers CA2RXU_LoRa_iGate 2.0 filter ";
aprsAuth += Config.aprs_is.filter;
upload(aprsAuth);
delay(200);
}
}

Expand Down Expand Up @@ -174,7 +172,7 @@ namespace APRS_IS_Utils {
}

void processLoRaPacket(const String& packet) {
if (espClient.connected() || modemLoggedToAPRSIS) {
if (passcodeValid && (espClient.connected() || modemLoggedToAPRSIS)) {
if (packet != "") {
if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("RFONLY") == -1)) {
int firstColonIndex = packet.indexOf(":");
Expand Down Expand Up @@ -259,13 +257,22 @@ namespace APRS_IS_Utils {
}

void processAPRSISPacket(const String& packet) {
if (!packet.startsWith("#")) {
if (!passcodeValid && packet.indexOf(Config.callsign) != -1) {
if (packet.indexOf("unverified") != -1 ) {
Serial.println("\n****APRS PASSCODE NOT VALID****\n");
displayShow(firstLine, "", " APRS PASSCODE", " NOT VALID !!!", "", "", "", 0);
while (1) {};
} else if (packet.indexOf("verified") != -1 ) {
passcodeValid = true;
}
}
if (passcodeValid && !packet.startsWith("#")) {
if (Config.aprs_is.messagesToRF && packet.indexOf("::") > 0) {
String Sender = packet.substring(0, packet.indexOf(">"));
const String& AddresseeAndMessage = packet.substring(packet.indexOf("::") + 2);
String Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":"));
Addressee.trim();
if (Addressee == Config.callsign) { // its for me!
if (Addressee == Config.callsign) { // its for me!
String receivedMessage;
if (AddresseeAndMessage.indexOf("{") > 0) { // ack?
String ackMessage = "ack";
Expand Down Expand Up @@ -350,4 +357,13 @@ namespace APRS_IS_Utils {
#endif
}

void firstConnection() {
if (Config.aprs_is.active && (WiFi.status() == WL_CONNECTED) && !espClient.connected()) {
connect();
while (!passcodeValid) {
listenAPRSIS();
}
}
}

}
5 changes: 3 additions & 2 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ extern int wxModuleType;
extern bool backUpDigiMode;
extern bool shouldSleepLowVoltage;
extern bool transmitFlag;
extern bool passcodeValid;

extern std::vector<LastHeardStation> lastHeardStations;

bool statusAfterBoot = true;
bool sendStartTelemetry = true;
bool beaconUpdate = true;
bool beaconUpdate = false;
uint32_t lastBeaconTx = 0;
uint32_t lastScreenOn = millis();
String beaconPacket;
Expand Down Expand Up @@ -185,7 +186,7 @@ namespace Utils {

void checkBeaconInterval() {
uint32_t lastTx = millis() - lastBeaconTx;
if (lastBeaconTx == 0 || lastTx >= Config.beacon.interval * 60 * 1000) {
if (passcodeValid && (lastBeaconTx == 0 || lastTx >= Config.beacon.interval * 60 * 1000)) {
beaconUpdate = true;
}

Expand Down

0 comments on commit 62107a5

Please sign in to comment.