Neu structure for the paging process (B-Netz)
Paging tones are not created within sound_alsa.c The audio API is now responsible to switch to paging channel. In case of SDR, the sdr.c will switch frequency offset.
This commit is contained in:
@@ -109,23 +109,23 @@ double bnetz_kanal2freq(int kanal, int unterband)
|
||||
return freq * 1e6;
|
||||
}
|
||||
|
||||
/* switch pilot signal (tone or file) */
|
||||
/* switch paging signal (tone or file) */
|
||||
static void switch_channel_19(bnetz_t *bnetz, int on)
|
||||
{
|
||||
/* affects only if pilot signal is used */
|
||||
sender_pilot(&bnetz->sender, on);
|
||||
/* affects only if paging signal is used */
|
||||
sender_paging(&bnetz->sender, on);
|
||||
|
||||
if (bnetz->pilot_file[0] && bnetz->pilot_is_on != on) {
|
||||
if (bnetz->paging_file[0] && bnetz->paging_is_on != on) {
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen(bnetz->pilot_file, "w");
|
||||
fp = fopen(bnetz->paging_file, "w");
|
||||
if (!fp) {
|
||||
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to open file '%s' to switch channel 19!\n", bnetz->pilot_file);
|
||||
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to open file '%s' to switch channel 19!\n", bnetz->paging_file);
|
||||
return;
|
||||
}
|
||||
fprintf(fp, "%s\n", (on) ? bnetz->pilot_on : bnetz->pilot_off);
|
||||
fprintf(fp, "%s\n", (on) ? bnetz->paging_on : bnetz->paging_off);
|
||||
fclose(fp);
|
||||
bnetz->pilot_is_on = on;
|
||||
bnetz->paging_is_on = on;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,11 +141,11 @@ 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 *audiodev, int samplerate, 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)
|
||||
int bnetz_create(int kanal, const char *audiodev, int samplerate, 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 *paging)
|
||||
{
|
||||
bnetz_t *bnetz;
|
||||
enum pilot_signal pilot_signal = PILOT_SIGNAL_NONE;
|
||||
char pilot_file[256] = "", pilot_on[256] = "", pilot_off[256] = "";
|
||||
enum paging_signal paging_signal = PAGING_SIGNAL_NONE;
|
||||
char paging_file[256] = "", paging_on[256] = "", paging_off[256] = "";
|
||||
int rc;
|
||||
|
||||
if (!(kanal >= 1 && kanal <= 39) && !(kanal >= 50 && kanal <= 86)) {
|
||||
@@ -163,34 +163,34 @@ int bnetz_create(int kanal, const char *audiodev, int samplerate, double rx_gain
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!strcmp(pilot, "notone"))
|
||||
pilot_signal = PILOT_SIGNAL_NOTONE;
|
||||
if (!strcmp(paging, "notone"))
|
||||
paging_signal = PAGING_SIGNAL_NOTONE;
|
||||
else
|
||||
if (!strcmp(pilot, "tone"))
|
||||
pilot_signal = PILOT_SIGNAL_TONE;
|
||||
if (!strcmp(paging, "tone"))
|
||||
paging_signal = PAGING_SIGNAL_TONE;
|
||||
else
|
||||
if (!strcmp(pilot, "positive"))
|
||||
pilot_signal = PILOT_SIGNAL_POSITIVE;
|
||||
if (!strcmp(paging, "positive"))
|
||||
paging_signal = PAGING_SIGNAL_POSITIVE;
|
||||
else
|
||||
if (!strcmp(pilot, "negative"))
|
||||
pilot_signal = PILOT_SIGNAL_NEGATIVE;
|
||||
if (!strcmp(paging, "negative"))
|
||||
paging_signal = PAGING_SIGNAL_NEGATIVE;
|
||||
else {
|
||||
char *p;
|
||||
|
||||
strncpy(pilot_file, pilot, sizeof(pilot_file) - 1);
|
||||
p = strchr(pilot_file, '=');
|
||||
strncpy(paging_file, paging, sizeof(paging_file) - 1);
|
||||
p = strchr(paging_file, '=');
|
||||
if (!p) {
|
||||
error_pilot:
|
||||
PDEBUG(DBNETZ, DEBUG_ERROR, "Given pilot file (to switch to channel 19) is missing parameters. Use <file>=<on>:<off> format!\n");
|
||||
error_paging:
|
||||
PDEBUG(DBNETZ, DEBUG_ERROR, "Given paging file (to switch to channel 19) is missing parameters. Use <file>=<on>:<off> format!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
*p++ = '\0';
|
||||
strncpy(pilot_on, p, sizeof(pilot_on) - 1);
|
||||
p = strchr(pilot_file, ':');
|
||||
strncpy(paging_on, p, sizeof(paging_on) - 1);
|
||||
p = strchr(paging_on, ':');
|
||||
if (!p)
|
||||
goto error_pilot;
|
||||
goto error_paging;
|
||||
*p++ = '\0';
|
||||
strncpy(pilot_off, p, sizeof(pilot_off) - 1);
|
||||
strncpy(paging_off, p, sizeof(paging_off) - 1);
|
||||
}
|
||||
|
||||
bnetz = calloc(1, sizeof(bnetz_t));
|
||||
@@ -202,11 +202,12 @@ 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, bnetz_kanal2freq(kanal, 0), bnetz_kanal2freq(kanal, 1), audiodev, samplerate, rx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, loss_factor, pilot_signal);
|
||||
rc = sender_create(&bnetz->sender, kanal, bnetz_kanal2freq(kanal, 0), bnetz_kanal2freq(kanal, 1), audiodev, samplerate, rx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, loss_factor, paging_signal);
|
||||
if (rc < 0) {
|
||||
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
|
||||
goto error;
|
||||
}
|
||||
bnetz->sender.ruffrequenz = bnetz_kanal2freq(19, 0);
|
||||
|
||||
/* init audio processing */
|
||||
rc = dsp_init_sender(bnetz);
|
||||
@@ -216,9 +217,9 @@ error_pilot:
|
||||
}
|
||||
|
||||
bnetz->gfs = gfs;
|
||||
strncpy(bnetz->pilot_file, pilot_file, sizeof(bnetz->pilot_file) - 1);
|
||||
strncpy(bnetz->pilot_on, pilot_on, sizeof(bnetz->pilot_on) - 1);
|
||||
strncpy(bnetz->pilot_off, pilot_off, sizeof(bnetz->pilot_off) - 1);
|
||||
strncpy(bnetz->paging_file, paging_file, sizeof(bnetz->paging_file) - 1);
|
||||
strncpy(bnetz->paging_on, paging_on, sizeof(bnetz->paging_on) - 1);
|
||||
strncpy(bnetz->paging_off, paging_off, sizeof(bnetz->paging_off) - 1);
|
||||
timer_init(&bnetz->timer, bnetz_timeout, bnetz);
|
||||
|
||||
/* go into idle state */
|
||||
|
@@ -53,10 +53,10 @@ typedef struct bnetz {
|
||||
int gfs; /* 'Gruppenfreisignal' */
|
||||
|
||||
/* switch sender to channel 19 */
|
||||
char pilot_file[256]; /* if set, write to given file to switch to channel 19 or back */
|
||||
char pilot_on[256]; /* what to write to switch to channel 19 */
|
||||
char pilot_off[256]; /* what to write to switch back */
|
||||
int pilot_is_on; /* set, if we are on channel 19. also used to switch back on exit */
|
||||
char paging_file[256]; /* if set, write to given file to switch to channel 19 or back */
|
||||
char paging_on[256]; /* what to write to switch to channel 19 */
|
||||
char paging_off[256]; /* what to write to switch back */
|
||||
int paging_is_on; /* set, if we are on channel 19. also used to switch back on exit */
|
||||
|
||||
/* all bnetz states */
|
||||
enum bnetz_state state; /* main state of sender */
|
||||
@@ -100,7 +100,7 @@ typedef struct bnetz {
|
||||
|
||||
double bnetz_kanal2freq(int kanal, int unterband);
|
||||
int bnetz_init(void);
|
||||
int bnetz_create(int kanal, const char *audiodev, int samplerate, 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);
|
||||
int bnetz_create(int kanal, const char *audiodev, int samplerate, 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 *paging);
|
||||
void bnetz_destroy(sender_t *sender);
|
||||
void bnetz_loss_indication(bnetz_t *bnetz);
|
||||
void bnetz_receive_tone(bnetz_t *bnetz, int bit);
|
||||
|
@@ -36,8 +36,8 @@
|
||||
#include "ansage.h"
|
||||
|
||||
int gfs = 2;
|
||||
int num_pilot = 0;
|
||||
const char *pilot[MAX_SENDER] = { "tone" };
|
||||
int num_paging = 0;
|
||||
const char *paging[MAX_SENDER] = { "tone" };
|
||||
double lossdetect = 0;
|
||||
|
||||
void print_help(const char *arg0)
|
||||
@@ -53,7 +53,7 @@ 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 | notone | positive | negative | <file>=<on>:<off>\n");
|
||||
printf(" -P --paging 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");
|
||||
@@ -63,7 +63,7 @@ void print_help(const char *arg0)
|
||||
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[0]);
|
||||
printf(" switch back. (default = %s)\n", paging[0]);
|
||||
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");
|
||||
@@ -79,7 +79,7 @@ static int handle_options(int argc, char **argv)
|
||||
|
||||
static struct option long_options_special[] = {
|
||||
{"gfs", 1, 0, 'G'},
|
||||
{"pilot", 1, 0, 'P'},
|
||||
{"paging", 1, 0, 'P'},
|
||||
{"loss", 1, 0, 'L'},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
@@ -109,7 +109,7 @@ static int handle_options(int argc, char **argv)
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'P':
|
||||
OPT_ARRAY(num_pilot, pilot, strdup(optarg))
|
||||
OPT_ARRAY(num_paging, paging, strdup(optarg))
|
||||
skip_args += 2;
|
||||
break;
|
||||
case 'L':
|
||||
@@ -159,10 +159,10 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "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(stderr, "You need to specify as many pilot tone settings as you have channels.\n");
|
||||
if (num_kanal == 1 && num_paging == 0)
|
||||
num_paging = 1; /* use defualt */
|
||||
if (num_kanal != num_paging) {
|
||||
fprintf(stderr, "You need to specify as many paging tone settings as you have channels.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -187,13 +187,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* create transceiver instance */
|
||||
for (i = 0; i < num_kanal; i++) {
|
||||
rc = bnetz_create(kanal[i], audiodev[i], samplerate, 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]);
|
||||
rc = bnetz_create(kanal[i], audiodev[i], samplerate, rx_gain, gfs, do_pre_emphasis, do_de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, loopback, (double)lossdetect / 100.0, paging[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) / 1e6, bnetz_kanal2freq(kanal[i], 1) / 1e6);
|
||||
printf("To call phone, switch transmitter (using pilot signal) to %.3f MHz.\n", bnetz_kanal2freq(19, 0) / 1e6);
|
||||
printf("To call phone, switch transmitter (using paging signal) to %.3f MHz.\n", bnetz_kanal2freq(19, 0) / 1e6);
|
||||
}
|
||||
|
||||
main_common(&quit, latency, interval, NULL);
|
||||
|
Reference in New Issue
Block a user