navigo.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. #include "navigo.h"
  2. #include "navigo_lists.h"
  3. #include "../../../metroflip_i.h"
  4. const char* get_navigo_service_provider(int provider) {
  5. switch(provider) {
  6. case NAVIGO_PROVIDER_SNCF:
  7. return "SNCF";
  8. case NAVIGO_PROVIDER_RATP:
  9. return "RATP";
  10. case 4:
  11. case 10:
  12. return "IDF Mobilites";
  13. case NAVIGO_PROVIDER_ORA:
  14. return "ORA";
  15. case NAVIGO_PROVIDER_VEOLIA_CSO:
  16. return "CSO (VEOLIA)";
  17. case NAVIGO_PROVIDER_VEOLIA_RBUS:
  18. return "R'Bus (VEOLIA)";
  19. case NAVIGO_PROVIDER_PHEBUS:
  20. return "Phebus";
  21. case NAVIGO_PROVIDER_RATP_VEOLIA_NANTERRE:
  22. return "RATP (Veolia Transport Nanterre)";
  23. default: {
  24. char* provider_str = malloc(6 * sizeof(char));
  25. snprintf(provider_str, 6, "%d", provider);
  26. return provider_str;
  27. }
  28. }
  29. }
  30. const char* get_navigo_tariff(int tariff) {
  31. switch(tariff) {
  32. case 0x0000:
  33. return "Navigo Mois";
  34. case 0x0001:
  35. return "Navigo Semaine";
  36. case 0x0002:
  37. return "Navigo Annuel";
  38. case 0x0003:
  39. return "Navigo Jour";
  40. case 0x0004:
  41. return "Imagine R Junior";
  42. case 0x0005:
  43. return "Imagine R Etudiant";
  44. case 0x000D:
  45. return "Navigo Jeunes Week-end";
  46. case 0x0015:
  47. return "Paris-Visite"; // Theoric
  48. case 0x1000:
  49. return "Navigo Liberte+";
  50. case 0x4000:
  51. return "Navigo Mois 75%%";
  52. case 0x4001:
  53. return "Navigo Semaine 75%%";
  54. case 0x4015:
  55. return "Paris-Visite (Enfant)"; // Theoric
  56. case 0x5000:
  57. return "Tickets T+";
  58. case 0x5004:
  59. return "Tickets OrlyBus"; // Theoric
  60. case 0x5005:
  61. return "Tickets RoissyBus"; // Theoric
  62. case 0x5006:
  63. return "Bus-Tram"; // Theoric
  64. case 0x5008:
  65. return "Metro-Train-RER"; // Theoric
  66. case 0x500b:
  67. return "Paris <> Aeroports"; // Theoric
  68. case 0x5010:
  69. return "Tickets T+ (Reduit)"; // Theoric
  70. case 0x5016:
  71. return "Bus-Tram (Reduit)"; // Theoric
  72. case 0x5018:
  73. return "Metro-Train-RER (Reduit)"; // Theoric
  74. case 0x501b:
  75. return "Paris <> Aeroports (Reduit)"; // Theoric
  76. case 0x8003:
  77. return "Navigo Solidarite Gratuit";
  78. default: {
  79. char* tariff_str = malloc(6 * sizeof(char));
  80. snprintf(tariff_str, 6, "%d", tariff);
  81. return tariff_str;
  82. }
  83. }
  84. }
  85. const char* get_zones(int* zones) {
  86. if(zones[0] && zones[4]) {
  87. return "All Zones (1-5)";
  88. } else if(zones[0] && zones[3]) {
  89. return "Zones 1-4";
  90. } else if(zones[0] && zones[2]) {
  91. return "Zones 1-3";
  92. } else if(zones[0] && zones[1]) {
  93. return "Zones 1-2";
  94. } else if(zones[0]) {
  95. return "Zone 1";
  96. } else if(zones[1] && zones[4]) {
  97. return "Zones 2-5";
  98. } else if(zones[1] && zones[3]) {
  99. return "Zones 2-4";
  100. } else if(zones[1] && zones[2]) {
  101. return "Zones 2-3";
  102. } else if(zones[1]) {
  103. return "Zone 2";
  104. } else if(zones[2] && zones[4]) {
  105. return "Zones 3-5";
  106. } else if(zones[2] && zones[3]) {
  107. return "Zones 3-4";
  108. } else if(zones[2]) {
  109. return "Zone 3";
  110. } else if(zones[3] && zones[4]) {
  111. return "Zones 4-5";
  112. } else if(zones[3]) {
  113. return "Zone 4";
  114. } else if(zones[4]) {
  115. return "Zone 5";
  116. } else {
  117. return "Unknown";
  118. }
  119. }
  120. char* get_token(char* psrc, const char* delimit, void* psave) {
  121. static char sret[512];
  122. register char* ptr = psave;
  123. memset(sret, 0, sizeof(sret));
  124. if(psrc != NULL) strcpy(ptr, psrc);
  125. if(ptr == NULL) return NULL;
  126. int i = 0, nlength = strlen(ptr);
  127. for(i = 0; i < nlength; i++) {
  128. if(ptr[i] == delimit[0]) break;
  129. if(ptr[i] == delimit[1]) {
  130. ptr = NULL;
  131. break;
  132. }
  133. sret[i] = ptr[i];
  134. }
  135. if(ptr != NULL) strcpy(ptr, &ptr[i + 1]);
  136. return sret;
  137. }
  138. char* get_navigo_station(
  139. int station_group_id,
  140. int station_id,
  141. int station_sub_id,
  142. int service_provider) {
  143. switch(service_provider) {
  144. case NAVIGO_PROVIDER_SNCF: {
  145. if(station_group_id < 77 && station_id < 19) {
  146. char* file_path = malloc(256 * sizeof(char));
  147. if(!file_path) {
  148. return "Unknown";
  149. }
  150. snprintf(
  151. file_path,
  152. 256,
  153. APP_ASSETS_PATH("navigo/stations/sncf/stations_%d.txt"),
  154. station_group_id);
  155. const char* sncf_stations_path = file_path;
  156. Storage* storage = furi_record_open(RECORD_STORAGE);
  157. Stream* stream = file_stream_alloc(storage);
  158. FuriString* line = furi_string_alloc();
  159. char* found_station_name = NULL;
  160. if(file_stream_open(stream, sncf_stations_path, FSAM_READ, FSOM_OPEN_EXISTING)) {
  161. while(stream_read_line(stream, line)) {
  162. // file is in csv format: station_id,station_sub_id,station_name
  163. // search for the station
  164. furi_string_replace_all(line, "\r", "");
  165. furi_string_replace_all(line, "\n", "");
  166. const char* string_line = furi_string_get_cstr(line);
  167. char* string_line_copy = strdup(string_line);
  168. if(!string_line_copy) {
  169. return "Unknown";
  170. }
  171. int line_station_id = atoi(get_token(string_line_copy, ",", string_line_copy));
  172. int line_station_sub_id =
  173. atoi(get_token(string_line_copy, ",", string_line_copy));
  174. if(line_station_id == station_id && line_station_sub_id == station_sub_id) {
  175. found_station_name =
  176. strdup(get_token(string_line_copy, ",", string_line_copy));
  177. free(string_line_copy);
  178. break;
  179. }
  180. free(string_line_copy);
  181. }
  182. } else {
  183. FURI_LOG_E("Metroflip:Scene:Calypso", "Failed to open sncf_stations.txt");
  184. }
  185. furi_string_free(line);
  186. file_stream_close(stream);
  187. stream_free(stream);
  188. free(file_path);
  189. if(found_station_name) {
  190. return found_station_name;
  191. }
  192. }
  193. // cast station_group_id-station_id-station_sub_id to a string
  194. char* station = malloc(12 * sizeof(char));
  195. if(!station) {
  196. return "Unknown";
  197. }
  198. snprintf(station, 10, "%d-%d-%d", station_group_id, station_id, station_sub_id);
  199. return station;
  200. }
  201. case NAVIGO_PROVIDER_RATP:
  202. case NAVIGO_PROVIDER_ORA: {
  203. if(station_group_id < 32 && station_id < 16) {
  204. char* file_path = malloc(256 * sizeof(char));
  205. if(!file_path) {
  206. return "Unknown";
  207. }
  208. snprintf(
  209. file_path,
  210. 256,
  211. APP_ASSETS_PATH("navigo/stations/ratp/stations_%d.txt"),
  212. station_group_id);
  213. const char* ratp_stations_path = file_path;
  214. Storage* storage = furi_record_open(RECORD_STORAGE);
  215. Stream* stream = file_stream_alloc(storage);
  216. FuriString* line = furi_string_alloc();
  217. char* found_station_name = NULL;
  218. if(file_stream_open(stream, ratp_stations_path, FSAM_READ, FSOM_OPEN_EXISTING)) {
  219. while(stream_read_line(stream, line)) {
  220. // file is in csv format: station_id,station_name
  221. // search for the station
  222. furi_string_replace_all(line, "\r", "");
  223. furi_string_replace_all(line, "\n", "");
  224. const char* string_line = furi_string_get_cstr(line);
  225. char* string_line_copy = strdup(string_line);
  226. if(!string_line_copy) {
  227. return "Unknown";
  228. }
  229. int line_station_id = atoi(get_token(string_line_copy, ",", string_line_copy));
  230. if(line_station_id == station_id) {
  231. found_station_name =
  232. strdup(get_token(string_line_copy, ",", string_line_copy));
  233. free(string_line_copy);
  234. break;
  235. }
  236. free(string_line_copy);
  237. }
  238. } else {
  239. FURI_LOG_E("Metroflip:Scene:Calypso", "Failed to open ratp_stations.txt");
  240. }
  241. furi_string_free(line);
  242. file_stream_close(stream);
  243. stream_free(stream);
  244. free(file_path);
  245. if(found_station_name) {
  246. return found_station_name;
  247. }
  248. }
  249. // cast station_group_id-station_id to a string
  250. char* station = malloc(12 * sizeof(char));
  251. if(!station) {
  252. return "Unknown";
  253. }
  254. snprintf(station, 10, "%d-%d", station_group_id, station_id);
  255. return station;
  256. }
  257. default: {
  258. // cast station_group_id-station_id to a string
  259. char* station = malloc(12 * sizeof(char));
  260. if(!station) {
  261. return "Unknown";
  262. }
  263. snprintf(station, 10, "%d-%d", station_group_id, station_id);
  264. return station;
  265. }
  266. }
  267. }
  268. char* get_navigo_sncf_sector(int station_group_id) {
  269. // group id is in format XY where X is the sector
  270. const char* station_name = NAVIGO_SNCF_SECTORS_LIST[station_group_id / 10];
  271. return strdup(station_name);
  272. }
  273. const char* get_navigo_tram_line(int route_number) {
  274. switch(route_number) {
  275. case 1:
  276. return "T3a";
  277. case 9:
  278. return "T9";
  279. case 16:
  280. return "T6";
  281. case 18:
  282. return "T8";
  283. default: {
  284. char* line = malloc(5 * sizeof(char));
  285. if(!line) {
  286. return "Unknown";
  287. }
  288. snprintf(line, 5, "?%d?", route_number);
  289. return line;
  290. }
  291. }
  292. }
  293. void show_navigo_event_info(
  294. NavigoCardEvent* event,
  295. NavigoCardContract* contracts,
  296. FuriString* parsed_data) {
  297. if(event->used_contract == 0) {
  298. furi_string_cat_printf(parsed_data, "No event data\n");
  299. return;
  300. }
  301. char* station = get_navigo_station(
  302. event->station_group_id, event->station_id, event->station_sub_id, event->service_provider);
  303. char* sector = NULL;
  304. if(event->service_provider == NAVIGO_PROVIDER_SNCF) {
  305. sector = get_navigo_sncf_sector(event->station_group_id);
  306. } else {
  307. sector = get_navigo_station(event->station_group_id, 0, 0, event->service_provider);
  308. }
  309. if(event->transport_type == URBAN_BUS || event->transport_type == INTERURBAN_BUS ||
  310. event->transport_type == METRO || event->transport_type == TRAM) {
  311. if(event->route_number_available) {
  312. if(event->transport_type == METRO && event->route_number == 103) {
  313. furi_string_cat_printf(
  314. parsed_data,
  315. "%s 3 bis\n%s\n",
  316. get_intercode_string_transport_type(event->transport_type),
  317. get_intercode_string_transition_type(event->transition));
  318. } else if(event->transport_type == TRAM) {
  319. furi_string_cat_printf(
  320. parsed_data,
  321. "%s %s\n%s\n",
  322. get_intercode_string_transport_type(event->transport_type),
  323. get_navigo_tram_line(event->route_number),
  324. get_intercode_string_transition_type(event->transition));
  325. } else {
  326. furi_string_cat_printf(
  327. parsed_data,
  328. "%s %d\n%s\n",
  329. get_intercode_string_transport_type(event->transport_type),
  330. event->route_number,
  331. get_intercode_string_transition_type(event->transition));
  332. }
  333. } else {
  334. furi_string_cat_printf(
  335. parsed_data,
  336. "%s\n%s\n",
  337. get_intercode_string_transport_type(event->transport_type),
  338. get_intercode_string_transition_type(event->transition));
  339. }
  340. furi_string_cat_printf(
  341. parsed_data,
  342. "Transporter: %s\n",
  343. get_navigo_service_provider(event->service_provider));
  344. furi_string_cat_printf(parsed_data, "Station: %s\nSector: %s\n", station, sector);
  345. if(event->location_gate_available) {
  346. furi_string_cat_printf(parsed_data, "Gate: %d\n", event->location_gate);
  347. }
  348. if(event->device_available) {
  349. if(event->transport_type == URBAN_BUS || event->transport_type == INTERURBAN_BUS) {
  350. const char* side = event->side == 0 ? "right" : "left";
  351. furi_string_cat_printf(parsed_data, "Door: %d\nSide: %s\n", event->door, side);
  352. } else {
  353. furi_string_cat_printf(parsed_data, "Device: %d\n", event->device);
  354. }
  355. }
  356. if(event->mission_available) {
  357. furi_string_cat_printf(parsed_data, "Mission: %d\n", event->mission);
  358. }
  359. if(event->vehicle_id_available) {
  360. furi_string_cat_printf(parsed_data, "Vehicle: %d\n", event->vehicle_id);
  361. }
  362. if(event->used_contract_available) {
  363. furi_string_cat_printf(
  364. parsed_data,
  365. "Contract: %d - %s\n",
  366. event->used_contract,
  367. get_navigo_tariff(contracts[event->used_contract - 1].tariff));
  368. }
  369. locale_format_datetime_cat(parsed_data, &event->date, true);
  370. furi_string_cat_printf(parsed_data, "\n");
  371. } else if(event->transport_type == COMMUTER_TRAIN) {
  372. if(event->route_number_available) {
  373. furi_string_cat_printf(
  374. parsed_data,
  375. "RER %c\n%s\n",
  376. (65 + event->route_number - 17),
  377. get_intercode_string_transition_type(event->transition));
  378. } else {
  379. furi_string_cat_printf(
  380. parsed_data,
  381. "%s\n%s\n",
  382. get_intercode_string_transport_type(event->transport_type),
  383. get_intercode_string_transition_type(event->transition));
  384. }
  385. furi_string_cat_printf(
  386. parsed_data,
  387. "Transporter: %s\n",
  388. get_navigo_service_provider(event->service_provider));
  389. furi_string_cat_printf(parsed_data, "Station: %s\nSector: %s\n", station, sector);
  390. if(event->location_gate_available) {
  391. furi_string_cat_printf(parsed_data, "Gate: %d\n", event->location_gate);
  392. }
  393. if(event->device_available) {
  394. if(event->service_provider == NAVIGO_PROVIDER_SNCF) {
  395. furi_string_cat_printf(parsed_data, "Device: %d\n", event->device & 0xFF);
  396. } else {
  397. furi_string_cat_printf(parsed_data, "Device: %d\n", event->device);
  398. }
  399. }
  400. if(event->mission_available) {
  401. furi_string_cat_printf(parsed_data, "Mission: %d\n", event->mission);
  402. }
  403. if(event->vehicle_id_available) {
  404. furi_string_cat_printf(parsed_data, "Vehicle: %d\n", event->vehicle_id);
  405. }
  406. if(event->used_contract_available) {
  407. furi_string_cat_printf(
  408. parsed_data,
  409. "Contract: %d - %s\n",
  410. event->used_contract,
  411. get_navigo_tariff(contracts[event->used_contract - 1].tariff));
  412. }
  413. locale_format_datetime_cat(parsed_data, &event->date, true);
  414. furi_string_cat_printf(parsed_data, "\n");
  415. } else {
  416. furi_string_cat_printf(
  417. parsed_data,
  418. "%s - %s\n",
  419. get_intercode_string_transport_type(event->transport_type),
  420. get_intercode_string_transition_type(event->transition));
  421. furi_string_cat_printf(
  422. parsed_data,
  423. "Transporter: %s\n",
  424. get_navigo_service_provider(event->service_provider));
  425. furi_string_cat_printf(parsed_data, "Station: %s\nSector: %s\n", station, sector);
  426. if(event->location_gate_available) {
  427. furi_string_cat_printf(parsed_data, "Gate: %d\n", event->location_gate);
  428. }
  429. if(event->device_available) {
  430. furi_string_cat_printf(parsed_data, "Device: %d\n", event->device);
  431. }
  432. if(event->mission_available) {
  433. furi_string_cat_printf(parsed_data, "Mission: %d\n", event->mission);
  434. }
  435. if(event->vehicle_id_available) {
  436. furi_string_cat_printf(parsed_data, "Vehicle: %d\n", event->vehicle_id);
  437. }
  438. if(event->used_contract_available) {
  439. furi_string_cat_printf(
  440. parsed_data,
  441. "Contract: %d - %s\n",
  442. event->used_contract,
  443. get_navigo_tariff(contracts[event->used_contract - 1].tariff));
  444. }
  445. locale_format_datetime_cat(parsed_data, &event->date, true);
  446. furi_string_cat_printf(parsed_data, "\n");
  447. }
  448. free(station);
  449. free(sector);
  450. }
  451. void show_navigo_special_event_info(NavigoCardSpecialEvent* event, FuriString* parsed_data) {
  452. char* station = get_navigo_station(
  453. event->station_group_id, event->station_id, event->station_sub_id, event->service_provider);
  454. char* sector = get_navigo_station(event->station_group_id, 0, 0, event->service_provider);
  455. if(event->transport_type == URBAN_BUS || event->transport_type == INTERURBAN_BUS ||
  456. event->transport_type == METRO || event->transport_type == TRAM) {
  457. if(event->route_number_available) {
  458. if(event->transport_type == METRO && event->route_number == 103) {
  459. furi_string_cat_printf(
  460. parsed_data,
  461. "%s 3 bis\n%s\n",
  462. get_intercode_string_transport_type(event->transport_type),
  463. get_intercode_string_transition_type(event->transition));
  464. } else if(event->transport_type == TRAM) {
  465. furi_string_cat_printf(
  466. parsed_data,
  467. "%s %s\n%s\n",
  468. get_intercode_string_transport_type(event->transport_type),
  469. get_navigo_tram_line(event->route_number),
  470. get_intercode_string_transition_type(event->transition));
  471. } else {
  472. furi_string_cat_printf(
  473. parsed_data,
  474. "%s %d\n%s\n",
  475. get_intercode_string_transport_type(event->transport_type),
  476. event->route_number,
  477. get_intercode_string_transition_type(event->transition));
  478. }
  479. } else {
  480. furi_string_cat_printf(
  481. parsed_data,
  482. "%s\n%s\n",
  483. get_intercode_string_transport_type(event->transport_type),
  484. get_intercode_string_transition_type(event->transition));
  485. }
  486. furi_string_cat_printf(
  487. parsed_data, "Result: %s\n", get_intercode_string_event_result(event->result));
  488. furi_string_cat_printf(
  489. parsed_data,
  490. "Transporter: %s\n",
  491. get_navigo_service_provider(event->service_provider));
  492. furi_string_cat_printf(parsed_data, "Station: %s\nSector: %s\n", station, sector);
  493. if(event->device_available) {
  494. furi_string_cat_printf(parsed_data, "Device: %d\n", event->device);
  495. }
  496. locale_format_datetime_cat(parsed_data, &event->date, true);
  497. furi_string_cat_printf(parsed_data, "\n");
  498. } else if(event->transport_type == COMMUTER_TRAIN) {
  499. if(event->route_number_available) {
  500. furi_string_cat_printf(
  501. parsed_data,
  502. "RER %c\n%s\n",
  503. (65 + event->route_number - 17),
  504. get_intercode_string_transition_type(event->transition));
  505. } else {
  506. furi_string_cat_printf(
  507. parsed_data,
  508. "%s\n%s\n",
  509. get_intercode_string_transport_type(event->transport_type),
  510. get_intercode_string_transition_type(event->transition));
  511. }
  512. furi_string_cat_printf(
  513. parsed_data, "Result: %s\n", get_intercode_string_event_result(event->result));
  514. furi_string_cat_printf(
  515. parsed_data,
  516. "Transporter: %s\n",
  517. get_navigo_service_provider(event->service_provider));
  518. furi_string_cat_printf(parsed_data, "Station: %s\nSector: %s\n", station, sector);
  519. if(event->device_available) {
  520. if(event->service_provider == NAVIGO_PROVIDER_SNCF) {
  521. furi_string_cat_printf(parsed_data, "Device: %d\n", event->device & 0xFF);
  522. } else {
  523. furi_string_cat_printf(parsed_data, "Device: %d\n", event->device);
  524. }
  525. }
  526. locale_format_datetime_cat(parsed_data, &event->date, true);
  527. furi_string_cat_printf(parsed_data, "\n");
  528. } else {
  529. furi_string_cat_printf(
  530. parsed_data,
  531. "%s - %s\n",
  532. get_intercode_string_transport_type(event->transport_type),
  533. get_intercode_string_transition_type(event->transition));
  534. furi_string_cat_printf(
  535. parsed_data, "Result: %s\n", get_intercode_string_event_result(event->result));
  536. furi_string_cat_printf(
  537. parsed_data,
  538. "Transporter: %s\n",
  539. get_navigo_service_provider(event->service_provider));
  540. furi_string_cat_printf(parsed_data, "Station: %s\nSector: %s\n", station, sector);
  541. if(event->device_available) {
  542. furi_string_cat_printf(parsed_data, "Device: %d\n", event->device);
  543. }
  544. locale_format_datetime_cat(parsed_data, &event->date, true);
  545. furi_string_cat_printf(parsed_data, "\n");
  546. }
  547. free(station);
  548. free(sector);
  549. }
  550. void show_navigo_contract_info(NavigoCardContract* contract, FuriString* parsed_data) {
  551. // Core type and ticket info
  552. furi_string_cat_printf(parsed_data, "Type: %s\n", get_navigo_tariff(contract->tariff));
  553. if(contract->counter_present) {
  554. furi_string_cat_printf(parsed_data, "Remaining Tickets: %d\n", contract->counter.count);
  555. furi_string_cat_printf(parsed_data, "Last load: %d\n", contract->counter.last_load);
  556. }
  557. // Validity period
  558. furi_string_cat_printf(parsed_data, "Valid from: ");
  559. locale_format_datetime_cat(parsed_data, &contract->start_date, false);
  560. furi_string_cat_printf(parsed_data, "\n");
  561. if(contract->end_date_available) {
  562. furi_string_cat_printf(parsed_data, "to: ");
  563. locale_format_datetime_cat(parsed_data, &contract->end_date, false);
  564. furi_string_cat_printf(parsed_data, "\n");
  565. }
  566. // Serial number (if available)
  567. if(contract->serial_number_available) {
  568. furi_string_cat_printf(parsed_data, "TCN Number: %d\n", contract->serial_number);
  569. }
  570. if(contract->price_amount_available) {
  571. furi_string_cat_printf(parsed_data, "Amount: %.2f EUR\n", contract->price_amount);
  572. }
  573. if(contract->pay_method_available) {
  574. furi_string_cat_printf(
  575. parsed_data,
  576. "Payment Method: %s\n",
  577. get_intercode_string_pay_method(contract->pay_method));
  578. }
  579. if(contract->zones_available) {
  580. furi_string_cat_printf(parsed_data, "%s\n", get_zones(contract->zones));
  581. }
  582. furi_string_cat_printf(parsed_data, "Sold on: ");
  583. locale_format_datetime_cat(parsed_data, &contract->sale_date, false);
  584. furi_string_cat_printf(parsed_data, "\n");
  585. furi_string_cat_printf(
  586. parsed_data, "Sales Agent: %s\n", get_navigo_service_provider(contract->sale_agent));
  587. furi_string_cat_printf(parsed_data, "Sales Terminal: %d\n", contract->sale_device);
  588. furi_string_cat_printf(
  589. parsed_data, "Status: %s\n", get_intercode_string_contract_status(contract->status));
  590. furi_string_cat_printf(parsed_data, "Authenticity Code: %d\n", contract->authenticator);
  591. }
  592. void show_navigo_environment_info(
  593. NavigoCardEnv* environment,
  594. NavigoCardHolder* holder,
  595. FuriString* parsed_data) {
  596. furi_string_cat_printf(
  597. parsed_data, "Card status: %s\n", get_intercode_string_holder_type(holder->card_status));
  598. if(is_intercode_string_holder_linked(holder->card_status)) {
  599. furi_string_cat_printf(parsed_data, "Linked to an organization\n");
  600. }
  601. furi_string_cat_printf(
  602. parsed_data,
  603. "App Version: %s - v%d\n",
  604. get_intercode_string_version(environment->app_version),
  605. get_intercode_string_subversion(environment->app_version));
  606. furi_string_cat_printf(
  607. parsed_data, "Country: %s\n", get_country_string(environment->country_num));
  608. furi_string_cat_printf(
  609. parsed_data,
  610. "Network: %s\n",
  611. get_network_string(guess_card_type(environment->country_num, environment->network_num)));
  612. furi_string_cat_printf(parsed_data, "End of validity:\n");
  613. locale_format_datetime_cat(parsed_data, &environment->end_dt, false);
  614. furi_string_cat_printf(parsed_data, "\n");
  615. }