waiting for procesing packet

This commit is contained in:
richonguzman 2024-01-30 11:53:36 -03:00
parent 677ff333d8
commit 295e91d335
6 changed files with 107 additions and 65 deletions

View File

@ -34,7 +34,7 @@ BluetoothSerial SerialBT;
OneButton userButton = OneButton(BUTTON_PIN, true, true);
#endif
String versionDate = "2024.01.26";
String versionDate = "2024.01.30";
int myBeaconsIndex = 0;
int myBeaconsSize = Config.beacons.size();

View File

@ -1,6 +1,7 @@
#include <logger.h>
#include <Wire.h>
#include "keyboard_utils.h"
#include "winlink_utils.h"
#include "station_utils.h"
#include "configuration.h"
#include "button_utils.h"
@ -72,7 +73,12 @@ namespace KEYBOARD_Utils {
if (menuDisplay < 30) {
menuDisplay = 31;
}
}else if (menuDisplay >= 60 && menuDisplay <= 62) {
} else if (menuDisplay >= 50 && menuDisplay <= 52) {
menuDisplay--;
if (menuDisplay < 50) {
menuDisplay = 52;
}
} else if (menuDisplay >= 60 && menuDisplay <= 62) {
menuDisplay--;
if (menuDisplay < 60) {
menuDisplay = 62;
@ -150,6 +156,13 @@ namespace KEYBOARD_Utils {
menuDisplay = 4;
}
else if (menuDisplay >= 50 && menuDisplay <= 52) {
menuDisplay++;
if (menuDisplay > 52) {
menuDisplay = 50;
}
}
else if (menuDisplay >= 60 && menuDisplay <= 62) {
menuDisplay++;
if (menuDisplay > 62) {
@ -170,7 +183,7 @@ namespace KEYBOARD_Utils {
} else if (menuDisplay==1300 || menuDisplay==1310) {
messageText = "";
menuDisplay = menuDisplay/10;
} else if ((menuDisplay>=10 && menuDisplay<=13) || (menuDisplay>=20 && menuDisplay<=29) || (menuDisplay==120) || (menuDisplay>=130 && menuDisplay<=133) || (menuDisplay>=200 && menuDisplay<=290) || (menuDisplay>=60 && menuDisplay<=62) || (menuDisplay>=30 && menuDisplay<=31) || (menuDisplay>=300 && menuDisplay<=310) || (menuDisplay==40)) {
} else if ((menuDisplay>=10 && menuDisplay<=13) || (menuDisplay>=20 && menuDisplay<=29) || (menuDisplay==120) || (menuDisplay>=130 && menuDisplay<=133) || (menuDisplay>=50 && menuDisplay<=52) || (menuDisplay>=200 && menuDisplay<=290) || (menuDisplay>=60 && menuDisplay<=62) || (menuDisplay>=30 && menuDisplay<=31) || (menuDisplay>=300 && menuDisplay<=310) || (menuDisplay==40)) {
menuDisplay = int(menuDisplay/10);
}
/* winlinkMailNumber = "";*/
@ -254,10 +267,21 @@ namespace KEYBOARD_Utils {
MSG_Utils::sendMessage(0, "CA2RXU-15", "wrl");
}
else if (menuDisplay == 5) {
show_display("_WINLINK_", "still on", "development..", 2000); /////////////////////////
Serial.println(Config.winlink.password);
menuDisplay = 50;
} else if (menuDisplay == 50) {
WINLINK_Utils::login();
menuDisplay = 500;
} else if (menuDisplay == 51) {
show_display("__WINLINK_", "", "READ MSG/MAIL", "", 1000);
} else if (menuDisplay == 52) {
show_display("__WINLINK_", "", "DELETE MSG/MAIL" ,"", 1000);
}
else if (menuDisplay == 6) {
menuDisplay = 60;
} else if (menuDisplay == 60) {

View File

@ -32,6 +32,7 @@ extern bool displayEcoMode;
extern bool screenBrightness;
extern bool disableGPS;
extern APRSPacket lastReceivedPacket;
extern int winlinkStatus;
namespace MENU_Utils {
@ -249,7 +250,7 @@ namespace MENU_Utils {
show_display("STATIONS>", "", " Packet Decoder", "> Near By Stations", "", "<Back");
break;
case 300: //3.Stations ---> Packet Decoder
case 300: //3.Stations ---> Packet Decoder
firstLineDecoder = lastReceivedPacket.sender;
for(int i=firstLineDecoder.length();i<9;i++) {
firstLineDecoder += ' ';
@ -304,33 +305,45 @@ namespace MENU_Utils {
// waiting for Weather Report
break;
case 50: // 5.Winlink
show_display("__WINLINK_", "" , "Login Initiation ...", "", "" , "<Back");
case 50: // 5.Winlink MENU
if (winlinkStatus == 0) {
show_display("__WINLINK_", "> Login" , " Read Saved Mails", " Delete Saved Mails", "" , lastLine);
} else {
menuDisplay = 5000;
}
break;
case 51: // 5.Winlink
show_display("__WINLINK_", " Login" , "> Read Saved Mails", " Delete Saved Mails", "" , lastLine);
break;
case 52: // 5.Winlink
show_display("__WINLINK_", " Login" , " Read Saved Mails", "> Delete Saved Mails", "" , lastLine);
break;
/* si no esta loggeado (50)
50) login --> 51
show_display("__WINLINK_", "" , "Login Initiation ...", "Challenge -> waiting", "" , "<Back");
show_display("__WINLINK_", "" , "Login Initiation ...", "Challenge -> sended", "" , "<Back");
show_display("__WINLINK_", "" , "Login Initiation ...", "Challenge -> ack ...", "" , "<Back");
5?1) Read saved Mails --> 52
5?2) delete saved mails --> 53
*/
case 500: // 5.Winlink ---> Login
show_display("__WINLINK_", "" , "Login Initiation ...", "Challenge -> waiting", "" , "<Back");
break;
case 501: // 5.Winlink ---> Login
show_display("__WINLINK_", "" , "Login Initiation ...", "Challenge -> sended", "" , "<Back");
break;
case 502: // 5.Winlink ---> Login
show_display("__WINLINK_", "" , "Login Initiation ...", "Challenge -> ack ...", "" , "<Back");
break;
/* si esta loggeado (500)
500) write mail
501) list pending mails
502) download mails
/* si esta loggeado (5000)
5010) write mail
5020) list pending mails
5030) download mails
51) read saved mails
503) reply mail
504) forward mail
5040) reply mail
5050) forward mail
52) delete mail (local o en winlink?)
505) alias menu ------->
510) log out
5060) alias menu ------->
5070) log out
*/
// check si no esta logeado o si
//show_display("__WINLINK_", "" , "Login Initiation ...", "", "" , "<Back");
case 60: // 6. Extras ---> Flashlight

View File

@ -3,6 +3,7 @@
#include "APRSPacketLib.h"
#include "notification_utils.h"
#include "bluetooth_utils.h"
#include "winlink_utils.h"
#include "configuration.h"
#include "lora_utils.h"
#include "ble_utils.h"
@ -25,9 +26,12 @@ extern uint32_t messageLedTime;
extern bool digirepeaterActive;
extern int ackNumberSend;
extern int winlinkStatus;
extern APRSPacket lastReceivedPacket;
String lastMessageAPRS = "";
int numAPRSMessages = 0;
bool noMessageWarning = false;
@ -228,12 +232,40 @@ namespace MSG_Utils {
show_display("<WEATHER>", "From --> " + lastReceivedPacket.sender, place, summary, fifthLineWR, sixthLineWR);
menuDisplay = 40;
menuTime = millis();
} else if (lastReceivedPacket.sender == "WLNK-1") {
String winlinkAckAnswer = lastReceivedPacket.message.substring(lastReceivedPacket.message.indexOf("ack")+3);
if (winlinkStatus == 1 && winlinkAckAnswer.toInt() == ackNumberSend) {
winlinkStatus = 2; // recibió ack de nuestro mensaje
Serial.println("waiting for Challenge");
menuDisplay = 500;
} else if (winlinkStatus <= 2 && lastReceivedPacket.message.indexOf("Login [") == 0) {
Serial.println("Challenge received");
String winlinkChallenge = lastReceivedPacket.message.substring(lastReceivedPacket.message.indexOf("[")+1,lastReceivedPacket.message.indexOf("]"));
Serial.println("el challenge es " + winlinkChallenge);
WINLINK_Utils::processWinlinkChallenge(winlinkChallenge);
winlinkStatus = 3;
menuDisplay = 501;
} else if (winlinkStatus == 2 && lastReceivedPacket.message.indexOf("Login [") == -1) {
Serial.println("Estamos conetados a WINLINK!!!!");
show_display("__WINLINK_", "", " LOGGED !!!!", 2000);
winlinkStatus = 5;
//menuDisplay = 800;
} else if (winlinkStatus == 3 && winlinkAckAnswer.toInt() == ackNumberSend) {
winlinkStatus = 4;
Serial.println("llego ack de recepcion challenge");
menuDisplay = 502;
} else if (lastReceivedPacket.message.indexOf("Login valid") > 0) {
winlinkStatus = 5;
Serial.println("Estamos conetados a WINLINK!!!!");
//menuDisplay = 800;
}
// que se hace con los mensajes recibidos desde Winlink cuando ya estamos conectados
} else {
show_display("< MSG Rx >", "From --> " + lastReceivedPacket.sender, "", lastReceivedPacket.message , 3000);
if (!Config.simplifiedTrackerMode) {
saveNewMessage("APRS", lastReceivedPacket.sender, lastReceivedPacket.message);
}
}
}
} else {
if ((lastReceivedPacket.type==0 || lastReceivedPacket.type==4) && !Config.simplifiedTrackerMode) {
GPS_Utils::calculateDistanceCourse(lastReceivedPacket.sender, lastReceivedPacket.latitude, lastReceivedPacket.longitude);

View File

@ -1,12 +1,15 @@
#include "winlink_utils.h"
#include "configuration.h"
#include "msg_utils.h"
#include "display.h"
extern Configuration Config;
extern int winlinkStatus
extern int winlinkStatus;
extern int menuDisplay;
namespace WINLINK_Utils {
String processWinlinkChallenge(String winlinkInteger) {
void processWinlinkChallenge(String winlinkInteger) {
String challengeAnswer;
for (int i=0; i<winlinkInteger.length(); i++) {
String number = String(winlinkInteger[i]);
@ -14,51 +17,21 @@ namespace WINLINK_Utils {
challengeAnswer += Config.winlink.password[digit-1];
}
challengeAnswer += "AZ6";
delay(8000); ///
Serial.println("el challenge creado es " + challengeAnswer);
return challengeAnswer;
MSG_Utils::sendMessage(1, "WLNK-1", challengeAnswer);
}
void login() {
Serial.println("Starting Winlink Login");
Serial.println("Starting Winlink Login"); // por borrar
show_display("__WINLINK_", "" , "Login Initiation ...", "", "" , "<Back");
if (winlinkStatus == 5) {
//menuDisplay = 800;
} else {
winlinkStatus = 1;
sendMessage(1, "WLNK-1", "L");
menuDisplay = 50;
MSG_Utils::sendMessage(1, "WLNK-1", "L");
menuDisplay = 500; // enviar a proceso LOGIN
}
/*
---genero ack number en random
---reviso si llega a 999 y paso a 1
---confirmo envio de Mensaje con ack
---espero confirimacion de ACK desde winlink para continuar a otro paso
menu50 seria:
si no logged:
start login
read msg/mails
delete all msg/mails
si esta logeado pasa a otro menu de :
L
R
Y
B
y mas
*/
// enviar "L" con ack
// recibir ack - esperar challenge
// recibir challenge con ack
// contestar ack
// procesar challenge
// enviar challenge con ack
// recibir ack

View File

@ -5,7 +5,7 @@
namespace WINLINK_Utils {
String processWinlinkChallenge(String winlinkInteger);
void processWinlinkChallenge(String winlinkInteger);
void login();
}