Changed command line options

* All lower case options define common options
* All upper case options define network specific options
This commit is contained in:
Andreas Eversberg 2016-11-27 06:47:06 +01:00
parent f911717aa4
commit b1c452cf12
28 changed files with 213 additions and 185 deletions

View File

@ -201,7 +201,7 @@ Tune the transmitter to 162.050 MHz and the receiver to 157.550 MHz.
You should tune the receiver to 164.050 MHz first, to check if you hear the idle signal from the base station.
Then tune to actually up-link frequency 157.550 MHz.
The actual level is not yet relevant.
(You may check the quality using '-L 2' command line option and build a radio loop by tuning the receiver to the transmitter.)
(You may check the quality using '-l 2' or '--loopback' command line option and build a radio loop by tuning the receiver to the transmitter.)
</p>
<pre>
@ -254,7 +254,7 @@ Be sure that the phone turns off the transmitter and indicates the (green) light
<p>
Level adjustment:
We see a receive level of around 140%.
Then start the base station using '-L 2' option for loop-back and tune receiver to the transmitter.
Then start the base station using '-l 2' option for loop-back and tune receiver to the transmitter.
The base station generates a 1750 Hz test signal, just like the mobile phone.
Use the variable resistor (connecting your transmitter) to adjust the volume until the received level matches the same level of your previously received signal.
In my case I adjust the transmitter to match around 140%. (+- 10% is good)

View File

@ -86,7 +86,7 @@ Setup of a base station
<pre>
# amps -k 334 -F yes -E -e
# amps -k 334 -F yes -p -d
...
Selected System ID (SID) 40 belongs to:
Salinas, CA (GTE Mobile)
@ -110,7 +110,7 @@ frame.c:3658 info : RX Level: 52% Quality: 60% Polarity: NEGATIVE
You should tune the receiver to 880.020 first, to check if you can hear and decode the idle signal from the base station.
Then tune to actually uplink frequency 835.020 MHz.
The actual level is not yet relevant.
(You may check the quality using '-L 2' command line option and build a radio loop by tuning the receiver to the transmitter.)
(You may check the quality using '-l 2' or '--loopback 2' command line option and build a radio loop by tuning the receiver to the transmitter.)
</p>
<pre>

View File

