pocsag: Add option to change text message padding character
This commit is contained in:
@@ -237,7 +237,7 @@ static uint32_t encode_alpha(pocsag_msg_t *msg)
|
||||
|
||||
/* fill remaining digit space with 0x04 (EOT) */
|
||||
while (bits <= 13) {
|
||||
word = (word << 7) | 0x10;
|
||||
word = (word << 7) | msg->padding;
|
||||
bits += 7;
|
||||
}
|
||||
|
||||
|
@@ -50,6 +50,7 @@ static double polarity = -1;
|
||||
static int polarity_given = 0;
|
||||
static enum pocsag_function function = POCSAG_FUNCTION_NUMERIC;
|
||||
static const char *message = "1234";
|
||||
static char padding = 4;
|
||||
static enum pocsag_language language = LANGUAGE_DEFAULT;
|
||||
static uint32_t scan_from = 0;
|
||||
static uint32_t scan_to = 0;
|
||||
@@ -87,6 +88,8 @@ void print_help(const char *arg0)
|
||||
printf(" time. The upper 5 digits of the RIC are sent as message, if numeric\n");
|
||||
printf(" function was selected. The upper 3 digits of the RIC are sent as\n");
|
||||
printf(" message (2 digits hexadecimal), if alphanumeric function was selected.\n");
|
||||
printf(" --padding 4 | 0 | ...\n");
|
||||
printf(" Text message padding uses 4 (EOT) by default. Old pagers want 0 (NUL).\n");
|
||||
printf("\n");
|
||||
printf("File: %s\n", MSG_SEND);
|
||||
printf(" Write \"<ric>,0,message\" to it to send a numerical message.\n");
|
||||
@@ -97,6 +100,8 @@ void print_help(const char *arg0)
|
||||
main_mobile_print_hotkeys();
|
||||
}
|
||||
|
||||
#define OPT_PADDING 256
|
||||
|
||||
static void add_options(void)
|
||||
{
|
||||
main_mobile_add_options();
|
||||
@@ -109,6 +114,7 @@ static void add_options(void)
|
||||
option_add('M', "message", 1);
|
||||
option_add('L', "language", 0);
|
||||
option_add('S', "scan", 2);
|
||||
option_add(OPT_PADDING, "padding", 1);
|
||||
}
|
||||
|
||||
static int handle_options(int short_option, int argi, char **argv)
|
||||
@@ -188,6 +194,9 @@ static int handle_options(int short_option, int argi, char **argv)
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
case OPT_PADDING:
|
||||
padding = atoi(argv[argi++]);
|
||||
break;
|
||||
default:
|
||||
return main_mobile_handle_options(short_option, argi, argv);
|
||||
}
|
||||
@@ -343,7 +352,7 @@ int main(int argc, char *argv[])
|
||||
printf("Invalid channel '%s', Use '-k list' to get a list of all channels.\n\n", kanal[i]);
|
||||
goto fail;
|
||||
}
|
||||
rc = pocsag_create(kanal[i], frequency, dsp_device[i], use_sdr, dsp_samplerate, rx_gain, tx_gain, tx, rx, language, baudrate, deviation, polarity, function, message, scan_from, scan_to, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback);
|
||||
rc = pocsag_create(kanal[i], frequency, dsp_device[i], use_sdr, dsp_samplerate, rx_gain, tx_gain, tx, rx, language, baudrate, deviation, polarity, function, message, padding, scan_from, scan_to, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
|
||||
goto fail;
|
||||
|
@@ -228,6 +228,7 @@ static pocsag_msg_t *pocsag_msg_create(pocsag_t *pocsag, uint32_t callref, uint3
|
||||
msg->repeat = 0;
|
||||
strncpy(msg->data, text, sizeof(msg->data));
|
||||
msg->data_length = (strlen(text) < sizeof(msg->data)) ? strlen(text) : sizeof(msg->data);
|
||||
msg->padding = pocsag->padding;
|
||||
|
||||
/* link */
|
||||
msg->pocsag = pocsag;
|
||||
@@ -340,7 +341,7 @@ void pocsag_msg_receive(enum pocsag_language language, const char *channel, uint
|
||||
}
|
||||
|
||||
/* Create transceiver instance and link to a list. */
|
||||
int pocsag_create(const char *kanal, double frequency, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int tx, int rx, enum pocsag_language language, int baudrate, double deviation, double polarity, enum pocsag_function function, const char *message, uint32_t scan_from, uint32_t scan_to, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback)
|
||||
int pocsag_create(const char *kanal, double frequency, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int tx, int rx, enum pocsag_language language, int baudrate, double deviation, double polarity, enum pocsag_function function, const char *message, char padding, uint32_t scan_from, uint32_t scan_to, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback)
|
||||
{
|
||||
pocsag_t *pocsag;
|
||||
int rc;
|
||||
@@ -374,6 +375,7 @@ int pocsag_create(const char *kanal, double frequency, const char *device, int u
|
||||
pocsag->default_message = message;
|
||||
pocsag->scan_from = scan_from;
|
||||
pocsag->scan_to = scan_to;
|
||||
pocsag->padding = padding;
|
||||
|
||||
pocsag_display_status();
|
||||
|
||||
|
@@ -34,6 +34,7 @@ typedef struct pocsag_msg {
|
||||
int data_index; /* current character transmitting */
|
||||
int bit_index; /* current bit transmitting */
|
||||
int repeat; /* how often the message is sent */
|
||||
char padding; /* EOT or other padding */
|
||||
} pocsag_msg_t;
|
||||
|
||||
/* instance of pocsag transmitter/receiver */
|
||||
@@ -46,6 +47,7 @@ typedef struct pocsag {
|
||||
enum pocsag_language language; /* special characters */
|
||||
enum pocsag_function default_function; /* default function, if not given by caller */
|
||||
const char *default_message; /* default message, if caller has no caller ID */
|
||||
char padding; /* EOT or other padding */
|
||||
|
||||
/* tx states */
|
||||
enum pocsag_state state; /* state (idle, preamble, message) */
|
||||
@@ -98,7 +100,7 @@ int pocsag_init(void);
|
||||
void pocsag_exit(void);
|
||||
void pocsag_new_state(pocsag_t *pocsag, enum pocsag_state new_state);
|
||||
void pocsag_msg_receive(enum pocsag_language language, const char *channel, uint32_t ric, enum pocsag_function function, const char *message);
|
||||
int pocsag_create(const char *kanal, double frequency, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int tx, int rx, enum pocsag_language language, int baudrate, double deviation, double polarity, enum pocsag_function function, const char *message, uint32_t scan_from, uint32_t scan_to, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback);
|
||||
int pocsag_create(const char *kanal, double frequency, const char *device, int use_sdr, int samplerate, double rx_gain, double tx_gain, int tx, int rx, enum pocsag_language language, int baudrate, double deviation, double polarity, enum pocsag_function function, const char *message, char padding, uint32_t scan_from, uint32_t scan_to, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback);
|
||||
void pocsag_destroy(sender_t *sender);
|
||||
void pocsag_msg_send(enum pocsag_language language, const char *text);
|
||||
void pocsag_msg_destroy(pocsag_msg_t *msg);
|
||||
|
Reference in New Issue
Block a user