Skip to content

Commit

Permalink
Change size of buffer in FSQ functions to reduce memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
NT7S committed Jul 10, 2016
1 parent d08965e commit cb87ffa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Public Methods
* Takes an arbitrary message and returns a FSQ channel symbol table.
*
* from_call - Callsign of issuing station (maximum size: 20)
* message - Null-terminated message string, no greater than 200 chars in length
* message - Null-terminated message string, no greater than 130 chars in length
* symbols - Array of channel symbols to transmit retunred by the method.
* Ensure that you pass a uint8_t array of at least the size of the message
* plus 5 characters to the method. Terminated in 0xFF.
Expand All @@ -204,8 +204,8 @@ Public Methods
*
* from_call - Callsign from which message is directed (maximum size: 20)
* to_call - Callsign to which message is directed (maximum size: 20)
* cmd - Directed command (maximum size: 20)
* message - Null-terminated message string, no greater than 200 chars in length
* cmd - Directed command (maximum size: 10)
* message - Null-terminated message string, no greater than 100 chars in length
* symbols - Array of channel symbols to transmit retunred by the method.
* Ensure that you pass a uint8_t array of at least the size of the message
* plus 5 characters to the method. Terminated in 0xFF.
Expand Down
28 changes: 16 additions & 12 deletions src/JTEncode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,24 @@ void JTEncode::wspr_encode(String call, String loc, uint8_t dbm, uint8_t * symbo
* Takes an arbitrary message and returns a FSQ channel symbol table.
*
* from_call - Callsign of issuing station (maximum size: 20)
* message - Null-terminated message string, no greater than 200 chars in length
* message - Null-terminated message string, no greater than 130 chars in length
* symbols - Array of channel symbols to transmit retunred by the method.
* Ensure that you pass a uint8_t array of at least the size of the message
* plus 5 characters to the method. Terminated in 0xFF.
*
*/
void JTEncode::fsq_encode(String from_call, String message, uint8_t * symbols)
{
char tx_buffer[255];
char tx_buffer[155];
char * tx_message;
uint16_t symbol_pos = 0;
uint8_t i, fch, vcode1, vcode2, tone;
uint8_t cur_tone = 0;

// Clear out the transmit buffer
// -----------------------------
memset(tx_buffer, 0, 155);

// Create the message to be transmitted
// ------------------------------------
sprintf(tx_buffer, " \n%s: %s", from_call.c_str(), message.c_str());
Expand Down Expand Up @@ -314,26 +318,22 @@ void JTEncode::fsq_encode(String from_call, String message, uint8_t * symbols)
}

/*
* fsq_dir_encode(String from_call, String to_call, String cmd, String message, uint8_t * symbols)
* fsq_dir_encode(String from_call, String to_call, char cmd, String message, uint8_t * symbols)
*
* Takes an arbitrary message and returns a FSQ channel symbol table.
*
* from_call - Callsign from which message is directed (maximum size: 20)
* to_call - Callsign to which message is directed (maximum size: 20)
* cmd - Directed command (maximum size: 20)
* message - Null-terminated message string, no greater than 200 chars in length
* cmd - Directed command
* message - Null-terminated message string, no greater than 100 chars in length
* symbols - Array of channel symbols to transmit retunred by the method.
* Ensure that you pass a uint8_t array of at least the size of the message
* plus 5 characters to the method. Terminated in 0xFF.
*
*/
void JTEncode::fsq_dir_encode(String from_call, String to_call, String cmd, String message, uint8_t * symbols)
void JTEncode::fsq_dir_encode(String from_call, String to_call, char cmd, String message, uint8_t * symbols)
{
//char from_call_array[20];
//char to_call_array[20];
//char cmd_array[20];
//char message_array[200];
char tx_buffer[255];
char tx_buffer[155];
char * tx_message;
uint16_t symbol_pos = 0;
uint8_t i, fch, vcode1, vcode2, tone, from_call_crc;
Expand All @@ -343,11 +343,15 @@ void JTEncode::fsq_dir_encode(String from_call, String to_call, String cmd, Stri
// ---------------------------
from_call_crc = crc8(from_call.c_str());

// Clear out the transmit buffer
// -----------------------------
memset(tx_buffer, 0, 155);

// Create the message to be transmitted
// We are building a directed message here.
// FSQ very specifically needs " \b " in
// directed mode to indicate EOT. A single backspace won't do it.
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 ");
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 ");

tx_message = tx_buffer;

Expand Down
2 changes: 1 addition & 1 deletion src/JTEncode.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class JTEncode
void jt4_encode(String, uint8_t *);
void wspr_encode(String, String, uint8_t, uint8_t *);
void fsq_encode(String, String, uint8_t *);
void fsq_dir_encode(String, String, String, String, uint8_t *);
void fsq_dir_encode(String, String, char, String, uint8_t *);
private:
uint8_t jt_code(char);
uint8_t wspr_code(char);
Expand Down

0 comments on commit cb87ffa

Please sign in to comment.