@ -121,6 +121,7 @@ All digit starts with sync pattern ("0 1 1 1 0").
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0 1 1 1 0|0 1 0 0 0|1|0 0 0 1 0| Funkwahl ohne Geb&uuml;hren&uuml;bermittlung
|0 1 1 1 0|0 0 1 0 0|1|0 0 1 0 0| Funkwahl mit Geb&uuml;hren&uuml;bermittlung
|0 1 1 1 0|0 0 0 1 0|1|0 1 0 0 0| Funkwahl mit Geb&uuml;hren&uuml;bermittlung (Payphone)
|0 1 1 1 0|1 0 0 0 0|1|0 0 0 0 1| Funkwahlende
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@ -514,7 +515,7 @@ But you get a busy signal, that means there is no channel.
<p>
Now run your base station on channel 1.
You may add '-g x' or '--gfs x' command line option to change the station ID from default to any value you like. (see help)
You may add '-G x' or '--gfs x' command line option to change the station ID from default to any value you like. (see help)
If you have a phone that supports GFS 19, please use this GFS 19 to reduce the transmit power of the phone to 100 mW instead of 15 Watts.
To see if your phone supports it, try to preselect GFS 19.
Tune the transmitter to 153.010 MHz and the receiver to 148.410 MHz.
@ -698,7 +699,7 @@ Detecting loss of carrier signal:
We do not have any RSSI (Received Signal Strength Indicator) signal from our radio, so we cannot directly find out if the signal is lost.
But we have a constant noise level when the signal is lost.
Be sure to have squelch on your receiver all the way open, so that noise reaches the base station.
In order to see this level, use command line option '-0 100 -D 0' or '--loss 100 --debug 0'.
In order to see this level, use command line option '-L 100 -v 0' or '--loss 100 --verbose 0'.
The noise level (relative to the sound card's input level) is shown:
</p>
@ -710,8 +711,8 @@ loss.c:74 debug : Noise level = 22%
<p>
Since we have a noise level of about 20%, we can use a threshold of 10%.
Use command line option '-0 10' in this case.
To see the process, keep debugging on by using command line option '-D 0'.
Use command line option '-L 10' in this case.
To see the process, keep debugging on by using command line option '-v 0'.
Whenever the noise level is above the given percentage, loss of carrier is assumed, if the noise level is constant.
If the noise level changes (due to speech), the noise is ignored and the loss counter is reset.
After a system specific duration of signal loss, the call is released.

View File

@ -384,7 +384,7 @@ To run the base station I the following command line options:
<pre>
# cnetz -k 131 -E -e -S 19.25,19.25
# cnetz -k 131 -p -d -S 19.25,19.25
...
cnetz.c:142 notice : You selected channel 131 ('Orga-Kanal') for combined callin
g + traffic channel. Some phones will reject this.
@ -409,7 +409,7 @@ After the call has been terminated, the control channel is restored and the othe
You should tune the receiver to 465.090 first, to check if you can hear and decode the idle signal from the base station.
Then tune to actually up-link frequency 455.090 MHz.
The actual level is not yet relevant.
(You may check the quality using '-L 2' command line option and build a radio loop by tuning the receiver to the transmitter.)
(You may check the quality using '-l 2' or '--loopback 2' command line option and build a radio loop by tuning the receiver to the transmitter.)
</p>
<p>

View File

@ -64,7 +64,7 @@ To calibrate input level (microphone), run the B-Netz base station with loop-bac
<pre>
# src/bnetz/bnetz -k 1 -L 3 -c hw:2,0
# src/bnetz/bnetz -k 1 -l 3 -c hw:2,0
bnetz.c:268 info : Entering IDLE state, sending 'Gruppenfreisignal' 2 on channel 1.
Base station ready, please tune transmitter to 153.010 MHz and receiver to 148.410 MHz.
To call phone, switch transmitter using pilot tone to 153.370 MHz

View File

@ -73,7 +73,7 @@ Implemented networks:
<center>
<ul>
<li><a href="a-netz.html">A-Netz</a> (Germany)</li>
<li><a href="b-netz.html">B-Netz</a> (Germany)</li>
<li><a href="b-netz.html">B-Netz</a> (Germany) ATF-1 (Netherlands)</li>
<li><a href="c-netz.html">C-Netz</a> (Germany)</li>
<li><a href="nmt.html">NMT - Nordic Mobile Telephone</a> (Scandinavia)</li>
<li><a href="amps.html">AMPS - Advanced Mobile Phone Service</a> (USA)</li>

View File

@ -51,7 +51,7 @@ Now you are ready for a quick test:
<pre>
# src/bnetz/bnetz -k 1 -L 2
# src/bnetz/bnetz -k 1 -l 2
bnetz.c:268 info : Entering IDLE state, sending 'Gruppenfreisignal' 2 on channel 1.
Base station ready, please tune transmitter to 153.010 MHz and receiver to 148.410 MHz.
To call phone, switch transmitter using pilot tone to 153.370 MHz

View File

@ -546,7 +546,7 @@ Check out what networks are available:
<pre>
# nmt -y list
# nmt -Y list
TA Short Country (Provider)
------------------------------------------------------------------------
5 DK Denmark (Tele Danmark Mobile)
@ -563,7 +563,7 @@ TA Short Country (Provider)
<p>
In this example we select 'Sweden'.
You must set you phone to network 'Sweden' or 'SE'.
Then use the command line parameter '-y SE,1' or '--traffic-area SE,1' to select cell area 1 in Sweden.
Then use the command line parameter '-Y SE,1' or '--traffic-area SE,1' to select cell area 1 in Sweden.
In this example we set the two digits 'traffic area' to 61.
If the phone was not in this area recently, it will send roaming update, as soon as it finds our network.
</p>
@ -583,7 +583,7 @@ Use a traffic are of 'SE,2', so the phone registers, if it was previously regist
<pre>
nmt -k 1 -y SE,2
nmt -k 1 -Y SE,2
nmt.c:278 info : Selecting country code 6 of SE,Sweden (provider 'Telia Mobitel')
...
nmt.c:402 info : Entering IDLE state, sending idle frames on combined calling &amp; traffic channel.

View File

@ -55,12 +55,12 @@ To call phone, switch transmitter (using pilot signal) to 153.370 MHz.
<p>
Alternatively select a different sound adapter.
If you prefer card 2, device 0, add '-d hw:2,0' or '--device hw:2,0' to the command line:
If you prefer card 2, device 0, add '-a hw:2,0' or '--audio-device hw:2,0' to the command line:
</p>
<pre>
# src/bnetz/bnetz -k 1 -d hw:2,0
# src/bnetz/bnetz -k 1 -a hw:2,0
</pre>
@ -83,13 +83,13 @@ Do not use input gain on the microphone.
<p>
Now we want to calibrate transmitter and receiver audio level.
Run the B-Netz base station in loopback test mode (-L 2).
Run the B-Netz base station in loopback test mode (-l 2).
Even if you plan to setup A-Netz base station, use B-Netz base station for calibration.
</p>
<pre>
# src/bnetz/bnetz -k 1 -L 2
# src/bnetz/bnetz -k 1 -l 2
bnetz.c:268 info : Entering IDLE state, sending 'Gruppenfreisignal' 2 on channel 1.
Base station ready, please tune transmitter to 153.010 MHz and receiver to 148.410 MHz.
To call phone, switch transmitter (using pilot signal) to 153.370 MHz.
@ -155,7 +155,7 @@ Use the command line option '-x' or '--cross':
<pre>
# src/bnetz/bnetz -k 1 -x -L 2
# src/bnetz/bnetz -k 1 -x -l 2
bnetz.c:268 info : Entering IDLE state, sending 'Gruppenfreisignal' 2 on channel 1.
Base station ready, please tune transmitter to 153.010 MHz and receiver to 148.410 MHz.
To call phone, switch transmitter (using pilot signal) to 153.370 MHz.
@ -186,7 +186,7 @@ A frequency of 2000 Hz is lowered down to half of it's amplitude (-6 db), so it
<p>
Generally a transmitter is doing pre-emphasis for you.
If you are connected directly to the PLL of your transmitter, you will also not have pre-emphasis.
In this case you need to do it inside the base station software. Use the command line option '-E' or '--pre-emphasis':
In this case you need to do it inside the base station software. Use the command line option '-p' or '--pre-emphasis':
</p>
<pre>
@ -198,7 +198,7 @@ In this case you need to do it inside the base station software. Use the command
<p>
The receiver is doing the de-emphasis for you.
If you are connected directly to the discriminator of your receiver, you will also not have de-emphasis.
In this case you need to do it inside the base station software. Use the command line option '-e' or '--de-emphasis':
In this case you need to do it inside the base station software. Use the command line option '-d' or '--de-emphasis':
</p>
<pre>
@ -216,13 +216,13 @@ Especially if you use discriminator output, you might have low output voltage.
In my experiments it helps to amplify the amplitude by factor two in order adjust a received signal to 100%.
A gain of 6 dB will amplify the amplitude by factor two.
Also the noise of the sound adapter will be amplified by factor two, but this is not relevant at 16 bit resolution.
Use the command line option '-G 6' or '--rx-gain 6'.
Use the command line option '-g 6' or '--rx-gain 6'.
In this example I use both, transmitter and receiver without emphasis (so software must do it) and add extra 6 dB gain to the input from the receiver:
</p>
<pre>
# src/bnetz/bnetz -k 1 -E -e -G 6
# src/bnetz/bnetz -k 1 -p -d -g 6
</pre>
@ -235,7 +235,7 @@ As used before, the loop-back test can be used to verify the signal process, suc
</p>
<p>
If command line option '-L 1' or '--loopback 1' is given, a loop-back inside the software is performed.
If command line option '-l 1' or '--loopback 1' is given, a loop-back inside the software is performed.
Also the audio signal is sent to the audio adapter, but not received from it.
This test is used to debug the software.
It can be used to see what the output of an external loop would look like.
@ -243,7 +243,7 @@ It can be used to see what the output of an external loop would look like.
<pre>
./bnetz/bnetz -k 1 -L 1
./bnetz/bnetz -k 1 -l 1
bnetz.c:351 info : Entering IDLE state, sending 'Gruppenfreisignal' 2.
Base station for channel 1 ready, please tune transmitter to 153.010 MHz and receiver to 148.410 MHz.
To call phone, switch transmitter (using pilot signal) to 153.370 MHz.
@ -266,13 +266,13 @@ bnetz.c:528 notice : Round trip delay is 0.001 seconds
</pre>
<p>
If command line option '-L 2' or '--loopback 2' is given, an external loop-back is performed.
If command line option '-l 2' or '--loopback 2' is given, an external loop-back is performed.
The receiver needs to be tuned to transmitter, so the software receives its own signal.
The received quality level is relevant. It should be not less than 90 for B-Netz.
</p>
<p>
If command line option '-L 3' or '--loopback 3' is given, the audio from the input is sent back to the output.
If command line option '-l 3' or '--loopback 3' is given, the audio from the input is sent back to the output.
It can be used to check a headset.
Everything that is spoken into the microphone should appear on the headphone.
</p>

View File

@ -356,7 +356,7 @@ static amps_t *search_pc(void)
static void amps_go_idle(amps_t *amps);
/* Create transceiver instance and link to a list. */
int amps_create(int channel, enum amps_chan_type chan_type, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback)
int amps_create(int channel, enum amps_chan_type chan_type, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback)
{
sender_t *sender;
amps_t *amps;
@ -422,7 +422,7 @@ int amps_create(int channel, enum amps_chan_type chan_type, const char *sounddev
PDEBUG(DAMPS, DEBUG_DEBUG, "Creating 'AMPS' instance for channel = %d (sample rate %d).\n", channel, samplerate);
/* init general part of transceiver */
rc = sender_create(&amps->sender, channel, sounddev, samplerate, cross_channels, rx_gain, 0, 0, write_wave, read_wave, loopback, 0, PILOT_SIGNAL_NONE);
rc = sender_create(&amps->sender, channel, sounddev, samplerate, cross_channels, rx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, loopback, 0, PILOT_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error;

View File

@ -163,7 +163,7 @@ const char *amps_min12number(uint32_t min1);
void amps_number2min(const char *number, uint32_t *min1, uint16_t *min2);
const char *amps_min2number(uint32_t min1, uint16_t min2);
const char *amps_scm(uint8_t scm);
int amps_create(int channel, enum amps_chan_type chan_type, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback);
int amps_create(int channel, enum amps_chan_type chan_type, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, amps_si *si, uint16_t sid, uint8_t sat, int polarity, int tolerant, int loopback);
void amps_destroy(sender_t *sender);
void amps_rx_signaling_tone(amps_t *amps, int tone, double quality);
void amps_rx_sat(amps_t *amps, int tone, double quality);

View File

@ -47,9 +47,9 @@ int tolerant = 0;
void print_help(const char *arg0)
{
print_help_common(arg0, "-E -e -F yes | no ");
print_help_common(arg0, "-p -d -F yes | no ");
/* - - */
printf(" -t --channel-type <channel type> | list\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(" -F --flip-polarity no | yes\n");
printf(" Flip polarity of transmitted FSK signal. If yes, the sound card\n");
@ -85,7 +85,7 @@ void print_help(const char *arg0)
printf(" -S --sysinfo bis=0 | bis=1\n");
printf(" If 0, phone ignores BUSY/IDLE bit on FOCC (default = '%d')\n", bis);
printf(" If 1, be sure to have a round-trip delay (latency) not more than 5 ms\n");
printf(" -T --tolerant\n");
printf(" -O --tolerant\n");
printf(" Be more tolerant when hunting for sync sequence\n");
printf("\nstation-id: Give 10 digit station-id, you don't need to enter it for every\n");
printf(" start of this program.\n");
@ -98,15 +98,15 @@ static int handle_options(int argc, char **argv)
int rc;
static struct option long_options_special[] = {
{"channel-type", 1, 0, 't'},
{"channel-type", 1, 0, 'T'},
{"flip-polarity", 1, 0, 'F'},
{"ms-power", 1, 0, 'P'},
{"sysinfo", 1, 0, 'S'},
{"tolerant", 0, 0, 'T'},
{"tolerant", 0, 0, 'O'},
{0, 0, 0, 0}
};
set_options_common("t:F:P:S:T", long_options_special);
set_options_common("T:F:P:S:O", long_options_special);
while (1) {
int option_index = 0, c;
@ -117,7 +117,7 @@ static int handle_options(int argc, char **argv)
break;
switch (c) {
case 't':
case 'T':
if (!strcmp(optarg, "list")) {
amps_channel_list();
exit(0);
@ -209,7 +209,7 @@ static int handle_options(int argc, char **argv)
}
skip_args += 2;
break;
case 'T':
case 'O':
tolerant = 1;
skip_args += 1;
break;
@ -326,7 +326,7 @@ int main(int argc, char *argv[])
if (!do_pre_emphasis || !do_de_emphasis) {
fprintf(stderr, "*******************************************************************************\n");
fprintf(stderr, "I strongly suggest to let me do pre- and de-emphasis (options -E -e)!\n");
fprintf(stderr, "I strongly suggest to let me do pre- and de-emphasis (options -p -d)!\n");
fprintf(stderr, "Use a transmitter/receiver without emphasis and let me do that!\n");
fprintf(stderr, "Because carrier FSK signaling does not use emphasis, I like to control\n");
fprintf(stderr, "emphasis by myself for best results.\n");
@ -347,7 +347,7 @@ int main(int argc, char *argv[])
amps_si si;
init_sysinfo(&si, ms_power, ms_power, dcc, sid >> 1, regh, regr, pureg, pdreg, locaid, regincr, bis);
rc = amps_create(kanal[i], chan_type[i], sounddev[i], samplerate, cross_channels, rx_gain, do_pre_emphasis, do_de_emphasis, write_wave, read_wave, &si, sid, scc, polarity, tolerant, loopback);
rc = amps_create(kanal[i], chan_type[i], sounddev[i], samplerate, cross_channels, rx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, &si, sid, scc, polarity, tolerant, loopback);
if (rc < 0) {
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
goto fail;

View File

@ -137,7 +137,7 @@ static void anetz_timeout(struct timer *timer);
static void anetz_go_idle(anetz_t *anetz);
/* Create transceiver instance and link to a list. */
int anetz_create(int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int page_sequence, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_volume)
int anetz_create(int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int page_sequence, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback, double loss_volume)
{
anetz_t *anetz;
int rc;
@ -156,7 +156,7 @@ int anetz_create(int kanal, const char *sounddev, int samplerate, int cross_chan
PDEBUG(DANETZ, DEBUG_DEBUG, "Creating 'A-Netz' instance for 'Kanal' = %d (sample rate %d).\n", kanal, samplerate);
/* init general part of transceiver */
rc = sender_create(&anetz->sender, kanal, sounddev, samplerate, cross_channels, rx_gain, pre_emphasis, de_emphasis, write_wave, read_wave, loopback, loss_volume, PILOT_SIGNAL_NONE);
rc = sender_create(&anetz->sender, kanal, sounddev, samplerate, cross_channels, rx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, loss_volume, PILOT_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DANETZ, DEBUG_ERROR, "Failed to init 'Sender' processing!\n");
goto error;

View File

@ -44,7 +44,7 @@ typedef struct anetz {
double anetz_kanal2freq(int kanal, int unterband);
int anetz_init(void);
int anetz_create(int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int page_sequence, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_volume);
int anetz_create(int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int page_sequence, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback, double loss_volume);
void anetz_destroy(sender_t *sender);
void anetz_loss_indication(anetz_t *anetz);
void anetz_receive_tone(anetz_t *anetz, int bit);

View File

@ -42,14 +42,14 @@ void print_help(const char *arg0)
{
print_help_common(arg0, "");
/* - - */
printf(" -g --geo <lat>,<lon>\n");
printf(" -G --geo <lat>,<lon>\n");
printf(" Give your coordinates of your location, to find closest base station.\n");
printf(" (e.g. '--geo 51.186959,7.080194') Or use '--geo list' to get a list of\n");
printf(" all base station locations.\n");
printf(" -P --page-sequence 0 | <ms>\n");
printf(" Cycle paging tones, rather than sending simultaniously.\n");
printf(" (default = '%d')\n", page_sequence);
printf(" -0 --loss <volume>\n");
printf(" -L --loss <volume>\n");
printf(" Detect loss of carrier by detecting steady noise above given volume in\n");
printf(" percent. (disabled by default)\n");
printf("\nstation-id: Give (last) 5 digits of station-id, you don't need to enter it\n");
@ -62,13 +62,13 @@ static int handle_options(int argc, char **argv)
char *p;
static struct option long_options_special[] = {
{"geo", 1, 0, 'g'},
{"geo", 1, 0, 'G'},
{"page-sequence", 1, 0, 'P'},
{"loss", 1, 0, '0'},
{"loss", 1, 0, 'L'},
{0, 0, 0, 0}
};
set_options_common("g:P:0:", long_options_special);
set_options_common("G:P:L:", long_options_special);
while (1) {
int option_index = 0, c;
@ -79,7 +79,7 @@ static int handle_options(int argc, char **argv)
break;
switch (c) {
case 'g':
case 'G':
if (!strcasecmp(optarg, "list")) {
station_list();
exit(0);
@ -95,7 +95,7 @@ static int handle_options(int argc, char **argv)
page_sequence = atoi(optarg);
skip_args += 2;
break;
case '0':
case 'L':
lossdetect = atoi(optarg);
skip_args += 2;
break;
@ -167,7 +167,7 @@ int main(int argc, char *argv[])
/* create transceiver instance */
for (i = 0; i < num_kanal; i++) {
rc = anetz_create(kanal[i], sounddev[i], samplerate, cross_channels, rx_gain, page_sequence, do_pre_emphasis, do_de_emphasis, write_wave, read_wave, loopback, lossdetect / 100.0);
rc = anetz_create(kanal[i], sounddev[i], samplerate, cross_channels, rx_gain, page_sequence, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, lossdetect / 100.0);
if (rc < 0) {
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
goto fail;

View File

@ -99,7 +99,7 @@ static void bnetz_timeout(struct timer *timer);
static void bnetz_go_idle(bnetz_t *bnetz);
/* Create transceiver instance and link to a list. */
int bnetz_create(int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_factor, const char *pilot)
int bnetz_create(int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback, double loss_factor, const char *pilot)
{
bnetz_t *bnetz;
enum pilot_signal pilot_signal = PILOT_SIGNAL_NONE;
@ -160,7 +160,7 @@ error_pilot:
PDEBUG(DBNETZ, DEBUG_DEBUG, "Creating 'B-Netz' instance for 'Kanal' = %d 'Gruppenfreisignal' = %d (sample rate %d).\n", kanal, gfs, samplerate);
/* init general part of transceiver */
rc = sender_create(&bnetz->sender, kanal, sounddev, samplerate, cross_channels, rx_gain, pre_emphasis, de_emphasis, write_wave, read_wave, loopback, loss_factor, pilot_signal);
rc = sender_create(&bnetz->sender, kanal, sounddev, samplerate, cross_channels, rx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, loss_factor, pilot_signal);
if (rc < 0) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error;

View File

@ -99,7 +99,7 @@ typedef struct bnetz {
double bnetz_kanal2freq(int kanal, int unterband);
int bnetz_init(void);
int bnetz_create(int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_factor, const char *pilot);
int bnetz_create(int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback, double loss_factor, const char *pilot);
void bnetz_destroy(sender_t *sender);
void bnetz_loss_indication(bnetz_t *bnetz);
void bnetz_receive_tone(bnetz_t *bnetz, int bit);

View File

@ -44,12 +44,12 @@ void print_help(const char *arg0)
{
print_help_common(arg0, "");
/* - - */
printf(" -g --gfs <gruppenfreisignal> | <lat>,<lon>\n");
printf(" -G --gfs <gruppenfreisignal> | <lat>,<lon>\n");
printf(" Gruppenfreisignal\" 1..9 | 19 | 10..18 (default = '%d')\n", gfs);
printf(" Alternative give your coordinates of your location, to find closest\n");
printf(" base station. (e.g. '--gfs 54.487291,9.069993') Or use '--gfs list' to\n");
printf(" get a list of all base station locations.\n");
printf(" -g --gfs 19\n");
printf(" -G --gfs 19\n");
printf(" Set to 19 in order to make the phone transmit at 100 mW instead of\n");
printf(" full 15 Watts. If supported, the phone uses the channel with low power\n");
printf(" (Kanal kleiner Leistung).\n");
@ -64,7 +64,7 @@ void print_help(const char *arg0)
printf(" Example: /sys/class/gpio/gpio17/value=1:0 writes a '1' to\n");
printf(" /sys/class/gpio/gpio17/value to switching to channel 19 and a '0' to\n");
printf(" switch back. (default = %s)\n", pilot[0]);
printf(" -0 --loss <volume>\n");
printf(" -L --loss <volume>\n");
printf(" Detect loss of carrier by detecting steady noise above given volume in\n");
printf(" percent. (disabled by default)\n");
printf("\nstation-id: Give 5 digit station-id, you don't need to enter it for every\n");
@ -77,13 +77,13 @@ static int handle_options(int argc, char **argv)
char *p;
static struct option long_options_special[] = {
{"gfs", 1, 0, 'g'},
{"gfs", 1, 0, 'G'},
{"pilot", 1, 0, 'P'},
{"loss", 1, 0, '0'},
{"loss", 1, 0, 'L'},
{0, 0, 0, 0},
};
set_options_common("g:P:0:", long_options_special);
set_options_common("G:P:L:", long_options_special);
while (1) {
int option_index = 0, c;
@ -94,7 +94,7 @@ static int handle_options(int argc, char **argv)
break;
switch (c) {
case 'g':
case 'G':
if (!strcasecmp(optarg, "list")) {
station_list();
exit(0);
@ -111,7 +111,7 @@ static int handle_options(int argc, char **argv)
OPT_ARRAY(num_pilot, pilot, strdup(optarg))
skip_args += 2;
break;
case '0':
case 'L':
lossdetect = atoi(optarg);
skip_args += 2;
break;
@ -186,7 +186,7 @@ int main(int argc, char *argv[])
/* create transceiver instance */
for (i = 0; i < num_kanal; i++) {
rc = bnetz_create(kanal[i], sounddev[i], samplerate, cross_channels, rx_gain, gfs, do_pre_emphasis, do_de_emphasis, write_wave, read_wave, loopback, (double)lossdetect / 100.0, pilot[i]);
rc = bnetz_create(kanal[i], sounddev[i], samplerate, cross_channels, rx_gain, gfs, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, (double)lossdetect / 100.0, pilot[i]);
if (rc < 0) {
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
goto fail;

View File

@ -178,7 +178,7 @@ int cnetz_init(void)
static void cnetz_go_idle(cnetz_t *cnetz);
/* Create transceiver instance and link to a list. */
int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int auth, int ms_power, int measure_speed, double clock_speed[2], int polarity, double noise, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback)
int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int auth, int ms_power, int measure_speed, double clock_speed[2], int polarity, double noise, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback)
{
sender_t *sender;
cnetz_t *cnetz;
@ -237,7 +237,7 @@ int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *sounddev
/* init general part of transceiver */
/* do not enable emphasis, since it is done by cnetz code, not by common sender code */
rc = sender_create(&cnetz->sender, kanal, sounddev, samplerate, cross_channels, rx_gain, 0, 0, write_wave, read_wave, loopback, 0, PILOT_SIGNAL_NONE);
rc = sender_create(&cnetz->sender, kanal, sounddev, samplerate, cross_channels, rx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, loopback, 0, PILOT_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DCNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error;

View File

@ -121,7 +121,7 @@ int cnetz_channel_by_short_name(const char *short_name);
const char *chan_type_short_name(enum cnetz_chan_type chan_type);
const char *chan_type_long_name(enum cnetz_chan_type chan_type);
int cnetz_init(void);
int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int auth, int ms_power, int measure_speed, double clock_speed[2], int polarity, double noise, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback);
int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int auth, int ms_power, int measure_speed, double clock_speed[2], int polarity, double noise, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback);
void cnetz_destroy(sender_t *sender);
void cnetz_sync_frame(cnetz_t *cnetz, double sync, int ts);
int cnetz_meldeaufruf(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest);

View File

@ -51,9 +51,9 @@ int voice_deviation = 1;
void print_help(const char *arg0)
{
print_help_common(arg0, "-S <rx ppm>,<tx ppm> -E -e ");
print_help_common(arg0, "-S <rx ppm>,<tx ppm> -p -d ");
/* - - */
printf(" -t --channel-type <channel type> | list\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(" -M --measure-speed\n");
printf(" Measures clock speed. THIS IS REQUIRED! See documentation!\n");
@ -93,7 +93,7 @@ static int handle_options(int argc, char **argv)
const char *p;
static struct option long_options_special[] = {
{"channel-type", 1, 0, 't'},
{"channel-type", 1, 0, 'T'},
{"measure-speed", 0, 0, 'M'},
{"clock-speed", 1, 0, 'S'},
{"flip-polarity", 1, 0, 'F'},
@ -104,7 +104,7 @@ static int handle_options(int argc, char **argv)
{0, 0, 0, 0}
};
set_options_common("t:MS:F:N:P:AV", long_options_special);
set_options_common("T:MS:F:N:P:AV", long_options_special);
while (1) {
int option_index = 0, c;
@ -115,7 +115,7 @@ static int handle_options(int argc, char **argv)
break;
switch (c) {
case 't':
case 'T':
if (!strcmp(optarg, "list")) {
cnetz_channel_list();
exit(0);
@ -286,7 +286,7 @@ int main(int argc, char *argv[])
if (!do_pre_emphasis || !do_de_emphasis) {
fprintf(stderr, "*******************************************************************************\n");
fprintf(stderr, "I strongly suggest to let me do pre- and de-emphasis (options -E -e)!\n");
fprintf(stderr, "I strongly suggest to let me do pre- and de-emphasis (options -p -d)!\n");
fprintf(stderr, "Use a transmitter/receiver without emphasis and let me do that!\n");
fprintf(stderr, "Because carrier FSK signaling and scrambled voice (default) does not use\n");
fprintf(stderr, "emphasis, I like to control emphasis by myself for best results.\n");
@ -301,7 +301,7 @@ int main(int argc, char *argv[])
/* create transceiver instance */
for (i = 0; i < num_kanal; i++) {
rc = cnetz_create(kanal[i], chan_type[i], sounddev[i], samplerate, cross_channels, rx_gain, auth, ms_power, (i == 0) ? measure_speed : 0, clock_speed, polarity, noise, do_pre_emphasis, do_de_emphasis, write_wave, read_wave, loopback);
rc = cnetz_create(kanal[i], chan_type[i], sounddev[i], samplerate, cross_channels, rx_gain, auth, ms_power, (i == 0) ? measure_speed : 0, clock_speed, polarity, noise, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback);
if (rc < 0) {
fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
goto fail;

View File

@ -15,8 +15,9 @@ extern int use_mncc_sock;
extern int send_patterns;
extern int loopback;
extern int rt_prio;
extern const char *read_wave;
extern const char *write_wave;
extern const char *write_rx_wave;
extern const char *write_tx_wave;
extern const char *read_rx_wave;
void print_help(const char *arg0);
void print_help_common(const char *arg0, const char *ext_usage);

View File

@ -51,8 +51,9 @@ int send_patterns = 1;
int release_on_disconnect = 1;
int loopback = 0;
int rt_prio = 0;
const char *read_wave = NULL;
const char *write_wave = NULL;
const char *write_rx_wave = NULL;
const char *write_tx_wave = NULL;
const char *read_rx_wave = NULL;
void print_help_common(const char *arg0, const char *ext_usage)
{
@ -61,14 +62,15 @@ void print_help_common(const char *arg0, const char *ext_usage)
/* - - */
printf(" -h --help\n");
printf(" This help\n");
printf(" -D --debug <level> | <level>,<category>[,<category>[,...]] | list\n");
printf(" -v --verbose <level> | <level>,<category>[,<category>[,...]] | list\n");
printf(" Use 'list' to get a list of all levels and categories\n");
printf(" Debug level: digit of debug level (default = '%d')\n", debuglevel);
printf(" Debug level+category: level digit followed by one or more categories\n");
printf(" Verbose level: digit of debug level (default = '%d')\n", debuglevel);
printf(" Verbose level+category: level digit followed by one or more categories\n");
printf(" -> If no category is specified, all categories are selected\n");
printf(" -k --kanal <channel>\n");
printf(" Channel number of \"Sender\"\n");
printf(" -d --device hw:<card>,<device>\n");
printf(" -k --channel <channel>\n");
printf(" Channel (German = Kanal) number of \"Sender\" (German = Transceiver)\n");
printf(" -a --audio-device hw:<card>,<device>\n");
printf(" Sound card and device number (default = '%s')\n", sounddev[0]);
printf(" -s --samplerate <rate>\n");
printf(" Sample rate of sound device (default = '%d')\n", samplerate);
@ -76,18 +78,18 @@ void print_help_common(const char *arg0, const char *ext_usage)
printf(" Interval of processing loop in ms (default = '%d' ms)\n", interval);
printf(" Use 25 to drastically reduce CPU usage. In case of buffer underrun,\n");
printf(" increase latency accordingly.\n");
printf(" -l --latency <delay>\n");
printf(" How many milliseconds processed in advance (default = '%d')\n", latency);
printf(" -b --buffer <ms>\n");
printf(" How many milliseconds are processed in advance (default = '%d')\n", latency);
printf(" -x --cross\n");
printf(" Cross channels on sound card. 1st channel (right) is swapped with\n");
printf(" second channel (left)\n");
printf(" -E --pre-emphasis\n");
printf(" -p --pre-emphasis\n");
printf(" Enable pre-emphasis, if you directly connect to the oscillator of the\n");
printf(" transmitter. (No pre-emphasis done by the transmitter.)\n");
printf(" -e --de-emphasis\n");
printf(" -d --de-emphasis\n");
printf(" Enable de-emphasis, if you directly connect to the discriminator of\n");
printf(" the receiver. (No de-emphasis done by the receiver.)\n");
printf(" -G --rx-gain <dB>\n");
printf(" -g --rx-gain <dB>\n");
printf(" Raise receiver RX level by given gain in dB. This is useful if input\n");
printf(" level of the sound device is too low, even after setting maximum level\n");
printf(" with the mixer settings.\n");
@ -95,55 +97,80 @@ void print_help_common(const char *arg0, const char *ext_usage)
printf(" Disable built-in call contol and offer socket (to LCR)\n");
printf(" -c --call-device hw:<card>,<device>\n");
printf(" Sound card and device number for headset (default = '%s')\n", call_sounddev);
printf(" -p --send-patterns 0 | 1\n");
printf(" -t --tones 0 | 1\n");
printf(" Connect call on setup/release to provide classic tones towards fixed\n");
printf(" network (default = '%d')\n", send_patterns);
printf(" -L --loopback <type>\n");
printf(" -l --loopback <type>\n");
printf(" Loopback test: 1 = internal | 2 = external | 3 = echo\n");
printf(" -r --realtime <prio>\n");
printf(" Set prio: 0 to diable, 99 for maximum (default = %d)\n", rt_prio);
printf(" -W --write-wave <file>\n");
printf(" --write-rx-wave <file>\n");
printf(" Write received audio to given wav audio file.\n");
printf(" -R --read-wave <file>\n");
printf(" --write-tx-wave <file>\n");
printf(" Write transmitted audio to given wav audio file.\n");
printf(" --read-rx-wave <file>\n");
printf(" Replace received audio by given wav audio file.\n");
}
#define OPT_CHANNEL 1000
#define OPT_WRITE_RX_WAVE 1001
#define OPT_WRITE_TX_WAVE 1002
#define OPT_READ_RX_WAVE 1003
static struct option long_options_common[] = {
{"help", 0, 0, 'h'},
{"debug", 1, 0, 'D'},
{"debug", 1, 0, 'v'},
{"kanal", 1, 0, 'k'},
{"device", 1, 0, 'd'},
{"call-device", 1, 0, 'c'},
{"channel", 1, 0, OPT_CHANNEL},
{"call-device", 1, 0, 'a'},
{"samplerate", 1, 0, 's'},
{"interval", 1, 0, 'i'},
{"latency", 1, 0, 'l'},
{"buffer", 1, 0, 'b'},
{"cross", 0, 0, 'x'},
{"pre-emphasis", 0, 0, 'E'},
{"de-emphasis", 0, 0, 'e'},
{"rx-gain", 0, 0, 'G'},
{"pre-emphasis", 0, 0, 'p'},
{"de-emphasis", 0, 0, 'd'},
{"rx-gain", 0, 0, 'g'},
{"mncc-sock", 0, 0, 'm'},
{"send-patterns", 0, 0, 'p'},
{"loopback", 1, 0, 'L'},
{"call-device", 1, 0, 'c'},
{"tones", 0, 0, 't'},
{"loopback", 1, 0, 'l'},
{"realtime", 1, 0, 'r'},
{"write-wave", 1, 0, 'W'},
{"read-wave", 1, 0, 'R'},
{"write-rx-wave", 1, 0, OPT_WRITE_RX_WAVE},
{"write-tx-wave", 1, 0, OPT_WRITE_TX_WAVE},
{"read-rx-wave", 1, 0, OPT_READ_RX_WAVE},
{0, 0, 0, 0}
};
const char *optstring_common = "hD:k:d:s:c:i:l:xEeG:mp:L:r:W:R:";
const char *optstring_common = "hv:k:a:s:i:b:xpdg:mc:t:l:r:";
struct option *long_options;
char *optstring;
static void check_duplicate_option(int num, struct option *option)
{
int i;
for (i = 0; i < num; i++) {
if (long_options[i].val == option->val) {
fprintf(stderr, "Duplicate option %d. Please fix!\n", option->val);
abort();
}
}
}
void set_options_common(const char *optstring_special, struct option *long_options_special)
{
int i;
long_options = calloc(sizeof(*long_options), 100);
for (i = 0; long_options_common[i].name; i++)
for (i = 0; long_options_common[i].name; i++) {
check_duplicate_option(i, &long_options_common[i]);
memcpy(&long_options[i], &long_options_common[i], sizeof(*long_options));
for (; long_options_special->name; i++)
}
for (; long_options_special->name; i++) {
check_duplicate_option(i, long_options_special);
memcpy(&long_options[i], long_options_special++, sizeof(*long_options));
}
optstring = calloc(strlen(optstring_common) + strlen(optstring_special) + 1, 1);
strcpy(optstring, optstring_common);
@ -158,7 +185,7 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
case 'h':
print_help(arg0);
exit(0);
case 'D':
case 'v':
if (!strcasecmp(optarg, "list")) {
debug_list_cat();
exit(0);
@ -170,10 +197,11 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
*skip_args += 2;
break;
case 'k':
case OPT_CHANNEL:
OPT_ARRAY(num_kanal, kanal, atoi(optarg))
*skip_args += 2;
break;
case 'd':
case 'a':
OPT_ARRAY(num_sounddev, sounddev, strdup(optarg))
*skip_args += 2;
break;
@ -181,10 +209,6 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
samplerate = atoi(optarg);
*skip_args += 2;
break;
case 'c':
call_sounddev = strdup(optarg);
*skip_args += 2;
break;
case 'i':
interval = atoi(optarg);
*skip_args += 2;
@ -193,7 +217,7 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
if (interval > 25)
interval = 25;
break;
case 'l':
case 'b':
latency = atoi(optarg);
*skip_args += 2;
break;
@ -201,15 +225,15 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
cross_channels = 1;
*skip_args += 1;
break;
case 'E':
case 'p':
do_pre_emphasis = 1;
*skip_args += 1;
break;
case 'e':
case 'd':
do_de_emphasis = 1;
*skip_args += 1;
break;
case 'G':
case 'g':
gain_db = atof(optarg);
if (gain_db < 0.0) {
fprintf(stderr, "Given gain is below 0. Tto reduce RX signal, use sound card's mixer (or resistor net)!\n");
@ -222,11 +246,15 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
use_mncc_sock = 1;
*skip_args += 1;
break;
case 'p':
case 'c':
call_sounddev = strdup(optarg);
*skip_args += 2;
break;
case 't':
send_patterns = atoi(optarg);
*skip_args += 2;
break;
case 'L':
case 'l':
loopback = atoi(optarg);
*skip_args += 2;
break;
@ -234,12 +262,16 @@ void opt_switch_common(int c, char *arg0, int *skip_args)
rt_prio = atoi(optarg);
*skip_args += 2;
break;
case 'W':
write_wave = strdup(optarg);
case OPT_WRITE_RX_WAVE:
write_rx_wave = strdup(optarg);
*skip_args += 2;
break;
case 'R':
read_wave = strdup(optarg);
case OPT_WRITE_TX_WAVE:
write_tx_wave = strdup(optarg);
*skip_args += 2;
break;
case OPT_READ_RX_WAVE:
read_rx_wave = strdup(optarg);
*skip_args += 2;
break;
default:

View File

@ -17,9 +17,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Uncomment this for writing TX as wave (For debug purpose) */
//#define WAVE_WRITE_TX
#define CHAN sender->kanal
#include <stdio.h>
@ -35,7 +32,7 @@ static sender_t **sender_tailp = &sender_head;
int cant_recover = 0;
/* Init transceiver instance and link to list of transceivers. */
int sender_create(sender_t *sender, int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal)
int sender_create(sender_t *sender, int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal)
{
sender_t *master;
int rc = 0;
@ -115,15 +112,22 @@ int sender_create(sender_t *sender, int kanal, const char *sounddev, int sampler
goto error;
}
if (write_wave) {
rc = wave_create_record(&sender->wave_rec, write_wave, samplerate);
if (write_rx_wave) {
rc = wave_create_record(&sender->wave_rx_rec, write_rx_wave, samplerate);
if (rc < 0) {
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
goto error;
}
}
if (read_wave) {
rc = wave_create_playback(&sender->wave_play, read_wave, samplerate);
if (write_tx_wave) {
rc = wave_create_record(&sender->wave_tx_rec, write_tx_wave, samplerate);
if (rc < 0) {
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
goto error;
}
}
if (read_rx_wave) {
rc = wave_create_playback(&sender->wave_rx_play, read_rx_wave, samplerate);
if (rc < 0) {
PDEBUG(DSENDER, DEBUG_ERROR, "Failed to create WAVE playback instance!\n");
goto error;
@ -169,8 +173,9 @@ void sender_destroy(sender_t *sender)
sender->sound = NULL;
}
wave_destroy_record(&sender->wave_rec);
wave_destroy_playback(&sender->wave_play);
wave_destroy_record(&sender->wave_rx_rec);
wave_destroy_record(&sender->wave_tx_rec);
wave_destroy_playback(&sender->wave_rx_play);
jitter_destroy(&sender->audio);
}
@ -239,18 +244,14 @@ cant_recover:
jitter_load(&sender->audio, samples, count);
else
sender_send(sender, samples, count);
#ifdef WAVE_WRITE_TX
if (sender->wave_rec.fp)
wave_write(&sender->wave_rec, samples, count);
#endif
if (sender->wave_tx_rec.fp)
wave_write(&sender->wave_tx_rec, samples, count);
/* internal loopback: loop back TX audio to RX */
if (sender->loopback == 1) {
#ifndef WAVE_WRITE_TX
if (sender->wave_rec.fp)
wave_write(&sender->wave_rec, samples, count);
if (sender->wave_rx_rec.fp)
wave_write(&sender->wave_rx_rec, samples, count);
display_wave(sender, samples, count);
sender_receive(sender, samples, count);
#endif
}
/* do pre emphasis towards radio, not wave_write */
if (sender->pre_emphasis)
@ -261,16 +262,12 @@ cant_recover:
jitter_load(&slave->audio, slave_samples, count);
else
sender_send(slave, slave_samples, count);
#ifdef WAVE_WRITE_TX
if (sender->wave_rec.fp)
wave_write(&slave->wave_rec, slave_samples, count);
#endif
if (sender->wave_tx_rec.fp)
wave_write(&slave->wave_tx_rec, slave_samples, count);
/* internal loopback, if audio slave is set */
if (slave && slave->loopback == 1) {
#ifndef WAVE_WRITE_TX
if (slave->wave_rec.fp)
wave_write(&slave->wave_rec, slave_samples, count);
#endif
if (slave->wave_rx_rec.fp)
wave_write(&slave->wave_rx_rec, slave_samples, count);
display_wave(slave, slave_samples, count);
sender_receive(slave, slave_samples, count);
}
@ -371,13 +368,11 @@ cant_recover:
/* do de emphasis from radio (then write_wave/wave_read), receive audio, process echo test */
if (sender->de_emphasis)
de_emphasis(&sender->estate, samples, count);
if (sender->wave_play.fp)
wave_read(&sender->wave_play, samples, count);
if (sender->wave_rx_play.fp)
wave_read(&sender->wave_rx_play, samples, count);
if (sender->loopback != 1) {
#ifndef WAVE_WRITE_TX
if (sender->wave_rec.fp)
wave_write(&sender->wave_rec, samples, count);
#endif
if (sender->wave_rx_rec.fp)
wave_write(&sender->wave_rx_rec, samples, count);
display_wave(sender, samples, count);
sender_receive(sender, samples, count);
}
@ -389,13 +384,11 @@ cant_recover:
gain_samples(slave_samples, count, slave->rx_gain);
if (slave->de_emphasis)
de_emphasis(&slave->estate, slave_samples, count);
if (slave->wave_play.fp)
wave_read(&slave->wave_play, slave_samples, count);
if (slave->wave_rx_play.fp)
wave_read(&slave->wave_rx_play, slave_samples, count);
if (slave->loopback != 1) {
#ifndef WAVE_WRITE_TX
if (slave->wave_rec.fp)
wave_write(&slave->wave_rec, slave_samples, count);
#endif
if (slave->wave_rx_rec.fp)
wave_write(&slave->wave_rx_rec, slave_samples, count);
display_wave(slave, slave_samples, count);
sender_receive(slave, slave_samples, count);
}

View File

@ -41,8 +41,9 @@ typedef struct sender {
int loopback; /* 0 = off, 1 = internal, 2 = external */
/* record and playback */
wave_rec_t wave_rec; /* wave recording */
wave_play_t wave_play; /* wave playback */
wave_rec_t wave_rx_rec; /* wave recording (from rx) */
wave_rec_t wave_tx_rec; /* wave recording (from tx) */
wave_play_t wave_rx_play; /* wave playback (as rx) */
/* audio buffer for audio to send to transmitter (also used as loopback buffer) */
jitter_t audio;
@ -69,7 +70,7 @@ typedef struct sender {
extern sender_t *sender_head;
extern int cant_recover;
int sender_create(sender_t *sender, int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal);
int sender_create(sender_t *sender, int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal);
void sender_destroy(sender_t *sender);
void process_sender_audio(sender_t *sender, int *quit, int latspl);
void sender_send(sender_t *sender, int16_t *samples, int count);

View File

@ -56,12 +56,12 @@ void print_help(const char *arg0)
{
print_help_common(arg0, "-y <traffic area> | list [-I]");
/* - - */
printf(" -t --channel-type <channel type> | list\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(" -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(" -y --traffic-area <traffic area> | list\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");
printf(" Give two digits of traffic area, the first digit defines the country\n");
@ -69,7 +69,7 @@ void print_help(const char *arg0)
printf(" Alternatively you can give the short code for country and the cell\n");
printf(" area seperated by comma. (Example: SE,1 = Sweden, cell 1)\n");
printf(" Use 'list' to get a list of available short country code names\n");
printf(" -a --area-number <area no> | 0\n");
printf(" -A --area-number <area no> | 0\n");
printf(" Give area number 1..4 or 0 for no area number. (default = '%d')\n", area_no);
printf(" -C --compandor 1 | 0\n");
printf(" Make use of the compandor to reduce noise during call. (default = '%d')\n", compandor);
@ -91,10 +91,10 @@ static int handle_options(int argc, char **argv)
int skip_args = 0;
static struct option long_options_special[] = {
{"channel-type", 1, 0, 't'},
{"channel-type", 1, 0, 'T'},
{"ms-power", 1, 0, 'P'},
{"area-number", 1, 0, 'a'},
{"traffic-area", 1, 0, 'y'},
{"traffic-area", 1, 0, 'Y'},
{"area-number", 1, 0, 'A'},
{"compandor", 1, 0, 'C'},
{"supervisory", 1, 0, '0'},
{"smsc-number", 1, 0, 'S'},
@ -102,7 +102,7 @@ static int handle_options(int argc, char **argv)
{0, 0, 0, 0}
};
set_options_common("t:P:a:y:C:0:S:I:", long_options_special);
set_options_common("T:P:Y:A:C:0:S:I:", long_options_special);
while (1) {
int option_index = 0, c, rc;
@ -113,7 +113,7 @@ static int handle_options(int argc, char **argv)
break;
switch (c) {
case 't':
case 'T':
if (!strcmp(optarg, "list")) {
nmt_channel_list();
exit(0);
@ -134,15 +134,7 @@ static int handle_options(int argc, char **argv)
ms_power = 1;
skip_args += 2;
break;
case 'a':
area_no = optarg[0] - '0';
if (area_no > 4) {
fprintf(stderr, "Area number '%s' out of range, please use 1..4 or 0 for no area\n", optarg);
exit(0);
}
skip_args += 2;
break;
case 'y':
case 'Y':
if (!strcmp(optarg, "list")) {
nmt_country_list();
@ -178,6 +170,14 @@ error_ta:
}
skip_args += 2;
break;
case 'A':
area_no = optarg[0] - '0';
if (area_no > 4) {
fprintf(stderr, "Area number '%s' out of range, please use 1..4 or 0 for no area\n", optarg);
exit(0);
}
skip_args += 2;
break;
case 'C':
compandor = atoi(optarg);
skip_args += 2;
@ -342,7 +342,7 @@ int main(int argc, char *argv[])
/* create transceiver instance */
for (i = 0; i < num_kanal; i++) {
rc = nmt_create(kanal[i], (loopback) ? CHAN_TYPE_TEST : chan_type[i], sounddev[i], samplerate, cross_channels, rx_gain, do_pre_emphasis, do_de_emphasis, write_wave, read_wave, ms_power, nmt_digits2value(traffic_area, 2), area_no, compandor, supervisory, smsc_number, send_callerid, loopback);
rc = nmt_create(kanal[i], (loopback) ? CHAN_TYPE_TEST : chan_type[i], sounddev[i], samplerate, cross_channels, rx_gain, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, ms_power, nmt_digits2value(traffic_area, 2), area_no, compandor, supervisory, smsc_number, send_callerid, loopback);
if (rc < 0) {
fprintf(stderr, "Failed to create transceiver instance. Quitting!\n");
goto fail;

View File

@ -303,7 +303,7 @@ uint8_t nmt_country_by_short_name(const char *short_name)
static void nmt_timeout(struct timer *timer);
/* Create transceiver instance and link to a list. */
int nmt_create(int channel, enum nmt_chan_type chan_type, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, uint8_t ms_power, uint8_t traffic_area, uint8_t area_no, int compandor, int supervisory, const char *smsc_number, int send_callerid, int loopback)
int nmt_create(int channel, enum nmt_chan_type chan_type, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, uint8_t ms_power, uint8_t traffic_area, uint8_t area_no, int compandor, int supervisory, const char *smsc_number, int send_callerid, int loopback)
{
nmt_t *nmt;
int rc;
@ -334,7 +334,7 @@ int nmt_create(int channel, enum nmt_chan_type chan_type, const char *sounddev,
PDEBUG(DNMT, DEBUG_DEBUG, "Creating 'NMT' instance for channel = %d (sample rate %d).\n", channel, samplerate);
/* init general part of transceiver */
rc = sender_create(&nmt->sender, channel, sounddev, samplerate, cross_channels, rx_gain, pre_emphasis, de_emphasis, write_wave, read_wave, loopback, 0, PILOT_SIGNAL_NONE);
rc = sender_create(&nmt->sender, channel, sounddev, samplerate, cross_channels, rx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, 0, PILOT_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DNMT, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error;

View File

@ -140,7 +140,7 @@ const char *chan_type_long_name(enum nmt_chan_type chan_type);
double nmt_channel2freq(int channel, int uplink);
void nmt_country_list(void);
uint8_t nmt_country_by_short_name(const char *short_name);
int nmt_create(int channel, enum nmt_chan_type chan_type, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, uint8_t ms_power, uint8_t traffic_area, uint8_t area_no, int compandor, int supervisory, const char *smsc_number, int send_callerid, int loopback);
int nmt_create(int channel, enum nmt_chan_type chan_type, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, uint8_t ms_power, uint8_t traffic_area, uint8_t area_no, int compandor, int supervisory, const char *smsc_number, int send_callerid, int loopback);
void nmt_check_channels(void);
void nmt_destroy(sender_t *sender);
void nmt_go_idle(nmt_t *nmt);