Skip to content

Commit

Permalink
Prime3 and Badge: a choice to use FlarmNet CDB file by an appropriate…
Browse files Browse the repository at this point in the history
… JSON setting
  • Loading branch information
lyusupov committed Oct 25, 2023
1 parent feaa6e6 commit d6be6eb
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 16 deletions.
38 changes: 31 additions & 7 deletions software/firmware/source/SoftRF/src/platform/ESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ ui_settings_t ui_settings = {
.protocol = PROTOCOL_NMEA,
.rotate = ROTATE_90,
.orientation = DIRECTION_TRACK_UP,
.adb = DB_NONE,
.adb = DB_OGN,
.idpref = ID_TYPE,
.vmode = VIEW_MODE_STATUS,
.voice = VOICE_OFF,
Expand Down Expand Up @@ -2674,6 +2674,18 @@ static void ESP32_EEPROM_extension(int cmd)
}
}

JsonVariant adb = root["adb"];
if (adb.success()) {
const char * adb_s = adb.as<char*>();
if (!strcmp(adb_s,"NONE")) {
ui_settings.adb = DB_NONE;
} else if (!strcmp(adb_s,"FLN")) {
ui_settings.adb = DB_FLN;
} else if (!strcmp(adb_s,"OGN")) {
ui_settings.adb = DB_OGN;
}
}

JsonVariant idpref = root["idpref"];
if (idpref.success()) {
const char * idpref_s = idpref.as<char*>();
Expand Down Expand Up @@ -4421,13 +4433,25 @@ IODev_ops_t ESP32SX_USBSerial_ops = {
static bool ESP32_ADB_setup()
{
if (FATFS_is_mounted) {
const char fileName[] = "/Aircrafts/ogn.cdb";
const char *fileName;

if (ucdb.open(fileName) != CDB_OK) {
Serial.print("Invalid CDB: ");
Serial.println(fileName);
} else {
ADB_is_open = true;
if (ui->adb == DB_OGN) {
fileName = "/Aircrafts/ogn.cdb";
if (ucdb.open(fileName) != CDB_OK) {
Serial.print("Invalid OGN CDB: ");
Serial.println(fileName);
} else {
ADB_is_open = true;
}
}
if (ui->adb == DB_FLN) {
fileName = "/Aircrafts/fln.cdb";
if (ucdb.open(fileName) != CDB_OK) {
Serial.print("Invalid FLN CDB: ");
Serial.println(fileName);
} else {
ADB_is_open = true;
}
}
}

Expand Down
42 changes: 33 additions & 9 deletions software/firmware/source/SoftRF/src/platform/nRF52.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ ui_settings_t ui_settings = {
.protocol = PROTOCOL_NMEA,
.rotate = ROTATE_0,
.orientation = DIRECTION_TRACK_UP,
.adb = DB_NONE,
.adb = DB_OGN,
.idpref = ID_TYPE,
.vmode = VIEW_MODE_STATUS,
.voice = VOICE_OFF,
Expand Down Expand Up @@ -1173,7 +1173,7 @@ static void nRF52_EEPROM_extension(int cmd)
strcpy(ui->key, "");
ui->rotate = ROTATE_0;
ui->orientation = DIRECTION_TRACK_UP;
ui->adb = DB_NONE;
ui->adb = DB_OGN;
ui->idpref = ID_TYPE;
ui->vmode = VIEW_MODE_STATUS;
ui->voice = VOICE_OFF;
Expand Down Expand Up @@ -1206,6 +1206,18 @@ static void nRF52_EEPROM_extension(int cmd)
parseSettings (root);
parseUISettings(root);

JsonVariant adb = root["adb"];
if (adb.success()) {
const char * adb_s = adb.as<char*>();
if (!strcmp(adb_s,"NONE")) {
ui_settings.adb = DB_NONE;
} else if (!strcmp(adb_s,"FLN")) {
ui_settings.adb = DB_FLN;
} else if (!strcmp(adb_s,"OGN")) {
ui_settings.adb = DB_OGN;
}
}

#if defined(ENABLE_PROL)
JsonVariant fromcall = root["fromcall"];
if (fromcall.success()) {
Expand Down Expand Up @@ -1875,13 +1887,25 @@ IODev_ops_t nRF52_USBSerial_ops = {
static bool nRF52_ADB_setup()
{
if (FATFS_is_mounted) {
const char fileName[] = "/Aircrafts/ogn.cdb";

if (ucdb.open(fileName) != CDB_OK) {
Serial.print("Invalid CDB: ");
Serial.println(fileName);
} else {
ADB_is_open = true;
const char *fileName;

if (ui->adb == DB_OGN) {
fileName = "/Aircrafts/ogn.cdb";
if (ucdb.open(fileName) != CDB_OK) {
Serial.print("Invalid OGN CDB: ");
Serial.println(fileName);
} else {
ADB_is_open = true;
}
}
if (ui->adb == DB_FLN) {
fileName = "/Aircrafts/fln.cdb";
if (ucdb.open(fileName) != CDB_OK) {
Serial.print("Invalid FLN CDB: ");
Serial.println(fileName);
} else {
ADB_is_open = true;
}
}
}

Expand Down

0 comments on commit d6be6eb

Please sign in to comment.