@@ -405,6 +405,7 @@ static int cse_spd_data_extension (int course, int speed, char *presult)
405405 * Purpose: Put frequency specification in beginning of comment field.
406406 *
407407 * Inputs: freq - MHz.
408+ * tone_type - T/Tone, C/Tone Squelch, D/DCS
408409 * tone - Hz.
409410 * offset - MHz.
410411 *
@@ -430,7 +431,7 @@ static int cse_spd_data_extension (int course, int speed, char *presult)
430431 *----------------------------------------------------------------*/
431432
432433
433- static int frequency_spec (float freq , float tone , float offset , char * presult )
434+ static int frequency_spec (float freq , char tone_type , float tone , float offset , char * presult )
434435{
435436 int result_size = 24 ; // TODO: add as parameter.
436437
@@ -456,7 +457,15 @@ static int frequency_spec (float freq, float tone, float offset, char *presult)
456457 strlcpy (stemp , "Toff " , sizeof (stemp ));
457458 }
458459 else {
459- snprintf (stemp , sizeof (stemp ), "T%03d " , (int )tone );
460+ /* Tone enabled */
461+ if (tone_type == 'T' || tone_type == 'C' || tone_type == 'D' ) {
462+ /* CTCSS Tone or DCS Code*/
463+ snprintf (stemp , sizeof (stemp ), "%c%03d " , tone_type , (int )tone );
464+ } else {
465+ /* Error */
466+ text_color_set (DW_COLOR_ERROR );
467+ dw_printf ("Invalid tone type\n" );
468+ }
460469 }
461470
462471 strlcat (presult , stemp , result_size );
@@ -499,6 +508,7 @@ static int frequency_spec (float freq, float tone, float offset, char *presult)
499508 * speed - knots. // TODO: should distinguish unknown(not revevant) vs. known zero.
500509 *
501510 * freq - MHz.
511+ * tone_type - T/C/D
502512 * tone - Hz.
503513 * offset - MHz.
504514 *
@@ -544,7 +554,7 @@ int encode_position (int messaging, int compressed, double lat, double lon, int
544554 char symtab , char symbol ,
545555 int power , int height , int gain , char * dir ,
546556 int course , int speed ,
547- float freq , float tone , float offset ,
557+ float freq , char tone_type , float tone , float offset ,
548558 char * comment ,
549559 char * presult , size_t result_size )
550560{
@@ -590,7 +600,7 @@ int encode_position (int messaging, int compressed, double lat, double lon, int
590600/* Optional frequency spec. */
591601
592602 if (freq != 0 || tone != 0 || offset != 0 ) {
593- result_len += frequency_spec (freq , tone , offset , presult + result_len );
603+ result_len += frequency_spec (freq , tone_type , tone , offset , presult + result_len );
594604 }
595605
596606 presult [result_len ] = '\0' ;
@@ -658,6 +668,7 @@ int encode_position (int messaging, int compressed, double lat, double lon, int
658668 * speed - knots.
659669 *
660670 * freq - MHz.
671+ * tone_type - T/C/D
661672 * tone - Hz.
662673 * offset - MHz.
663674 *
@@ -695,7 +706,7 @@ int encode_object (char *name, int compressed, time_t thyme, double lat, double
695706 char symtab , char symbol ,
696707 int power , int height , int gain , char * dir ,
697708 int course , int speed ,
698- float freq , float tone , float offset , char * comment ,
709+ float freq , char tone_type , float tone , float offset , char * comment ,
699710 char * presult , size_t result_size )
700711{
701712 aprs_object_t * p = (aprs_object_t * ) presult ;
@@ -761,7 +772,7 @@ int encode_object (char *name, int compressed, time_t thyme, double lat, double
761772/* Optional frequency spec. */
762773
763774 if (freq != 0 || tone != 0 || offset != 0 ) {
764- result_len += frequency_spec (freq , tone , offset , presult + result_len );
775+ result_len += frequency_spec (freq , tone_type , tone , offset , presult + result_len );
765776 }
766777
767778 presult [result_len ] = '\0' ;
@@ -865,58 +876,58 @@ int main (int argc, char *argv[])
865876/*********** Position ***********/
866877
867878 encode_position (0 , 0 , 42 + 34.61 /60 , - (71 + 26.47 /60 ), 0 , G_UNKNOWN , 'D' , '&' ,
868- 0 , 0 , 0 , NULL , G_UNKNOWN , 0 , 0 , 0 , 0 , NULL , result , sizeof (result ));
879+ 0 , 0 , 0 , NULL , G_UNKNOWN , 0 , 0 , 'T' , 0 , 0 , NULL , result , sizeof (result ));
869880 dw_printf ("%s\n" , result );
870881 if (strcmp (result , "!4234.61ND07126.47W&" ) != 0 ) { dw_printf ("ERROR! line %d\n" , __LINE__ ); errors ++ ; }
871882
872883/* with PHG. */
873884// TODO: Need to test specifying some but not all.
874885
875886 encode_position (0 , 0 , 42 + 34.61 /60 , - (71 + 26.47 /60 ), 0 , G_UNKNOWN , 'D' , '&' ,
876- 50 , 100 , 6 , "N" , G_UNKNOWN , 0 , 0 , 0 , 0 , NULL , result , sizeof (result ));
887+ 50 , 100 , 6 , "N" , G_UNKNOWN , 0 , 0 , 'T' , 0 , 0 , NULL , result , sizeof (result ));
877888 dw_printf ("%s\n" , result );
878889 if (strcmp (result , "!4234.61ND07126.47W&PHG7368" ) != 0 ) { dw_printf ("ERROR! line %d\n" , __LINE__ ); errors ++ ; }
879890
880891/* with freq & tone. minus offset, no offset, explicit simplex. */
881892
882893 encode_position (0 , 0 , 42 + 34.61 /60 , - (71 + 26.47 /60 ), 0 , G_UNKNOWN , 'D' , '&' ,
883- 0 , 0 , 0 , NULL , G_UNKNOWN , 0 , 146.955 , 74.4 , -0.6 , NULL , result , sizeof (result ));
894+ 0 , 0 , 0 , NULL , G_UNKNOWN , 0 , 146.955 , 'T' , 74.4 , -0.6 , NULL , result , sizeof (result ));
884895 dw_printf ("%s\n" , result );
885896 if (strcmp (result , "!4234.61ND07126.47W&146.955MHz T074 -060 " ) != 0 ) { dw_printf ("ERROR! line %d\n" , __LINE__ ); errors ++ ; }
886897
887898 encode_position (0 , 0 , 42 + 34.61 /60 , - (71 + 26.47 /60 ), 0 , G_UNKNOWN , 'D' , '&' ,
888- 0 , 0 , 0 , NULL , G_UNKNOWN , 0 , 146.955 , 74.4 , G_UNKNOWN , NULL , result , sizeof (result ));
899+ 0 , 0 , 0 , NULL , G_UNKNOWN , 0 , 146.955 , 'T' , 74.4 , G_UNKNOWN , NULL , result , sizeof (result ));
889900 dw_printf ("%s\n" , result );
890901 if (strcmp (result , "!4234.61ND07126.47W&146.955MHz T074 " ) != 0 ) { dw_printf ("ERROR! line %d\n" , __LINE__ ); errors ++ ; }
891902
892903 encode_position (0 , 0 , 42 + 34.61 /60 , - (71 + 26.47 /60 ), 0 , G_UNKNOWN , 'D' , '&' ,
893- 0 , 0 , 0 , NULL , G_UNKNOWN , 0 , 146.955 , 74.4 , 0 , NULL , result , sizeof (result ));
904+ 0 , 0 , 0 , NULL , G_UNKNOWN , 0 , 146.955 , 'T' , 74.4 , 0 , NULL , result , sizeof (result ));
894905 dw_printf ("%s\n" , result );
895906 if (strcmp (result , "!4234.61ND07126.47W&146.955MHz T074 +000 " ) != 0 ) { dw_printf ("ERROR! line %d\n" , __LINE__ ); errors ++ ; }
896907
897908/* with course/speed, freq, and comment! */
898909
899910 encode_position (0 , 0 , 42 + 34.61 /60 , - (71 + 26.47 /60 ), 0 , G_UNKNOWN , 'D' , '&' ,
900- 0 , 0 , 0 , NULL , 180 , 55 , 146.955 , 74.4 , -0.6 , "River flooding" , result , sizeof (result ));
911+ 0 , 0 , 0 , NULL , 180 , 55 , 146.955 , 'T' , 74.4 , -0.6 , "River flooding" , result , sizeof (result ));
901912 dw_printf ("%s\n" , result );
902913 if (strcmp (result , "!4234.61ND07126.47W&180/055146.955MHz T074 -060 River flooding" ) != 0 ) { dw_printf ("ERROR! line %d\n" , __LINE__ ); errors ++ ; }
903914
904915/* Course speed, no tone, + offset */
905916
906917 encode_position (0 , 0 , 42 + 34.61 /60 , - (71 + 26.47 /60 ), 0 , G_UNKNOWN , 'D' , '&' ,
907- 0 , 0 , 0 , NULL , 180 , 55 , 146.955 , G_UNKNOWN , 0.6 , "River flooding" , result , sizeof (result ));
918+ 0 , 0 , 0 , NULL , 180 , 55 , 146.955 , 'T' , G_UNKNOWN , 0.6 , "River flooding" , result , sizeof (result ));
908919 dw_printf ("%s\n" , result );
909920 if (strcmp (result , "!4234.61ND07126.47W&180/055146.955MHz +060 River flooding" ) != 0 ) { dw_printf ("ERROR! line %d\n" , __LINE__ ); errors ++ ; }
910921
911922/* Course speed, no tone, + offset + altitude */
912923
913924 encode_position (0 , 0 , 42 + 34.61 /60 , - (71 + 26.47 /60 ), 0 , 12345 , 'D' , '&' ,
914- 0 , 0 , 0 , NULL , 180 , 55 , 146.955 , G_UNKNOWN , 0.6 , "River flooding" , result , sizeof (result ));
925+ 0 , 0 , 0 , NULL , 180 , 55 , 146.955 , 'T' , G_UNKNOWN , 0.6 , "River flooding" , result , sizeof (result ));
915926 dw_printf ("%s\n" , result );
916927 if (strcmp (result , "!4234.61ND07126.47W&180/055146.955MHz +060 /A=012345River flooding" ) != 0 ) { dw_printf ("ERROR! line %d\n" , __LINE__ ); errors ++ ; }
917928
918929 encode_position (0 , 0 , 42 + 34.61 /60 , - (71 + 26.47 /60 ), 0 , 12345 , 'D' , '&' ,
919- 0 , 0 , 0 , NULL , 180 , 55 , 146.955 , 0 , 0.6 , "River flooding" , result , sizeof (result ));
930+ 0 , 0 , 0 , NULL , 180 , 55 , 146.955 , 'T' , 0 , 0.6 , "River flooding" , result , sizeof (result ));
920931 dw_printf ("%s\n" , result );
921932 if (strcmp (result , "!4234.61ND07126.47W&180/055146.955MHz Toff +060 /A=012345River flooding" ) != 0 ) { dw_printf ("ERROR! line %d\n" , __LINE__ ); errors ++ ; }
922933
@@ -925,22 +936,22 @@ int main (int argc, char *argv[])
925936/*********** Compressed position. ***********/
926937
927938 encode_position (0 , 1 , 42 + 34.61 /60 , - (71 + 26.47 /60 ), 0 , G_UNKNOWN , 'D' , '&' ,
928- 0 , 0 , 0 , NULL , G_UNKNOWN , 0 , 0 , 0 , 0 , NULL , result , sizeof (result ));
939+ 0 , 0 , 0 , NULL , G_UNKNOWN , 0 , 0 , 'T' , 0 , 0 , NULL , result , sizeof (result ));
929940 dw_printf ("%s\n" , result );
930941 if (strcmp (result , "!D8yKC<Hn[& !" ) != 0 ) { dw_printf ("ERROR! line %d\n" , __LINE__ ); errors ++ ; }
931942
932943
933944/* with PHG. In this case it is converted to precomputed radio range. TODO: check on this. Is 27.4 correct? */
934945
935946 encode_position (0 , 1 , 42 + 34.61 /60 , - (71 + 26.47 /60 ), 0 , G_UNKNOWN , 'D' , '&' ,
936- 50 , 100 , 6 , "N" , G_UNKNOWN , 0 , 0 , 0 , 0 , NULL , result , sizeof (result ));
947+ 50 , 100 , 6 , "N" , G_UNKNOWN , 0 , 0 , 'T' , 0 , 0 , NULL , result , sizeof (result ));
937948 dw_printf ("%s\n" , result );
938949 if (strcmp (result , "!D8yKC<Hn[&{CG" ) != 0 ) { dw_printf ("ERROR! line %d\n" , __LINE__ ); errors ++ ; }
939950
940951/* with course/speed, freq, and comment! Roundoff. 55 knots should be 63 MPH. we get 62. */
941952
942953 encode_position (0 , 1 , 42 + 34.61 /60 , - (71 + 26.47 /60 ), 0 , G_UNKNOWN , 'D' , '&' ,
943- 0 , 0 , 0 , NULL , 180 , 55 , 146.955 , 74.4 , -0.6 , "River flooding" , result , sizeof (result ));
954+ 0 , 0 , 0 , NULL , 180 , 55 , 146.955 , 'T' , 74.4 , -0.6 , "River flooding" , result , sizeof (result ));
944955 dw_printf ("%s\n" , result );
945956 if (strcmp (result , "!D8yKC<Hn[&NUG146.955MHz T074 -060 River flooding" ) != 0 ) { dw_printf ("ERROR! line %d\n" , __LINE__ ); errors ++ ; }
946957
@@ -950,7 +961,7 @@ int main (int argc, char *argv[])
950961/*********** Object. ***********/
951962
952963 encode_object ("WB1GOF-C" , 0 , 0 , 42 + 34.61 /60 , - (71 + 26.47 /60 ), 0 , 'D' , '&' ,
953- 0 , 0 , 0 , NULL , G_UNKNOWN , 0 , 0 , 0 , 0 , NULL , result , sizeof (result ));
964+ 0 , 0 , 0 , NULL , G_UNKNOWN , 0 , 0 , 'T' , 0 , 0 , NULL , result , sizeof (result ));
954965 dw_printf ("%s\n" , result );
955966 if (strcmp (result , ";WB1GOF-C *111111z4234.61ND07126.47W&" ) != 0 ) { dw_printf ("ERROR! line %d\n" , __LINE__ ); errors ++ ; }
956967
0 commit comments