diff options
Diffstat (limited to 'etisnoop.cpp')
-rw-r--r-- | etisnoop.cpp | 154 |
1 files changed, 153 insertions, 1 deletions
diff --git a/etisnoop.cpp b/etisnoop.cpp index 3876a78..19d4c3a 100644 --- a/etisnoop.cpp +++ b/etisnoop.cpp @@ -1,6 +1,7 @@ /* Copyright (C) 2014 CSP Innovazione nelle ICT s.c.a r.l. (http://www.csp.it/) Copyright (C) 2014 Matthias P. Braendli (http://www.opendigitalradio.org) + Copyright (C) 2015 Data Path This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,6 +22,9 @@ Authors: Sergio Sagliocco <sergio.sagliocco@csp.it> Matthias P. Braendli <matthias@mpb.li> + / | |- ')|) |-|_ _ (|,_ .| _ ,_ \ + Data Path \(|(||_(|/_| (||_||(a)_||||(|||.(_()|||/ + */ @@ -1701,6 +1705,154 @@ void decodeFIG(FIGalyser &figs, } } break; + case 11: // FIG 0/11 Region definition + { // ETSI EN 300 401 8.1.16.1 + Lat_Lng gps_pos = {0, 0}; + signed short Latitude_coarse, Longitude_coarse; + unsigned short Region_Id, Extent_Latitude, Extent_Longitude, key; + unsigned char i = 1, j, k, GATy, Rfu, Length_TII_list, Rfa, MainId, Length_SubId_list, SubId; + signed char bit_pos; + char tmpbuf[256]; + bool GE_flag; + + while (i < (figlen - 1)) { + // iterate over Region definition + GATy = f[i] >> 4; + GE_flag = (f[i] >> 3) & 0x01; + Region_Id = ((unsigned short)(f[i] & 0x07) << 8) | ((unsigned short)f[i+1]); + key = ((unsigned short)oe << 12) | ((unsigned short)pd << 11) | Region_Id; + i += 2; + if (GATy == 0) { + // TII list + sprintf(desc, "GATy=%d Geographical area defined by a TII list, G/E flag=%d %s coverage area, RegionId=0x%X, database key=0x%X", + GATy, GE_flag, GE_flag?"Global":"Ensemble", Region_Id, key); + if (i < figlen) { + Rfu = f[i] >> 5; + if (Rfu != 0) { + sprintf(tmpbuf, ", Rfu=%d invalid value", Rfu); + strcat(desc, tmpbuf); + } + Length_TII_list = f[i] & 0x1F; + sprintf(tmpbuf, ", Length of TII list=%d", Length_TII_list); + strcat(desc, tmpbuf); + if (Length_TII_list == 0) { + strcat(desc, ", CEI"); + } + printbuf(desc, indent+1, NULL, 0); + i++; + + for(j = 0;(i < (figlen - 1)) && (j < Length_TII_list); j++) { + // iterate over Transmitter group + Rfa = f[i] >> 7; + MainId = f[i] & 0x7F; + if (Rfa != 0) { + sprintf(desc, "Rfa=%d invalid value, MainId=0x%X", + Rfa, MainId); + } + else { + sprintf(desc, "MainId=0x%X", MainId); + } + // check MainId value + if ((Mode_Identity == 1) || (Mode_Identity == 2) || (Mode_Identity == 4)) { + if (MainId > 69) { + // The coding range shall be 0 to 69 for transmission modes I, II and IV + sprintf(tmpbuf, " invalid value for transmission mode %d", Mode_Identity); + strcat(desc, tmpbuf); + } + } + else if (Mode_Identity == 3) { + if (MainId > 5) { + // The coding range shall be 0 to 5 for transmission modes I, II and IV + sprintf(tmpbuf, " invalid value for transmission mode %d", Mode_Identity); + strcat(desc, tmpbuf); + } + } + Rfa = f[i+1] >> 5; + if (Rfa != 0) { + sprintf(tmpbuf, ", Rfa=%d invalid value", Rfa); + strcat(desc, tmpbuf); + } + Length_SubId_list = f[i+1] & 0x1F; + sprintf(tmpbuf, ", Length of SubId=%d", Length_SubId_list); + strcat(desc, tmpbuf); + printbuf(desc, indent+2, NULL, 0); + i += 2; + + bit_pos = 3; + SubId = 0; + for(k = 0;(i < figlen) && (k < Length_SubId_list); k++) { + // iterate SubId + // b7-3, b2-0 b7-6, b5-1, b0 b7-4, b3-0 b7, b6-2, b1-0 b7-5, b4-0, b7-3 + if (bit_pos >= 0) { + SubId |= (f[i] >> bit_pos) & 0x1F; + sprintf(desc, "SubId=0x%X", SubId); + // check SubId value + if ((SubId == 0) || (SubId > 23)) { + strcat(desc, " invalid value"); + } + printbuf(desc, indent+3, NULL, 0); + bit_pos -= 5; + SubId = 0; + } + if (bit_pos < 0) { + SubId = (f[i] << abs(bit_pos)) & 0x1F; + bit_pos += 8; + i++; + } + } + if (bit_pos > 3) { + // jump padding + i++; + } + if (k < Length_SubId_list) { + sprintf(desc, "%d SubId missing, fig length too short !", (Length_SubId_list - k)); + printbuf(desc, indent+3, NULL, 0); + } + } + if (j < Length_TII_list) { + sprintf(desc, "%d Transmitter group missing, fig length too short !", (Length_TII_list - j)); + printbuf(desc, indent+2, NULL, 0); + } + } + } + else if (GATy == 1) { + // Coordinates + sprintf(desc, "GATy=%d Geographical area defined as a spherical rectangle by the geographical co-ordinates of one corner and its latitude and longitude extents, G/E flag=%d %s coverage area, RegionId=0x%X, database key=0x%X", + GATy, GE_flag, GE_flag?"Global":"Ensemble", Region_Id, key); + if (i < (figlen - 6)) { + Latitude_coarse = ((signed short)f[i] << 8) | ((unsigned short)f[i+1]); + Longitude_coarse = ((signed short)f[i+2] << 8) | ((unsigned short)f[i+3]); + gps_pos.latitude = ((double)Latitude_coarse) * 90 / 32768; + gps_pos.longitude = ((double)Latitude_coarse) * 180 / 32768; + sprintf(tmpbuf, ", Lat Lng coarse=0x%X 0x%X => %f, %f", + Latitude_coarse, Longitude_coarse, gps_pos.latitude, gps_pos.longitude); + strcat(desc, tmpbuf); + Extent_Latitude = ((unsigned short)f[i+4] << 4) | ((unsigned short)(f[i+5] >> 4)); + Extent_Longitude = ((unsigned short)(f[i+5] & 0x0F) << 8) | ((unsigned short)f[i+6]); + gps_pos.latitude += ((double)Extent_Latitude) * 90 / 32768; + gps_pos.longitude += ((double)Extent_Longitude) * 180 / 32768; + sprintf(tmpbuf, ", Extent Lat Lng=0x%X 0x%X => %f, %f", + Extent_Latitude, Extent_Longitude, gps_pos.latitude, gps_pos.longitude); + strcat(desc, tmpbuf); + } + else { + sprintf(tmpbuf, ", Coordinates missing, fig length too short !"); + strcat(desc, tmpbuf); + } + printbuf(desc, indent+1, NULL, 0); + i += 7; + } + else { + // Rfu + sprintf(desc, "GATy=%d reserved for future use of the geographical, G/E flag=%d %s coverage area, RegionId=0x%X, database key=0x%X, stop Region definition iteration %d/%d", + GATy, GE_flag, GE_flag?"Global":"Ensemble", Region_Id, key, i, figlen); + printbuf(desc, indent+1, NULL, 0); + // stop Region definition iteration + i = figlen; + } + } + } + break; case 13: // FIG 0/13 User application information { // ETSI EN 300 401 8.1.20 uint32_t SId; @@ -2286,7 +2438,7 @@ void decodeFIG(FIGalyser &figs, sprintf(desc, "M/S=%d %sidentifier, MainId=0x%X", MS, MS?"Sub-":"Main ", MainId); // check MainId value - if ((Mode_Identity == 1) || (Mode_Identity == 2) || (MainId == 4)) { + if ((Mode_Identity == 1) || (Mode_Identity == 2) || (Mode_Identity == 4)) { if (MainId > 69) { // The coding range shall be 0 to 69 for transmission modes I, II and IV sprintf(tmpbuf, " invalid value for transmission mode %d", Mode_Identity); |