testing Loading right

This commit is contained in:
richonguzman 2024-02-28 09:48:31 -03:00
parent db9786fb60
commit 0d28a12458
6 changed files with 127 additions and 94 deletions

View File

@ -99,13 +99,29 @@
"stationBeep": false,
"lowBatteryBeep": false
},
"lora": {
"frequency": 433775000,
"spreadingFactor": 12,
"signalBandwidth": 125000,
"codingRate4": 5,
"power": 20
},
"lora": [
{
"frequency": 433775000,
"spreadingFactor": 12,
"signalBandwidth": 125000,
"codingRate4": 5,
"power": 20
},
{
"frequency": 434855000,
"spreadingFactor": 9,
"signalBandwidth": 125000,
"codingRate4": 7,
"power": 20
},
{
"frequency": 439912500,
"spreadingFactor": 12,
"signalBandwidth": 125000,
"codingRate4": 5,
"power": 20
}
],
"pttTrigger": {
"active": false,
"io_pin": 4,

View File

@ -39,95 +39,98 @@ ________________________________________________________________________________
#include "SPIFFS.h"
#include "utils.h"
Configuration Config;
HardwareSerial neo6m_gps(1);
TinyGPSPlus gps;
Configuration Config;
HardwareSerial neo6m_gps(1);
TinyGPSPlus gps;
#if !defined(TTGO_T_Beam_S3_SUPREME_V3) && !defined(HELTEC_V3_GPS)
BluetoothSerial SerialBT;
BluetoothSerial SerialBT;
#endif
#ifdef HAS_BUTTON
OneButton userButton = OneButton(BUTTON_PIN, true, true);
OneButton userButton = OneButton(BUTTON_PIN, true, true);
#endif
String versionDate = "2024.02.24";
String versionDate = "2024.02.24";
int myBeaconsIndex = 0;
int myBeaconsSize = Config.beacons.size();
Beacon *currentBeacon = &Config.beacons[myBeaconsIndex];
int myBeaconsIndex = 0;
int myBeaconsSize = Config.beacons.size();
Beacon *currentBeacon = &Config.beacons[myBeaconsIndex];
int loraIndex = 0;
int loraIndexSize = Config.loraTypes.size();
LoraType *currentLoRaType = &Config.loraTypes[loraIndex];
int menuDisplay = 100;
int menuDisplay = 100;
int messagesIterator = 0;
std::vector<String> loadedAPRSMessages;
std::vector<String> loadedWLNKMails;
std::deque<String> outputBufferPackets;
int messagesIterator = 0;
std::vector<String> loadedAPRSMessages;
std::vector<String> loadedWLNKMails;
std::deque<String> outputBufferPackets;
bool displayEcoMode = Config.display.ecoMode;
bool displayState = true;
uint32_t displayTime = millis();
uint32_t refreshDisplayTime = millis();
bool displayEcoMode = Config.display.ecoMode;
bool displayState = true;
uint32_t displayTime = millis();
uint32_t refreshDisplayTime = millis();
bool sendUpdate = true;
int updateCounter = Config.sendCommentAfterXBeacons;
bool sendStandingUpdate = false;
bool statusState = true;
uint32_t statusTime = millis();
bool bluetoothConnected = false;
bool bluetoothActive = Config.bluetoothActive;
bool sendBleToLoRa = false;
String BLEToLoRaPacket = "";
bool sendUpdate = true;
int updateCounter = Config.sendCommentAfterXBeacons;
bool sendStandingUpdate = false;
bool statusState = true;
uint32_t statusTime = millis();
bool bluetoothConnected = false;
bool bluetoothActive = Config.bluetoothActive;
bool sendBleToLoRa = false;
String BLEToLoRaPacket = "";
bool messageLed = false;
uint32_t messageLedTime = millis();
int lowBatteryPercent = 21;
bool messageLed = false;
uint32_t messageLedTime = millis();
int lowBatteryPercent = 21;
uint32_t lastTelemetryTx = millis();
uint32_t telemetryTx = millis();
uint32_t lastTelemetryTx = millis();
uint32_t telemetryTx = millis();
uint32_t lastTx = 0.0;
uint32_t txInterval = 60000L;
uint32_t lastTxTime = millis();
double lastTxLat = 0.0;
double lastTxLng = 0.0;
double lastTxDistance = 0.0;
double currentHeading = 0;
double previousHeading = 0;
uint32_t lastTx = 0.0;
uint32_t txInterval = 60000L;
uint32_t lastTxTime = millis();
double lastTxLat = 0.0;
double lastTxLng = 0.0;
double lastTxDistance = 0.0;
double currentHeading = 0;
double previousHeading = 0;
uint32_t menuTime = millis();
bool symbolAvailable = true;
uint32_t menuTime = millis();
bool symbolAvailable = true;
uint32_t bmeLastReading = -60000;
uint32_t bmeLastReading = -60000;
int screenBrightness = 1;
bool keyboardConnected = false;
bool keyDetected = false;
uint32_t keyboardTime = millis();
String messageCallsign = "";
String messageText = "";
int screenBrightness = 1;
bool keyboardConnected = false;
bool keyDetected = false;
uint32_t keyboardTime = millis();
String messageCallsign = "";
String messageText = "";
bool flashlight = false;
bool digirepeaterActive = false;
bool sosActive = false;
bool disableGPS;
bool flashlight = false;
bool digirepeaterActive = false;
bool sosActive = false;
bool disableGPS;
bool miceActive = false;
bool miceActive = false;
bool smartBeaconValue = true;
bool smartBeaconValue = true;
int ackNumberSend;
uint32_t ackTime = millis();
int ackNumberSend;
uint32_t ackTime = millis();
int winlinkStatus = 0;
String winlinkMailNumber = "_?";
String winlinkAddressee = "";
String winlinkSubject = "";
String winlinkBody = "";
String winlinkAlias = "";
String winlinkAliasComplete = "";
int winlinkStatus = 0;
String winlinkMailNumber = "_?";
String winlinkAddressee = "";
String winlinkSubject = "";
String winlinkBody = "";
String winlinkAlias = "";
String winlinkAliasComplete = "";
APRSPacket lastReceivedPacket;
APRSPacket lastReceivedPacket;
logging::Logger logger;
logging::Logger logger;
void setup() {
Serial.begin(115200);
@ -165,6 +168,7 @@ void setup() {
MSG_Utils::loadNumMessages();
GPS_Utils::setup();
currentLoRaType = &Config.loraTypes[loraIndex];
LoRa_Utils::setup();
BME_Utils::setup();
STATION_Utils::loadCallsignIndex();

View File

@ -71,11 +71,17 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) {
notification.stationBeep = data["notification"]["stationBeep"].as<bool>();
notification.lowBatteryBeep = data["notification"]["lowBatteryBeep"].as<bool>();
loramodule.frequency = data["lora"]["frequency"].as<long>();
loramodule.spreadingFactor = data["lora"]["spreadingFactor"].as<int>();
loramodule.signalBandwidth = data["lora"]["signalBandwidth"].as<long>();
loramodule.codingRate4 = data["lora"]["codingRate4"].as<int>();
loramodule.power = data["lora"]["power"].as<int>();
JsonArray LoraTypesArray = data["lora"];
for (int j = 0; j < LoraTypesArray.size(); j++) {
LoraType loraType;
loraType.frequency = LoraTypesArray[j]["frequency"].as<long>();
loraType.spreadingFactor = LoraTypesArray[j]["spreadingFactor"].as<int>();
loraType.signalBandwidth = LoraTypesArray[j]["signalBandwidth"].as<long>();
loraType.codingRate4 = LoraTypesArray[j]["codingRate4"].as<int>();
loraType.power = LoraTypesArray[j]["power"].as<int>();
loraTypes.push_back(loraType);
}
ptt.active = data["pttTrigger"]["active"].as<bool>();
ptt.io_pin = data["pttTrigger"]["io_pin"].as<int>();

View File

@ -61,7 +61,7 @@ public:
bool lowBatteryBeep;
};
class LoraModule {
class LoraType {
public:
long frequency;
int spreadingFactor;
@ -82,13 +82,13 @@ public:
class Configuration {
public:
std::vector<Beacon> beacons;
Display display;
Winlink winlink;
BME bme;
Notification notification;
LoraModule loramodule;
Ptt ptt;
std::vector<Beacon> beacons;
Display display;
Winlink winlink;
BME bme;
Notification notification;
std::vector<LoraType> loraTypes;
Ptt ptt;
bool simplifiedTrackerMode;
int sendCommentAfterXBeacons;

View File

@ -20,8 +20,8 @@ extern logging::Logger logger;
extern bool sendUpdate;
extern int menuDisplay;
extern uint32_t menuTime;
extern int myBeaconsSize;
extern int myBeaconsIndex;
extern int myBeaconsSize;
extern bool keyboardConnected;
extern bool keyDetected;
extern uint32_t keyboardTime;

View File

@ -8,8 +8,10 @@
#include "msg_utils.h"
#include "display.h"
extern logging::Logger logger;
extern Configuration Config;
extern logging::Logger logger;
extern Configuration Config;
extern LoraType *currentLoRaType;
#if defined(TTGO_T_Beam_V1_0_SX1268) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(OE5HWN_MeshCom)
SX1268 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUSY_PIN);
@ -68,7 +70,8 @@ namespace LoRa_Utils {
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS);
LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ);
long freq = Config.loramodule.frequency;
//long freq = Config.loramodule.frequency;
long freq = currentLoRaType->frequency;
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "Frequency: %d", freq);
if (!LoRa.begin(freq)) {
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "LoRa", "Starting LoRa failed!");
@ -77,11 +80,15 @@ namespace LoRa_Utils {
delay(1000);
}
}
LoRa.setSpreadingFactor(Config.loramodule.spreadingFactor);
LoRa.setSignalBandwidth(Config.loramodule.signalBandwidth);
LoRa.setCodingRate4(Config.loramodule.codingRate4);
//LoRa.setSpreadingFactor(Config.loramodule.spreadingFactor);
LoRa.setSpreadingFactor(currentLoRaType->spreadingFactor);
//LoRa.setSignalBandwidth(Config.loramodule.signalBandwidth);
LoRa.setSignalBandwidth(currentLoRaType->signalBandwidth);
//LoRa.setCodingRate4(Config.loramodule.codingRate4);
LoRa.setCodingRate4(currentLoRaType->codingRate4);
LoRa.enableCrc();
LoRa.setTxPower(Config.loramodule.power);
//LoRa.setTxPower(Config.loramodule.power);
LoRa.setTxPower(currentLoRaType->power);
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "LoRa", "LoRa init done!");
#endif
}