NMT-900 System implementation
NMT can now be run as 450 or 900 Network.
This commit is contained in:
@@ -44,9 +44,10 @@
|
||||
static int sms_deliver_fd = -1;
|
||||
|
||||
/* settings */
|
||||
int nmt_system = 450;
|
||||
int num_chan_type = 0;
|
||||
enum nmt_chan_type chan_type[MAX_SENDER] = { CHAN_TYPE_CC_TC };
|
||||
int ms_power = 1; /* 1..3 */
|
||||
int ms_power = 1; /* 0..3 */
|
||||
char country[16] = "";
|
||||
char traffic_area[3] = "";
|
||||
char area_no = 0;
|
||||
@@ -58,13 +59,19 @@ int send_callerid = 0;
|
||||
|
||||
void print_help(const char *arg0)
|
||||
{
|
||||
print_help_common(arg0, "-Y <traffic area> | list [-I 1] [-0 1] ");
|
||||
print_help_common(arg0, "[-N 900] -Y <traffic area> | list [-I 1] [-0 1] ");
|
||||
/* - - */
|
||||
printf(" -N --nmt-system 450/900\n");
|
||||
printf(" Give NMT type as first paramer. (default = '%d')\n", nmt_system);
|
||||
printf(" Note: This option must be given at first!\n");
|
||||
printf(" -T --channel-type <channel type> | list\n");
|
||||
printf(" Give channel type, use 'list' to get a list. (default = '%s')\n", chan_type_short_name(chan_type[0]));
|
||||
printf(" Give channel type, use 'list' to get a list. (default = '%s')\n", chan_type_short_name(nmt_system, chan_type[0]));
|
||||
printf(" -P --ms-power <power level>\n");
|
||||
printf(" Give power level of the mobile station 1..3. (default = '%d')\n", ms_power);
|
||||
printf(" 3 = 15 W / 7 W (handheld), 2 = 1.5 W, 1 = 150 mW\n");
|
||||
printf(" Give power level of the mobile station 0..3. (default = '%d')\n", ms_power);
|
||||
if (nmt_system == 450)
|
||||
printf(" NMT-450: 3 = 15 W / 7 W (handheld), 2 = 1.5 W, 1/0 = 150 mW\n");
|
||||
else
|
||||
printf(" NMT-900: 3/2 = 6 W, 1 = 1.5 W, 0 = 150 mW\n");
|
||||
printf(" -Y --traffic-area <traffic area> | list\n");
|
||||
printf(" NOTE: MUST MATCH WITH YOUR ROAMING SETTINGS IN THE PHONE!\n");
|
||||
printf(" Your phone will not connect, if country code is different!\n");
|
||||
@@ -97,6 +104,7 @@ static int handle_options(int argc, char **argv)
|
||||
int skip_args = 0;
|
||||
|
||||
static struct option long_options_special[] = {
|
||||
{"nmt-system", 1, 0, 'N'},
|
||||
{"channel-type", 1, 0, 'T'},
|
||||
{"ms-power", 1, 0, 'P'},
|
||||
{"traffic-area", 1, 0, 'Y'},
|
||||
@@ -108,10 +116,11 @@ static int handle_options(int argc, char **argv)
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
set_options_common("T:P:Y:A:C:0:S:I:", long_options_special);
|
||||
set_options_common("N:T:P:Y:A:C:0:S:I:", long_options_special);
|
||||
|
||||
while (1) {
|
||||
int option_index = 0, c, rc;
|
||||
static int first_option = 1;
|
||||
|
||||
c = getopt_long(argc, argv, optstring, long_options, &option_index);
|
||||
|
||||
@@ -119,12 +128,26 @@ static int handle_options(int argc, char **argv)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 'T':
|
||||
if (!strcmp(optarg, "list")) {
|
||||
nmt_channel_list();
|
||||
case 'N':
|
||||
nmt_system = atoi(optarg);
|
||||
if (nmt_system != 450 && nmt_system != 900) {
|
||||
fprintf(stderr, "Error, NMT system type '%s' unknown. Please use '-N 450' for NMT-450 or '-N 900' for NMT-900.\n", optarg);
|
||||
exit(0);
|
||||
}
|
||||
rc = nmt_channel_by_short_name(optarg);
|
||||
if (nmt_system == 900)
|
||||
ms_power = 0;
|
||||
if (!first_option) {
|
||||
fprintf(stderr, "Please specify the NMT system (-N) as first command line option!\n");
|
||||
exit(0);
|
||||
}
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'T':
|
||||
if (!strcmp(optarg, "list")) {
|
||||
nmt_channel_list(nmt_system);
|
||||
exit(0);
|
||||
}
|
||||
rc = nmt_channel_by_short_name(nmt_system, optarg);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Error, channel type '%s' unknown. Please use '-t list' to get a list. I suggest to use the default.\n", optarg);
|
||||
exit(0);
|
||||
@@ -136,14 +159,14 @@ static int handle_options(int argc, char **argv)
|
||||
ms_power = atoi(optarg);
|
||||
if (ms_power > 3)
|
||||
ms_power = 3;
|
||||
if (ms_power < 1)
|
||||
ms_power = 1;
|
||||
if (ms_power < 0)
|
||||
ms_power = 0;
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'Y':
|
||||
|
||||
if (!strcmp(optarg, "list")) {
|
||||
nmt_country_list();
|
||||
nmt_country_list(nmt_system);
|
||||
exit(0);
|
||||
}
|
||||
/* digits */
|
||||
@@ -155,7 +178,7 @@ static int handle_options(int argc, char **argv)
|
||||
exit(0);
|
||||
}
|
||||
*p++ = '\0';
|
||||
rc = nmt_country_by_short_name(country);
|
||||
rc = nmt_country_by_short_name(nmt_system, country);
|
||||
if (rc < 0) {
|
||||
error_ta:
|
||||
fprintf(stderr, "Invalid traffic area '%s', use '-Y list' for a list of valid areas\n", optarg);
|
||||
@@ -163,7 +186,7 @@ error_ta:
|
||||
}
|
||||
traffic_area[0] = rc + '0';
|
||||
if (p[strlen(p) - 1] != '!') {
|
||||
rc = nmt_ta_by_short_name(country, atoi(p));
|
||||
rc = nmt_ta_by_short_name(nmt_system, country, atoi(p));
|
||||
if (rc < 0)
|
||||
goto error_ta;
|
||||
}
|
||||
@@ -203,6 +226,7 @@ error_ta:
|
||||
default:
|
||||
opt_switch_common(c, argv[0], &skip_args);
|
||||
}
|
||||
first_option = 0;
|
||||
}
|
||||
|
||||
free(long_options);
|
||||
@@ -378,15 +402,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* create transceiver instance */
|
||||
for (i = 0; i < num_kanal; i++) {
|
||||
rc = nmt_create(country, kanal[i], (loopback) ? CHAN_TYPE_TEST : chan_type[i], audiodev[i], use_sdr, samplerate, rx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, ms_power, nmt_digits2value(traffic_area, 2), area_no, compandor, supervisory[i], smsc_number, send_callerid, loopback);
|
||||
rc = nmt_create(nmt_system, country, kanal[i], (loopback) ? CHAN_TYPE_TEST : chan_type[i], audiodev[i], use_sdr, samplerate, rx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, ms_power, nmt_digits2value(traffic_area, 2), area_no, compandor, supervisory[i], smsc_number, send_callerid, loopback);
|
||||
if (rc < 0) {
|
||||
fprintf(stderr, "Failed to create transceiver instance. Quitting!\n");
|
||||
goto fail;
|
||||
}
|
||||
printf("base station on channel %d ready, please tune transmitter to %.4f MHz and receiver to %.4f MHz.\n", kanal[i], nmt_channel2freq(country, kanal[i], 0, NULL, NULL, NULL) / 1e6, nmt_channel2freq(country, kanal[i], 1, NULL, NULL, NULL) / 1e6);
|
||||
printf("base station on channel %d ready, please tune transmitter to %.4f MHz and receiver to %.4f MHz.\n", kanal[i], nmt_channel2freq(nmt_system, country, kanal[i], 0, NULL, NULL, NULL) / 1e6, nmt_channel2freq(nmt_system, country, kanal[i], 1, NULL, NULL, NULL) / 1e6);
|
||||
}
|
||||
|
||||
nmt_check_channels();
|
||||
nmt_check_channels(nmt_system);
|
||||
|
||||
main_common(&quit, latency, interval, myhandler, station_id, 7);
|
||||
|
||||
|
Reference in New Issue
Block a user