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); OneButton userButton = OneButton(BUTTON_PIN, true, true);
#endif #endif
String versionDate = "2024.01.26"; String versionDate = "2024.01.30";
int myBeaconsIndex = 0; int myBeaconsIndex = 0;
int myBeaconsSize = Config.beacons.size(); int myBeaconsSize = Config.beacons.size();

View File

@ -1,6 +1,7 @@
#include <logger.h> #include <logger.h>
#include <Wire.h> #include <Wire.h>
#include "keyboard_utils.h" #include "keyboard_utils.h"
#include "winlink_utils.h"
#include "station_utils.h" #include "station_utils.h"
#include "configuration.h" #include "configuration.h"
#include "button_utils.h" #include "button_utils.h"
@ -72,7 +73,12 @@ namespace KEYBOARD_Utils {
if (menuDisplay < 30) { if (menuDisplay < 30) {
menuDisplay = 31; 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--; menuDisplay--;
if (menuDisplay < 60) { if (menuDisplay < 60) {
menuDisplay = 62; menuDisplay = 62;
@ -150,6 +156,13 @@ namespace KEYBOARD_Utils {
menuDisplay = 4; menuDisplay = 4;
} }
else if (menuDisplay >= 50 && menuDisplay <= 52) {
menuDisplay++;
if (menuDisplay > 52) {
menuDisplay = 50;
}
}
else if (menuDisplay >= 60 && menuDisplay <= 62) { else if (menuDisplay >= 60 && menuDisplay <= 62) {
menuDisplay++; menuDisplay++;
if (menuDisplay > 62) { if (menuDisplay > 62) {
@ -170,7 +183,7 @@ namespace KEYBOARD_Utils {
} else if (menuDisplay==1300 || menuDisplay==1310) { } else if (menuDisplay==1300 || menuDisplay==1310) {
messageText = ""; messageText = "";
menuDisplay = menuDisplay/10; 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); menuDisplay = int(menuDisplay/10);
} }
/* winlinkMailNumber = "";*/ /* winlinkMailNumber = "";*/
@ -254,10 +267,21 @@ namespace KEYBOARD_Utils {
MSG_Utils::sendMessage(0, "CA2RXU-15", "wrl"); MSG_Utils::sendMessage(0, "CA2RXU-15", "wrl");
} }
else if (menuDisplay == 5) { else if (menuDisplay == 5) {
show_display("_WINLINK_", "still on", "development..", 2000); ///////////////////////// menuDisplay = 50;
Serial.println(Config.winlink.password); } 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) { else if (menuDisplay == 6) {
menuDisplay = 60; menuDisplay = 60;
} else if (menuDisplay == 60) { } else if (menuDisplay == 60) {

View File

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

View File

@ -3,6 +3,7 @@
#include "APRSPacketLib.h" #include "APRSPacketLib.h"
#include "notification_utils.h" #include "notification_utils.h"
#include "bluetooth_utils.h" #include "bluetooth_utils.h"
#include "winlink_utils.h"
#include "configuration.h" #include "configuration.h"
#include "lora_utils.h" #include "lora_utils.h"
#include "ble_utils.h" #include "ble_utils.h"
@ -25,9 +26,12 @@ extern uint32_t messageLedTime;
extern bool digirepeaterActive; extern bool digirepeaterActive;
extern int ackNumberSend; extern int ackNumberSend;
extern int winlinkStatus;
extern APRSPacket lastReceivedPacket; extern APRSPacket lastReceivedPacket;
String lastMessageAPRS = ""; String lastMessageAPRS = "";
int numAPRSMessages = 0; int numAPRSMessages = 0;
bool noMessageWarning = false; bool noMessageWarning = false;
@ -228,12 +232,40 @@ namespace MSG_Utils {
show_display("<WEATHER>", "From --> " + lastReceivedPacket.sender, place, summary, fifthLineWR, sixthLineWR); show_display("<WEATHER>", "From --> " + lastReceivedPacket.sender, place, summary, fifthLineWR, sixthLineWR);
menuDisplay = 40; menuDisplay = 40;
menuTime = millis(); 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 { } else {
show_display("< MSG Rx >", "From --> " + lastReceivedPacket.sender, "", lastReceivedPacket.message , 3000); show_display("< MSG Rx >", "From --> " + lastReceivedPacket.sender, "", lastReceivedPacket.message , 3000);
if (!Config.simplifiedTrackerMode) { if (!Config.simplifiedTrackerMode) {
saveNewMessage("APRS", lastReceivedPacket.sender, lastReceivedPacket.message); saveNewMessage("APRS", lastReceivedPacket.sender, lastReceivedPacket.message);
} }
} }
} else { } else {
if ((lastReceivedPacket.type==0 || lastReceivedPacket.type==4) && !Config.simplifiedTrackerMode) { if ((lastReceivedPacket.type==0 || lastReceivedPacket.type==4) && !Config.simplifiedTrackerMode) {
GPS_Utils::calculateDistanceCourse(lastReceivedPacket.sender, lastReceivedPacket.latitude, lastReceivedPacket.longitude); GPS_Utils::calculateDistanceCourse(lastReceivedPacket.sender, lastReceivedPacket.latitude, lastReceivedPacket.longitude);

View File

@ -1,12 +1,15 @@
#include "winlink_utils.h" #include "winlink_utils.h"
#include "configuration.h" #include "configuration.h"
#include "msg_utils.h"
#include "display.h"
extern Configuration Config; extern Configuration Config;
extern int winlinkStatus extern int winlinkStatus;
extern int menuDisplay;
namespace WINLINK_Utils { namespace WINLINK_Utils {
String processWinlinkChallenge(String winlinkInteger) { void processWinlinkChallenge(String winlinkInteger) {
String challengeAnswer; String challengeAnswer;
for (int i=0; i<winlinkInteger.length(); i++) { for (int i=0; i<winlinkInteger.length(); i++) {
String number = String(winlinkInteger[i]); String number = String(winlinkInteger[i]);
@ -14,51 +17,21 @@ namespace WINLINK_Utils {
challengeAnswer += Config.winlink.password[digit-1]; challengeAnswer += Config.winlink.password[digit-1];
} }
challengeAnswer += "AZ6"; challengeAnswer += "AZ6";
delay(8000); ///
Serial.println("el challenge creado es " + challengeAnswer); Serial.println("el challenge creado es " + challengeAnswer);
return challengeAnswer; MSG_Utils::sendMessage(1, "WLNK-1", challengeAnswer);
} }
void login() { void login() {
Serial.println("Starting Winlink Login"); Serial.println("Starting Winlink Login"); // por borrar
show_display("__WINLINK_", "" , "Login Initiation ...", "", "" , "<Back");
if (winlinkStatus == 5) { if (winlinkStatus == 5) {
//menuDisplay = 800; //menuDisplay = 800;
} else { } else {
winlinkStatus = 1; winlinkStatus = 1;
sendMessage(1, "WLNK-1", "L"); MSG_Utils::sendMessage(1, "WLNK-1", "L");
menuDisplay = 50; 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 // procesar challenge
// enviar challenge con ack // enviar challenge con ack
// recibir ack // recibir ack

View File

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