diff options
Diffstat (limited to 'src/nmt/main.c')
-rw-r--r-- | src/nmt/main.c | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/src/nmt/main.c b/src/nmt/main.c index 7d4c91e..5a5715e 100644 --- a/src/nmt/main.c +++ b/src/nmt/main.c @@ -28,7 +28,7 @@ #include <sys/stat.h> #include "../libsample/sample.h" #include "../libmobile/main_mobile.h" -#include "../libdebug/debug.h" +#include "../liblogging/logging.h" #include "../liboptions/options.h" #include "nmt.h" #include "frame.h" @@ -55,6 +55,7 @@ int num_supervisory = 0; int supervisory[MAX_SENDER] = { 1 }; const char *smsc_number = "767"; int send_callerid = 0; +int send_clock = 0; void print_help(const char *arg0) { @@ -93,8 +94,10 @@ void print_help(const char *arg0) printf(" Message Service Center). (default = '%s')\n", smsc_number); printf(" -I --caller-id 1 | 0\n"); printf(" If set, the caller ID is sent while ringing the phone. (default = '%d')\n", send_callerid); - printf("\nstation-id: Give 7 digits of station-id, you don't need to enter it\n"); - printf(" for every start of this program.\n"); + printf(" -U --clock 1 | 0\n"); + printf(" If set, the current time is transmitted with CC. (default = '%d')\n", send_clock); + printf(" Note that this works only with pure CC, not with combined CC+TC.\n"); + main_mobile_print_station_id(); main_mobile_print_hotkeys(); } @@ -110,6 +113,7 @@ static void add_options(void) option_add('0', "supervisory", 1); option_add('S', "smsc-number", 1); option_add('I', "caller-id", 1); + option_add('U', "clock", 1); } static int handle_options(int short_option, int argi, char **argv) @@ -207,6 +211,9 @@ error_ta: case 'I': send_callerid = atoi(argv[argi]); break; + case 'U': + send_clock = atoi(argv[argi]); + break; default: return main_mobile_handle_options(short_option, argi, argv); } @@ -258,6 +265,11 @@ int submit_sms(const char *sms) return 0; } +static const struct number_lengths number_lengths[] = { + { 7, "NMT number (1st digit country code)" }, + { 0, NULL } +}; + int main(int argc, char *argv[]) { int rc, argi; @@ -269,7 +281,8 @@ int main(int argc, char *argv[]) init_nmt_tones(); init_announcement(); - main_mobile_init(); + /* init mobile interface */ + main_mobile_init("0123456789", number_lengths, NULL, NULL); /* handle options / config file */ add_options(); @@ -282,10 +295,9 @@ int main(int argc, char *argv[]) if (argi < argc) { station_id = argv[argi]; - if (strlen(station_id) != 7) { - printf("Given station ID '%s' does not have 7 digits\n", station_id); - return 0; - } + rc = main_mobile_number_ask(station_id, "station ID"); + if (rc) + return rc; } if (!num_kanal) { @@ -293,10 +305,10 @@ int main(int argc, char *argv[]) mandatory = 1; } if (use_sdr) { - /* set audiodev */ + /* set device */ for (i = 0; i < num_kanal; i++) - audiodev[i] = "sdr"; - num_audiodev = num_kanal; + dsp_device[i] = "sdr"; + num_device = num_kanal; /* set channel types for more than 1 channel */ if (num_kanal > 1 && num_chan_type == 0) { if (loopback) @@ -318,9 +330,9 @@ int main(int argc, char *argv[]) num_supervisory = num_kanal; } } - if (num_kanal == 1 && num_audiodev == 0) - num_audiodev = 1; /* use default */ - if (num_kanal != num_audiodev) { + if (num_kanal == 1 && num_device == 0) + num_device = 1; /* use default */ + if (num_kanal != num_device) { fprintf(stderr, "You need to specify as many sound devices as you have channels.\n"); return -EINVAL; } @@ -397,7 +409,7 @@ int main(int argc, char *argv[]) /* create transceiver instance */ for (i = 0; i < num_kanal; i++) { - rc = nmt_create(nmt_system, country, kanal[i], chan_type[i], audiodev[i], use_sdr, samplerate, rx_gain, tx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, ms_power, traffic_area, area_no, compandor, supervisory[i], smsc_number, send_callerid, loopback); + rc = nmt_create(nmt_system, country, kanal[i], chan_type[i], dsp_device[i], use_sdr, dsp_samplerate, rx_gain, tx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, ms_power, traffic_area, area_no, compandor, supervisory[i], smsc_number, send_callerid, send_clock, loopback); if (rc < 0) { fprintf(stderr, "Failed to create transceiver instance. Quitting!\n"); goto fail; @@ -407,7 +419,7 @@ int main(int argc, char *argv[]) nmt_check_channels(nmt_system); - main_mobile("nmt", &quit, latency, interval, myhandler, station_id, 7); + main_mobile_loop("nmt", &quit, myhandler, station_id); fail: /* fifo */ @@ -420,6 +432,7 @@ fail: nmt_destroy(sender_head); /* exits */ + main_mobile_exit(); fm_exit(); options_free(); |