aboutsummaryrefslogtreecommitdiffstats
path: root/src/bnetz
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2016-04-25 20:20:54 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2016-05-08 15:48:13 +0200
commit7434e21dc21fe448fba3c119d9c211b790eb0153 (patch)
treeecff6ebbe91f38e1ab68d50780d770424a74364d /src/bnetz
parentde0ce7ba983e98976763612410da7b31e3b46dd5 (diff)
Multi transceiver support
This can be multiple transceivers on multiple sound cards. Two transceivers can be bundled on one sound device as well, using both channels.
Diffstat (limited to 'src/bnetz')
-rw-r--r--src/bnetz/bnetz.c4
-rw-r--r--src/bnetz/bnetz.h2
-rw-r--r--src/bnetz/main.c40
3 files changed, 30 insertions, 16 deletions
diff --git a/src/bnetz/bnetz.c b/src/bnetz/bnetz.c
index e7a941c..d1e94d3 100644
--- a/src/bnetz/bnetz.c
+++ b/src/bnetz/bnetz.c
@@ -242,7 +242,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(const char *sounddev, int samplerate, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int kanal, int gfs, int loopback, double loss_factor, const char *pilot)
+int bnetz_create(int kanal, const char *sounddev, int samplerate, int cross_channels, int gfs, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int loopback, double loss_factor, const char *pilot)
{
bnetz_t *bnetz;
int use_pilot_tone = -1;
@@ -300,7 +300,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, sounddev, samplerate, pre_emphasis, de_emphasis, write_wave, read_wave, kanal, loopback, loss_factor, use_pilot_tone);
+ rc = sender_create(&bnetz->sender, kanal, sounddev, samplerate, cross_channels, pre_emphasis, de_emphasis, write_wave, read_wave, loopback, loss_factor, use_pilot_tone);
if (rc < 0) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error;
diff --git a/src/bnetz/bnetz.h b/src/bnetz/bnetz.h
index c61cade..e83b371 100644
--- a/src/bnetz/bnetz.h
+++ b/src/bnetz/bnetz.h
@@ -90,7 +90,7 @@ typedef struct bnetz {
double bnetz_kanal2freq(int kanal, int unterband);
int bnetz_init(void);
-int bnetz_create(const char *sounddev, int samplerate, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_wave, int kanal, int gfs, int loopback, double loss_volume, const char *pilot);
+int bnetz_create(int kanal, const char *sounddev, int samplerate, int cross_channels, int gfs, int pre_emphasis, int de_emphasis, const char *write_wave, const char *read_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);
diff --git a/src/bnetz/main.c b/src/bnetz/main.c
index 91e71de..97c32c8 100644
--- a/src/bnetz/main.c
+++ b/src/bnetz/main.c
@@ -37,7 +37,8 @@
#include "ansage.h"
int gfs = 2;
-const char *pilot = "tone";
+int num_pilot = 0;
+const char *pilot[MAX_SENDER] = { "tone" };
double lossdetect = 0;
void print_help(const char *arg0)
@@ -49,13 +50,13 @@ void print_help(const char *arg0)
printf(" -P --pilot tone | positive | negative | <file>=<on>:<off>\n");
printf(" Send a tone, give a signal or write to a file when switching to\n");
printf(" channel 19. (paging the phone).\n");
- printf(" 'tone', 'positive', 'negative' is sent on right audio channel.\n");
+ printf(" 'tone', 'positive', 'negative' is sent on second audio channel.\n");
printf(" 'tone' sends a tone whenever channel 19 is switchted.\n");
printf(" 'positive' sends a positive signal for channel 19, else negative.\n");
printf(" 'negative' sends a negative signal for channel 19, else positive.\n");
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);
+ printf(" switch back. (default = %s)\n", pilot[0]);
printf(" -0 --loss <volume>\n");
printf(" Detect loss of carrier by detecting steady noise above given volume in\n");
printf(" percent. (disabled by default)\n");
@@ -90,7 +91,7 @@ static int handle_options(int argc, char **argv)
skip_args += 2;
break;
case 'P':
- pilot = strdup(optarg);
+ OPT_ARRAY(num_pilot, pilot, strdup(optarg))
skip_args += 2;
break;
case '0':
@@ -110,6 +111,7 @@ int main(int argc, char *argv[])
int rc;
int skip_args;
const char *station_id = "";
+ int i;
/* init common tones */
init_freiton();
@@ -128,11 +130,23 @@ int main(int argc, char *argv[])
}
}
- if (!kanal) {
+ if (!num_kanal) {
printf("No channel (\"Kanal\") is specified, I suggest channel 1.\n\n");
print_help(argv[-skip_args]);
return 0;
}
+ if (num_kanal == 1 && num_sounddev == 0)
+ num_sounddev = 1; /* use defualt */
+ if (num_kanal != num_sounddev) {
+ fprintf(stdout, "You need to specify as many sound devices as you have channels.\n");
+ exit(0);
+ }
+ if (num_kanal == 1 && num_pilot == 0)
+ num_pilot = 1; /* use defualt */
+ if (num_kanal != num_pilot) {
+ fprintf(stdout, "You need to specify as many pilot tone settings as you have channels.\n");
+ exit(0);
+ }
if (!loopback)
print_image();
@@ -154,15 +168,15 @@ int main(int argc, char *argv[])
}
/* create transceiver instance */
- rc = bnetz_create(sounddev, samplerate, do_pre_emphasis, do_de_emphasis, write_wave, read_wave, kanal, gfs, loopback, (double)lossdetect / 100.0, pilot);
- if (rc < 0) {
- fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
- goto fail;
+ for (i = 0; i < num_kanal; i++) {
+ rc = bnetz_create(kanal[i], sounddev[i], samplerate, cross_channels, gfs, do_pre_emphasis, do_de_emphasis, write_wave, read_wave, loopback, (double)lossdetect / 100.0, pilot[i]);
+ if (rc < 0) {
+ fprintf(stderr, "Failed to create \"Sender\" instance. Quitting!\n");
+ goto fail;
+ }
+ printf("Base station for channel %d ready, please tune transmitter to %.3f MHz and receiver " "to %.3f MHz.\n", kanal[i], bnetz_kanal2freq(kanal[i], 0), bnetz_kanal2freq(kanal[i], 1));
+ printf("To call phone, switch transmitter (using pilot signal) to %.3f MHz.\n", bnetz_kanal2freq(19, 0));
}
- printf("Base station ready, please tune transmitter to %.3f MHz and receiver "
- "to %.3f MHz.\n", bnetz_kanal2freq(kanal, 0),
- bnetz_kanal2freq(kanal, 1));
- printf("To call phone, switch transmitter (using pilot signal) to %.3f MHz.\n", bnetz_kanal2freq(19, 0));
signal(SIGINT,sighandler);
signal(SIGHUP,sighandler);