aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2020-04-04 16:34:39 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2020-04-04 16:34:39 +0200
commit6b07d8b2740702ea2798cd9be6cf39f408c4886e (patch)
treeff5101474f99876fc4d660495efa6ffc292c2141
parentfa6a73a2e16e9bf43f827c91bc93fd9f02124cc6 (diff)
A string is used to define what digits can be dialed via console
By default it is "0123456789". This is used by "eurosignal" to add special A..E digits.
-rw-r--r--src/eurosignal/main.c2
-rw-r--r--src/libmncc/mncc_console.c33
-rw-r--r--src/libmncc/mncc_console.h2
-rw-r--r--src/libmobile/main_mobile.c5
-rw-r--r--src/libmobile/main_mobile.h1
-rw-r--r--src/libsdr/sdr_config.c2
-rw-r--r--src/radio/main.c2
7 files changed, 29 insertions, 18 deletions
diff --git a/src/eurosignal/main.c b/src/eurosignal/main.c
index c5a9579..88f63bc 100644
--- a/src/eurosignal/main.c
+++ b/src/eurosignal/main.c
@@ -177,6 +177,8 @@ int main(int argc, char *argv[])
init_es_teilges();
init_es_kaudn();
+ /* init mobile interface */
+ console_digits = "0123456789ABCDE";
main_mobile_init();
/* handle options / config file */
diff --git a/src/libmncc/mncc_console.c b/src/libmncc/mncc_console.c
index 06d5778..599dad7 100644
--- a/src/libmncc/mncc_console.c
+++ b/src/libmncc/mncc_console.c
@@ -75,9 +75,10 @@ typedef struct console {
int test_audio_pos; /* position for test tone toward mobile */
sample_t tx_buffer[160];/* transmit audio buffer */
int tx_buffer_pos; /* current position in transmit audio buffer */
- int dial_digits; /* number of digits to be dialed */
+ int num_digits; /* number of digits to be dialed */
int loopback; /* loopback test for echo */
int echo_test; /* send echo back to mobile phone */
+ const char *digits; /* list of dialable digits */
} console_t;
static console_t console;
@@ -187,8 +188,8 @@ static int console_mncc_up(uint8_t *buf, int length)
}
console.callref = mncc->callref;
if (mncc->calling.number[0]) {
- strncpy(console.station_id, mncc->calling.number, console.dial_digits);
- console.station_id[console.dial_digits] = '\0';
+ strncpy(console.station_id, mncc->calling.number, console.num_digits);
+ console.station_id[console.num_digits] = '\0';
}
strncpy(console.dialing, mncc->called.number, sizeof(console.dialing) - 1);
console.dialing[sizeof(console.dialing) - 1] = '\0';
@@ -205,8 +206,8 @@ static int console_mncc_up(uint8_t *buf, int length)
case MNCC_SETUP_CNF:
PDEBUG(DMNCC, DEBUG_INFO, "Call connected to '%s'\n", mncc->connected.number);
console_new_state(CONSOLE_CONNECT);
- strncpy(console.station_id, mncc->connected.number, console.dial_digits);
- console.station_id[console.dial_digits] = '\0';
+ strncpy(console.station_id, mncc->connected.number, console.num_digits);
+ console.station_id[console.num_digits] = '\0';
/* send down reused MNCC */
mncc->msg_type = MNCC_SETUP_COMPL_REQ;
mncc_down(buf, length);
@@ -249,7 +250,7 @@ static void _print_console_text(void)
printf("\033[0;39m");
}
-int console_init(const char *station_id, const char *audiodev, int samplerate, int latency, int dial_digits, int loopback, int echo_test)
+int console_init(const char *station_id, const char *audiodev, int samplerate, int latency, int num_digits, int loopback, int echo_test, const char *digits)
{
int rc = 0;
@@ -263,9 +264,10 @@ int console_init(const char *station_id, const char *audiodev, int samplerate, i
strncpy(console.audiodev, audiodev, sizeof(console.audiodev) - 1);
console.samplerate = samplerate;
console.latspl = latency * samplerate / 1000;
- console.dial_digits = dial_digits;
+ console.num_digits = num_digits;
console.loopback = loopback;
console.echo_test = echo_test;
+ console.digits = digits;
mncc_up = console_mncc_up;
@@ -339,18 +341,23 @@ static void process_ui(int c)
{
char text[256];
int len;
+ int i;
switch (console.state) {
case CONSOLE_IDLE:
if (c > 0) {
- if (c >= '0' && c <= '9' && (int)strlen(console.station_id) < console.dial_digits) {
- console.station_id[strlen(console.station_id) + 1] = '\0';
- console.station_id[strlen(console.station_id)] = c;
+ if ((int)strlen(console.station_id) < console.num_digits) {
+ for (i = 0; i < (int)strlen(console.digits); i++) {
+ if (c == console.digits[i]) {
+ console.station_id[strlen(console.station_id) + 1] = '\0';
+ console.station_id[strlen(console.station_id)] = c;
+ }
+ }
}
if ((c == 8 || c == 127) && strlen(console.station_id))
console.station_id[strlen(console.station_id) - 1] = '\0';
dial_after_hangup:
- if (c == 'd' && (int)strlen(console.station_id) == console.dial_digits) {
+ if (c == 'd' && (int)strlen(console.station_id) == console.num_digits) {
int callref = ++new_callref;
uint8_t buf[sizeof(struct gsm_mncc)];
struct gsm_mncc *mncc = (struct gsm_mncc *)buf;
@@ -372,8 +379,8 @@ dial_after_hangup:
mncc_down(buf, sizeof(struct gsm_mncc));
}
}
- if (console.dial_digits != (int)strlen(console.station_id))
- sprintf(text, "on-hook: %s%s (enter digits 0..9)\r", console.station_id, "..............." + 15 - console.dial_digits + strlen(console.station_id));
+ if (console.num_digits != (int)strlen(console.station_id))
+ sprintf(text, "on-hook: %s%s (enter digits 0..9)\r", console.station_id, "..............." + 15 - console.num_digits + strlen(console.station_id));
else
sprintf(text, "on-hook: %s (press d=dial)\r", console.station_id);
break;
diff --git a/src/libmncc/mncc_console.h b/src/libmncc/mncc_console.h
index 7a80d97..9ec1aaa 100644
--- a/src/libmncc/mncc_console.h
+++ b/src/libmncc/mncc_console.h
@@ -1,5 +1,5 @@
-int console_init(const char *station_id, const char *audiodev, int samplerate, int latency, int dial_digits, int loopback, int echo_test);
+int console_init(const char *station_id, const char *audiodev, int samplerate, int latency, int dial_digits, int loopback, int echo_test, const char *digits);
void console_cleanup(void);
int console_open_audio(int latspl);
int console_start_audio(void);
diff --git a/src/libmobile/main_mobile.c b/src/libmobile/main_mobile.c
index ac3ac61..2ae7bf7 100644
--- a/src/libmobile/main_mobile.c
+++ b/src/libmobile/main_mobile.c
@@ -76,6 +76,7 @@ const char *write_tx_wave = NULL;
const char *write_rx_wave = NULL;
const char *read_tx_wave = NULL;
const char *read_rx_wave = NULL;
+const char *console_digits = "0123456789";
void main_mobile_init(void)
{
@@ -473,7 +474,7 @@ void main_mobile(int *quit, int latency, int interval, void (*myhandler)(void),
return;
}
} else {
- console_init(station_id, call_audiodev, call_samplerate, latency, station_id_digits, loopback, echo_test);
+ console_init(station_id, call_audiodev, call_samplerate, latency, station_id_digits, loopback, echo_test, console_digits);
}
/* init call control instance */
@@ -617,7 +618,7 @@ next_char:
dump_info();
goto next_char;
#ifdef HAVE_SDR
- case 'B':
+ case 'b':
calibrate_bias();
goto next_char;
#endif
diff --git a/src/libmobile/main_mobile.h b/src/libmobile/main_mobile.h
index 9742f6d..aa6625c 100644
--- a/src/libmobile/main_mobile.h
+++ b/src/libmobile/main_mobile.h
@@ -20,6 +20,7 @@ extern const char *write_rx_wave;
extern const char *write_tx_wave;
extern const char *read_rx_wave;
extern const char *read_tx_wave;
+extern const char *console_digits;
void main_mobile_init(void);
void main_mobile_print_help(const char *arg0, const char *ext_usage);
diff --git a/src/libsdr/sdr_config.c b/src/libsdr/sdr_config.c
index 960d718..df138ae 100644
--- a/src/libsdr/sdr_config.c
+++ b/src/libsdr/sdr_config.c
@@ -102,7 +102,7 @@ void sdr_config_print_hotkeys(void)
{
printf("Press 'q' key to toggle display of RX I/Q vector.\n");
printf("Press 's' key to toggle display of RX spectrum.\n");
- printf("Press shift + 'B' key to remove DC level.\n");
+ printf("Press 'b' key to remove DC level.\n");
}
#define OPT_SDR_UHD 1500
diff --git a/src/radio/main.c b/src/radio/main.c
index 5cae0be..6b3ba59 100644
--- a/src/radio/main.c
+++ b/src/radio/main.c
@@ -482,7 +482,7 @@ next_char:
display_spectrum_on(0);
display_wave_on(-1);
goto next_char;
- case 'B':
+ case 'b':
calibrate_bias();
goto next_char;
}