diff options
Diffstat (limited to 'src/anetz')
-rw-r--r-- | src/anetz/Makefile.am | 9 | ||||
-rw-r--r-- | src/anetz/anetz.c | 126 | ||||
-rw-r--r-- | src/anetz/anetz.h | 2 | ||||
-rw-r--r-- | src/anetz/besetztton.c | 1 | ||||
-rw-r--r-- | src/anetz/dsp.c | 57 | ||||
-rw-r--r-- | src/anetz/freiton.c | 1 | ||||
-rw-r--r-- | src/anetz/main.c | 5 | ||||
-rw-r--r-- | src/anetz/stations.c | 45 |
8 files changed, 149 insertions, 97 deletions
diff --git a/src/anetz/Makefile.am b/src/anetz/Makefile.am index 66de260..2f3972e 100644 --- a/src/anetz/Makefile.am +++ b/src/anetz/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) +AM_CPPFLAGS = -Wall -Wextra -Wmissing-prototypes -g $(all_includes) bin_PROGRAMS = \ anetz @@ -19,22 +19,21 @@ anetz_LDADD = \ $(COMMON_LA) \ libgermanton.a \ $(top_builddir)/src/liboptions/liboptions.a \ - $(top_builddir)/src/libdebug/libdebug.a \ $(top_builddir)/src/libmobile/libmobile.a \ - $(top_builddir)/src/libosmocc/libosmocc.a \ $(top_builddir)/src/libdisplay/libdisplay.a \ $(top_builddir)/src/libgoertzel/libgoertzel.a \ $(top_builddir)/src/libjitter/libjitter.a \ $(top_builddir)/src/libsquelch/libsquelch.a \ - $(top_builddir)/src/libtimer/libtimer.a \ $(top_builddir)/src/libsamplerate/libsamplerate.a \ $(top_builddir)/src/libemphasis/libemphasis.a \ $(top_builddir)/src/libfm/libfm.a \ $(top_builddir)/src/libfilter/libfilter.a \ $(top_builddir)/src/libwave/libwave.a \ $(top_builddir)/src/libsample/libsample.a \ - $(top_builddir)/src/libg711/libg711.a \ $(top_builddir)/src/libaaimage/libaaimage.a \ + $(top_builddir)/src/liblogging/liblogging.a \ + $(LIBOSMOCORE_LIBS) \ + $(LIBOSMOCC_LIBS) \ -lm if HAVE_ALSA diff --git a/src/anetz/anetz.c b/src/anetz/anetz.c index 3af185b..af3a741 100644 --- a/src/anetz/anetz.c +++ b/src/anetz/anetz.c @@ -25,19 +25,19 @@ #include <string.h> #include <errno.h> #include "../libsample/sample.h" -#include "../libdebug/debug.h" -#include "../libtimer/timer.h" +#include "../liblogging/logging.h" +#include <osmocom/core/timer.h> #include "../libmobile/call.h" #include "../libmobile/cause.h" -#include "../libosmocc/message.h" +#include <osmocom/cc/message.h> #include "anetz.h" #include "dsp.h" /* Timers */ -#define PAGING_TO 30 /* Nach dieser Zeit ist der Operator genervt... */ -#define RELEASE_TO 3 /* Release time, so station keeps blocked for a while */ +#define PAGING_TO 30,0 /* Nach dieser Zeit ist der Operator genervt... */ +#define RELEASE_TO 3,0 /* Release time, so station keeps blocked for a while */ -const char *anetz_state_name(enum anetz_state state) +static const char *anetz_state_name(enum anetz_state state) { static char invalid[16]; @@ -58,7 +58,7 @@ const char *anetz_state_name(enum anetz_state state) return invalid; } -void anetz_display_status(void) +static void anetz_display_status(void) { sender_t *sender; anetz_t *anetz; @@ -77,7 +77,7 @@ static void anetz_new_state(anetz_t *anetz, enum anetz_state new_state) { if (anetz->state == new_state) return; - PDEBUG_CHAN(DANETZ, DEBUG_DEBUG, "State change: %s -> %s\n", anetz_state_name(anetz->state), anetz_state_name(new_state)); + LOGP_CHAN(DANETZ, LOGL_DEBUG, "State change: %s -> %s\n", anetz_state_name(anetz->state), anetz_state_name(new_state)); anetz->state = new_state; anetz_display_status(); } @@ -141,7 +141,7 @@ static double *anetz_nummer2freq(const char *nummer) /* get decade */ dekade = anetz_gruppenkennziffer[*nummer - '0'].dekade; - PDEBUG(DANETZ, DEBUG_DEBUG, "Dekaden: %d %d %d %d\n", dekade[0], dekade[1], dekade[2], dekade[3]); + LOGP(DANETZ, LOGL_DEBUG, "Dekaden: %d %d %d %d\n", dekade[0], dekade[1], dekade[2], dekade[3]); nummer++; /* get 4 frequencies out of decades */ @@ -161,7 +161,7 @@ static double *anetz_nummer2freq(const char *nummer) } } - PDEBUG(DANETZ, DEBUG_DEBUG, "Frequencies: F%d=%.1f F%d=%.1f F%d=%.1f F%d=%.1f\n", f[0], freq[0], f[1], freq[1], f[2], freq[2], f[3], freq[3]); + LOGP(DANETZ, LOGL_DEBUG, "Frequencies: F%d=%.1f F%d=%.1f F%d=%.1f F%d=%.1f\n", f[0], freq[0], f[1], freq[1], f[2], freq[2], f[3], freq[3]); return freq; } @@ -186,7 +186,7 @@ int anetz_init(void) return 0; } -static void anetz_timeout(struct timer *timer); +static void anetz_timeout(void *data); static void anetz_go_idle(anetz_t *anetz); /* Create transceiver instance and link to a list. */ @@ -196,40 +196,40 @@ int anetz_create(const char *kanal, const char *device, int use_sdr, int sampler int rc; if (atoi(kanal) < 30 || atoi(kanal) > 63) { - PDEBUG(DANETZ, DEBUG_ERROR, "Channel ('Kanal') number %s invalid.\n", kanal); + LOGP(DANETZ, LOGL_ERROR, "Channel ('Kanal') number %s invalid.\n", kanal); return -EINVAL; } anetz = calloc(1, sizeof(anetz_t)); if (!anetz) { - PDEBUG(DANETZ, DEBUG_ERROR, "No memory!\n"); + LOGP(DANETZ, LOGL_ERROR, "No memory!\n"); return -EIO; } anetz->operator = operator; - PDEBUG(DANETZ, DEBUG_DEBUG, "Creating 'A-Netz' instance for 'Kanal' = %s (sample rate %d).\n", kanal, samplerate); + LOGP(DANETZ, LOGL_DEBUG, "Creating 'A-Netz' instance for 'Kanal' = %s (sample rate %d).\n", kanal, samplerate); /* init general part of transceiver */ rc = sender_create(&anetz->sender, kanal, anetz_kanal2freq(atoi(kanal), 0), anetz_kanal2freq(atoi(kanal), 1), device, use_sdr, samplerate, rx_gain, tx_gain, pre_emphasis, de_emphasis, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE); if (rc < 0) { - PDEBUG(DANETZ, DEBUG_ERROR, "Failed to init 'Sender' processing!\n"); + LOGP(DANETZ, LOGL_ERROR, "Failed to init 'Sender' processing!\n"); goto error; } /* init audio processing */ rc = dsp_init_sender(anetz, page_gain, page_sequence, squelch_db); if (rc < 0) { - PDEBUG(DANETZ, DEBUG_ERROR, "Failed to init signal processing!\n"); + LOGP(DANETZ, LOGL_ERROR, "Failed to init signal processing!\n"); goto error; } - timer_init(&anetz->timer, anetz_timeout, anetz); + osmo_timer_setup(&anetz->timer, anetz_timeout, anetz); /* go into idle state */ anetz_go_idle(anetz); - PDEBUG(DANETZ, DEBUG_NOTICE, "Created 'Kanal' #%s\n", kanal); + LOGP(DANETZ, LOGL_NOTICE, "Created 'Kanal' #%s\n", kanal); return 0; @@ -244,9 +244,9 @@ void anetz_destroy(sender_t *sender) { anetz_t *anetz = (anetz_t *) sender; - PDEBUG(DANETZ, DEBUG_DEBUG, "Destroying 'A-Netz' instance for 'Kanal' = %s.\n", sender->kanal); + LOGP(DANETZ, LOGL_DEBUG, "Destroying 'A-Netz' instance for 'Kanal' = %s.\n", sender->kanal); - timer_exit(&anetz->timer); + osmo_timer_del(&anetz->timer); dsp_cleanup_sender(anetz); sender_destroy(&anetz->sender); free(sender); @@ -255,9 +255,9 @@ void anetz_destroy(sender_t *sender) /* Abort connection towards mobile station by sending idle tone. */ static void anetz_go_idle(anetz_t *anetz) { - timer_stop(&anetz->timer); + osmo_timer_del(&anetz->timer); - PDEBUG(DANETZ, DEBUG_INFO, "Entering IDLE state on channel %s, sending 2280 Hz tone.\n", anetz->sender.kanal); + LOGP(DANETZ, LOGL_INFO, "Entering IDLE state on channel %s, sending 2280 Hz tone.\n", anetz->sender.kanal); anetz->station_id[0] = '\0'; /* remove station ID before state change, so status is shown correctly */ anetz_new_state(anetz, ANETZ_FREI); /* also reset detector, so if there is a new call it is answered */ @@ -267,31 +267,31 @@ static void anetz_go_idle(anetz_t *anetz) /* Release connection towards mobile station by sending idle tone for a while. */ static void anetz_release(anetz_t *anetz) { - timer_stop(&anetz->timer); + osmo_timer_del(&anetz->timer); - PDEBUG_CHAN(DANETZ, DEBUG_INFO, "Sending 2280 Hz release tone.\n"); + LOGP_CHAN(DANETZ, LOGL_INFO, "Sending 2280 Hz release tone.\n"); anetz->station_id[0] = '\0'; /* remove station ID before state change, so status is shown correctly */ anetz_new_state(anetz, ANETZ_AUSLOESEN); anetz_set_dsp_mode(anetz, DSP_MODE_TONE, 0); - timer_start(&anetz->timer, RELEASE_TO); + osmo_timer_schedule(&anetz->timer, RELEASE_TO); } /* Enter paging state and transmit 4 paging tones. */ static void anetz_page(anetz_t *anetz, const char *dial_string, double *freq) { - PDEBUG_CHAN(DANETZ, DEBUG_INFO, "Entering paging state, sending 'Selektivruf' to '%s'.\n", dial_string); + LOGP_CHAN(DANETZ, LOGL_INFO, "Entering paging state, sending 'Selektivruf' to '%s'.\n", dial_string); strcpy(anetz->station_id, dial_string); /* set station ID before state change, so status is shown correctly */ anetz_new_state(anetz, ANETZ_ANRUF); anetz_set_dsp_mode(anetz, DSP_MODE_PAGING, 0); dsp_set_paging(anetz, freq); - timer_start(&anetz->timer, PAGING_TO); + osmo_timer_schedule(&anetz->timer, PAGING_TO); } /* Loss of signal was detected, release active call. */ void anetz_loss_indication(anetz_t *anetz, double loss_time) { if (anetz->state == ANETZ_GESPRAECH) { - PDEBUG_CHAN(DANETZ, DEBUG_NOTICE, "Detected loss of signal after %.1f seconds, releasing.\n", loss_time); + LOGP_CHAN(DANETZ, LOGL_NOTICE, "Detected loss of signal after %.1f seconds, releasing.\n", loss_time); anetz_release(anetz); call_up_release(anetz->callref, CAUSE_TEMPFAIL); anetz->callref = 0; @@ -302,9 +302,9 @@ void anetz_loss_indication(anetz_t *anetz, double loss_time) void anetz_receive_tone(anetz_t *anetz, int tone) { if (tone >= 0) - PDEBUG_CHAN(DANETZ, DEBUG_DEBUG, "Received contiuous %d Hz tone.\n", (tone) ? 1750 : 2280); + LOGP_CHAN(DANETZ, LOGL_DEBUG, "Received contiuous %d Hz tone.\n", (tone) ? 1750 : 2280); else - PDEBUG_CHAN(DANETZ, DEBUG_DEBUG, "Continuous tone is gone.\n"); + LOGP_CHAN(DANETZ, LOGL_DEBUG, "Continuous tone is gone.\n"); /* skip any handling in loopback mode */ if (anetz->sender.loopback) @@ -318,7 +318,7 @@ void anetz_receive_tone(anetz_t *anetz, int tone) case ANETZ_FREI: /* initiate call on calling tone */ if (tone == 1) { - PDEBUG_CHAN(DANETZ, DEBUG_INFO, "Received 1750 Hz calling signal from mobile station, removing idle signal.\n"); + LOGP_CHAN(DANETZ, LOGL_INFO, "Received 1750 Hz calling signal from mobile station, removing idle signal.\n"); strcpy(anetz->station_id, "unknown"); /* set station ID before state change, so status is shown correctly */ anetz_new_state(anetz, ANETZ_GESPRAECH); @@ -330,17 +330,17 @@ void anetz_receive_tone(anetz_t *anetz, int tone) /* throughconnect speech when calling/answer tone is gone */ if (tone != 1) { if (!anetz->callref) { - PDEBUG_CHAN(DANETZ, DEBUG_INFO, "1750 Hz signal from mobile station is gone, setup call.\n"); + LOGP_CHAN(DANETZ, LOGL_INFO, "1750 Hz signal from mobile station is gone, setup call.\n"); anetz->callref = call_up_setup(NULL, anetz->operator, OSMO_CC_NETWORK_ANETZ_NONE, ""); } else { - PDEBUG_CHAN(DANETZ, DEBUG_INFO, "1750 Hz signal from mobile station is gone, answer call.\n"); + LOGP_CHAN(DANETZ, LOGL_INFO, "1750 Hz signal from mobile station is gone, answer call.\n"); call_up_answer(anetz->callref, anetz->station_id); } anetz_set_dsp_mode(anetz, DSP_MODE_AUDIO, 0); } /* release call */ if (tone == 1) { - PDEBUG_CHAN(DANETZ, DEBUG_INFO, "Received 1750 Hz release signal from mobile station, sending release tone.\n"); + LOGP_CHAN(DANETZ, LOGL_INFO, "Received 1750 Hz release signal from mobile station, sending release tone.\n"); anetz_release(anetz); call_up_release(anetz->callref, CAUSE_NORMAL); anetz->callref = 0; @@ -350,8 +350,8 @@ void anetz_receive_tone(anetz_t *anetz, int tone) case ANETZ_ANRUF: /* answer call on answer tone */ if (tone == 1) { - PDEBUG_CHAN(DANETZ, DEBUG_INFO, "Received 1750 Hz answer signal from mobile station, removing paging tones.\n"); - timer_stop(&anetz->timer); + LOGP_CHAN(DANETZ, LOGL_INFO, "Received 1750 Hz answer signal from mobile station, removing paging tones.\n"); + osmo_timer_del(&anetz->timer); anetz_new_state(anetz, ANETZ_GESPRAECH); anetz_set_dsp_mode(anetz, DSP_MODE_SILENCE, 0); break; @@ -362,13 +362,13 @@ void anetz_receive_tone(anetz_t *anetz, int tone) } /* Timeout handling */ -static void anetz_timeout(struct timer *timer) +static void anetz_timeout(void *data) { - anetz_t *anetz = (anetz_t *)timer->priv; + anetz_t *anetz = data; switch (anetz->state) { case ANETZ_ANRUF: - PDEBUG_CHAN(DANETZ, DEBUG_NOTICE, "Timeout while waiting for answer, releasing.\n"); + LOGP_CHAN(DANETZ, LOGL_NOTICE, "Timeout while waiting for answer, releasing.\n"); anetz_go_idle(anetz); call_up_release(anetz->callref, CAUSE_NOANSWER); anetz->callref = 0; @@ -391,8 +391,8 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id, /* 1. determine paging frequencies */ freq = anetz_nummer2freq(dialing); if (!freq) { - PDEBUG(DANETZ, DEBUG_NOTICE, "Number invalid: %s\n", anetz_nummer2freq_error); - PDEBUG(DANETZ, DEBUG_NOTICE, "Outgoing call to invalid number '%s', rejecting!\n", dialing); + LOGP(DANETZ, LOGL_NOTICE, "Number invalid: %s\n", anetz_nummer2freq_error); + LOGP(DANETZ, LOGL_NOTICE, "Outgoing call to invalid number '%s', rejecting!\n", dialing); return -CAUSE_INVALNUMBER; } @@ -405,7 +405,7 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id, break; } if (sender) { - PDEBUG(DANETZ, DEBUG_NOTICE, "Outgoing call to busy number, rejecting!\n"); + LOGP(DANETZ, LOGL_NOTICE, "Outgoing call to busy number, rejecting!\n"); return -CAUSE_BUSY; } @@ -416,13 +416,13 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id, break; } if (!sender) { - PDEBUG(DANETZ, DEBUG_NOTICE, "Outgoing call, but no free channel, rejecting!\n"); + LOGP(DANETZ, LOGL_NOTICE, "Outgoing call, but no free channel, rejecting!\n"); return -CAUSE_NOCHANNEL; } - PDEBUG_CHAN(DANETZ, DEBUG_INFO, "Call to mobile station, paging with tones: %.1f %.1f %.1f %.1f\n", freq[0], freq[1], freq[2], freq[3]); + LOGP_CHAN(DANETZ, LOGL_INFO, "Call to mobile station, paging with tones: %.1f %.1f %.1f %.1f\n", freq[0], freq[1], freq[2], freq[3]); if (anetz->page_sequence) - PDEBUG(DANETZ, DEBUG_NOTICE, "Sending paging tones in sequence.\n"); + LOGP(DANETZ, LOGL_NOTICE, "Sending paging tones in sequence.\n"); /* 4. trying to page mobile station */ anetz->callref = callref; @@ -433,7 +433,7 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id, return 0; } -void call_down_answer(int __attribute__((unused)) callref) +void call_down_answer(int __attribute__((unused)) callref, struct timeval __attribute__((unused)) *tv_meter) { } @@ -446,7 +446,7 @@ void call_down_disconnect(int callref, int cause) sender_t *sender; anetz_t *anetz; - PDEBUG(DANETZ, DEBUG_INFO, "Call has been disconnected by network.\n"); + LOGP(DANETZ, LOGL_INFO, "Call has been disconnected by network.\n"); for (sender = sender_head; sender; sender = sender->next) { anetz = (anetz_t *) sender; @@ -454,7 +454,7 @@ void call_down_disconnect(int callref, int cause) break; } if (!sender) { - PDEBUG(DANETZ, DEBUG_NOTICE, "Outgoing disconnect, but no callref!\n"); + LOGP(DANETZ, LOGL_NOTICE, "Outgoing disconnect, but no callref!\n"); call_up_release(callref, CAUSE_INVALCALLREF); return; } @@ -464,7 +464,7 @@ void call_down_disconnect(int callref, int cause) return; switch (anetz->state) { case ANETZ_ANRUF: - PDEBUG_CHAN(DANETZ, DEBUG_NOTICE, "Outgoing disconnect, during alerting, going idle!\n"); + LOGP_CHAN(DANETZ, LOGL_NOTICE, "Outgoing disconnect, during alerting, going idle!\n"); anetz_go_idle(anetz); break; default: @@ -483,7 +483,7 @@ void call_down_release(int callref, __attribute__((unused)) int cause) sender_t *sender; anetz_t *anetz; - PDEBUG(DANETZ, DEBUG_INFO, "Call has been released by network, releasing call.\n"); + LOGP(DANETZ, LOGL_INFO, "Call has been released by network, releasing call.\n"); for (sender = sender_head; sender; sender = sender->next) { anetz = (anetz_t *) sender; @@ -491,7 +491,7 @@ void call_down_release(int callref, __attribute__((unused)) int cause) break; } if (!sender) { - PDEBUG(DANETZ, DEBUG_NOTICE, "Outgoing release, but no callref!\n"); + LOGP(DANETZ, LOGL_NOTICE, "Outgoing release, but no callref!\n"); /* don't send release, because caller already released */ return; } @@ -500,11 +500,11 @@ void call_down_release(int callref, __attribute__((unused)) int cause) switch (anetz->state) { case ANETZ_GESPRAECH: - PDEBUG_CHAN(DANETZ, DEBUG_NOTICE, "Outgoing release, during call, sending release tone!\n"); + LOGP_CHAN(DANETZ, LOGL_NOTICE, "Outgoing release, during call, sending release tone!\n"); anetz_release(anetz); break; case ANETZ_ANRUF: - PDEBUG_CHAN(DANETZ, DEBUG_NOTICE, "Outgoing release, during alerting, going idle!\n"); + LOGP_CHAN(DANETZ, LOGL_NOTICE, "Outgoing release, during alerting, going idle!\n"); anetz_go_idle(anetz); break; default: @@ -512,25 +512,5 @@ void call_down_release(int callref, __attribute__((unused)) int cause) } } -/* Receive audio from call instance. */ -void call_down_audio(int callref, uint16_t sequence, uint32_t timestamp, uint32_t ssrc, sample_t *samples, int count) -{ - sender_t *sender; - anetz_t *anetz; - - for (sender = sender_head; sender; sender = sender->next) { - anetz = (anetz_t *) sender; - if (anetz->callref == callref) - break; - } - if (!sender) - return; - - if (anetz->dsp_mode == DSP_MODE_AUDIO) - jitter_save(&anetz->sender.dejitter, samples, count, 1, sequence, timestamp, ssrc); -} - -void call_down_clock(void) {} - void dump_info(void) {} diff --git a/src/anetz/anetz.h b/src/anetz/anetz.h index fc04d95..fcb7a61 100644 --- a/src/anetz/anetz.h +++ b/src/anetz/anetz.h @@ -24,7 +24,7 @@ typedef struct anetz { enum anetz_state state; /* current sender's state */ int callref; /* call reference */ char station_id[8]; /* current station ID */ - struct timer timer; + struct osmo_timer_list timer; /* display measurements */ dispmeasparam_t *dmp_tone_level; diff --git a/src/anetz/besetztton.c b/src/anetz/besetztton.c index 701e62a..4c5df68 100644 --- a/src/anetz/besetztton.c +++ b/src/anetz/besetztton.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include "besetztton.h" static int16_t pattern[] = { 0x0004, 0xffe9, 0xffc9, 0xffac, 0xff92, 0xff83, 0xff75, 0xff56, diff --git a/src/anetz/dsp.c b/src/anetz/dsp.c index e9a4dbb..06c5ac7 100644 --- a/src/anetz/dsp.c +++ b/src/anetz/dsp.c @@ -26,8 +26,8 @@ #include <errno.h> #include <math.h> #include "../libsample/sample.h" -#include "../libdebug/debug.h" -#include "../libtimer/timer.h" +#include "../liblogging/logging.h" +#include <osmocom/core/timer.h> #include "../libmobile/call.h" #include "anetz.h" #include "dsp.h" @@ -68,7 +68,7 @@ void dsp_init(void) int i; double s; - PDEBUG(DDSP, DEBUG_DEBUG, "Generating sine tables.\n"); + LOGP(DDSP, LOGL_DEBUG, "Generating sine tables.\n"); for (i = 0; i < 65536; i++) { s = sin((double)i / 65536.0 * 2.0 * PI); dsp_sine_tone[i] = s * TX_PEAK_TONE; @@ -83,7 +83,7 @@ int dsp_init_sender(anetz_t *anetz, double page_gain, int page_sequence, double int i; double tone; - PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for 'Sender'.\n"); + LOGP_CHAN(DDSP, LOGL_DEBUG, "Init DSP for 'Sender'.\n"); /* init squelch */ squelch_init(&anetz->squelch, anetz->sender.kanal, squelch_db, MUTE_TIME, LOSS_TIME); @@ -95,10 +95,10 @@ int dsp_init_sender(anetz_t *anetz, double page_gain, int page_sequence, double anetz->page_sequence = page_sequence; anetz->samples_per_chunk = anetz->sender.samplerate * CHUNK_DURATION; - PDEBUG(DDSP, DEBUG_DEBUG, "Using %d samples per filter chunk duration.\n", anetz->samples_per_chunk); + LOGP(DDSP, LOGL_DEBUG, "Using %d samples per filter chunk duration.\n", anetz->samples_per_chunk); spl = calloc(anetz->samples_per_chunk, sizeof(sample_t)); if (!spl) { - PDEBUG(DDSP, DEBUG_ERROR, "No memory!\n"); + LOGP(DDSP, LOGL_ERROR, "No memory!\n"); return -ENOMEM; } anetz->fsk_filter_spl = spl; @@ -119,7 +119,7 @@ int dsp_init_sender(anetz_t *anetz, double page_gain, int page_sequence, double /* Cleanup transceiver instance. */ void dsp_cleanup_sender(anetz_t *anetz) { - PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for 'Sender'.\n"); + LOGP_CHAN(DDSP, LOGL_DEBUG, "Cleanup DSP for 'Sender'.\n"); if (anetz->fsk_filter_spl) { free(anetz->fsk_filter_spl); @@ -133,7 +133,7 @@ static void fsk_receive_tone(anetz_t *anetz, int tone, int goodtone, double leve /* lost tone because it is not good anymore or has changed */ if (!goodtone || tone != anetz->tone_detected) { if (anetz->tone_count >= TONE_DETECT_TH) { - PDEBUG_CHAN(DDSP, DEBUG_INFO, "Lost %.0f Hz tone after %.0f ms.\n", fsk_tones[anetz->tone_detected], 1000.0 * CHUNK_DURATION * anetz->tone_count); + LOGP_CHAN(DDSP, LOGL_INFO, "Lost %.0f Hz tone after %.0f ms.\n", fsk_tones[anetz->tone_detected], 1000.0 * CHUNK_DURATION * anetz->tone_count); anetz_receive_tone(anetz, -1); } if (goodtone) @@ -148,7 +148,7 @@ static void fsk_receive_tone(anetz_t *anetz, int tone, int goodtone, double leve anetz->tone_count++; if (anetz->tone_count == TONE_DETECT_TH) { - PDEBUG_CHAN(DDSP, DEBUG_INFO, "Detecting continuous %.0f Hz tone. (level = %.0f%%, quality =%.0f%%)\n", fsk_tones[anetz->tone_detected], level * 100.0, quality * 100.0); + LOGP_CHAN(DDSP, LOGL_INFO, "Detecting continuous %.0f Hz tone. (level = %.0f%%, quality =%.0f%%)\n", fsk_tones[anetz->tone_detected], level * 100.0, quality * 100.0); anetz_receive_tone(anetz, anetz->tone_detected); } } @@ -171,7 +171,7 @@ static void fsk_decode_chunk(anetz_t *anetz, sample_t *spl, int max) display_measurements_update(anetz->dmp_tone_level, level * 100.0, 0.0); display_measurements_update(anetz->dmp_tone_quality, quality[1] * 100.0, 0.0); if ((level > TONE_THRESHOLD && quality[1] > QUAL_THRESHOLD) || anetz->sender.loopback) - PDEBUG_CHAN(DDSP, DEBUG_INFO, "Tone %.0f: Level=%3.0f%% Quality=%3.0f%%\n", fsk_tones[1], level * 100.0, quality[1] * 100.0); + LOGP_CHAN(DDSP, LOGL_INFO, "Tone %.0f: Level=%3.0f%% Quality=%3.0f%%\n", fsk_tones[1], level * 100.0, quality[1] * 100.0); /* adjust level, so we get peak of sine curve */ /* indicate detected tone */ @@ -367,7 +367,11 @@ void sender_send(sender_t *sender, sample_t *samples, uint8_t *power, int length break; case DSP_MODE_AUDIO: input_num = samplerate_upsample_input_num(&sender->srstate, length); - jitter_load(&sender->dejitter, samples, input_num); + { + int16_t spl[input_num]; + jitter_load_samples(&sender->dejitter, (uint8_t *)spl, input_num, sizeof(*spl), jitter_conceal_s16, NULL); + int16_to_samples_speech(samples, spl, input_num); + } samplerate_upsample(&sender->srstate, samples, input_num, samples, length); break; case DSP_MODE_TONE: @@ -382,7 +386,7 @@ void sender_send(sender_t *sender, sample_t *samples, uint8_t *power, int length } } -const char *anetz_dsp_mode_name(enum dsp_mode mode) +static const char *anetz_dsp_mode_name(enum dsp_mode mode) { static char invalid[16]; @@ -403,7 +407,10 @@ const char *anetz_dsp_mode_name(enum dsp_mode mode) void anetz_set_dsp_mode(anetz_t *anetz, enum dsp_mode mode, int detect_reset) { - PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "DSP mode %s -> %s\n", anetz_dsp_mode_name(anetz->dsp_mode), anetz_dsp_mode_name(mode)); + LOGP_CHAN(DDSP, LOGL_DEBUG, "DSP mode %s -> %s\n", anetz_dsp_mode_name(anetz->dsp_mode), anetz_dsp_mode_name(mode)); + if (mode == DSP_MODE_AUDIO && anetz->dsp_mode != mode) + jitter_reset(&anetz->sender.dejitter); + anetz->dsp_mode = mode; /* reset sequence paging */ anetz->paging_tone = 0; @@ -414,3 +421,27 @@ void anetz_set_dsp_mode(anetz_t *anetz, enum dsp_mode mode, int detect_reset) anetz->tone_detected = -1; } +/* Receive audio from call instance. */ +void call_down_audio(void *decoder, void *decoder_priv, int callref, uint16_t sequence, uint8_t marker, uint32_t timestamp, uint32_t ssrc, uint8_t *payload, int payload_len) +{ + sender_t *sender; + anetz_t *anetz; + + for (sender = sender_head; sender; sender = sender->next) { + anetz = (anetz_t *) sender; + if (anetz->callref == callref) + break; + } + if (!sender) + return; + + if (anetz->dsp_mode == DSP_MODE_AUDIO) { + jitter_frame_t *jf; + jf = jitter_frame_alloc(decoder, decoder_priv, payload, payload_len, marker, sequence, timestamp, ssrc); + if (jf) + jitter_save(&anetz->sender.dejitter, jf); + } +} + +void call_down_clock(void) {} + diff --git a/src/anetz/freiton.c b/src/anetz/freiton.c index 7964c3f..ec2e94d 100644 --- a/src/anetz/freiton.c +++ b/src/anetz/freiton.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include "freiton.h" static int16_t pattern[] = { 0x0056, 0x0068, 0x0065, 0x005d, 0x0040, 0x0031, 0x001a, 0x000d, diff --git a/src/anetz/main.c b/src/anetz/main.c index cd6f015..8286f71 100644 --- a/src/anetz/main.c +++ b/src/anetz/main.c @@ -25,8 +25,8 @@ #include <math.h> #include "../libsample/sample.h" #include "../libmobile/main_mobile.h" -#include "../libdebug/debug.h" -#include "../libtimer/timer.h" +#include "../liblogging/logging.h" +#include <osmocom/core/timer.h> #include "../libmobile/call.h" #include "../liboptions/options.h" #include "../libfm/fm.h" @@ -198,6 +198,7 @@ fail: anetz_destroy(sender_head); /* exits */ + main_mobile_exit(); fm_exit(); options_free(); diff --git a/src/anetz/stations.c b/src/anetz/stations.c index 9908755..a7878bb 100644 --- a/src/anetz/stations.c +++ b/src/anetz/stations.c @@ -2,6 +2,7 @@ #include <stdlib.h> #include <string.h> #include <math.h> +#include "stations.h" static struct anetz_stations { const char *standort; @@ -147,7 +148,7 @@ static struct anetz_stations { { NULL, 0, 0, 0, 0, 0, NULL } }; -double lat_from_coordinates(const char *string) +static double lat_from_coordinates(const char *string) { if (strlen(string) != 11) abort(); @@ -168,7 +169,7 @@ double lat_from_coordinates(const char *string) (double)(string[4] - '0') / 60.0; } -double lon_from_coordinates(const char *string) +static double lon_from_coordinates(const char *string) { if (strlen(string) != 11) abort(); @@ -200,7 +201,45 @@ void station_list(void) printf("List of all base stations:\n"); for (i = 0; anetz_stations[i].standort; i++) { - printf("%s (%.2f° N %.2f° E)\n", anetz_stations[i].standort, lat_from_coordinates(anetz_stations[i].coordinates), lon_from_coordinates(anetz_stations[i].coordinates)); + printf("%s (%.2f deg N %.2f deg E)\n", anetz_stations[i].standort, lat_from_coordinates(anetz_stations[i].coordinates), lon_from_coordinates(anetz_stations[i].coordinates)); + if (anetz_stations[i].kanal21) { + if (anetz_stations[i].kanal22) + printf("\tPrefix 21: Channel %d\n", anetz_stations[i].kanal21); + else if (anetz_stations[i].kanal23) + printf("\tPrefix 21-22: Channel %d\n", anetz_stations[i].kanal21); + else if (anetz_stations[i].kanal24) + printf("\tPrefix 21-23: Channel %d\n", anetz_stations[i].kanal21); + else if (anetz_stations[i].kanal25) + printf("\tPrefix 21-24: Channel %d\n", anetz_stations[i].kanal21); + else + printf("\tPrefix 21-25: Channel %d\n", anetz_stations[i].kanal21); + } + if (anetz_stations[i].kanal22) { + if (anetz_stations[i].kanal23) + printf("\tPrefix 22: Channel %d\n", anetz_stations[i].kanal22); + else if (anetz_stations[i].kanal24) + printf("\tPrefix 22-23: Channel %d\n", anetz_stations[i].kanal22); + else if (anetz_stations[i].kanal25) + printf("\tPrefix 22-24: Channel %d\n", anetz_stations[i].kanal22); + else + printf("\tPrefix 22-25: Channel %d\n", anetz_stations[i].kanal22); + } + if (anetz_stations[i].kanal23) { + if (anetz_stations[i].kanal24) + printf("\tPrefix 23: Channel %d\n", anetz_stations[i].kanal23); + else if (anetz_stations[i].kanal25) + printf("\tPrefix 23-24: Channel %d\n", anetz_stations[i].kanal23); + else + printf("\tPrefix 23-25: Channel %d\n", anetz_stations[i].kanal23); + } + if (anetz_stations[i].kanal24) { + if (anetz_stations[i].kanal25) + printf("\tPrefix 24: Channel %d\n", anetz_stations[i].kanal24); + else + printf("\tPrefix 24-25: Channel %d\n", anetz_stations[i].kanal24); + } + if (anetz_stations[i].kanal25) + printf("\tPrefix 25: Channel %d\n", anetz_stations[i].kanal25); } } |