aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/amps/amps.c2
-rw-r--r--src/anetz/anetz.c2
-rw-r--r--src/bnetz/bnetz.c23
-rw-r--r--src/bnetz/main.c5
-rw-r--r--src/cnetz/cnetz.c2
-rw-r--r--src/common/sender.c32
-rw-r--r--src/common/sender.h14
-rw-r--r--src/nmt/nmt.c2
8 files changed, 55 insertions, 27 deletions
diff --git a/src/amps/amps.c b/src/amps/amps.c
index 27cdaa5..61ee54d 100644
--- a/src/amps/amps.c
+++ b/src/amps/amps.c
@@ -400,7 +400,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, -1);
+ rc = sender_create(&amps->sender, channel, sounddev, samplerate, cross_channels, rx_gain, 0, 0, write_wave, read_wave, loopback, 0, PILOT_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error;
diff --git a/src/anetz/anetz.c b/src/anetz/anetz.c
index a65b157..a837b73 100644
--- a/src/anetz/anetz.c
+++ b/src/anetz/anetz.c
@@ -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, -1);
+ 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);
if (rc < 0) {
PDEBUG(DANETZ, DEBUG_ERROR, "Failed to init 'Sender' processing!\n");
goto error;
diff --git a/src/bnetz/bnetz.c b/src/bnetz/bnetz.c
index 2aa598d..06b5509 100644
--- a/src/bnetz/bnetz.c
+++ b/src/bnetz/bnetz.c
@@ -207,17 +207,15 @@ static struct impulstelegramme *bnetz_telegramm(int digit)
/* switch pilot signal (tone or file) */
static void switch_channel_19(bnetz_t *bnetz, int on)
{
- if (bnetz->sender.use_pilot_signal >= 0) {
- bnetz->sender.pilot_on = on;
- return;
- }
+ /* affects only if pilot signal is used */
+ sender_pilot(&bnetz->sender, on);
- if (bnetz->pilot_file && bnetz->pilot_is_on != on) {
+ if (bnetz->pilot_file[0] && bnetz->pilot_is_on != on) {
FILE *fp;
fp = fopen(bnetz->pilot_file, "w");
if (!fp) {
- PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to open file '%s' to switch channel 19!\n");
+ PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to open file '%s' to switch channel 19!\n", bnetz->pilot_file);
return;
}
fprintf(fp, "%s\n", (on) ? bnetz->pilot_on : bnetz->pilot_off);
@@ -250,7 +248,7 @@ static void bnetz_go_idle(bnetz_t *bnetz);
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)
{
bnetz_t *bnetz;
- int use_pilot_tone = -1;
+ enum pilot_signal pilot_signal = PILOT_SIGNAL_NONE;
char pilot_file[256] = "", pilot_on[256] = "", pilot_off[256] = "";
int rc;
@@ -269,14 +267,17 @@ int bnetz_create(int kanal, const char *sounddev, int samplerate, int cross_chan
return -EINVAL;
}
+ if (!strcmp(pilot, "notone"))
+ pilot_signal = PILOT_SIGNAL_NOTONE;
+ else
if (!strcmp(pilot, "tone"))
- use_pilot_tone = 2;
+ pilot_signal = PILOT_SIGNAL_TONE;
else
if (!strcmp(pilot, "positive"))
- use_pilot_tone = 1;
+ pilot_signal = PILOT_SIGNAL_POSITIVE;
else
if (!strcmp(pilot, "negative"))
- use_pilot_tone = 0;
+ pilot_signal = PILOT_SIGNAL_NEGATIVE;
else {
char *p;
@@ -305,7 +306,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, use_pilot_tone);
+ 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);
if (rc < 0) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error;
diff --git a/src/bnetz/main.c b/src/bnetz/main.c
index 60b4cff..0ddfde9 100644
--- a/src/bnetz/main.c
+++ b/src/bnetz/main.c
@@ -55,11 +55,12 @@ void print_help(const char *arg0)
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");
- printf(" -P --pilot tone | positive | negative | <file>=<on>:<off>\n");
+ printf(" -P --pilot tone | notone | 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 second audio channel.\n");
- printf(" 'tone' sends a tone whenever channel 19 is switchted.\n");
+ printf(" 'tone' sends a tone whenever channel 19 is switched.\n");
+ printf(" 'notone' sends a tone whenever channel 19 is NOT switched.\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");
diff --git a/src/cnetz/cnetz.c b/src/cnetz/cnetz.c
index e6fbcb8..46989b7 100644
--- a/src/cnetz/cnetz.c
+++ b/src/cnetz/cnetz.c
@@ -235,7 +235,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, -1);
+ rc = sender_create(&cnetz->sender, kanal, sounddev, samplerate, cross_channels, rx_gain, 0, 0, write_wave, read_wave, loopback, 0, PILOT_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DCNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error;
diff --git a/src/common/sender.c b/src/common/sender.c
index 0fcd97a..caa2689 100644
--- a/src/common/sender.c
+++ b/src/common/sender.c
@@ -35,7 +35,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, int use_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_wave, const char *read_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal)
{
sender_t *master;
int rc = 0;
@@ -49,7 +49,7 @@ int sender_create(sender_t *sender, int kanal, const char *sounddev, int sampler
sender->de_emphasis = de_emphasis;
sender->loopback = loopback;
sender->loss_volume = loss_volume;
- sender->use_pilot_signal = use_pilot_signal;
+ sender->pilot_signal = pilot_signal;
sender->pilotton_phaseshift = 1.0 / ((double)samplerate / 1000.0);
PDEBUG_CHAN(DSENDER, DEBUG_DEBUG, "Creating 'Sender' instance\n");
@@ -79,12 +79,12 @@ int sender_create(sender_t *sender, int kanal, const char *sounddev, int sampler
rc = -EBUSY;
goto error;
}
- if (master->use_pilot_signal >= 0) {
+ if (master->pilot_signal != PILOT_SIGNAL_NONE) {
PDEBUG(DSENDER, DEBUG_ERROR, "Cannot share sound device with channel %d, because second channel is used for pilot signal!\n", master->kanal);
rc = -EBUSY;
goto error;
}
- if (use_pilot_signal >= 0) {
+ if (pilot_signal != PILOT_SIGNAL_NONE) {
PDEBUG(DSENDER, DEBUG_ERROR, "Cannot share sound device with channel %d, because we need a stereo channel for pilot signal!\n", master->kanal);
rc = -EBUSY;
goto error;
@@ -277,8 +277,8 @@ cant_recover:
if (slave->pre_emphasis)
pre_emphasis(&slave->estate, slave_samples, count);
}
- switch (sender->use_pilot_signal) {
- case 2:
+ switch (sender->pilot_signal) {
+ case PILOT_SIGNAL_TONE:
/* tone if pilot signal is on */
if (sender->pilot_on)
gen_pilotton(sender, pilot, count);
@@ -289,7 +289,18 @@ cant_recover:
else
rc = sound_write(sender->sound, pilot, samples, count);
break;
- case 1:
+ case PILOT_SIGNAL_NOTONE:
+ /* tone if pilot signal is off */
+ if (!sender->pilot_on)
+ gen_pilotton(sender, pilot, count);
+ else
+ memset(pilot, 0, count << 1);
+ if (!sender->cross_channels)
+ rc = sound_write(sender->sound, samples, pilot, count);
+ else
+ rc = sound_write(sender->sound, pilot, samples, count);
+ break;
+ case PILOT_SIGNAL_POSITIVE:
/* positive signal if pilot signal is on */
if (sender->pilot_on)
memset(pilot, 127, count << 1);
@@ -300,7 +311,7 @@ cant_recover:
else
rc = sound_write(sender->sound, pilot, samples, count);
break;
- case 0:
+ case PILOT_SIGNAL_NEGATIVE:
/* negative signal if pilot signal is on */
if (sender->pilot_on)
memset(pilot, 128, count << 1);
@@ -393,3 +404,8 @@ cant_recover:
}
}
+void sender_pilot(sender_t *sender, int on)
+{
+ sender->pilot_on = on;
+}
+
diff --git a/src/common/sender.h b/src/common/sender.h
index d3556e6..7a5d1c8 100644
--- a/src/common/sender.h
+++ b/src/common/sender.h
@@ -8,6 +8,15 @@
#define MAX_SENDER 16
+/* how to send a 'pilot' signal (trigger transmitter) */
+enum pilot_signal {
+ PILOT_SIGNAL_NONE = 0,
+ PILOT_SIGNAL_TONE,
+ PILOT_SIGNAL_NOTONE,
+ PILOT_SIGNAL_POSITIVE,
+ PILOT_SIGNAL_NEGATIVE,
+};
+
/* common structure of each transmitter */
typedef struct sender {
struct sender *next;
@@ -47,7 +56,7 @@ typedef struct sender {
loss_t loss;
/* pilot tone */
- int use_pilot_signal; /* -1 if not used, 1 for positive, 0 for negative, 2 for tone */
+ enum pilot_signal pilot_signal; /* if pilot signal is used and how it is performed */
int pilot_on; /* 1 or 0 for on or off */
double pilotton_phaseshift; /* phase to shift every sample */
double pilotton_phase; /* current phase */
@@ -60,9 +69,10 @@ 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, int use_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_wave, const char *read_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);
void sender_receive(sender_t *sender, int16_t *samples, int count);
+void sender_pilot(sender_t *sender, int on);
diff --git a/src/nmt/nmt.c b/src/nmt/nmt.c
index 7bdae54..558aa17 100644
--- a/src/nmt/nmt.c
+++ b/src/nmt/nmt.c
@@ -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, -1);
+ 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);
if (rc < 0) {
PDEBUG(DNMT, DEBUG_ERROR, "Failed to init transceiver process!\n");
goto error;