Skip to content

Commit cb87ffa

Browse files
committed
Change size of buffer in FSQ functions to reduce memory usage
1 parent d08965e commit cb87ffa

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ Public Methods
187187
* Takes an arbitrary message and returns a FSQ channel symbol table.
188188
*
189189
* from_call - Callsign of issuing station (maximum size: 20)
190-
* message - Null-terminated message string, no greater than 200 chars in length
190+
* message - Null-terminated message string, no greater than 130 chars in length
191191
* symbols - Array of channel symbols to transmit retunred by the method.
192192
* Ensure that you pass a uint8_t array of at least the size of the message
193193
* plus 5 characters to the method. Terminated in 0xFF.
@@ -204,8 +204,8 @@ Public Methods
204204
*
205205
* from_call - Callsign from which message is directed (maximum size: 20)
206206
* to_call - Callsign to which message is directed (maximum size: 20)
207-
* cmd - Directed command (maximum size: 20)
208-
* message - Null-terminated message string, no greater than 200 chars in length
207+
* cmd - Directed command (maximum size: 10)
208+
* message - Null-terminated message string, no greater than 100 chars in length
209209
* symbols - Array of channel symbols to transmit retunred by the method.
210210
* Ensure that you pass a uint8_t array of at least the size of the message
211211
* plus 5 characters to the method. Terminated in 0xFF.

src/JTEncode.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,24 @@ void JTEncode::wspr_encode(String call, String loc, uint8_t dbm, uint8_t * symbo
238238
* Takes an arbitrary message and returns a FSQ channel symbol table.
239239
*
240240
* from_call - Callsign of issuing station (maximum size: 20)
241-
* message - Null-terminated message string, no greater than 200 chars in length
241+
* message - Null-terminated message string, no greater than 130 chars in length
242242
* symbols - Array of channel symbols to transmit retunred by the method.
243243
* Ensure that you pass a uint8_t array of at least the size of the message
244244
* plus 5 characters to the method. Terminated in 0xFF.
245245
*
246246
*/
247247
void JTEncode::fsq_encode(String from_call, String message, uint8_t * symbols)
248248
{
249-
char tx_buffer[255];
249+
char tx_buffer[155];
250250
char * tx_message;
251251
uint16_t symbol_pos = 0;
252252
uint8_t i, fch, vcode1, vcode2, tone;
253253
uint8_t cur_tone = 0;
254254

255+
// Clear out the transmit buffer
256+
// -----------------------------
257+
memset(tx_buffer, 0, 155);
258+
255259
// Create the message to be transmitted
256260
// ------------------------------------
257261
sprintf(tx_buffer, " \n%s: %s", from_call.c_str(), message.c_str());
@@ -314,26 +318,22 @@ void JTEncode::fsq_encode(String from_call, String message, uint8_t * symbols)
314318
}
315319

316320
/*
317-
* fsq_dir_encode(String from_call, String to_call, String cmd, String message, uint8_t * symbols)
321+
* fsq_dir_encode(String from_call, String to_call, char cmd, String message, uint8_t * symbols)
318322
*
319323
* Takes an arbitrary message and returns a FSQ channel symbol table.
320324
*
321325
* from_call - Callsign from which message is directed (maximum size: 20)
322326
* to_call - Callsign to which message is directed (maximum size: 20)
323-
* cmd - Directed command (maximum size: 20)
324-
* message - Null-terminated message string, no greater than 200 chars in length
327+
* cmd - Directed command
328+
* message - Null-terminated message string, no greater than 100 chars in length
325329
* symbols - Array of channel symbols to transmit retunred by the method.
326330
* Ensure that you pass a uint8_t array of at least the size of the message
327331
* plus 5 characters to the method. Terminated in 0xFF.
328332
*
329333
*/
330-
void JTEncode::fsq_dir_encode(String from_call, String to_call, String cmd, String message, uint8_t * symbols)
334+
void JTEncode::fsq_dir_encode(String from_call, String to_call, char cmd, String message, uint8_t * symbols)
331335
{
332-
//char from_call_array[20];
333-
//char to_call_array[20];
334-
//char cmd_array[20];
335-
//char message_array[200];
336-
char tx_buffer[255];
336+
char tx_buffer[155];
337337
char * tx_message;
338338
uint16_t symbol_pos = 0;
339339
uint8_t i, fch, vcode1, vcode2, tone, from_call_crc;
@@ -343,11 +343,15 @@ void JTEncode::fsq_dir_encode(String from_call, String to_call, String cmd, Stri
343343
// ---------------------------
344344
from_call_crc = crc8(from_call.c_str());
345345

346+
// Clear out the transmit buffer
347+
// -----------------------------
348+
memset(tx_buffer, 0, 155);
349+
346350
// Create the message to be transmitted
347351
// We are building a directed message here.
348352
// FSQ very specifically needs " \b " in
349353
// directed mode to indicate EOT. A single backspace won't do it.
350-
sprintf(tx_buffer, " \n%s:%02x%s%s%s%s", from_call.c_str(), from_call_crc, to_call.c_str(), cmd.c_str(), message.c_str(), " \b ");
354+
sprintf(tx_buffer, " \n%s:%02x%s%c%s%s", from_call.c_str(), from_call_crc, to_call.c_str(), cmd, message.c_str(), " \b ");
351355

352356
tx_message = tx_buffer;
353357

src/JTEncode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class JTEncode
194194
void jt4_encode(String, uint8_t *);
195195
void wspr_encode(String, String, uint8_t, uint8_t *);
196196
void fsq_encode(String, String, uint8_t *);
197-
void fsq_dir_encode(String, String, String, String, uint8_t *);
197+
void fsq_dir_encode(String, String, char, String, uint8_t *);
198198
private:
199199
uint8_t jt_code(char);
200200
uint8_t wspr_code(char);

0 commit comments

Comments
 (0)