|
|
@@ -2,27 +2,6 @@
|
|
|
#include "navigo_lists.h"
|
|
|
#include "../../../metroflip_i.h"
|
|
|
|
|
|
-const char* get_navigo_transport_type(int type) {
|
|
|
- switch(type) {
|
|
|
- case URBAN_BUS:
|
|
|
- return "Urban Bus";
|
|
|
- case INTERURBAN_BUS:
|
|
|
- return "Interurban Bus";
|
|
|
- case METRO:
|
|
|
- return "Metro";
|
|
|
- case TRAM:
|
|
|
- return "Tram";
|
|
|
- case COMMUTER_TRAIN:
|
|
|
- return "Train";
|
|
|
- case PARKING:
|
|
|
- return "Parking";
|
|
|
- case EXPRESS_COMMUTER_TRAIN:
|
|
|
- return "TER";
|
|
|
- default:
|
|
|
- return "Unknown";
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
const char* get_navigo_service_provider(int provider) {
|
|
|
switch(provider) {
|
|
|
case NAVIGO_PROVIDER_SNCF:
|
|
|
@@ -50,23 +29,6 @@ const char* get_navigo_service_provider(int provider) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const char* get_navigo_type(int type) {
|
|
|
- switch(type) {
|
|
|
- case NAVIGO_EASY:
|
|
|
- return "Navigo Easy";
|
|
|
- case NAVIGO_DECOUVERTE:
|
|
|
- return "Navigo Decouverte";
|
|
|
- case NAVIGO_STANDARD:
|
|
|
- return "Navigo Standard";
|
|
|
- case NAVIGO_INTEGRAL:
|
|
|
- return "Navigo Integral";
|
|
|
- case IMAGINE_R:
|
|
|
- return "Imagine R";
|
|
|
- default:
|
|
|
- return "Navigo";
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
const char* get_navigo_tariff(int tariff) {
|
|
|
switch(tariff) {
|
|
|
case 0x0000:
|
|
|
@@ -123,39 +85,6 @@ const char* get_navigo_tariff(int tariff) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-bool is_ticket_count_available(int tariff) {
|
|
|
- return tariff >= 0x5000 && tariff <= 0x501b;
|
|
|
-}
|
|
|
-
|
|
|
-const char* get_pay_method(int pay_method) {
|
|
|
- switch(pay_method) {
|
|
|
- case 0x30:
|
|
|
- return "Apple Pay/Google Pay";
|
|
|
- case 0x80:
|
|
|
- return "Debit PME";
|
|
|
- case 0x90:
|
|
|
- return "Cash";
|
|
|
- case 0xA0:
|
|
|
- return "Mobility Check";
|
|
|
- case 0xB3:
|
|
|
- return "Payment Card";
|
|
|
- case 0xA4:
|
|
|
- return "Check";
|
|
|
- case 0xA5:
|
|
|
- return "Vacation Check";
|
|
|
- case 0xB7:
|
|
|
- return "Telepayment";
|
|
|
- case 0xD0:
|
|
|
- return "Remote Payment";
|
|
|
- case 0xD7:
|
|
|
- return "Voucher, Prepayment, Exchange Voucher, Travel Voucher";
|
|
|
- case 0xD9:
|
|
|
- return "Discount Voucher";
|
|
|
- default:
|
|
|
- return "Unknown";
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
const char* get_zones(int* zones) {
|
|
|
if(zones[0] && zones[4]) {
|
|
|
return "All Zones (1-5)";
|
|
|
@@ -218,9 +147,9 @@ char* get_navigo_station(
|
|
|
int station_group_id,
|
|
|
int station_id,
|
|
|
int station_sub_id,
|
|
|
- int service_provider) {
|
|
|
- switch(service_provider) {
|
|
|
- case NAVIGO_PROVIDER_SNCF: {
|
|
|
+ int transport_type) {
|
|
|
+ switch(transport_type) {
|
|
|
+ case COMMUTER_TRAIN: {
|
|
|
if(station_group_id < 77 && station_id < 19) {
|
|
|
char* file_path = malloc(256 * sizeof(char));
|
|
|
if(!file_path) {
|
|
|
@@ -229,7 +158,7 @@ char* get_navigo_station(
|
|
|
snprintf(
|
|
|
file_path,
|
|
|
256,
|
|
|
- APP_ASSETS_PATH("navigo/stations/sncf/stations_%d.txt"),
|
|
|
+ APP_ASSETS_PATH("navigo/stations/train/stations_%d.txt"),
|
|
|
station_group_id);
|
|
|
const char* sncf_stations_path = file_path;
|
|
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
|
@@ -262,7 +191,7 @@ char* get_navigo_station(
|
|
|
free(string_line_copy);
|
|
|
}
|
|
|
} else {
|
|
|
- FURI_LOG_E("Metroflip:Scene:Calypso", "Failed to open sncf_stations.txt");
|
|
|
+ FURI_LOG_E("Metroflip:Scene:Calypso", "Failed to open train stations file");
|
|
|
}
|
|
|
|
|
|
furi_string_free(line);
|
|
|
@@ -282,8 +211,73 @@ char* get_navigo_station(
|
|
|
snprintf(station, 10, "%d-%d-%d", station_group_id, station_id, station_sub_id);
|
|
|
return station;
|
|
|
}
|
|
|
- case NAVIGO_PROVIDER_RATP:
|
|
|
- case NAVIGO_PROVIDER_ORA: {
|
|
|
+ case TRAM: {
|
|
|
+ char* file_path = malloc(256 * sizeof(char));
|
|
|
+ if(!file_path) {
|
|
|
+ return "Unknown";
|
|
|
+ }
|
|
|
+ snprintf(
|
|
|
+ file_path,
|
|
|
+ 256,
|
|
|
+ APP_ASSETS_PATH("navigo/stations/tram/stations_%d.txt"),
|
|
|
+ station_group_id);
|
|
|
+ const char* sncf_stations_path = file_path;
|
|
|
+ Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
|
+
|
|
|
+ Stream* stream = file_stream_alloc(storage);
|
|
|
+ FuriString* line = furi_string_alloc();
|
|
|
+
|
|
|
+ char* found_station_name = NULL;
|
|
|
+
|
|
|
+ if(file_stream_open(stream, sncf_stations_path, FSAM_READ, FSOM_OPEN_EXISTING)) {
|
|
|
+ while(stream_read_line(stream, line)) {
|
|
|
+ // file is in csv format: station_id,station_sub_id,station_name
|
|
|
+ // search for the station
|
|
|
+ furi_string_replace_all(line, "\r", "");
|
|
|
+ furi_string_replace_all(line, "\n", "");
|
|
|
+ const char* string_line = furi_string_get_cstr(line);
|
|
|
+ char* string_line_copy = strdup(string_line);
|
|
|
+ if(!string_line_copy) {
|
|
|
+ return "Unknown";
|
|
|
+ }
|
|
|
+ int line_station_id = atoi(get_token(string_line_copy, ",", string_line_copy));
|
|
|
+ int line_station_sub_id = atoi(get_token(string_line_copy, ",", string_line_copy));
|
|
|
+ if(line_station_id == station_id && line_station_sub_id == station_sub_id) {
|
|
|
+ found_station_name =
|
|
|
+ strdup(get_token(string_line_copy, ",", string_line_copy));
|
|
|
+ free(string_line_copy);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ free(string_line_copy);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ FURI_LOG_E("Metroflip:Scene:Calypso", "Failed to open tram stations file");
|
|
|
+ }
|
|
|
+
|
|
|
+ furi_string_free(line);
|
|
|
+ file_stream_close(stream);
|
|
|
+ stream_free(stream);
|
|
|
+ free(file_path);
|
|
|
+
|
|
|
+ if(found_station_name) {
|
|
|
+ return found_station_name;
|
|
|
+ }
|
|
|
+
|
|
|
+ // cast station_group_id-station_id-station_sub_id to a string
|
|
|
+ char* station = malloc(12 * sizeof(char));
|
|
|
+ if(!station) {
|
|
|
+ return "Unknown";
|
|
|
+ }
|
|
|
+ if(station_sub_id != 0) {
|
|
|
+ snprintf(station, 10, "%d-%d-%d", station_group_id, station_id, station_sub_id);
|
|
|
+ } else if(station_id != 0) {
|
|
|
+ snprintf(station, 10, "%d-%d", station_group_id, station_id);
|
|
|
+ } else {
|
|
|
+ snprintf(station, 10, "%d", station_group_id);
|
|
|
+ }
|
|
|
+ return station;
|
|
|
+ }
|
|
|
+ case METRO: {
|
|
|
if(station_group_id < 32 && station_id < 16) {
|
|
|
char* file_path = malloc(256 * sizeof(char));
|
|
|
if(!file_path) {
|
|
|
@@ -292,7 +286,7 @@ char* get_navigo_station(
|
|
|
snprintf(
|
|
|
file_path,
|
|
|
256,
|
|
|
- APP_ASSETS_PATH("navigo/stations/ratp/stations_%d.txt"),
|
|
|
+ APP_ASSETS_PATH("navigo/stations/metro/stations_%d.txt"),
|
|
|
station_group_id);
|
|
|
const char* ratp_stations_path = file_path;
|
|
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
|
|
@@ -323,7 +317,7 @@ char* get_navigo_station(
|
|
|
free(string_line_copy);
|
|
|
}
|
|
|
} else {
|
|
|
- FURI_LOG_E("Metroflip:Scene:Calypso", "Failed to open ratp_stations.txt");
|
|
|
+ FURI_LOG_E("Metroflip:Scene:Calypso", "Failed to open metro stations file");
|
|
|
}
|
|
|
|
|
|
furi_string_free(line);
|
|
|
@@ -340,7 +334,13 @@ char* get_navigo_station(
|
|
|
if(!station) {
|
|
|
return "Unknown";
|
|
|
}
|
|
|
- snprintf(station, 10, "%d-%d", station_group_id, station_id);
|
|
|
+ if(station_sub_id != 0) {
|
|
|
+ snprintf(station, 10, "%d-%d-%d", station_group_id, station_id, station_sub_id);
|
|
|
+ } else if(station_id != 0) {
|
|
|
+ snprintf(station, 10, "%d-%d", station_group_id, station_id);
|
|
|
+ } else {
|
|
|
+ snprintf(station, 10, "%d", station_group_id);
|
|
|
+ }
|
|
|
return station;
|
|
|
}
|
|
|
default: {
|
|
|
@@ -349,22 +349,28 @@ char* get_navigo_station(
|
|
|
if(!station) {
|
|
|
return "Unknown";
|
|
|
}
|
|
|
- snprintf(station, 10, "%d-%d", station_group_id, station_id);
|
|
|
+ if(station_sub_id != 0) {
|
|
|
+ snprintf(station, 10, "%d-%d-%d", station_group_id, station_id, station_sub_id);
|
|
|
+ } else if(station_id != 0) {
|
|
|
+ snprintf(station, 10, "%d-%d", station_group_id, station_id);
|
|
|
+ } else {
|
|
|
+ snprintf(station, 10, "%d", station_group_id);
|
|
|
+ }
|
|
|
return station;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const char* get_navigo_sncf_train_line(int station_group_id) {
|
|
|
- if(station_group_id < 77) {
|
|
|
- return NAVIGO_SNCF_TRAIN_LINES_LIST[station_group_id];
|
|
|
- }
|
|
|
- return "Unknown";
|
|
|
+char* get_navigo_train_sector(int station_group_id) {
|
|
|
+ // group id is in format XY where X is the sector
|
|
|
+ const char* station_name = NAVIGO_SNCF_SECTORS_LIST[station_group_id / 10];
|
|
|
+ return strdup(station_name);
|
|
|
}
|
|
|
|
|
|
const char* get_navigo_tram_line(int route_number) {
|
|
|
switch(route_number) {
|
|
|
case 1:
|
|
|
+ case 13:
|
|
|
return "T3a";
|
|
|
case 9:
|
|
|
return "T9";
|
|
|
@@ -391,9 +397,15 @@ void show_navigo_event_info(
|
|
|
furi_string_cat_printf(parsed_data, "No event data\n");
|
|
|
return;
|
|
|
}
|
|
|
+ int navigo_station_type = event->transport_type;
|
|
|
char* station = get_navigo_station(
|
|
|
- event->station_group_id, event->station_id, event->station_sub_id, event->service_provider);
|
|
|
- char* sector = get_navigo_station(event->station_group_id, 0, 0, event->service_provider);
|
|
|
+ event->station_group_id, event->station_id, event->station_sub_id, navigo_station_type);
|
|
|
+ char* sector = NULL;
|
|
|
+ if(navigo_station_type == COMMUTER_TRAIN || navigo_station_type == TRAM) {
|
|
|
+ sector = get_navigo_train_sector(event->station_group_id);
|
|
|
+ } else {
|
|
|
+ sector = get_navigo_station(event->station_group_id, 0, 0, navigo_station_type);
|
|
|
+ }
|
|
|
|
|
|
if(event->transport_type == URBAN_BUS || event->transport_type == INTERURBAN_BUS ||
|
|
|
event->transport_type == METRO || event->transport_type == TRAM) {
|
|
|
@@ -402,20 +414,20 @@ void show_navigo_event_info(
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"%s 3 bis\n%s\n",
|
|
|
- get_navigo_transport_type(event->transport_type),
|
|
|
+ get_intercode_string_transport_type(event->transport_type),
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
} else if(event->transport_type == TRAM) {
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"%s %s\n%s\n",
|
|
|
- get_navigo_transport_type(event->transport_type),
|
|
|
+ get_intercode_string_transport_type(event->transport_type),
|
|
|
get_navigo_tram_line(event->route_number),
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
} else {
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"%s %d\n%s\n",
|
|
|
- get_navigo_transport_type(event->transport_type),
|
|
|
+ get_intercode_string_transport_type(event->transport_type),
|
|
|
event->route_number,
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
}
|
|
|
@@ -423,7 +435,7 @@ void show_navigo_event_info(
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"%s\n%s\n",
|
|
|
- get_navigo_transport_type(event->transport_type),
|
|
|
+ get_intercode_string_transport_type(event->transport_type),
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
}
|
|
|
furi_string_cat_printf(
|
|
|
@@ -462,21 +474,20 @@ void show_navigo_event_info(
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"RER %c\n%s\n",
|
|
|
- (65 + event->route_number - 17),
|
|
|
+ (65 + event->route_number - 16),
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
} else {
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
- "%s %s\n%s\n",
|
|
|
- get_navigo_transport_type(event->transport_type),
|
|
|
- get_navigo_sncf_train_line(event->station_group_id),
|
|
|
+ "%s\n%s\n",
|
|
|
+ get_intercode_string_transport_type(event->transport_type),
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
}
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"Transporter: %s\n",
|
|
|
get_navigo_service_provider(event->service_provider));
|
|
|
- furi_string_cat_printf(parsed_data, "Station: %s\n", station);
|
|
|
+ furi_string_cat_printf(parsed_data, "Station: %s\nSector: %s\n", station, sector);
|
|
|
if(event->location_gate_available) {
|
|
|
furi_string_cat_printf(parsed_data, "Gate: %d\n", event->location_gate);
|
|
|
}
|
|
|
@@ -506,13 +517,13 @@ void show_navigo_event_info(
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"%s - %s\n",
|
|
|
- get_navigo_transport_type(event->transport_type),
|
|
|
+ get_intercode_string_transport_type(event->transport_type),
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"Transporter: %s\n",
|
|
|
get_navigo_service_provider(event->service_provider));
|
|
|
- furi_string_cat_printf(parsed_data, "Station: %s\n", station);
|
|
|
+ furi_string_cat_printf(parsed_data, "Station: %s\nSector: %s\n", station, sector);
|
|
|
if(event->location_gate_available) {
|
|
|
furi_string_cat_printf(parsed_data, "Gate: %d\n", event->location_gate);
|
|
|
}
|
|
|
@@ -541,9 +552,15 @@ void show_navigo_event_info(
|
|
|
}
|
|
|
|
|
|
void show_navigo_special_event_info(NavigoCardSpecialEvent* event, FuriString* parsed_data) {
|
|
|
+ int navigo_station_type = event->transport_type;
|
|
|
char* station = get_navigo_station(
|
|
|
- event->station_group_id, event->station_id, event->station_sub_id, event->service_provider);
|
|
|
- char* sector = get_navigo_station(event->station_group_id, 0, 0, event->service_provider);
|
|
|
+ event->station_group_id, event->station_id, event->station_sub_id, navigo_station_type);
|
|
|
+ char* sector = NULL;
|
|
|
+ if(navigo_station_type == COMMUTER_TRAIN || navigo_station_type == TRAM) {
|
|
|
+ sector = get_navigo_train_sector(event->station_group_id);
|
|
|
+ } else {
|
|
|
+ sector = get_navigo_station(event->station_group_id, 0, 0, navigo_station_type);
|
|
|
+ }
|
|
|
|
|
|
if(event->transport_type == URBAN_BUS || event->transport_type == INTERURBAN_BUS ||
|
|
|
event->transport_type == METRO || event->transport_type == TRAM) {
|
|
|
@@ -552,20 +569,20 @@ void show_navigo_special_event_info(NavigoCardSpecialEvent* event, FuriString* p
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"%s 3 bis\n%s\n",
|
|
|
- get_navigo_transport_type(event->transport_type),
|
|
|
+ get_intercode_string_transport_type(event->transport_type),
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
} else if(event->transport_type == TRAM) {
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"%s %s\n%s\n",
|
|
|
- get_navigo_transport_type(event->transport_type),
|
|
|
+ get_intercode_string_transport_type(event->transport_type),
|
|
|
get_navigo_tram_line(event->route_number),
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
} else {
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"%s %d\n%s\n",
|
|
|
- get_navigo_transport_type(event->transport_type),
|
|
|
+ get_intercode_string_transport_type(event->transport_type),
|
|
|
event->route_number,
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
}
|
|
|
@@ -573,7 +590,7 @@ void show_navigo_special_event_info(NavigoCardSpecialEvent* event, FuriString* p
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"%s\n%s\n",
|
|
|
- get_navigo_transport_type(event->transport_type),
|
|
|
+ get_intercode_string_transport_type(event->transport_type),
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
}
|
|
|
furi_string_cat_printf(
|
|
|
@@ -593,14 +610,13 @@ void show_navigo_special_event_info(NavigoCardSpecialEvent* event, FuriString* p
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"RER %c\n%s\n",
|
|
|
- (65 + event->route_number - 17),
|
|
|
+ (65 + event->route_number - 16),
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
} else {
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
- "%s %s\n%s\n",
|
|
|
- get_navigo_transport_type(event->transport_type),
|
|
|
- get_navigo_sncf_train_line(event->station_group_id),
|
|
|
+ "%s\n%s\n",
|
|
|
+ get_intercode_string_transport_type(event->transport_type),
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
}
|
|
|
furi_string_cat_printf(
|
|
|
@@ -609,7 +625,7 @@ void show_navigo_special_event_info(NavigoCardSpecialEvent* event, FuriString* p
|
|
|
parsed_data,
|
|
|
"Transporter: %s\n",
|
|
|
get_navigo_service_provider(event->service_provider));
|
|
|
- furi_string_cat_printf(parsed_data, "Station: %s\n", station);
|
|
|
+ furi_string_cat_printf(parsed_data, "Station: %s\nSector: %s\n", station, sector);
|
|
|
if(event->device_available) {
|
|
|
if(event->service_provider == NAVIGO_PROVIDER_SNCF) {
|
|
|
furi_string_cat_printf(parsed_data, "Device: %d\n", event->device & 0xFF);
|
|
|
@@ -623,7 +639,7 @@ void show_navigo_special_event_info(NavigoCardSpecialEvent* event, FuriString* p
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data,
|
|
|
"%s - %s\n",
|
|
|
- get_navigo_transport_type(event->transport_type),
|
|
|
+ get_intercode_string_transport_type(event->transport_type),
|
|
|
get_intercode_string_transition_type(event->transition));
|
|
|
furi_string_cat_printf(
|
|
|
parsed_data, "Result: %s\n", get_intercode_string_event_result(event->result));
|
|
|
@@ -631,7 +647,7 @@ void show_navigo_special_event_info(NavigoCardSpecialEvent* event, FuriString* p
|
|
|
parsed_data,
|
|
|
"Transporter: %s\n",
|
|
|
get_navigo_service_provider(event->service_provider));
|
|
|
- furi_string_cat_printf(parsed_data, "Station: %s\n", station);
|
|
|
+ furi_string_cat_printf(parsed_data, "Station: %s\nSector: %s\n", station, sector);
|
|
|
if(event->device_available) {
|
|
|
furi_string_cat_printf(parsed_data, "Device: %d\n", event->device);
|
|
|
}
|
|
|
@@ -670,7 +686,9 @@ void show_navigo_contract_info(NavigoCardContract* contract, FuriString* parsed_
|
|
|
}
|
|
|
if(contract->pay_method_available) {
|
|
|
furi_string_cat_printf(
|
|
|
- parsed_data, "Payment Method: %s\n", get_pay_method(contract->pay_method));
|
|
|
+ parsed_data,
|
|
|
+ "Payment Method: %s\n",
|
|
|
+ get_intercode_string_pay_method(contract->pay_method));
|
|
|
}
|
|
|
if(contract->zones_available) {
|
|
|
furi_string_cat_printf(parsed_data, "%s\n", get_zones(contract->zones));
|