@@ -150,7 +150,7 @@ static void process_comment (decode_aprs_t *A, char *pstart, int clen);
150
150
*
151
151
*------------------------------------------------------------------*/
152
152
153
- void decode_aprs (decode_aprs_t * A , packet_t pp , int quiet )
153
+ void decode_aprs (decode_aprs_t * A , packet_t pp , int quiet , int metric )
154
154
{
155
155
156
156
char dest [AX25_MAX_ADDR_LEN ];
@@ -163,6 +163,7 @@ void decode_aprs (decode_aprs_t *A, packet_t pp, int quiet)
163
163
memset (A , 0 , sizeof (* A ));
164
164
165
165
A -> g_quiet = quiet ;
166
+ A -> g_metric = metric ;
166
167
167
168
snprintf (A -> g_msg_type , sizeof (A -> g_msg_type ), "Unknown APRS Data Type Indicator \"%c\"" , * pinfo );
168
169
@@ -543,7 +544,11 @@ void decode_aprs_print (decode_aprs_t *A) {
543
544
char spd [20 ];
544
545
545
546
if (strlen (stemp ) > 0 ) strlcat (stemp , ", " , sizeof (stemp ));
546
- snprintf (spd , sizeof (spd ), "%.0f MPH" , A -> g_speed_mph );
547
+ if (A -> g_metric ) {
548
+ snprintf (spd , sizeof (spd ), "%.0f km/h" , DW_MILES_TO_KM (A -> g_speed_mph ));
549
+ } else {
550
+ snprintf (spd , sizeof (spd ), "%.0f MPH" , A -> g_speed_mph );
551
+ }
547
552
strlcat (stemp , spd , sizeof (stemp ));
548
553
};
549
554
@@ -559,7 +564,11 @@ void decode_aprs_print (decode_aprs_t *A) {
559
564
char alt [20 ];
560
565
561
566
if (strlen (stemp ) > 0 ) strlcat (stemp , ", " , sizeof (stemp ));
562
- snprintf (alt , sizeof (alt ), "alt %.0f ft" , A -> g_altitude_ft );
567
+ if (A -> g_metric ) {
568
+ snprintf (alt , sizeof (alt ), "alt %.0f m" , DW_FEET_TO_METERS (A -> g_altitude_ft ));
569
+ } else {
570
+ snprintf (alt , sizeof (alt ), "alt %.0f ft" , A -> g_altitude_ft );
571
+ }
563
572
strlcat (stemp , alt , sizeof (stemp ));
564
573
};
565
574
@@ -4719,6 +4728,7 @@ int main (int argc, char *argv[])
4719
4728
int num_bytes ;
4720
4729
char * p ;
4721
4730
packet_t pp ;
4731
+ int metric = 0 ;
4722
4732
4723
4733
#if __WIN32__
4724
4734
@@ -4879,7 +4889,7 @@ int main (int argc, char *argv[])
4879
4889
ax25_safe_print ((char * )pinfo , info_len , 1 ); // Display non-ASCII to hexadecimal.
4880
4890
dw_printf ("\n" );
4881
4891
4882
- decode_aprs (& A , pp , 0 ); // Extract information into structure.
4892
+ decode_aprs (& A , pp , 0 , metric ); // Extract information into structure.
4883
4893
4884
4894
decode_aprs_print (& A ); // Now print it in human readable format.
4885
4895
@@ -4900,9 +4910,9 @@ int main (int argc, char *argv[])
4900
4910
if (pp != NULL ) {
4901
4911
decode_aprs_t A ;
4902
4912
4903
- decode_aprs (& A , pp , 0 ); // Extract information into structure.
4913
+ decode_aprs (& A , pp , 0 , metric ); // Extract information into structure.
4904
4914
4905
- decode_aprs_print (& A ); // Now print it in human readable format.
4915
+ decode_aprs_print (& A ); // Now print it in human readable format.
4906
4916
4907
4917
// This seems to be redundant because we used strict option
4908
4918
// when parsing the monitoring format text.
0 commit comments