diff --git a/TODO.t2t b/TODO.t2t index 0617834..33914d0 100644 --- a/TODO.t2t +++ b/TODO.t2t @@ -21,13 +21,6 @@ Work to do in OwlPS - Known bugs: - libconfuse bug (Listener & Aggregator): http://bugs.debian.org/639115 -- Handle the aggregation format version - - In the aggregation files, a version number describing the file format - should be added (as the 2nd field, right after the client's MAC - address). That would allow the positioning server to handle several - formats instead of just the last version. - - Add a library to parse aggregation files, handling the different formats ? diff --git a/libowlps/owlps.h b/libowlps/owlps.h index 9758440..287729e 100644 --- a/libowlps/owlps.h +++ b/libowlps/owlps.h @@ -61,6 +61,12 @@ extern "C" { //@} +/** @name Miscellaneous informations */ +//@{ +#define OWL_LATEST_AGGREGATION_CSV_FORMAT 1 +//@} + + /// Directions enum owl_directions { diff --git a/owlps-aggregator/owlps-aggregatord.c b/owlps-aggregator/owlps-aggregatord.c index 311781d..821858b 100644 --- a/owlps-aggregator/owlps-aggregatord.c +++ b/owlps-aggregator/owlps-aggregatord.c @@ -1000,6 +1000,9 @@ void output_request(request_list *const request_ptr, owl_request_info info; request_info_list *request_info_ptr = NULL ; + // Print CSV format version to the output file + fprintf(stream, "%d;", OWL_LATEST_AGGREGATION_CSV_FORMAT) ; + // Print mobile MAC address to the output file owl_mac_bytes_to_string_r(request_ptr->mobile_mac_addr_bytes, mac_str) ; diff --git a/owlps-positioner/inputcsv.cc b/owlps-positioner/inputcsv.cc index fd2ab55..04e805b 100644 --- a/owlps-positioner/inputcsv.cc +++ b/owlps-positioner/inputcsv.cc @@ -44,6 +44,28 @@ bool InputCSV::fill_current_request() return false ; ++current_line_nb ; + // Read CSV format version + uint_fast16_t csv_format_version ; + if (! file.read_field(csv_format_version)) + { + // Wrong number of fields + if (Configuration::is_configured("verbose")) + cerr << "InputCSV: cannot read the CSV format version.\n" ; + return false ; + } + + // Check the CSV format + switch (csv_format_version) + { + case 1 : + // Format 1 is the only one we handle for now. + break ; + default : + cerr << "InputCSV: CSV format version " << csv_format_version + << " is not handled!\n" ; + return false ; + } + // Read Mobile MAC field string mac_mobile ; if (! file.read_field(mac_mobile)) // Wrong number of fields diff --git a/owlps-positioner/inputcsv.hh b/owlps-positioner/inputcsv.hh index bd17fe5..880e2ef 100644 --- a/owlps-positioner/inputcsv.hh +++ b/owlps-positioner/inputcsv.hh @@ -23,8 +23,9 @@ /// Reads [requests](@ref Request) from a CSV file /** * CSV format is: - * Mobile_MAC;Request_type;Number_of_packets;Timestamp;X;Y;Z;Direction; - * AP_MAC_1;Packet_ID_1;SS_1;…;AP_MAC_n;Packet_ID_n;SS_n + * Format_version;Mobile_MAC;Request_type;Number_of_packets; + * Timestamp;X;Y;Z;Direction;AP_MAC_1;Packet_ID_1;SS_1;…; + * AP_MAC_n;Packet_ID_n;SS_n */ class InputCSV: public InputMedium { diff --git a/owlps-positioner/request.cc b/owlps-positioner/request.cc index 9aa0b84..5e499b0 100644 --- a/owlps-positioner/request.cc +++ b/owlps-positioner/request.cc @@ -210,6 +210,12 @@ const string Request::to_csv() const { ostringstream csv_line ; + // CSV format version + // (this should match OWL_LATEST_AGGREGATION_CSV_FORMAT) + constexpr unsigned int aggregation_csv_format = 1 ; + + csv_line << aggregation_csv_format << ';' ; + if (mobile != NULL) csv_line << mobile->get_mac_addr() ;