saving callsing to memory

This commit is contained in:
richonguzman 2023-09-11 11:24:37 -03:00
parent f06aca6397
commit a01137b55a
3 changed files with 34 additions and 0 deletions

View File

@ -1,5 +1,6 @@
#include <logger.h>
#include "configuration.h"
#include "station_utils.h"
#include "button_utils.h"
#include "msg_utils.h"
#include "display.h"
@ -74,6 +75,7 @@ namespace BUTTON_Utils {
display_toggle(true);
displayTime = millis();
show_display("__INFO____", "", "CHANGING CALLSIGN ...", 1000);
STATION_Utils::saveCallsingIndex(myBeaconsIndex);
} else if (menuDisplay == 1) {
MSG_Utils::deleteFile();
show_display("__INFO____", "", "ALL MESSAGES DELETED!", 2000);

View File

@ -1,4 +1,5 @@
#include <TinyGPS++.h>
#include <SPIFFS.h>
#include <vector>
#include "station_utils.h"
#include "configuration.h"
@ -426,4 +427,34 @@ namespace STATION_Utils {
}
}
void saveCallsingIndex(int index) {
if(!SPIFFS.begin(true)) {
Serial.println("An Error has occurred while mounting SPIFFS");
return;
}
/*if (SPIFFS.exists("/file.txt")) {
Serial.println("File exists in SPIFFS");
} else {
Serial.println("File does not exist in SPIFFS");
}*/
File fileCallsignIndex = SPIFFS.open("/callsignIndex.txt", "w");
if(!fileCallsignIndex){
Serial.println("no existe archivo, se escribe");
Serial.println("Failed to open APRS_Msg for reading");
//return;
} else {
Serial.println("ya existe archivo pero se SOBRE escribe");
}
String dataToSave = String(index);
if (fileCallsignIndex.println(dataToSave)) {
Serial.println("Callsign Index saved to SPIFFS");
} else {
Serial.println("Error saving data to file");
}
fileCallsignIndex.close();
}
}

View File

@ -17,6 +17,7 @@ void checkSmartBeaconInterval(int speed);
void checkStandingUpdateTime();
void checkSmartBeaconState();
void sendBeacon();
void saveCallsingIndex(int index);
}