Sfoglia il codice sorgente

Update some parser functions + Add Villejuif IGR station and ORA provider

DocSystem 1 anno fa
parent
commit
e08b463cf2

+ 35 - 3
api/calypso/cards/intercode.c

@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include "intercode.h"
 
-CalypsoApp* get_intercode_contract_structure() {
+CalypsoApp* get_intercode_structure_contract() {
     CalypsoApp* IntercodeContractStructure = malloc(sizeof(CalypsoApp));
     if(!IntercodeContractStructure) {
         return NULL;
@@ -248,7 +248,7 @@ CalypsoApp* get_intercode_contract_structure() {
     return IntercodeContractStructure;
 }
 
-CalypsoApp* get_intercode_event_structure() {
+CalypsoApp* get_intercode_structure_event() {
     CalypsoApp* IntercodeEventStructure = malloc(sizeof(CalypsoApp));
     if(!IntercodeEventStructure) {
         return NULL;
@@ -382,7 +382,7 @@ CalypsoApp* get_intercode_event_structure() {
     return IntercodeEventStructure;
 }
 
-CalypsoApp* get_intercode_env_holder_structure() {
+CalypsoApp* get_intercode_structure_env_holder() {
     CalypsoApp* IntercodeEnvHolderStructure = malloc(sizeof(CalypsoApp));
     if(!IntercodeEnvHolderStructure) {
         return NULL;
@@ -548,3 +548,35 @@ CalypsoApp* get_intercode_env_holder_structure() {
 
     return IntercodeEnvHolderStructure;
 }
+
+const char* get_intercode_string_transition_type(int transition) {
+    switch(transition) {
+    case 0x1:
+        return "Entry (First validation)";
+    case 0x2:
+        return "Exit";
+    case 0x4:
+        return "Inspection";
+    case 0x5:
+        return "Test validation";
+    case 0x6:
+        return "Entry (Interchange)";
+    case 0x7:
+        return "Exit (Interchange)";
+    case 0x9:
+        return "Validation cancelled";
+    case 0xA:
+        return "Entry (Public road)";
+    case 0xB:
+        return "Exit (Public road)";
+    case 0xD:
+        return "Distribution";
+    case 0xF:
+        return "Invalidation";
+    default: {
+        char* transition_str = malloc(6 * sizeof(char));
+        snprintf(transition_str, 6, "%d", transition);
+        return transition_str;
+    }
+    }
+}

+ 44 - 3
api/calypso/cards/intercode.h

@@ -3,10 +3,51 @@
 #ifndef INTERCODE_STRUCTURES_H
 #define INTERCODE_STRUCTURES_H
 
-CalypsoApp* get_intercode_contract_structure();
+CalypsoApp* get_intercode_structure_contract();
 
-CalypsoApp* get_intercode_event_structure();
+CalypsoApp* get_intercode_structure_event();
 
-CalypsoApp* get_intercode_env_holder_structure();
+CalypsoApp* get_intercode_structure_env_holder();
+
+const char* get_intercode_string_transition_type(int transition);
+
+typedef enum {
+    URBAN_BUS = 1,
+    INTERURBAN_BUS = 2,
+    METRO = 3,
+    TRAM = 4,
+    COMMUTER_TRAIN = 5,
+    WATERBORNE_VEHICLE = 6,
+    TOLL = 7,
+    PARKING = 8,
+    TAXI = 9,
+    HIGH_SPEED_TRAIN = 10,
+    RURAL_BUS = 11,
+    EXPRESS_COMMUTER_TRAIN = 12,
+    PARA_TRANSIT = 13,
+    SELF_DRIVE_VEHICLE = 14,
+    COACH = 15,
+    LOCOMOTIVE = 16,
+    POWERED_MOTOR_VEHICLE = 17,
+    TRAILER = 18,
+    REGIONAL_TRAIN = 19,
+    INTER_CITY = 20,
+    FUNICULAR = 21,
+    CABLE_CAR = 22,
+    SELF_SERVICE_BICYCLE = 23,
+    CAR_SHARING = 24,
+    CAR_POOLING = 25,
+} INTERCODE_TRANSPORT_TYPE;
+
+typedef enum {
+    ENTRY = 1,
+    EXIT = 2,
+    PASSAGE = 3,
+    CHECKPOINT_INSPECTION = 4,
+    AUTONOMOUS = 5,
+    INTERCHANGE = 6,
+    VALIDATION = 7,
+    PRESENCE_DETECTED = 8,
+} INTERCODE_USER_ACTION;
 
 #endif // INTERCODE_STRUCTURES_H

+ 72 - 92
api/calypso/transit/navigo.c

@@ -4,15 +4,15 @@
 
 const char* get_navigo_transport_type(int type) {
     switch(type) {
-    case BUS_URBAIN:
+    case URBAN_BUS:
         return "Bus Urbain";
-    case BUS_INTERURBAIN:
+    case INTERURBAN_BUS:
         return "Bus Interurbain";
     case METRO:
         return "Metro";
     case TRAM:
         return "Tram";
-    case TRAIN:
+    case COMMUTER_TRAIN:
         return "Train";
     case PARKING:
         return "Parking";
@@ -29,6 +29,8 @@ const char* get_navigo_service_provider(int provider) {
         return "RATP";
     case 4:
         return "IDF Mobilites";
+    case 8:
+        return "ORA";
     case 10:
         return "IDF Mobilites";
     case 115:
@@ -39,39 +41,10 @@ const char* get_navigo_service_provider(int provider) {
         return "Phebus";
     case 175:
         return "RATP (Veolia Transport Nanterre)";
-    default:
-        return "Unknown";
-    }
-}
-
-const char* get_transition_type(int transition) {
-    switch(transition) {
-    case 1:
-        return "Entry";
-    case 2:
-        return "Exit";
-    case 4:
-        return "Controle volant (a bord)";
-    case 5:
-        return "Test validation";
-    case 6:
-        return "Interchange - Entry";
-    case 7:
-        return "Interchange - Exit";
-    case 9:
-        return "Validation cancelled";
-    case 10:
-        return "Entry";
-    case 11:
-        return "Exit";
-    case 13:
-        return "Distribution";
-    case 15:
-        return "Invalidation";
     default: {
-        char* transition_str = malloc(6 * sizeof(char));
-        snprintf(transition_str, 6, "%d", transition);
-        return transition_str;
+        char* provider_str = malloc(6 * sizeof(char));
+        snprintf(provider_str, 6, "%d", provider);
+        return provider_str;
     }
     }
 }
@@ -237,40 +210,58 @@ int get_intercode_subversion(int version) {
     return version & 0x07;
 }
 
-const char* get_navigo_metro_station(int station_group_id, int station_id) {
-    // Use NAVIGO_H constants
-    if(station_group_id < 32 && station_id < 16) {
-        return NAVIGO_METRO_STATION_LIST[station_group_id][station_id];
+const char* get_navigo_station(int station_group_id, int station_id, int service_provider) {
+    switch(service_provider) {
+    case NAVIGO_PROVIDER_SNCF: {
+        if(station_group_id < 77 && station_id < 19) {
+            const char* station_name = NAVIGO_SNCF_LOCATION_LIST[station_group_id][station_id];
+            if(station_name) {
+                return station_name;
+            }
+        }
+        // cast station_group_id-station_id to a string
+        char* station = malloc(12 * sizeof(char));
+        if(!station) {
+            return "Unknown";
+        }
+        snprintf(station, 10, "%d-%d", station_group_id, station_id);
+        return station;
+    }
+    case NAVIGO_PROVIDER_RATP:
+    case NAVIGO_PROVIDER_ORA: {
+        if(station_group_id < 32 && station_id < 16) {
+            const char* station_name = NAVIGO_RATP_LOCATION_LIST[station_group_id][station_id];
+            if(station_name) {
+                return station_name;
+            }
+        }
+        // cast station_group_id-station_id to a string
+        char* station = malloc(12 * sizeof(char));
+        if(!station) {
+            return "Unknown";
+        }
+        snprintf(station, 10, "%d-%d", station_group_id, station_id);
+        return station;
+    }
+    default: {
+        // cast station_group_id-station_id to a string
+        char* station = malloc(12 * sizeof(char));
+        if(!station) {
+            return "Unknown";
+        }
+        snprintf(station, 10, "%d-%d", station_group_id, station_id);
+        return station;
     }
-    // cast station_group_id-station_id to a string
-    char* station = malloc(12 * sizeof(char));
-    if(!station) {
-        return "Unknown";
     }
-    snprintf(station, 10, "%d-%d", station_group_id, station_id);
-    return station;
 }
 
-const char* get_navigo_train_line(int station_group_id) {
+const char* get_navigo_sncf_train_line(int station_group_id) {
     if(station_group_id < 77) {
-        return NAVIGO_TRAIN_LINES_LIST[station_group_id];
+        return NAVIGO_SNCF_TRAIN_LINES_LIST[station_group_id];
     }
     return "Unknown";
 }
 
-const char* get_navigo_train_station(int station_group_id, int station_id) {
-    if(station_group_id < 77 && station_id < 19) {
-        return NAVIGO_TRAIN_STATION_LIST[station_group_id][station_id];
-    }
-    // cast station_group_id-station_id to a string
-    char* station = malloc(12 * sizeof(char));
-    if(!station) {
-        return "Unknown";
-    }
-    snprintf(station, 10, "%d-%d", station_group_id, station_id);
-    return station;
-}
-
 const char* get_navigo_tram_line(int route_number) {
     switch(route_number) {
     case 1:
@@ -296,7 +287,7 @@ void show_navigo_event_info(
         furi_string_cat_printf(parsed_data, "No event data\n");
         return;
     }
-    if(event->transport_type == BUS_URBAIN || event->transport_type == BUS_INTERURBAIN ||
+    if(event->transport_type == URBAN_BUS || event->transport_type == INTERURBAN_BUS ||
        event->transport_type == METRO || event->transport_type == TRAM) {
         if(event->route_number_available) {
             if(event->transport_type == METRO && event->route_number == 103) {
@@ -304,48 +295,43 @@ void show_navigo_event_info(
                     parsed_data,
                     "%s 3 bis\n%s\n",
                     get_navigo_transport_type(event->transport_type),
-                    get_transition_type(event->transition));
+                    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_navigo_tram_line(event->route_number),
-                    get_transition_type(event->transition));
+                    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),
                     event->route_number,
-                    get_transition_type(event->transition));
+                    get_intercode_string_transition_type(event->transition));
             }
         } else {
             furi_string_cat_printf(
                 parsed_data,
                 "%s\n%s\n",
                 get_navigo_transport_type(event->transport_type),
-                get_transition_type(event->transition));
+                get_intercode_string_transition_type(event->transition));
         }
         furi_string_cat_printf(
             parsed_data,
             "Transporter: %s\n",
             get_navigo_service_provider(event->service_provider));
-        if(event->transport_type == METRO) {
-            furi_string_cat_printf(
-                parsed_data,
-                "Station: %s\nSector: %s\n",
-                get_navigo_metro_station(event->station_group_id, event->station_id),
-                get_navigo_metro_station(event->station_group_id, 0));
-        } else {
-            furi_string_cat_printf(
-                parsed_data, "Station ID: %d-%d\n", event->station_group_id, event->station_id);
-        }
+        furi_string_cat_printf(
+            parsed_data,
+            "Station: %s\nSector: %s\n",
+            get_navigo_station(event->station_group_id, event->station_id, event->service_provider),
+            get_navigo_station(event->station_group_id, 0, event->service_provider));
         if(event->location_gate_available) {
             furi_string_cat_printf(parsed_data, "Gate: %d\n", event->location_gate);
         }
         if(event->device_available) {
-            if(event->transport_type == BUS_URBAIN || event->transport_type == BUS_INTERURBAIN) {
+            if(event->transport_type == URBAN_BUS || event->transport_type == INTERURBAN_BUS) {
                 const char* side = event->side == 0 ? "right" : "left";
                 furi_string_cat_printf(parsed_data, "Door: %d\nSide: %s\n", event->door, side);
             } else {
@@ -367,36 +353,30 @@ void show_navigo_event_info(
         }
         locale_format_datetime_cat(parsed_data, &event->date, true);
         furi_string_cat_printf(parsed_data, "\n");
-    } else if(event->transport_type == TRAIN) {
+    } else if(event->transport_type == COMMUTER_TRAIN) {
         if(event->route_number_available) {
             furi_string_cat_printf(
                 parsed_data,
                 "RER %c\n%s\n",
                 (65 + event->route_number - 17),
-                get_transition_type(event->transition));
+                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_train_line(event->station_group_id),
-                get_transition_type(event->transition));
+                get_navigo_sncf_train_line(event->station_group_id),
+                get_intercode_string_transition_type(event->transition));
         }
         furi_string_cat_printf(
             parsed_data,
             "Transporter: %s\n",
             get_navigo_service_provider(event->service_provider));
-        if(event->service_provider == 2) {
-            furi_string_cat_printf(
-                parsed_data,
-                "Station: %s\n",
-                get_navigo_train_station(event->station_group_id, event->station_id));
-        } else if(event->service_provider == 3) {
-            furi_string_cat_printf(
-                parsed_data,
-                "Station: %s\n",
-                get_navigo_metro_station(event->station_group_id, event->station_id));
-        }
+        furi_string_cat_printf(
+            parsed_data,
+            "Station: %s\n",
+            get_navigo_station(
+                event->station_group_id, event->station_id, event->service_provider));
         /* if(event->route_number_available) {
             furi_string_cat_printf(parsed_data, "Route: %d\n", event->route_number);
         } */
@@ -430,7 +410,7 @@ void show_navigo_event_info(
             parsed_data,
             "%s - %s\n",
             get_navigo_transport_type(event->transport_type),
-            get_transition_type(event->transition));
+            get_intercode_string_transition_type(event->transition));
         furi_string_cat_printf(
             parsed_data,
             "Transporter: %s\n",

+ 14 - 12
api/calypso/transit/navigo.h

@@ -10,11 +10,11 @@
 
 const char* get_navigo_type(int type);
 
-const char* get_navigo_metro_station(int station_group_id, int station_id);
+const char* get_navigo_station(int station_group_id, int station_id, int service_provider);
 
-const char* get_navigo_train_line(int station_group_id);
+const char* get_navigo_sncf_train_line(int station_group_id);
 
-const char* get_navigo_train_station(int station_group_id, int station_id);
+const char* get_navigo_sncf_station(int station_group_id, int station_id);
 
 const char* get_navigo_tram_line(int route_number);
 
@@ -27,15 +27,6 @@ void show_navigo_contract_info(NavigoCardContract* contract, FuriString* parsed_
 
 void show_navigo_environment_info(NavigoCardEnv* environment, FuriString* parsed_data);
 
-typedef enum {
-    BUS_URBAIN = 1,
-    BUS_INTERURBAIN = 2,
-    METRO = 3,
-    TRAM = 4,
-    TRAIN = 5,
-    PARKING = 8
-} NAVIGO_TRANSPORT_TYPE;
-
 typedef enum {
     NAVIGO_EASY = 0,
     NAVIGO_DECOUVERTE = 1,
@@ -44,4 +35,15 @@ typedef enum {
     IMAGINE_R = 14
 } NAVIGO_CARD_STATUS;
 
+typedef enum {
+    NAVIGO_PROVIDER_SNCF = 2,
+    NAVIGO_PROVIDER_RATP = 3,
+    NAVIGO_PROVIDER_IDFM = 4,
+    NAVIGO_PROVIDER_ORA = 8,
+    NAVIGO_PROVIDER_VEOLIA_CSO = 115,
+    NAVIGO_PROVIDER_VEOLIA_RBUS = 116,
+    NAVIGO_PROVIDER_PHEBUS = 156,
+    NAVIGO_PROVIDER_RATP_VEOLIA_SERVICE = 175
+} NAVIGO_SERVICE_PROVIDER;
+
 #endif // NAVIGO_H

+ 5 - 4
api/calypso/transit/navigo_lists.h

@@ -1,7 +1,7 @@
 #ifndef NAVIGO_LISTS_H
 #define NAVIGO_LISTS_H
 
-static const char* NAVIGO_METRO_STATION_LIST[32][16] =
+static const char* NAVIGO_RATP_LOCATION_LIST[32][16] =
     {[1] =
          {[0] = "Cite",
           [1] = "Saint-Michel",
@@ -323,7 +323,8 @@ static const char* NAVIGO_METRO_STATION_LIST[32][16] =
           [6] = "Le Kremlin-Bicetre",
           [7] = "Villejuif - Leo Lagrange",
           [8] = "Villejuif - Paul Vaillant-Couturier",
-          [9] = "Villejuif - Louis Aragon"},
+          [9] = "Villejuif - Louis Aragon",
+          [11] = "Villejuif - Institut Gustave Roussy"},
      [27] =
          {[0] = "Vanves",
           [2] = "Porte de Vanves",
@@ -373,7 +374,7 @@ static const char* NAVIGO_METRO_STATION_LIST[32][16] =
          [13] = "Place de Clichy",
          [14] = "La Fourche"}};
 
-static const char* NAVIGO_TRAIN_LINES_LIST[77] = {
+static const char* NAVIGO_SNCF_TRAIN_LINES_LIST[77] = {
     [1] = "RER B",         [3] = "RER B",         [6] = "RER A",         [14] = "RER B",
     [15] = "RER B",        [16] = "RER A",        [17] = "RER A",        [18] = "RER B",
     [20] = "Transilien P", [21] = "Transilien P", [22] = "T4",           [23] = "Transilien P",
@@ -386,7 +387,7 @@ static const char* NAVIGO_TRAIN_LINES_LIST[77] = {
     [64] = "RER C",        [65] = "Transilien V", [70] = "RER B",        [72] = "Transilien J",
     [73] = "Transilien J", [75] = "RER C",        [76] = "RER C"};
 
-static const char* NAVIGO_TRAIN_STATION_LIST[77][19] = {
+static const char* NAVIGO_SNCF_LOCATION_LIST[77][19] = {
     [1] = {[0] = "Châtelet-Les Halles", [1] = "Châtelet-Les Halles", [7] = "Luxembourg"},
     [3] = {[0] = "Saint-Michel Notre-Dame"},
     [6] = {[0] = "Auber", [6] = "Auber"},

+ 3 - 3
scenes/metroflip_scene_calypso.c

@@ -434,7 +434,7 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
                     card->navigo->environment.country_num = country_num;
                     card->navigo->environment.network_num = network_num;
 
-                    CalypsoApp* IntercodeEnvHolderStructure = get_intercode_env_holder_structure();
+                    CalypsoApp* IntercodeEnvHolderStructure = get_intercode_structure_env_holder();
 
                     // EnvApplicationVersionNumber
                     const char* env_key = "EnvApplicationVersionNumber";
@@ -499,7 +499,7 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
                     }
 
                     // Prepare calypso structure
-                    CalypsoApp* IntercodeContractStructure = get_intercode_contract_structure();
+                    CalypsoApp* IntercodeContractStructure = get_intercode_structure_contract();
                     if(!IntercodeContractStructure) {
                         FURI_LOG_E(TAG, "Failed to load Intercode Contract structure");
                         break;
@@ -804,7 +804,7 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
                     }
 
                     // Load the calypso structure for events
-                    CalypsoApp* IntercodeEventStructure = get_intercode_event_structure();
+                    CalypsoApp* IntercodeEventStructure = get_intercode_structure_event();
                     if(!IntercodeEventStructure) {
                         FURI_LOG_E(TAG, "Failed to load Intercode Event structure");
                         break;