@@ -49,6 +49,7 @@ JTEncode::JTEncode(void)
4949{
5050 // Initialize the Reed-Solomon encoder
5151 rs_inst = (struct rs *)(intptr_t )init_rs_int (6 , 0x43 , 3 , 1 , 51 , 0 );
52+ memset (callsign, 0 , 12 );
5253}
5354
5455/*
@@ -189,11 +190,10 @@ void JTEncode::jt4_encode(const char * msg, uint8_t * symbols)
189190/*
190191 * wspr_encode(const char * call, const char * loc, const uint8_t dbm, uint8_t * symbols)
191192 *
192- * Takes a callsign, grid locator, and power level and returns a WSPR symbol
193- * table for a Type 1, 2, or 3 message.
193+ * Takes an arbitrary message of up to 13 allowable characters and returns
194194 *
195- * call - Callsign (11 characters maximum).
196- * loc - Maidenhead grid locator (6 characters maximum).
195+ * call - Callsign (6 characters maximum).
196+ * loc - Maidenhead grid locator (4 characters maximum).
197197 * dbm - Output power in dBm.
198198 * symbols - Array of channel symbols to transmit returned by the method.
199199 * Ensure that you pass a uint8_t array of at least size WSPR_SYMBOL_COUNT to the method.
@@ -814,14 +814,14 @@ void JTEncode::wspr_bit_packing(uint8_t * c)
814814 if (callsign[0 ] == ' <' )
815815 {
816816 // Type 3 message
817- char base_call[7 ];
818- memset (base_call, 0 , 7 );
817+ char base_call[12 ];
818+ memset (base_call, 0 , 12 );
819819 uint32_t init_val = 146 ;
820820 char * bracket_avail = strchr (callsign, (int )' >' );
821821 int call_len = bracket_avail - callsign - 1 ;
822822 strncpy (base_call, callsign + 1 , call_len);
823823 uint32_t hash = nhash_ (base_call, &call_len, &init_val);
824- uint16_t call_hash = hash & 32767 ;
824+ hash &= 32767 ;
825825
826826 // Convert 6 char grid square to "callsign" format for transmission
827827 // by putting the first character at the end
@@ -840,7 +840,7 @@ void JTEncode::wspr_bit_packing(uint8_t * c)
840840 n = n * 27 + (wspr_code (locator[4 ]) - 10 );
841841 n = n * 27 + (wspr_code (locator[5 ]) - 10 );
842842
843- m = (call_hash * 128 ) - (power + 1 ) + 64 ;
843+ m = (hash * 128 ) - (power + 1 ) + 64 ;
844844 }
845845 else if (slash_avail == (void *)0 )
846846 {
@@ -870,7 +870,7 @@ void JTEncode::wspr_bit_packing(uint8_t * c)
870870 char base_call[7 ];
871871 memset (base_call, 0 , 7 );
872872 strncpy (base_call, callsign, slash_pos);
873- for (i = 0 ; i < 6 ; i++)
873+ for (i = 0 ; i < 7 ; i++)
874874 {
875875 base_call[i] = toupper (base_call[i]);
876876 if (!(isdigit (base_call[i]) || isupper (base_call[i])))
@@ -904,7 +904,6 @@ void JTEncode::wspr_bit_packing(uint8_t * c)
904904 m = 60000 - 32768 + x;
905905
906906 m = (m * 128 ) + power + 2 + 64 ;
907-
908907 }
909908 else if (callsign[slash_pos + 3 ] == ' ' || callsign[slash_pos + 3 ] == 0 )
910909 {
0 commit comments