Move from local to external osmo* libraries

src/libdebug -> libosmocore
src/libselect -> libosmocore
src/libtimer -> libosmocore
src/libosmocc -> libosmo-cc
src/libg711 -> libosmo-cc
This commit is contained in:
Andreas Eversberg 2024-01-05 14:20:36 +01:00
parent 6cd2c3e323
commit 3158c48365
198 changed files with 4202 additions and 12564 deletions

7
.gitignore vendored
View File

@ -19,8 +19,8 @@ compile
.deps
.libs
.dirstamp
src/liblogging/liblogging.a
src/liboptions/liboptions.a
src/libdebug/libdebug.a
src/libmobile/libmobile.a
src/libdisplay/libdisplay.a
src/libimage/libimage.a
@ -31,9 +31,6 @@ src/libjitter/libjitter.a
src/libsquelch/libsquelch.a
src/libhagelbarger/libhagelbarger.a
src/libdtmf/libdtmf.a
src/libtimer/libtimer.a
src/libselect/libselect.a
src/libph_socket/libph_socket.a
src/libsamplerate/libsamplerate.a
src/libscrambler/libscrambler.a
src/libemphasis/libemphasis.a
@ -50,8 +47,6 @@ src/libclipper/libclipper.a
src/libserial/libserial.a
src/libv27/libv27.a
src/libmtp/libmtp.a
src/libosmocc/libosmocc.a
src/libg711/libg711.a
src/libaaimage/libaaimage.a
src/anetz/libgermanton.a
src/anetz/anetz

32
INSTALL
View File

@ -1,24 +1,30 @@
You need to have the following packages install:
* libosmocore, core libraries for various osmocom related projects
* libosmo-cc, call control interface library, to interconnect applications
* automake, gcc for compilation
* libasound2 for sound card support, which is what you need!
* libsoapysdr or libuhd (developer) to support SDR
* -> SoapySDR modules to support your SDR hardware
* libimagamagick version >= 7 (developer) optionally for TV image display
Install libosmocore:
See: https://osmocom.org/projects/libosmocore/wiki/Libosmocore
Generate "configure":
$ autoreconf -if
Run "configure":
$ ./configure
Build and install:
Install libosmo-cc:
$ git clone https://gitea.osmocom.org/osmocom/libosmo-cc.git
$ cd libosmocore/
$ autoreconf -i
$./configure
$ make
$ make install
s udo make install
$ sudo ldconfig -i
$ cd ..
Install osmocom-analog:
$ autoreconf -i
$ ./configure
$ make
$ sudo make install

View File

@ -1,7 +1,5 @@
dnl Process this file with autoconf to produce a configure script
AC_INIT([abcnetz],
m4_esyscmd([./git-version-gen .tarball-version]),
[jolly@eversberg.eu])
AC_INIT([abcnetz],[m4_esyscmd(./git-version-gen .tarball-version)],[jolly@eversberg.eu])
AM_INIT_AUTOMAKE([dist-bzip2])
@ -17,9 +15,6 @@ AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_RANLIB
dnl checks for header files
AC_HEADER_STDC
dnl Checks for typedefs, structures and compiler characteristics
AC_CANONICAL_HOST
@ -27,6 +22,9 @@ AC_CANONICAL_HOST
AC_CHECK_LIB([m], [main], [], [echo "Failed to find lib!" ; exit -1])
AC_CHECK_LIB([pthread], [main], [], [echo "Failed to find lib!" ; exit -1])
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.6.0)
PKG_CHECK_MODULES(LIBOSMOCC, libosmocc >= 1.0.0)
with_sdr=no
soapy_0_8_0_or_higher=
AC_ARG_WITH([alsa], [AS_HELP_STRING([--with-alsa], [compile with Alsa driver @<:@default=check@:>@]) ], [], [with_alsa="check"])
@ -60,9 +58,8 @@ AS_IF([test "x$with_alsa" != "xyes" -a "x$with_sdr" != "xyes"],[AC_MSG_NOTICE( W
SOAPY_CFLAGS="$soapy_0_8_0_or_higher"
AC_OUTPUT(
AC_CONFIG_FILES([src/liblogging/Makefile
src/liboptions/Makefile
src/libdebug/Makefile
src/libmobile/Makefile
src/libdisplay/Makefile
src/libimage/Makefile
@ -73,9 +70,6 @@ AC_OUTPUT(
src/libsquelch/Makefile
src/libhagelbarger/Makefile
src/libdtmf/Makefile
src/libtimer/Makefile
src/libselect/Makefile
src/libph_socket/Makefile
src/libsamplerate/Makefile
src/libscrambler/Makefile
src/libemphasis/Makefile
@ -92,8 +86,6 @@ AC_OUTPUT(
src/libserial/Makefile
src/libv27/Makefile
src/libmtp/Makefile
src/libosmocc/Makefile
src/libg711/Makefile
src/libaaimage/Makefile
src/anetz/Makefile
src/bnetz/Makefile
@ -119,6 +111,7 @@ AC_OUTPUT(
src/test/Makefile
src/Makefile
extra/Makefile
Makefile)
Makefile])
AC_OUTPUT

View File

@ -66,7 +66,7 @@ Create a virtual machine with the following settings:
<ul>
<li>Create a virtual machine with Ubuntu (64-bit)
<li>Choose memory size of at least 2 GB
<li>Create a virtual hard drive with at least 10 GB
<li>Create a virtual hard drive with 25 GB
<li>Emulate sound with output and input
<li>Select USB 3.0 (xHCI) Controller
</ul>
@ -162,6 +162,18 @@ Installing osmocom-analog
</p>
<p>
You need two libraries, the first is "libosmocore". It is included with Ubuntu/Debian:
</p>
<pre>
# sudo apt install libosmocore-dev
</pre>
<p>
The next library is "libosmo-cc". It is not included with Ubuntu/Debian, so you need to install it from GIT.
Use GIT to clone latest source repository. First you need to install GIT.
</p>
@ -173,7 +185,73 @@ Use GIT to clone latest source repository. First you need to install GIT.
</pre>
<p>
Then you can clone osmocom-analog from <a href="https://gitea.osmocom.org/cellular-infrastructure/osmocom-analog">https://gitea.osmocom.org/cellular-infrastructure/osmocom-analog</a> in your home directory.
Then you can clone libosmo-cc from <a href="https://gitea.osmocom.org/cc/libosmo-cc">https://gitea.osmocom.org/cc/libosmo-cc</a> in your home directory.
</p>
<pre>
# cd ~
# git clone https://gitea.osmocom.org/cc/libosmo-cc
Cloning into 'libosmo-cc'...
...
</pre>
<p>
Before you can compile, you need to install <b>"autoconf"</b>, <b>"gcc"</b> and <b>"make"</b>, and <b>"libtool"</b>.
</p>
<pre>
# sudo apt install autoconf gcc make libtool
</pre>
<p>
Change to the repository directory and run <b>"autoconf -if"</b> once. This is only needed the first time compiling. It will generate the configure script.
</p>
<pre>
# cd libosmo-c
# autoreconf -if
...
#
</pre>
<p>
Run configure script. It will generate the make files depending on your supported libraries.
</p>
<pre>
# ./configure
</pre>
<p>
Run <b>"make"</b> and <b>"make install"</b> to build and install osmocom-analog. Don't forget to run <b>"ldconfig"</b>, so you library database does know it.
</p>
<pre>
# make clean # always do this after you pulled from GIT server
# make
...
# sudo make install
...
# sudo ldconfig
# cd ..
</pre>
<p>
Use GIT to clone latest source repository. First you need to install GIT.
</p>
<p>
Then you can clone osmocom-analog from <a href="https://gitea.osmocom.org/cellular-infrastructure/osmocom-analog">https://gitea.osmocom.org/cellular-infrastructure/osmocom-analog</a> in your home directory.
</p>
<pre>
@ -184,20 +262,6 @@ Cloning into 'osmocom-analog'...
...
</pre>
<p>
Before you can compile, you need to install <b>"autoconf"</b>, <b>"gcc"</b> and <b>"make"</b>.
</p>
<pre>
# sudo apt install autoconf
# sudo apt install gcc
# sudo apt install make
</pre>
</pre>
<p>
@ -242,6 +306,10 @@ configure: Compiling with FUSE
</pre>
<p style="background-color: yellow;">
If you get something like "sytax error near unexpected token `ALSA,`", check, if pkg-config is installed. If you just installed it, run "autoreconf -if" again and then "./configure".
</p>
<p>
Run <b>"make"</b> and <b>"make install"</b> to build and install osmocom-analog.
</p>
@ -253,6 +321,7 @@ Run <b>"make"</b> and <b>"make install"</b> to build and install osmocom-analog.
...
# sudo make install
...
# cd ..
</pre>

View File

@ -7,6 +7,7 @@ cnetz_memory_card_generator_SOURCES = \
main.c
cnetz_memory_card_generator_LDADD = \
$(COMMON_LA) \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/liboptions/liboptions.a
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/liblogging/liblogging.a \
$(LIBOSMOCORE_LIBS)

View File

@ -22,7 +22,7 @@
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <../src/libdebug/debug.h>
#include <../src/liblogging/logging.h>
#include <../src/liboptions/options.h>
int num_kanal = 1;
@ -196,7 +196,8 @@ int main(int argc, char *argv[])
int argi;
int i;
debuglevel = DEBUG_INFO;
loglevel = LOGL_INFO;
logging_init();
add_options();
@ -255,3 +256,5 @@ inval_sub:
return 0;
}
void osmo_cc_set_log_cat(void) {}

View File

@ -1,8 +1,8 @@
AUTOMAKE_OPTIONS = foreign
SUBDIRS = \
liblogging \
liboptions \
libdebug \
libmobile \
libdisplay \
libsample \
@ -14,9 +14,6 @@ SUBDIRS = \
libsquelch \
libhagelbarger \
libdtmf \
libtimer \
libselect \
libph_socket \
libsamplerate \
libscrambler \
libemphasis \
@ -30,8 +27,6 @@ SUBDIRS = \
libserial \
libv27 \
libmtp \
libosmocc \
libg711 \
libaaimage
if HAVE_ALSA

View File

@ -31,23 +31,21 @@ amps_LDADD = \
libamps.a \
libusatone.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/libcompandor/libcompandor.a \
$(top_builddir)/src/libgoertzel/libgoertzel.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libselect/libselect.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
@ -76,23 +74,21 @@ tacs_LDADD = \
$(COMMON_LA) \
libamps.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/libcompandor/libcompandor.a \
$(top_builddir)/src/libgoertzel/libgoertzel.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libselect/libselect.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
@ -120,23 +116,21 @@ jtacs_LDADD = \
$(COMMON_LA) \
libamps.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/libcompandor/libcompandor.a \
$(top_builddir)/src/libgoertzel/libgoertzel.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libselect/libselect.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

View File

@ -43,10 +43,10 @@
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include <osmocom/cc/message.h>
#include "amps.h"
#include "dsp.h"
#include "frame.h"
@ -57,15 +57,15 @@
/* Uncomment this to test SAT via loopback */
//#define DEBUG_VC
#define SAT_TO1 5.0 /* 5 sec to detect after setup */
#define SAT_TO2 5.0 /* 5 sec lost until abort (specs say 5) */
#define PAGE_TRIES 2 /* how many times to page the phone */
#define PAGE_TO1 8.0 /* max time to wait for paging reply */
#define PAGE_TO2 4.0 /* max time to wait for last paging reply */
#define ALERT_TRIES 3 /* how many times to alert the phone */
#define ALERT_TO 0.6 /* max time to wait for alert confirm */
#define ANSWER_TO 60.0 /* max time to wait for answer */
#define RELEASE_TIMER 5.0 /* max time to send release messages */
#define SAT_TO1 5,0 /* 5 sec to detect after setup */
#define SAT_TO2 5,0 /* 5 sec lost until abort (specs say 5) */
#define PAGE_TRIES 2 /* how many times to page the phone */
#define PAGE_TO1 8,0 /* max time to wait for paging reply */
#define PAGE_TO2 4,0 /* max time to wait for last paging reply */
#define ALERT_TRIES 3 /* how many times to alert the phone */
#define ALERT_TO 0,600000 /* max time to wait for alert confirm */
#define ANSWER_TO 60,0 /* max time to wait for answer */
#define RELEASE_TIMER 5,0 /* max time to send release messages */
/* Convert channel number to frequency number of base station.
Set 'uplink' to 1 to get frequency of mobile station. */
@ -395,7 +395,7 @@ static void amps_new_state(amps_t *amps, enum amps_state new_state)
{
if (amps->state == new_state)
return;
PDEBUG_CHAN(DAMPS, DEBUG_DEBUG, "State change: %s -> %s\n", amps_state_name(amps->state), amps_state_name(new_state));
LOGP_CHAN(DAMPS, LOGL_DEBUG, "State change: %s -> %s\n", amps_state_name(amps->state), amps_state_name(new_state));
amps->state = new_state;
amps_display_status();
}
@ -429,7 +429,7 @@ int amps_channel_by_short_name(const char *short_name)
for (i = 0; amps_channels[i].short_name; i++) {
if (!strcasecmp(amps_channels[i].short_name, short_name)) {
PDEBUG(DAMPS, DEBUG_INFO, "Selecting channel '%s' = %s\n", amps_channels[i].short_name, amps_channels[i].long_name);
LOGP(DAMPS, LOGL_INFO, "Selecting channel '%s' = %s\n", amps_channels[i].short_name, amps_channels[i].long_name);
return amps_channels[i].chan_type;
}
}
@ -528,15 +528,15 @@ int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *de
/* check for channel number */
if (amps_channel2freq(atoi(kanal), 0) == 0) {
PDEBUG(DAMPS, DEBUG_ERROR, "Channel number %s invalid.\n", kanal);
LOGP(DAMPS, LOGL_ERROR, "Channel number %s invalid.\n", kanal);
if (jtacs)
PDEBUG(DAMPS, DEBUG_ERROR, "Try an even channel number, like 440.\n");
LOGP(DAMPS, LOGL_ERROR, "Try an even channel number, like 440.\n");
return -EINVAL;
}
/* no paging channel (without control channel) support */
if (chan_type == CHAN_TYPE_PC) {
PDEBUG(DAMPS, DEBUG_ERROR, "Dedicated paging channel currently not supported. Please select CC/PC or CC/PC/VC instead.\n");
LOGP(DAMPS, LOGL_ERROR, "Dedicated paging channel currently not supported. Please select CC/PC or CC/PC/VC instead.\n");
return -EINVAL;
}
@ -545,7 +545,7 @@ int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *de
for (sender = sender_head; sender; sender = sender->next) {
amps = (amps_t *)sender;
if (amps->chan_type == CHAN_TYPE_PC || amps->chan_type == CHAN_TYPE_CC_PC || amps->chan_type == CHAN_TYPE_CC_PC_VC) {
PDEBUG(DAMPS, DEBUG_ERROR, "Only one paging channel is currently supported. Please check your channel types.\n");
LOGP(DAMPS, LOGL_ERROR, "Only one paging channel is currently supported. Please check your channel types.\n");
return -EINVAL;
}
}
@ -554,51 +554,51 @@ int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *de
/* check if channel type matches channel number */
ct = amps_channel2type(atoi(kanal));
if (ct == CHAN_TYPE_CC && chan_type != CHAN_TYPE_PC && chan_type != CHAN_TYPE_CC_PC && chan_type != CHAN_TYPE_CC_PC_VC) {
PDEBUG(DAMPS, DEBUG_NOTICE, "Channel number %s belongs to a control channel, but your channel type '%s' requires to be on a voice channel number. Some phone may reject this, but all my phones don't.\n", kanal, chan_type_long_name(chan_type));
LOGP(DAMPS, LOGL_NOTICE, "Channel number %s belongs to a control channel, but your channel type '%s' requires to be on a voice channel number. Some phone may reject this, but all my phones don't.\n", kanal, chan_type_long_name(chan_type));
}
if (ct == CHAN_TYPE_VC && chan_type != CHAN_TYPE_VC) {
PDEBUG(DAMPS, DEBUG_ERROR, "Channel number %s belongs to a voice channel, but your channel type '%s' requires to be on a control channel number. Please use correct channel.\n", kanal, chan_type_long_name(chan_type));
LOGP(DAMPS, LOGL_ERROR, "Channel number %s belongs to a voice channel, but your channel type '%s' requires to be on a control channel number. Please use correct channel.\n", kanal, chan_type_long_name(chan_type));
return -EINVAL;
}
/* only even channels */
if (jtacs && chan_type != CHAN_TYPE_VC && (atoi(kanal) & 1)) {
PDEBUG(DAMPS, DEBUG_ERROR, "Control channel on JTACS system seem not to work with odd channel numbers. Please use even channel number.\n");
LOGP(DAMPS, LOGL_ERROR, "Control channel on JTACS system seem not to work with odd channel numbers. Please use even channel number.\n");
return -EINVAL;
}
/* check if sid machtes channel band */
band = amps_channel2band(atoi(kanal));
if (band[0] == 'A' && (sid & 1) == 0 && chan_type != CHAN_TYPE_VC) {
PDEBUG(DAMPS, DEBUG_ERROR, "Channel number %s belongs to system A, but your %s %d is even and belongs to system B. Please give odd %s.\n", kanal, (!tacs) ? "SID" : "AID", sid, (!tacs) ? "SID" : "AID");
LOGP(DAMPS, LOGL_ERROR, "Channel number %s belongs to system A, but your %s %d is even and belongs to system B. Please give odd %s.\n", kanal, (!tacs) ? "SID" : "AID", sid, (!tacs) ? "SID" : "AID");
return -EINVAL;
}
if (band[0] == 'B' && (sid & 1) == 1 && chan_type != CHAN_TYPE_VC) {
PDEBUG(DAMPS, DEBUG_ERROR, "Channel number %s belongs to system B, but your %s %d is odd and belongs to system A. Please give even %s.\n", kanal, (!tacs) ? "SID" : "AID", sid, (!tacs) ? "SID" : "AID");
LOGP(DAMPS, LOGL_ERROR, "Channel number %s belongs to system B, but your %s %d is odd and belongs to system A. Please give even %s.\n", kanal, (!tacs) ? "SID" : "AID", sid, (!tacs) ? "SID" : "AID");
return -EINVAL;
}
/* check if we use combined voice channel hack */
if (chan_type == CHAN_TYPE_CC_PC_VC) {
PDEBUG(DAMPS, DEBUG_NOTICE, "You selected '%s'. This is a hack, but the only way to use control channel and voice channel on one transceiver. Some phones may reject this, but all my phones don't.\n", chan_type_long_name(chan_type));
LOGP(DAMPS, LOGL_NOTICE, "You selected '%s'. This is a hack, but the only way to use control channel and voice channel on one transceiver. Some phones may reject this, but all my phones don't.\n", chan_type_long_name(chan_type));
}
/* check if we selected a voice channel that i outside 20 MHz band */
if (chan_type == CHAN_TYPE_VC && atoi(kanal) > 666) {
PDEBUG(DAMPS, DEBUG_NOTICE, "You selected '%s' on channel #%s. Older phones do not support channels above #666.\n", chan_type_long_name(chan_type), kanal);
LOGP(DAMPS, LOGL_NOTICE, "You selected '%s' on channel #%s. Older phones do not support channels above #666.\n", chan_type_long_name(chan_type), kanal);
}
amps = calloc(1, sizeof(amps_t));
if (!amps) {
PDEBUG(DAMPS, DEBUG_ERROR, "No memory!\n");
LOGP(DAMPS, LOGL_ERROR, "No memory!\n");
return -ENOMEM;
}
PDEBUG(DAMPS, DEBUG_DEBUG, "Creating 'AMPS' instance for channel = %s of band %s (sample rate %d).\n", kanal, band, samplerate);
LOGP(DAMPS, LOGL_DEBUG, "Creating 'AMPS' instance for channel = %s of band %s (sample rate %d).\n", kanal, band, samplerate);
/* init general part of transceiver */
rc = sender_create(&amps->sender, kanal, amps_channel2freq(atoi(kanal), 0), amps_channel2freq(atoi(kanal), 1), device, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to init transceiver process!\n");
LOGP(DAMPS, LOGL_ERROR, "Failed to init transceiver process!\n");
goto error;
}
@ -619,7 +619,7 @@ int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *de
/* init audio processing */
rc = dsp_init_sender(amps, tolerant);
if (rc < 0) {
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to init audio processing!\n");
LOGP(DAMPS, LOGL_ERROR, "Failed to init audio processing!\n");
goto error;
}
@ -634,7 +634,7 @@ int amps_create(const char *kanal, enum amps_chan_type chan_type, const char *de
// amps_new_state(amps, STATE_BUSY);
#endif
PDEBUG(DAMPS, DEBUG_NOTICE, "Created channel #%s (System %s) of type '%s' = %s\n", kanal, band, chan_type_short_name(chan_type), chan_type_long_name(chan_type));
LOGP(DAMPS, LOGL_NOTICE, "Created channel #%s (System %s) of type '%s' = %s\n", kanal, band, chan_type_short_name(chan_type), chan_type_long_name(chan_type));
return 0;
@ -650,11 +650,11 @@ void amps_destroy(sender_t *sender)
amps_t *amps = (amps_t *) sender;
transaction_t *trans;
PDEBUG(DAMPS, DEBUG_DEBUG, "Destroying 'AMPS' instance for channel = %s.\n", sender->kanal);
LOGP(DAMPS, LOGL_DEBUG, "Destroying 'AMPS' instance for channel = %s.\n", sender->kanal);
while ((trans = amps->trans_list)) {
const char *number = amps_min2number(trans->min1, trans->min2);
PDEBUG(DAMPS, DEBUG_NOTICE, "Removing pending transaction for subscriber '%s'\n", number);
LOGP(DAMPS, LOGL_NOTICE, "Removing pending transaction for subscriber '%s'\n", number);
destroy_transaction(trans);
}
@ -672,7 +672,7 @@ void amps_go_idle(amps_t *amps)
return;
if (amps->trans_list) {
PDEBUG(DAMPS, DEBUG_ERROR, "Releasing but still having transaction, please fix!\n");
LOGP(DAMPS, LOGL_ERROR, "Releasing but still having transaction, please fix!\n");
if (amps->trans_list->callref)
call_up_release(amps->trans_list->callref, CAUSE_NORMAL);
destroy_transaction(amps->trans_list);
@ -681,14 +681,14 @@ void amps_go_idle(amps_t *amps)
amps_new_state(amps, STATE_IDLE);
if (amps->chan_type != CHAN_TYPE_VC) {
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Entering IDLE state, sending Overhead/Filler frames on %s.\n", chan_type_long_name(amps->chan_type));
LOGP_CHAN(DAMPS, LOGL_INFO, "Entering IDLE state, sending Overhead/Filler frames on %s.\n", chan_type_long_name(amps->chan_type));
if (amps->sender.loopback)
frame_length = 441; /* bits after sync (FOCC) */
else
frame_length = 247; /* bits after sync (RECC) */
amps_set_dsp_mode(amps, DSP_MODE_FRAME_RX_FRAME_TX, frame_length);
} else {
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Entering IDLE state (sending silence / no RF) on %s.\n", chan_type_long_name(amps->chan_type));
LOGP_CHAN(DAMPS, LOGL_INFO, "Entering IDLE state (sending silence / no RF) on %s.\n", chan_type_long_name(amps->chan_type));
amps_set_dsp_mode(amps, DSP_MODE_OFF, 0);
}
}
@ -698,8 +698,8 @@ static void amps_release(transaction_t *trans, uint8_t cause)
{
amps_t *amps = trans->amps;
timer_stop(&trans->timer);
timer_start(&trans->timer, RELEASE_TIMER);
osmo_timer_del(&trans->timer);
osmo_timer_schedule(&trans->timer, RELEASE_TIMER);
trans_new_state(trans, TRANS_CALL_RELEASE);
trans->chan = 0;
trans->msg_type = 0;
@ -722,14 +722,14 @@ void amps_rx_signaling_tone(amps_t *amps, int tone, double quality)
{
transaction_t *trans = amps->trans_list;
if (trans == NULL) {
PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "Signaling Tone without transaction, please fix!\n");
LOGP_CHAN(DAMPS, LOGL_ERROR, "Signaling Tone without transaction, please fix!\n");
return;
}
if (tone)
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Detected Signaling Tone with quality=%.0f.\n", quality * 100.0);
LOGP_CHAN(DAMPS, LOGL_INFO, "Detected Signaling Tone with quality=%.0f.\n", quality * 100.0);
else
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Lost Signaling Tone signal\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Lost Signaling Tone signal\n");
switch (trans->state) {
case TRANS_CALL_MO_ASSIGN_CONFIRM: // should not happen
@ -740,7 +740,7 @@ void amps_rx_signaling_tone(amps_t *amps, int tone, double quality)
case TRANS_CALL_RELEASE:
case TRANS_CALL_RELEASE_SEND:
/* also loosing singaling tone indicates release confirm (after alerting) */
timer_stop(&trans->timer);
osmo_timer_del(&trans->timer);
if (trans->callref)
call_up_release(trans->callref, CAUSE_NORMAL);
destroy_transaction(trans);
@ -751,24 +751,24 @@ void amps_rx_signaling_tone(amps_t *amps, int tone, double quality)
case TRANS_CALL_MT_ALERT_SEND: // should not happen
case TRANS_CALL_MT_ALERT_CONFIRM:
if (tone) {
timer_stop(&trans->timer);
osmo_timer_del(&trans->timer);
call_up_alerting(trans->callref);
amps_set_dsp_mode(amps, DSP_MODE_AUDIO_RX_AUDIO_TX, 0);
trans_new_state(trans, TRANS_CALL_MT_ANSWER_WAIT);
timer_start(&trans->timer, ANSWER_TO);
osmo_timer_schedule(&trans->timer, ANSWER_TO);
}
break;
case TRANS_CALL_MT_ANSWER_WAIT:
if (!tone) {
timer_stop(&trans->timer);
osmo_timer_del(&trans->timer);
if (!trans->sat_detected)
timer_start(&trans->timer, SAT_TO1);
osmo_timer_schedule(&trans->timer, SAT_TO1);
call_up_answer(trans->callref, amps_min2number(trans->min1, trans->min2));
trans_new_state(trans, TRANS_CALL);
}
break;
default:
PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "Signaling Tone without active call, please fix!\n");
LOGP_CHAN(DAMPS, LOGL_ERROR, "Signaling Tone without active call, please fix!\n");
}
}
@ -776,7 +776,7 @@ void amps_rx_sat(amps_t *amps, int tone, double quality)
{
transaction_t *trans = amps->trans_list;
if (trans == NULL) {
PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "SAT signal without transaction, please fix!\n");
LOGP_CHAN(DAMPS, LOGL_ERROR, "SAT signal without transaction, please fix!\n");
return;
}
@ -793,40 +793,40 @@ void amps_rx_sat(amps_t *amps, int tone, double quality)
&& trans->state != TRANS_CALL_MT_ALERT_CONFIRM
&& trans->state != TRANS_CALL_MT_ANSWER_WAIT
&& trans->state != TRANS_CALL) {
PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "SAT signal without active call, please fix!\n");
LOGP_CHAN(DAMPS, LOGL_ERROR, "SAT signal without active call, please fix!\n");
return;
}
if (tone) {
PDEBUG(DAMPS, DEBUG_INFO, "Detected SAT signal with quality=%.0f.\n", quality * 100.0);
LOGP(DAMPS, LOGL_INFO, "Detected SAT signal with quality=%.0f.\n", quality * 100.0);
trans->sat_detected = 1;
} else {
PDEBUG(DAMPS, DEBUG_INFO, "Lost SAT signal\n");
LOGP(DAMPS, LOGL_INFO, "Lost SAT signal\n");
trans->sat_detected = 0;
}
/* initial SAT received */
if (tone && trans->state == TRANS_CALL_MO_ASSIGN_CONFIRM) {
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Confirm from mobile (SAT) received\n");
timer_stop(&trans->timer);
LOGP_CHAN(DAMPS, LOGL_INFO, "Confirm from mobile (SAT) received\n");
osmo_timer_del(&trans->timer);
trans_new_state(trans, TRANS_CALL);
amps_set_dsp_mode(amps, DSP_MODE_AUDIO_RX_AUDIO_TX, 0);
}
if (tone && trans->state == TRANS_CALL_MT_ASSIGN_CONFIRM) {
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Confirm from mobile (SAT) received\n");
timer_stop(&trans->timer);
LOGP_CHAN(DAMPS, LOGL_INFO, "Confirm from mobile (SAT) received\n");
osmo_timer_del(&trans->timer);
trans->alert_retry = 1;
trans_new_state(trans, TRANS_CALL_MT_ALERT);
amps_set_dsp_mode(amps, DSP_MODE_AUDIO_RX_FRAME_TX, 0);
}
if (tone) {
timer_stop(&trans->timer);
osmo_timer_del(&trans->timer);
} else {
if (!trans->dtx)
timer_start(&trans->timer, SAT_TO2);
osmo_timer_schedule(&trans->timer, SAT_TO2);
else
timer_stop(&trans->timer);
osmo_timer_del(&trans->timer);
}
if (amps->sender.loopback)
@ -843,50 +843,50 @@ void amps_rx_recc(amps_t *amps, uint8_t scm, uint8_t mpci, uint32_t esn, uint32_
/* check if we are busy, so we ignore all signaling */
if (amps->state == STATE_BUSY) {
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Ignoring RECC messages from phone while using this channel for voice.\n");
LOGP_CHAN(DAMPS, LOGL_NOTICE, "Ignoring RECC messages from phone while using this channel for voice.\n");
return;
}
if (order == 13 && (ordq == 0 || ordq == 1 || ordq == 2 || ordq == 3) && msg_type == 0) {
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Registration %s (ESN = %s, %s, %s)\n", callerid, esn_to_string(esn), amps_scm(scm), amps_mpci(mpci));
LOGP_CHAN(DAMPS, LOGL_INFO, "Registration %s (ESN = %s, %s, %s)\n", callerid, esn_to_string(esn), amps_scm(scm), amps_mpci(mpci));
_register:
numbering(callerid, &carrier, &country, &national_number);
if (carrier)
PDEBUG_CHAN(DAMPS, DEBUG_INFO, " -> Home carrier: %s\n", carrier);
LOGP_CHAN(DAMPS, LOGL_INFO, " -> Home carrier: %s\n", carrier);
if (country)
PDEBUG_CHAN(DAMPS, DEBUG_INFO, " -> Home country: %s\n", country);
LOGP_CHAN(DAMPS, LOGL_INFO, " -> Home country: %s\n", country);
if (national_number)
PDEBUG_CHAN(DAMPS, DEBUG_INFO, " -> Home number: %s\n", national_number);
LOGP_CHAN(DAMPS, LOGL_INFO, " -> Home number: %s\n", national_number);
trans = create_transaction(amps, TRANS_REGISTER_ACK, min1, min2, esn, msg_type, ordq, order, 0);
if (!trans) {
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to create transaction\n");
LOGP(DAMPS, LOGL_ERROR, "Failed to create transaction\n");
return;
}
} else
if (order == 13 && ordq == 3 && msg_type == 1) {
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Registration - Power Down %s (ESN = %s, %s, %s)\n", callerid, esn_to_string(esn), amps_scm(scm), amps_mpci(mpci));
LOGP_CHAN(DAMPS, LOGL_INFO, "Registration - Power Down %s (ESN = %s, %s, %s)\n", callerid, esn_to_string(esn), amps_scm(scm), amps_mpci(mpci));
goto _register;
} else
if (order == 0 && ordq == 0 && msg_type == 0) {
if (!dialing)
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Paging reply %s (ESN = %s, %s, %s)\n", callerid, esn_to_string(esn), amps_scm(scm), amps_mpci(mpci));
LOGP_CHAN(DAMPS, LOGL_INFO, "Paging reply %s (ESN = %s, %s, %s)\n", callerid, esn_to_string(esn), amps_scm(scm), amps_mpci(mpci));
else
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call %s -> %s (ESN = %s, %s, %s)\n", callerid, dialing, esn_to_string(esn), amps_scm(scm), amps_mpci(mpci));
LOGP_CHAN(DAMPS, LOGL_INFO, "Call %s -> %s (ESN = %s, %s, %s)\n", callerid, dialing, esn_to_string(esn), amps_scm(scm), amps_mpci(mpci));
trans = search_transaction_number(amps, min1, min2);
if (!trans && !dialing) {
PDEBUG(DAMPS, DEBUG_NOTICE, "Paging reply, but call is already gone, rejecting call\n");
LOGP(DAMPS, LOGL_NOTICE, "Paging reply, but call is already gone, rejecting call\n");
goto reject;
}
if (trans && dialing)
PDEBUG(DAMPS, DEBUG_NOTICE, "There is already a transaction for this phone. Cloning?\n");
LOGP(DAMPS, LOGL_NOTICE, "There is already a transaction for this phone. Cloning?\n");
vc = search_free_vc();
if (!vc) {
PDEBUG(DAMPS, DEBUG_NOTICE, "No free channel, rejecting call\n");
LOGP(DAMPS, LOGL_NOTICE, "No free channel, rejecting call\n");
reject:
if (!trans) {
trans = create_transaction(amps, TRANS_CALL_REJECT, min1, min2, esn, 0, 0, 3, 0);
if (!trans) {
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to create transaction\n");
LOGP(DAMPS, LOGL_ERROR, "Failed to create transaction\n");
return;
}
} else {
@ -902,7 +902,7 @@ reject:
trans = create_transaction(amps, TRANS_CALL_MO_ASSIGN, min1, min2, esn, 0, 0, 0, atoi(vc->sender.kanal));
strncpy(trans->dialing, dialing, sizeof(trans->dialing) - 1);
if (!trans) {
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to create transaction\n");
LOGP(DAMPS, LOGL_ERROR, "Failed to create transaction\n");
return;
}
} else {
@ -912,13 +912,13 @@ reject:
/* if we support DTX and also the phone does, we set DTX state of transaction */
if (amps->si.word2.dtx) {
if ((scm & 4)) {
PDEBUG(DAMPS, DEBUG_INFO, " -> Use DTX for this call\n");
LOGP(DAMPS, LOGL_INFO, " -> Use DTX for this call\n");
trans->dtx = 1;
} else
PDEBUG(DAMPS, DEBUG_INFO, " -> Requested DTX, but not supported by phone\n");
LOGP(DAMPS, LOGL_INFO, " -> Requested DTX, but not supported by phone\n");
}
} else
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Unsupported RECC messages: ORDER: %d ORDQ: %d MSG TYPE: %d (See Table 4 of specs.)\n", order, ordq, msg_type);
LOGP_CHAN(DAMPS, LOGL_NOTICE, "Unsupported RECC messages: ORDER: %d ORDQ: %d MSG TYPE: %d (See Table 4 of specs.)\n", order, ordq, msg_type);
}
/*
@ -939,7 +939,7 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
/* 2. check if the subscriber is attached */
// if (!find_db(min1, min2)) {
// PDEBUG(DAMPS, DEBUG_NOTICE, "Outgoing call to not attached subscriber, rejecting!\n");
// LOGP(DAMPS, LOGL_NOTICE, "Outgoing call to not attached subscriber, rejecting!\n");
// return -CAUSE_OUTOFORDER;
// }
@ -952,29 +952,29 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
break;
}
if (sender) {
PDEBUG(DAMPS, DEBUG_NOTICE, "Outgoing call to busy number, rejecting!\n");
LOGP(DAMPS, LOGL_NOTICE, "Outgoing call to busy number, rejecting!\n");
return -CAUSE_BUSY;
}
/* 4. check if all senders are busy, return NOCHANNEL */
if (!search_free_vc()) {
PDEBUG(DAMPS, DEBUG_NOTICE, "Outgoing call, but no free channel, rejecting!\n");
LOGP(DAMPS, LOGL_NOTICE, "Outgoing call, but no free channel, rejecting!\n");
return -CAUSE_NOCHANNEL;
}
/* 5. check if we have (currently) no paging channel, return NOCHANNEL */
amps = search_pc();
if (!amps) {
PDEBUG(DAMPS, DEBUG_NOTICE, "Outgoing call, but paging channel (control channel) is currently busy, rejecting!\n");
LOGP(DAMPS, LOGL_NOTICE, "Outgoing call, but paging channel (control channel) is currently busy, rejecting!\n");
return -CAUSE_NOCHANNEL;
}
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call to mobile station, paging station id '%s'\n", dialing);
LOGP_CHAN(DAMPS, LOGL_INFO, "Call to mobile station, paging station id '%s'\n", dialing);
/* 6. trying to page mobile station */
trans = create_transaction(amps, TRANS_PAGE, min1, min2, 0, 0, 0, 0, 0);
if (!trans) {
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to create transaction\n");
LOGP(DAMPS, LOGL_ERROR, "Failed to create transaction\n");
return -CAUSE_TEMPFAIL;
}
trans->callref = callref;
@ -1002,7 +1002,7 @@ void call_down_disconnect(int callref, int cause)
amps_t *amps;
transaction_t *trans;
PDEBUG(DAMPS, DEBUG_INFO, "Call has been disconnected by network.\n");
LOGP(DAMPS, LOGL_INFO, "Call has been disconnected by network.\n");
for (sender = sender_head; sender; sender = sender->next) {
amps = (amps_t *) sender;
@ -1012,7 +1012,7 @@ void call_down_disconnect(int callref, int cause)
break;
}
if (!sender) {
PDEBUG(DAMPS, DEBUG_NOTICE, "Outgoing disconnect, but no callref!\n");
LOGP(DAMPS, LOGL_NOTICE, "Outgoing disconnect, but no callref!\n");
call_up_release(callref, CAUSE_INVALCALLREF);
return;
}
@ -1027,12 +1027,12 @@ void call_down_disconnect(int callref, int cause)
|| trans->state == TRANS_CALL_MT_ALERT_SEND
|| trans->state == TRANS_CALL_MT_ALERT_CONFIRM
|| trans->state == TRANS_CALL_MT_ANSWER_WAIT) {
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call control disconnect on voice channel while alerting, releasing towards mobile station.\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Call control disconnect on voice channel while alerting, releasing towards mobile station.\n");
amps_release(trans, cause);
}
return;
default:
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call control disconnects on control channel, removing transaction.\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Call control disconnects on control channel, removing transaction.\n");
call_up_release(callref, cause);
trans->callref = 0;
destroy_transaction(trans);
@ -1047,7 +1047,7 @@ void call_down_release(int callref, int cause)
amps_t *amps;
transaction_t *trans;
PDEBUG(DAMPS, DEBUG_INFO, "Call has been released by network, releasing call.\n");
LOGP(DAMPS, LOGL_INFO, "Call has been released by network, releasing call.\n");
for (sender = sender_head; sender; sender = sender->next) {
amps = (amps_t *) sender;
@ -1057,7 +1057,7 @@ void call_down_release(int callref, int cause)
break;
}
if (!sender) {
PDEBUG(DAMPS, DEBUG_NOTICE, "Outgoing release, but no callref!\n");
LOGP(DAMPS, LOGL_NOTICE, "Outgoing release, but no callref!\n");
/* don't send release, because caller already released */
return;
}
@ -1068,11 +1068,11 @@ void call_down_release(int callref, int cause)
case DSP_MODE_AUDIO_RX_SILENCE_TX:
case DSP_MODE_AUDIO_RX_AUDIO_TX:
case DSP_MODE_AUDIO_RX_FRAME_TX:
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call control releases on voice channel, releasing towards mobile station.\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Call control releases on voice channel, releasing towards mobile station.\n");
amps_release(trans, cause);
break;
default:
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call control releases on control channel, removing transaction.\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Call control releases on control channel, removing transaction.\n");
destroy_transaction(trans);
amps_go_idle(amps);
}
@ -1109,47 +1109,47 @@ void transaction_timeout(void *data)
switch (trans->state) {
case TRANS_CALL_MO_ASSIGN_CONFIRM:
case TRANS_CALL_MT_ASSIGN_CONFIRM:
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Timeout after %.0f seconds not receiving initial SAT signal.\n", trans->timer.duration);
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Release call towards network.\n");
LOGP_CHAN(DAMPS, LOGL_NOTICE, "Timeout after %ld seconds not receiving initial SAT signal.\n", trans->timer.timeout.tv_sec);
LOGP_CHAN(DAMPS, LOGL_INFO, "Release call towards network.\n");
amps_release(amps->trans_list, CAUSE_TEMPFAIL);
break;
case TRANS_CALL:
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Timeout after %.0f seconds loosing SAT signal.\n", trans->timer.duration);
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Release call towards network.\n");
LOGP_CHAN(DAMPS, LOGL_NOTICE, "Timeout after %ld seconds loosing SAT signal.\n", trans->timer.timeout.tv_sec);
LOGP_CHAN(DAMPS, LOGL_INFO, "Release call towards network.\n");
amps_release(amps->trans_list, CAUSE_TEMPFAIL);
break;
case TRANS_CALL_RELEASE:
case TRANS_CALL_RELEASE_SEND:
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Release timeout, destroying transaction\n");
LOGP_CHAN(DAMPS, LOGL_NOTICE, "Release timeout, destroying transaction\n");
destroy_transaction(trans);
amps_go_idle(amps);
break;
case TRANS_CALL_MT_ALERT_SEND:
case TRANS_CALL_MT_ALERT_CONFIRM:
if (trans->alert_retry++ == ALERT_TRIES) {
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Phone does not respond to alert order, destroying transaction\n");
LOGP_CHAN(DAMPS, LOGL_NOTICE, "Phone does not respond to alert order, destroying transaction\n");
amps_release(trans, CAUSE_TEMPFAIL);
} else {
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Phone does not respond to alert order, retrying\n");
LOGP_CHAN(DAMPS, LOGL_NOTICE, "Phone does not respond to alert order, retrying\n");
trans_new_state(trans, TRANS_CALL_MT_ALERT);
amps_set_dsp_mode(amps, DSP_MODE_AUDIO_RX_FRAME_TX, 0);
}
break;
case TRANS_CALL_MT_ANSWER_WAIT:
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Alerting timeout, destroying transaction\n");
LOGP_CHAN(DAMPS, LOGL_NOTICE, "Alerting timeout, destroying transaction\n");
amps_release(trans, CAUSE_NOANSWER);
break;
case TRANS_PAGE_REPLY:
if (trans->page_retry++ == PAGE_TRIES) {
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Paging timeout, destroying transaction\n");
LOGP_CHAN(DAMPS, LOGL_NOTICE, "Paging timeout, destroying transaction\n");
amps_release(trans, CAUSE_OUTOFORDER);
} else {
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Paging timeout, retrying\n");
LOGP_CHAN(DAMPS, LOGL_NOTICE, "Paging timeout, retrying\n");
trans_new_state(trans, TRANS_PAGE);
}
break;
default:
PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "Timeout unhandled in state %d\n", trans->state);
LOGP_CHAN(DAMPS, LOGL_ERROR, "Timeout unhandled in state %d\n", trans->state);
}
}
@ -1161,18 +1161,18 @@ static amps_t *assign_voice_channel(transaction_t *trans)
vc = search_channel(trans->chan);
if (!vc) {
PDEBUG(DAMPS, DEBUG_NOTICE, "Channel %d is not free anymore, rejecting call\n", trans->chan);
LOGP(DAMPS, LOGL_NOTICE, "Channel %d is not free anymore, rejecting call\n", trans->chan);
amps_release(trans, CAUSE_NOCHANNEL);
return NULL;
}
if (vc == amps)
PDEBUG(DAMPS, DEBUG_INFO, "Staying on combined control + voice channel %s\n", vc->sender.kanal);
LOGP(DAMPS, LOGL_INFO, "Staying on combined control + voice channel %s\n", vc->sender.kanal);
else
PDEBUG(DAMPS, DEBUG_INFO, "Moving to voice channel %s\n", vc->sender.kanal);
LOGP(DAMPS, LOGL_INFO, "Moving to voice channel %s\n", vc->sender.kanal);
/* switch channel... */
timer_start(&trans->timer, SAT_TO1);
osmo_timer_schedule(&trans->timer, SAT_TO1);
/* make channel busy */
amps_new_state(vc, STATE_BUSY);
/* relink */
@ -1185,7 +1185,7 @@ static amps_t *assign_voice_channel(transaction_t *trans)
char esn_text[16];
sprintf(esn_text, "%u", trans->esn);
/* setup call */
PDEBUG(DAMPS, DEBUG_INFO, "Setup call to network.\n");
LOGP(DAMPS, LOGL_INFO, "Setup call to network.\n");
trans->callref = call_up_setup(callerid, trans->dialing, OSMO_CC_NETWORK_AMPS_ESN, esn_text);
}
@ -1204,52 +1204,55 @@ again:
switch (trans->state) {
case TRANS_REGISTER_ACK:
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Sending Register acknowledge\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Sending Register acknowledge\n");
trans_new_state(trans, TRANS_REGISTER_ACK_SEND);
return trans;
case TRANS_REGISTER_ACK_SEND:
destroy_transaction(trans);
goto again;
case TRANS_CALL_REJECT:
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Rejecting call from mobile station\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Rejecting call from mobile station\n");
trans_new_state(trans, TRANS_CALL_REJECT_SEND);
return trans;
case TRANS_CALL_REJECT_SEND:
destroy_transaction(trans);
goto again;
case TRANS_CALL_MO_ASSIGN:
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Assigning channel to call from mobile station\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Assigning channel to call from mobile station\n");
trans_new_state(trans, TRANS_CALL_MO_ASSIGN_SEND);
return trans;
case TRANS_CALL_MO_ASSIGN_SEND:
vc = assign_voice_channel(trans);
if (vc) {
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Assignment complete, voice connected\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Assignment complete, voice connected\n");
/* timer and other things are processed at assign_voice_channel() */
trans_new_state(trans, TRANS_CALL_MO_ASSIGN_CONFIRM);
amps_set_dsp_mode(vc, DSP_MODE_AUDIO_RX_SILENCE_TX, 0);
}
return NULL;
case TRANS_CALL_MT_ASSIGN:
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Assigning channel to call to mobile station\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Assigning channel to call to mobile station\n");
trans_new_state(trans, TRANS_CALL_MT_ASSIGN_SEND);
return trans;
case TRANS_CALL_MT_ASSIGN_SEND:
vc = assign_voice_channel(trans);
if (vc) {
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Assignment complete, waiting for SAT on VC\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Assignment complete, waiting for SAT on VC\n");
/* timer and other things are processed at assign_voice_channel() */
trans_new_state(trans, TRANS_CALL_MT_ASSIGN_CONFIRM);
amps_set_dsp_mode(vc, DSP_MODE_AUDIO_RX_SILENCE_TX, 0);
}
return NULL;
case TRANS_PAGE:
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Paging the phone\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Paging the phone\n");
trans_new_state(trans, TRANS_PAGE_SEND);
return trans;
case TRANS_PAGE_SEND:
trans_new_state(trans, TRANS_PAGE_REPLY);
timer_start(&trans->timer, (trans->page_retry == PAGE_TRIES) ? PAGE_TO2 : PAGE_TO1);
if (trans->page_retry == PAGE_TRIES)
osmo_timer_schedule(&trans->timer, PAGE_TO2);
else
osmo_timer_schedule(&trans->timer, PAGE_TO1);
return NULL;
default:
return NULL;
@ -1266,11 +1269,11 @@ transaction_t *amps_tx_frame_fvc(amps_t *amps)
switch (trans->state) {
case TRANS_CALL_RELEASE:
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Releasing call towards mobile station\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Releasing call towards mobile station\n");
trans_new_state(trans, TRANS_CALL_RELEASE_SEND);
return trans;
case TRANS_CALL_RELEASE_SEND:
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Release call was sent, continue sending release\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Release call was sent, continue sending release\n");
return trans;
case TRANS_CALL_MT_ALERT:
trans->chan = 0;
@ -1278,17 +1281,17 @@ transaction_t *amps_tx_frame_fvc(amps_t *amps)
trans->ordq = 0;
// "Alert with caller ID" causes older phones to interrupt the connection for some reason, therefore we don't use order 17 when no caller ID is set
if (amps->send_callerid && trans->alert_retry == 1 && trans->caller_id[0]) {
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Sending alerting with caller ID\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Sending alerting with caller ID\n");
trans->order = 17;
} else {
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Sending alerting\n");
LOGP_CHAN(DAMPS, LOGL_INFO, "Sending alerting\n");
trans->order = 1;
}
trans_new_state(trans, TRANS_CALL_MT_ALERT_SEND);
return trans;
case TRANS_CALL_MT_ALERT_SEND:
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Alerting was sent, continue waiting for ST or timeout\n");
timer_start(&trans->timer, ALERT_TO);
LOGP_CHAN(DAMPS, LOGL_INFO, "Alerting was sent, continue waiting for ST or timeout\n");
osmo_timer_schedule(&trans->timer, ALERT_TO);
amps_set_dsp_mode(amps, DSP_MODE_AUDIO_RX_SILENCE_TX, 0);
trans_new_state(trans, TRANS_CALL_MT_ALERT_CONFIRM);
return NULL;

View File

@ -1,6 +1,6 @@
#include "../libgoertzel/goertzel.h"
#include "../libmobile/sender.h"
#include "../libtimer/timer.h"
#include <osmocom/core/timer.h>
#include "../libcompandor/compandor.h"
typedef struct amps amps_t;
#include "sysinfo.h"

View File

@ -82,8 +82,9 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/get_time.h"
#include "amps.h"
#include "frame.h"
#include "dsp.h"
@ -146,7 +147,7 @@ void dsp_init(void)
int i;
double s;
PDEBUG(DDSP, DEBUG_DEBUG, "Generating sine table for SAT signal.\n");
LOGP(DDSP, LOGL_DEBUG, "Generating sine table for SAT signal.\n");
for (i = 0; i < 65536; i++) {
s = sin((double)i / 65536.0 * 2.0 * PI);
dsp_sine_sat[i] = s * ((!tacs) ? AMPS_SAT_DEVIATION : TACS_SAT_DEVIATION);
@ -171,7 +172,7 @@ static void dsp_init_ramp(amps_t *amps)
double c;
int i;
PDEBUG(DDSP, DEBUG_DEBUG, "Generating smooth ramp table.\n");
LOGP(DDSP, LOGL_DEBUG, "Generating smooth ramp table.\n");
for (i = 0; i < 256; i++) {
c = cos((double)i / 256.0 * PI);
#if 0
@ -198,7 +199,7 @@ int dsp_init_sender(amps_t *amps, int tolerant)
/* attack (3ms) and recovery time (13.5ms) according to amps specs */
setup_compandor(&amps->cstate, 8000, 3.0, 13.5);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for transceiver.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Init DSP for transceiver.\n");
/* set modulation parameters */
sender_set_fm(&amps->sender,
@ -208,18 +209,18 @@ int dsp_init_sender(amps_t *amps, int tolerant)
(!tacs) ? AMPS_MAX_DISPLAY : TACS_MAX_DISPLAY);
if (amps->sender.samplerate < 96000) {
PDEBUG(DDSP, DEBUG_ERROR, "Sample rate must be at least 96000 Hz to process FSK and SAT signals.\n");
LOGP(DDSP, LOGL_ERROR, "Sample rate must be at least 96000 Hz to process FSK and SAT signals.\n");
return -EINVAL;
}
amps->fsk_bitduration = (double)amps->sender.samplerate / (double)((!tacs) ? AMPS_BITRATE : TACS_BITRATE);
amps->fsk_bitstep = 1.0 / amps->fsk_bitduration;
PDEBUG(DDSP, DEBUG_DEBUG, "Use %.4f samples for full bit duration @ %d.\n", amps->fsk_bitduration, amps->sender.samplerate);
LOGP(DDSP, LOGL_DEBUG, "Use %.4f samples for full bit duration @ %d.\n", amps->fsk_bitduration, amps->sender.samplerate);
amps->fsk_tx_buffer_size = amps->fsk_bitduration + 10; /* 10 extra to avoid overflow due to rounding */
spl = calloc(sizeof(*spl), amps->fsk_tx_buffer_size);
if (!spl) {
PDEBUG(DDSP, DEBUG_ERROR, "No memory!\n");
LOGP(DDSP, LOGL_ERROR, "No memory!\n");
rc = -ENOMEM;
goto error;
}
@ -230,12 +231,12 @@ int dsp_init_sender(amps_t *amps, int tolerant)
amps->fsk_rx_window_begin = half >> 1;
amps->fsk_rx_window_half = half;
amps->fsk_rx_window_end = amps->fsk_rx_window_length - (half >> 1);
PDEBUG(DDSP, DEBUG_DEBUG, "Bit window length: %d\n", amps->fsk_rx_window_length);
PDEBUG(DDSP, DEBUG_DEBUG, " -> Samples in window to analyse level left of edge: %d..%d\n", amps->fsk_rx_window_begin, amps->fsk_rx_window_half - 1);
PDEBUG(DDSP, DEBUG_DEBUG, " -> Samples in window to analyse level right of edge: %d..%d\n", amps->fsk_rx_window_half, amps->fsk_rx_window_end - 1);
LOGP(DDSP, LOGL_DEBUG, "Bit window length: %d\n", amps->fsk_rx_window_length);
LOGP(DDSP, LOGL_DEBUG, " -> Samples in window to analyse level left of edge: %d..%d\n", amps->fsk_rx_window_begin, amps->fsk_rx_window_half - 1);
LOGP(DDSP, LOGL_DEBUG, " -> Samples in window to analyse level right of edge: %d..%d\n", amps->fsk_rx_window_half, amps->fsk_rx_window_end - 1);
spl = calloc(sizeof(*amps->fsk_rx_window), amps->fsk_rx_window_length);
if (!spl) {
PDEBUG(DDSP, DEBUG_ERROR, "No memory!\n");
LOGP(DDSP, LOGL_ERROR, "No memory!\n");
rc = -ENOMEM;
goto error;
}
@ -252,10 +253,10 @@ int dsp_init_sender(amps_t *amps, int tolerant)
amps->sat_samples = (int)((double)amps->sender.samplerate * (1.0 / (SAT_BANDWIDTH / 2.0)) + 0.5);
spl = calloc(sizeof(*spl), amps->sat_samples);
if (!spl) {
PDEBUG(DDSP, DEBUG_ERROR, "No memory!\n");
LOGP(DDSP, LOGL_ERROR, "No memory!\n");
return -ENOMEM;
}
PDEBUG(DDSP, DEBUG_DEBUG, "Sat detection interval is %d ms.\n", amps->sat_samples * 1000 / amps->sender.samplerate);
LOGP(DDSP, LOGL_DEBUG, "Sat detection interval is %d ms.\n", amps->sat_samples * 1000 / amps->sender.samplerate);
amps->sat_filter_spl = spl;
/* count SAT tones */
@ -289,7 +290,7 @@ error:
/* Cleanup transceiver instance. */
void dsp_cleanup_sender(amps_t *amps)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for treansceiver.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Cleanup DSP for treansceiver.\n");
if (amps->fsk_tx_buffer)
free(amps->fsk_tx_buffer);
@ -770,7 +771,7 @@ static void sat_decode(amps_t *amps, sample_t *samples, int length)
/* debug SAT */
if (++amps->sat_print == SAT_PRINT) {
PDEBUG_CHAN(DDSP, DEBUG_NOTICE, "SAT level %.2f%% quality %.0f%%\n", sat_level * 100.0, sat_quality * 100.0);
LOGP_CHAN(DDSP, LOGL_NOTICE, "SAT level %.2f%% quality %.0f%%\n", sat_level * 100.0, sat_quality * 100.0);
amps->sat_print = 0;
}
@ -779,8 +780,8 @@ static void sat_decode(amps_t *amps, sample_t *samples, int length)
display_measurements_update(amps->dmp_sat_quality, sat_quality * 100.0, 0.0);
/* debug signaling tone */
if (amps->sender.loopback || debuglevel == DEBUG_DEBUG) {
PDEBUG_CHAN(DDSP, debuglevel, "Signaling Tone level %.2f%% quality %.0f%%\n", sig_level * 100.0, sig_quality * 100.0);
if (amps->sender.loopback || loglevel == LOGL_DEBUG) {
LOGP_CHAN(DDSP, loglevel, "Signaling Tone level %.2f%% quality %.0f%%\n", sig_level * 100.0, sig_quality * 100.0);
}
/* mute if SAT quality or level is below threshold */
@ -796,7 +797,7 @@ static void sat_decode(amps_t *amps, sample_t *samples, int length)
if (amps->sat_detect_count == SAT_DETECT_COUNT) {
amps->sat_detected = 1;
amps->sat_detect_count = 0;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "SAT signal detected with level=%.0f%%, quality=%.0f%%.\n", sat_level * 100.0, sat_quality * 100.0);
LOGP_CHAN(DDSP, LOGL_DEBUG, "SAT signal detected with level=%.0f%%, quality=%.0f%%.\n", sat_level * 100.0, sat_quality * 100.0);
amps_rx_sat(amps, 1, sat_quality);
}
} else
@ -807,7 +808,7 @@ static void sat_decode(amps_t *amps, sample_t *samples, int length)
if (amps->sat_detect_count == SAT_LOST_COUNT) {
amps->sat_detected = 0;
amps->sat_detect_count = 0;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "SAT signal lost.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "SAT signal lost.\n");
amps_rx_sat(amps, 0, 0.0);
}
} else
@ -821,7 +822,7 @@ static void sat_decode(amps_t *amps, sample_t *samples, int length)
if (amps->sig_detect_count == SIG_DETECT_COUNT) {
amps->sig_detected = 1;
amps->sig_detect_count = 0;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Signaling Tone detected with level=%.0f%%, quality=%.0f%%.\n", sig_level * 100.0, sig_quality * 100.0);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Signaling Tone detected with level=%.0f%%, quality=%.0f%%.\n", sig_level * 100.0, sig_quality * 100.0);
amps_rx_signaling_tone(amps, 1, sig_quality);
}
} else
@ -832,7 +833,7 @@ static void sat_decode(amps_t *amps, sample_t *samples, int length)
if (amps->sig_detect_count == SIG_LOST_COUNT) {
amps->sig_detected = 0;
amps->sig_detect_count = 0;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Signaling Tone lost.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Signaling Tone lost.\n");
amps_rx_signaling_tone(amps, 0, 0.0);
}
} else
@ -918,7 +919,7 @@ void sender_receive(sender_t *sender, sample_t *samples, int length, double __at
/* Reset SAT detection states, so ongoing tone will be detected again. */
static void sat_reset(amps_t *amps, const char *reason)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "SAT detector reset: %s.\n", reason);
LOGP_CHAN(DDSP, LOGL_DEBUG, "SAT detector reset: %s.\n", reason);
amps->sat_detected = 0;
amps->sat_detect_count = 0;
amps->sig_detected = 0;
@ -935,28 +936,28 @@ void amps_set_dsp_mode(amps_t *amps, enum dsp_mode mode, int frame_length)
if (mode == DSP_MODE_FRAME_RX_FRAME_TX) {
/* reset SAT detection */
sat_reset(amps, "Change to FOCC");
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Change mode to FOCC\n");
LOGP_CHAN(DDSP, LOGL_INFO, "Change mode to FOCC\n");
amps->tx_focc_debugged = 0;
}
if (amps->dsp_mode == DSP_MODE_FRAME_RX_FRAME_TX
&& (mode == DSP_MODE_AUDIO_RX_AUDIO_TX || mode == DSP_MODE_AUDIO_RX_FRAME_TX || mode == DSP_MODE_AUDIO_RX_SILENCE_TX)) {
/* reset SAT detection */
sat_reset(amps, "Change from FOCC to FVC");
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Change mode from FOCC to FVC\n");
LOGP_CHAN(DDSP, LOGL_INFO, "Change mode from FOCC to FVC\n");
}
if (amps->dsp_mode == DSP_MODE_OFF
&& (mode == DSP_MODE_AUDIO_RX_AUDIO_TX || mode == DSP_MODE_AUDIO_RX_FRAME_TX || mode == DSP_MODE_AUDIO_RX_SILENCE_TX)) {
/* reset SAT detection */
sat_reset(amps, "Enable FVC");
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Change mode from OFF to FVC\n");
LOGP_CHAN(DDSP, LOGL_INFO, "Change mode from OFF to FVC\n");
}
if (mode == DSP_MODE_OFF) {
/* reset SAT detection */
sat_reset(amps, "Disable FVC");
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Change mode from FVC to OFF\n");
LOGP_CHAN(DDSP, LOGL_INFO, "Change mode from FVC to OFF\n");
}
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Reset FSK frame transmitter, due to setting dsp mode.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Reset FSK frame transmitter, due to setting dsp mode.\n");
amps->dsp_mode = mode;
if (frame_length)

View File

@ -22,10 +22,10 @@
#include <string.h>
#include <pthread.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include <osmocom/cc/message.h>
#include "amps.h"
#include "esn.h"

View File

@ -27,7 +27,8 @@
#include <math.h>
#include <inttypes.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/get_time.h"
#include "amps.h"
#include "dsp.h"
#include "frame.h"
@ -2719,7 +2720,7 @@ static uint64_t amps_encode_word(frame_t *frame, struct def_word *w, int debug)
sum_bits += w->ie[i].bits;
if (debug)
PDEBUG(DFRAME, DEBUG_INFO, "Transmit: %s\n", w->name);
LOGP(DFRAME, LOGL_INFO, "Transmit: %s\n", w->name);
word = 0;
for (i = 0; w->ie[i].name; i++) {
bits = w->ie[i].bits;
@ -2730,9 +2731,9 @@ static uint64_t amps_encode_word(frame_t *frame, struct def_word *w, int debug)
word = (word << bits) | (value & cut_bits[bits]);
if (debug) {
if (amps_ie_desc[w->ie[i].ie].decoder)
PDEBUG(DFRAME, DEBUG_DEBUG, " %s%s: %" PRIu64 " = %s (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].decoder(value), amps_ie_desc[w->ie[i].ie].desc);
LOGP(DFRAME, LOGL_DEBUG, " %s%s: %" PRIu64 " = %s (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].decoder(value), amps_ie_desc[w->ie[i].ie].desc);
else
PDEBUG(DFRAME, DEBUG_DEBUG, " %s%s: %" PRIu64 " (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].desc);
LOGP(DFRAME, LOGL_DEBUG, " %s%s: %" PRIu64 " (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].desc);
}
/* show result for 3 IEs of table 4 */
if (w->ie[i].ie == AMPS_IE_LOCAL_MSG_TYPE || w->ie[i].ie == AMPS_IE_ORDQ || w->ie[i].ie == AMPS_IE_ORDER)
@ -2740,7 +2741,7 @@ static uint64_t amps_encode_word(frame_t *frame, struct def_word *w, int debug)
if (t4 == 3) {
t4 = 0;
if (debug)
PDEBUG(DFRAME, DEBUG_DEBUG, " %s--> %s\n", spaces, amps_table4_name(frame->ie[AMPS_IE_LOCAL_MSG_TYPE], frame->ie[AMPS_IE_ORDQ], frame->ie[AMPS_IE_ORDER]));
LOGP(DFRAME, LOGL_DEBUG, " %s--> %s\n", spaces, amps_table4_name(frame->ie[AMPS_IE_LOCAL_MSG_TYPE], frame->ie[AMPS_IE_ORDQ], frame->ie[AMPS_IE_ORDER]));
}
}
@ -3070,22 +3071,22 @@ static frame_t *amps_decode_word(uint64_t word, struct def_word *w)
for (i = 0; w->ie[i].name; i++)
bits_left += w->ie[i].bits;
PDEBUG(DFRAME, DEBUG_INFO, "Received: %s\n", w->name);
LOGP(DFRAME, LOGL_INFO, "Received: %s\n", w->name);
for (i = 0; w->ie[i].name; i++) {
bits = w->ie[i].bits;
bits_left -= bits;
value = (word >> bits_left) & cut_bits[bits];
frame.ie[w->ie[i].ie] = value;
if (amps_ie_desc[w->ie[i].ie].decoder)
PDEBUG(DFRAME, DEBUG_DEBUG, " %s%s: %" PRIu64 " = %s (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].decoder(value), amps_ie_desc[w->ie[i].ie].desc);
LOGP(DFRAME, LOGL_DEBUG, " %s%s: %" PRIu64 " = %s (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].decoder(value), amps_ie_desc[w->ie[i].ie].desc);
else
PDEBUG(DFRAME, DEBUG_DEBUG, " %s%s: %" PRIu64 " (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].desc);
LOGP(DFRAME, LOGL_DEBUG, " %s%s: %" PRIu64 " (%s)\n", spaces + strlen(w->ie[i].name), w->ie[i].name, value, amps_ie_desc[w->ie[i].ie].desc);
/* show result for 3 IEs of table 4 */
if (w->ie[i].ie == AMPS_IE_LOCAL_MSG_TYPE || w->ie[i].ie == AMPS_IE_ORDQ || w->ie[i].ie == AMPS_IE_ORDER)
t4++;
if (t4 == 3) {
t4 = 0;
PDEBUG(DFRAME, DEBUG_DEBUG, " %s--> %s\n", spaces, amps_table4_name(frame.ie[AMPS_IE_LOCAL_MSG_TYPE], frame.ie[AMPS_IE_ORDQ], frame.ie[AMPS_IE_ORDER]));
LOGP(DFRAME, LOGL_DEBUG, " %s--> %s\n", spaces, amps_table4_name(frame.ie[AMPS_IE_LOCAL_MSG_TYPE], frame.ie[AMPS_IE_ORDQ], frame.ie[AMPS_IE_ORDER]));
}
}
@ -3103,7 +3104,7 @@ static void amps_decode_word_focc(amps_t *amps, uint64_t word)
/* control message */
if (t1t2 != 3) {
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Received Mobile Station Control Message (T1T2 = %d)\n", t1t2);
LOGP_CHAN(DFRAME, LOGL_INFO, "Received Mobile Station Control Message (T1T2 = %d)\n", t1t2);
if (t1t2 == 1)
amps->rx_focc_word_count = 1;
if (t1t2 == 0 || t1t2 == 1) {
@ -3120,7 +3121,7 @@ static void amps_decode_word_focc(amps_t *amps, uint64_t word)
w = &word2_extended_address_word_b;
goto decode;
}
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Decoding of more than 2 Control messages not supported\n");
LOGP_CHAN(DFRAME, LOGL_INFO, "Decoding of more than 2 Control messages not supported\n");
}
return;
}
@ -3188,14 +3189,14 @@ static void amps_decode_word_focc(amps_t *amps, uint64_t word)
decode:
if (!w) {
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Received Illegal Overhead Message\n");
LOGP_CHAN(DFRAME, LOGL_INFO, "Received Illegal Overhead Message\n");
return;
}
frame = amps_decode_word(word, w);
/* show control filler delay */
if (amps->sender.loopback && ohd == 1)
PDEBUG_CHAN(DDSP, DEBUG_NOTICE, "Round trip delay is %.3f seconds\n", amps->when_received - amps->when_transmitted[frame->ie[AMPS_IE_1111]]);
LOGP_CHAN(DDSP, LOGL_NOTICE, "Round trip delay is %.3f seconds\n", amps->when_received - amps->when_transmitted[frame->ie[AMPS_IE_1111]]);
}
/* get word from data bits and call decoder function
@ -3214,24 +3215,24 @@ static int amps_decode_word_recc(amps_t *amps, uint64_t word, int first)
amps->rx_recc_word_count = 0;
amps->rx_recc_nawc = nawc;
if (f == 0) {
PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received first word, but F bit is not set.\n");
LOGP_CHAN(DFRAME, LOGL_NOTICE, "Received first word, but F bit is not set.\n");
return 0;
}
} else {
if (f == 1) {
PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received additional word, but F bit is set.\n");
LOGP_CHAN(DFRAME, LOGL_NOTICE, "Received additional word, but F bit is set.\n");
return 0;
}
amps->rx_recc_nawc--;
if (amps->rx_recc_nawc != nawc) {
PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received additional word with NAWC mismatch!\n");
LOGP_CHAN(DFRAME, LOGL_NOTICE, "Received additional word with NAWC mismatch!\n");
}
}
msg_count = amps->rx_recc_word_count;
if (msg_count == 8) {
PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received too many words.\n");
LOGP_CHAN(DFRAME, LOGL_NOTICE, "Received too many words.\n");
return 0;
}
@ -3268,7 +3269,7 @@ static int amps_decode_word_recc(amps_t *amps, uint64_t word, int first)
if (!w) {
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Received Illegal RECC Message\n");
LOGP_CHAN(DFRAME, LOGL_INFO, "Received Illegal RECC Message\n");
goto done;
}
@ -3333,7 +3334,7 @@ static int amps_decode_word_recc(amps_t *amps, uint64_t word, int first)
amps->rx_recc_dialing[31] = digit2number[frame->ie[AMPS_IE_DIGIT_32]];
}
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "expecting %d more word(s) to come\n", amps->rx_recc_nawc);
LOGP_CHAN(DFRAME, LOGL_INFO, "expecting %d more word(s) to come\n", amps->rx_recc_nawc);
if (msg_count >= 3 && amps->rx_recc_nawc == 0) {
/* if no digit messages are present, send NULL as dial string (paging reply) */
@ -3400,16 +3401,16 @@ static void amps_encode_focc_bits(uint64_t word_a, uint64_t word_b, char *bits)
bits[k] = '\0';
#ifdef BIT_DEBUGGING
if (debuglevel == DEBUG_DEBUG) {
if (loglevel == LOGL_DEBUG) {
char text[64];
strncpy(text, bits, 23);
text[23] = '\0';
PDEBUG(DFRAME, DEBUG_INFO, "TX FOCC: %s\n", text);
LOGP(DFRAME, LOGL_INFO, "TX FOCC: %s\n", text);
for (i = 0; i < 10; i++) {
strncpy(text, bits + 23 + i * 44, 44);
text[44] = '\0';
PDEBUG(DFRAME, DEBUG_DEBUG, " word %c - %s\n", (i & 1) ? 'b' : 'a', text);
LOGP(DFRAME, LOGL_DEBUG, " word %c - %s\n", (i & 1) ? 'b' : 'a', text);
}
}
#endif
@ -3440,8 +3441,8 @@ static void amps_encode_fvc_bits(uint64_t word_a, char *bits)
bits[k] = '\0';
#ifdef BIT_DEBUGGING
if (debuglevel == DEBUG_DEBUG) {
PDEBUG(DFRAME, DEBUG_INFO, "TX FVC: %s\n", bits);
if (loglevel == LOGL_DEBUG) {
LOGP(DFRAME, LOGL_INFO, "TX FVC: %s\n", bits);
}
#endif
}
@ -3511,7 +3512,7 @@ int amps_encode_frame_focc(amps_t *amps, char *bits)
if (++amps->tx_focc_frame_count >= amps->si.overhead_repeat)
amps->tx_focc_frame_count = 0;
if (debug)
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Subsequent system/filler frames are not show, to prevent flooding the output.\n");
LOGP_CHAN(DFRAME, LOGL_INFO, "Subsequent system/filler frames are not show, to prevent flooding the output.\n");
amps->tx_focc_debugged = 1;
send:
@ -3626,17 +3627,17 @@ static void amps_decode_bits_focc(amps_t *amps, const char *bits)
else
idle = 0;
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "RX FOCC: B/I = %s\n", (idle) ? "idle" : "busy");
if (debuglevel == DEBUG_DEBUG) {
LOGP_CHAN(DFRAME, LOGL_INFO, "RX FOCC: B/I = %s\n", (idle) ? "idle" : "busy");
if (loglevel == LOGL_DEBUG) {
char text[64];
for (i = 0; i < 10; i++) {
strncpy(text, bits + i * 44, 44);
text[44] = '\0';
if ((i & 1) == 0)
PDEBUG_CHAN(DFRAME, DEBUG_DEBUG, " word a - %s%s\n", text, (crc_a_ok[i >> 1]) ? " ok" : " BAD CRC!");
LOGP_CHAN(DFRAME, LOGL_DEBUG, " word a - %s%s\n", text, (crc_a_ok[i >> 1]) ? " ok" : " BAD CRC!");
else
PDEBUG_CHAN(DFRAME, DEBUG_DEBUG, " word b - %s%s\n", text, (crc_b_ok[i >> 1]) ? " ok" : " BAD CRC!");
LOGP_CHAN(DFRAME, LOGL_DEBUG, " word b - %s%s\n", text, (crc_b_ok[i >> 1]) ? " ok" : " BAD CRC!");
}
}
@ -3712,7 +3713,7 @@ static int amps_decode_bits_recc(amps_t *amps, const char *bits, int first)
crc_ok++;
}
if (crc_ok) {
PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Seems we RX FOCC frame due to loopback, ignoring!\n");
LOGP_CHAN(DFRAME, LOGL_NOTICE, "Seems we RX FOCC frame due to loopback, ignoring!\n");
return 0;
}
bits_ -= 221;
@ -3724,24 +3725,24 @@ static int amps_decode_bits_recc(amps_t *amps, const char *bits, int first)
}
if (first) {
if (debuglevel == DEBUG_DEBUG || crc_ok_count > 0) {
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "RX RECC: DCC=%d (%d of 5 CRCs are ok)\n", dcc, crc_ok_count);
if (loglevel == LOGL_DEBUG || crc_ok_count > 0) {
LOGP_CHAN(DFRAME, LOGL_INFO, "RX RECC: DCC=%d (%d of 5 CRCs are ok)\n", dcc, crc_ok_count);
if (dcc != amps->si.dcc) {
PDEBUG(DFRAME, DEBUG_INFO, "received DCC=%d mismatches the base station's DCC=%d\n", dcc, amps->si.dcc);
LOGP(DFRAME, LOGL_INFO, "received DCC=%d mismatches the base station's DCC=%d\n", dcc, amps->si.dcc);
return 0;
}
}
} else {
if (debuglevel == DEBUG_DEBUG || crc_ok_count > 0)
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "RX RECC: (%d of 5 CRCs are ok)\n", crc_ok_count);
if (loglevel == LOGL_DEBUG || crc_ok_count > 0)
LOGP_CHAN(DFRAME, LOGL_INFO, "RX RECC: (%d of 5 CRCs are ok)\n", crc_ok_count);
}
if (debuglevel == DEBUG_DEBUG) {
if (loglevel == LOGL_DEBUG) {
char text[64];
for (i = 0; i < 5; i++) {
strncpy(text, bits + i * 48, 48);
text[48] = '\0';
PDEBUG_CHAN(DFRAME, DEBUG_DEBUG, " word - %s%s\n", text, (crc_a_ok[i]) ? " ok" : " BAD CRC!");
LOGP_CHAN(DFRAME, LOGL_DEBUG, " word - %s%s\n", text, (crc_a_ok[i]) ? " ok" : " BAD CRC!");
}
}
@ -3756,7 +3757,7 @@ int amps_decode_frame(amps_t *amps, const char *bits, int count, double level, d
/* not if additional words are received without sync */
if (count != 240) {
PDEBUG_CHAN(DDSP, DEBUG_INFO, "RX Level: %.0f%% Quality: %.0f%% Polarity: %s\n", level * 100.0, quality * 100.0, (negative) ? "NEGATIVE" : "POSITIVE");
LOGP_CHAN(DDSP, LOGL_INFO, "RX Level: %.0f%% Quality: %.0f%% Polarity: %s\n", level * 100.0, quality * 100.0, (negative) ? "NEGATIVE" : "POSITIVE");
}
if (count == 441) {
amps_decode_bits_focc(amps, bits);
@ -3765,7 +3766,7 @@ int amps_decode_frame(amps_t *amps, const char *bits, int count, double level, d
} else if (count == 240) {
more = amps_decode_bits_recc(amps, bits, 0);
} else {
PDEBUG_CHAN(DFRAME, DEBUG_ERROR, "Frame with unknown length = %d, please fix!\n", count);
LOGP_CHAN(DFRAME, LOGL_ERROR, "Frame with unknown length = %d, please fix!\n", count);
}
return more;

View File

@ -24,7 +24,7 @@
#include <errno.h>
#include "../libsample/sample.h"
#include "../libmobile/main_mobile.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../liboptions/options.h"
#include "../libfm/fm.h"
@ -423,6 +423,7 @@ fail:
amps_destroy(sender_head);
/* exits */
main_mobile_exit();
fm_exit();
options_free();

View File

@ -21,7 +21,7 @@
#include <stdint.h>
#include <stdlib.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "amps.h"
@ -133,7 +133,7 @@ transaction_t *create_transaction(amps_t *amps, enum amps_trans_state state, uin
const char *number = amps_min2number(trans->min1, trans->min2);
int old_callref = trans->callref;
amps_t *old_amps = trans->amps;
PDEBUG(DTRANS, DEBUG_NOTICE, "Found already pending transaction for subscriber '%s', deleting!\n", number);
LOGP(DTRANS, LOGL_NOTICE, "Found already pending transaction for subscriber '%s', deleting!\n", number);
destroy_transaction(trans);
if (old_amps) /* should be... */
amps_go_idle(old_amps);
@ -143,11 +143,11 @@ transaction_t *create_transaction(amps_t *amps, enum amps_trans_state state, uin
trans = calloc(1, sizeof(*trans));
if (!trans) {
PDEBUG(DTRANS, DEBUG_ERROR, "No memory!\n");
LOGP(DTRANS, LOGL_ERROR, "No memory!\n");
return NULL;
}
timer_init(&trans->timer, transaction_timeout, trans);
osmo_timer_setup(&trans->timer, transaction_timeout, trans);
trans_new_state(trans, state);
trans->min1 = min1;
@ -159,7 +159,7 @@ transaction_t *create_transaction(amps_t *amps, enum amps_trans_state state, uin
trans->chan = chan;
const char *number = amps_min2number(trans->min1, trans->min2);
PDEBUG(DTRANS, DEBUG_INFO, "Created transaction for subscriber '%s'\n", number);
LOGP(DTRANS, LOGL_INFO, "Created transaction for subscriber '%s'\n", number);
link_transaction(trans, amps);
@ -172,9 +172,9 @@ void destroy_transaction(transaction_t *trans)
unlink_transaction(trans);
const char *number = amps_min2number(trans->min1, trans->min2);
PDEBUG(DTRANS, DEBUG_INFO, "Destroying transaction for subscriber '%s'\n", number);
LOGP(DTRANS, LOGL_INFO, "Destroying transaction for subscriber '%s'\n", number);
timer_exit(&trans->timer);
osmo_timer_del(&trans->timer);
trans_new_state(trans, 0);
@ -187,7 +187,7 @@ void link_transaction(transaction_t *trans, amps_t *amps)
transaction_t **transp;
/* attach to end of list, so first transaction is served first */
PDEBUG(DTRANS, DEBUG_DEBUG, "Linking transaction %p to amps %p\n", trans, amps);
LOGP(DTRANS, LOGL_DEBUG, "Linking transaction %p to amps %p\n", trans, amps);
trans->amps = amps;
trans->next = NULL;
transp = &amps->trans_list;
@ -203,12 +203,12 @@ void unlink_transaction(transaction_t *trans)
transaction_t **transp;
/* unlink */
PDEBUG(DTRANS, DEBUG_DEBUG, "Unlinking transaction %p from amps %p\n", trans, trans->amps);
LOGP(DTRANS, LOGL_DEBUG, "Unlinking transaction %p from amps %p\n", trans, trans->amps);
transp = &trans->amps->trans_list;
while (*transp && *transp != trans)
transp = &((*transp)->next);
if (!(*transp)) {
PDEBUG(DTRANS, DEBUG_ERROR, "Transaction not in list, please fix!!\n");
LOGP(DTRANS, LOGL_ERROR, "Transaction not in list, please fix!!\n");
abort();
}
*transp = trans->next;
@ -224,7 +224,7 @@ transaction_t *search_transaction_number(amps_t *amps, uint32_t min1, uint16_t m
if (trans->min1 == min1
&& trans->min2 == min2) {
const char *number = amps_min2number(trans->min1, trans->min2);
PDEBUG(DTRANS, DEBUG_DEBUG, "Found transaction for subscriber '%s'\n", number);
LOGP(DTRANS, LOGL_DEBUG, "Found transaction for subscriber '%s'\n", number);
return trans;
}
trans = trans->next;
@ -243,7 +243,7 @@ transaction_t *search_transaction_callref(amps_t *amps, int callref)
while (trans) {
if (trans->callref == callref) {
const char *number = amps_min2number(trans->min1, trans->min2);
PDEBUG(DTRANS, DEBUG_DEBUG, "Found transaction for subscriber '%s'\n", number);
LOGP(DTRANS, LOGL_DEBUG, "Found transaction for subscriber '%s'\n", number);
return trans;
}
trans = trans->next;
@ -254,7 +254,7 @@ transaction_t *search_transaction_callref(amps_t *amps, int callref)
void trans_new_state(transaction_t *trans, int state)
{
PDEBUG(DTRANS, DEBUG_INFO, "Transaction state %s -> %s\n", trans_state_name(trans->state), trans_state_name(state));
LOGP(DTRANS, LOGL_INFO, "Transaction state %s -> %s\n", trans_state_name(trans->state), trans_state_name(state));
trans->state = state;
amps_display_status();
}
@ -263,12 +263,12 @@ void amps_flush_other_transactions(amps_t *amps, transaction_t *trans)
{
/* flush after this very trans */
while (trans->next) {
PDEBUG(DTRANS, DEBUG_NOTICE, "Kicking other pending transaction\n");
LOGP(DTRANS, LOGL_NOTICE, "Kicking other pending transaction\n");
destroy_transaction(trans->next);
}
/* flush before this very trans */
while (amps->trans_list != trans) {
PDEBUG(DTRANS, DEBUG_NOTICE, "Kicking other pending transaction\n");
LOGP(DTRANS, LOGL_NOTICE, "Kicking other pending transaction\n");
destroy_transaction(amps->trans_list);
}
}

View File

@ -39,7 +39,7 @@ typedef struct transaction {
char caller_id[33]; /* id of calling phone */
char dialing[33]; /* number dialed by the phone */
enum amps_trans_state state; /* state of transaction */
struct timer timer; /* for varous timeouts */
struct osmo_timer_list timer; /* for varous timeouts */
int sat_detected; /* state if we detected SAT */
int dtx; /* if set, DTX is used with this call */
} transaction_t;

View File

@ -19,23 +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/libselect/libselect.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

View File

@ -25,17 +25,17 @@
#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)
{
@ -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;
}
@ -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;
@ -368,7 +368,7 @@ static void anetz_timeout(void *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;
@ -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:

View File

@ -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;

View File

@ -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 */
@ -403,7 +403,7 @@ 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));
anetz->dsp_mode = mode;
/* reset sequence paging */
anetz->paging_tone = 0;

View File

@ -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();

View File

@ -16,14 +16,10 @@ bnetz_LDADD = \
$(COMMON_LA) \
../anetz/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/libjitter/libjitter.a \
$(top_builddir)/src/libsquelch/libsquelch.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libselect/libselect.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfsk/libfsk.a \
@ -31,8 +27,10 @@ bnetz_LDADD = \
$(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
bnetz_dialer_SOURCES = \
@ -41,12 +39,14 @@ bnetz_dialer_SOURCES = \
bnetz_dialer_LDADD = \
$(COMMON_LA) \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libfsk/libfsk.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/liblogging/liblogging.a \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOCC_LIBS) \
$(ALSA_LIBS)
-lm

View File

@ -25,30 +25,31 @@
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include "../libmobile/get_time.h"
#include <osmocom/cc/message.h>
#include "bnetz.h"
#include "telegramm.h"
#include "dsp.h"
/* mobile originating call */
#define CARRIER_TO 0.08 /* 80 ms search for carrier */
#define DIALING_TO 3.8 /* timeout after channel allocation "Kanalbelegung" (according to FTZ 1727 Pfl 32 Clause 3.2.2.2.8) */
#define DIALING_TO2 0.5 /* timeout while receiving digits */
#define CARRIER_TO 0.080000 /* 80 ms search for carrier */
#define DIALING_TO 3,800000 /* timeout after channel allocation "Kanalbelegung" (according to FTZ 1727 Pfl 32 Clause 3.2.2.2.8) */
#define DIALING_TO2 0,500000 /* timeout while receiving digits */
/* mobile terminating call */
#define ALERTING_TO 60 /* timeout after 60 seconds alerting the MS (according to FTZ 1727 Pfl 32 Clause 3.2.2.2.7) */
#define PAGING_TO 2.1 /* 700..2100 ms timeout after paging "Selektivruf" (according to FTZ 1727 Pfl 32 Clause 3.2.2.2.4.3) */
#define PAGE_TRIES 2 /* two tries (see Clause 3.2.2.2.4.3) */
#define SWITCH19_TIME 1.0 /* time to switch channel (radio should be tansmitting after that) */
#define SWITCHBACK_TIME 0.1 /* time to wait until switching back (latency of sound device shall be lower) */
#define ALERTING_TO 60,0 /* timeout after 60 seconds alerting the MS (according to FTZ 1727 Pfl 32 Clause 3.2.2.2.7) */
#define PAGING_TO 2,100000 /* 700..2100 ms timeout after paging "Selektivruf" (according to FTZ 1727 Pfl 32 Clause 3.2.2.2.4.3) */
#define PAGE_TRIES 2 /* two tries (see Clause 3.2.2.2.4.3) */
#define SWITCH19_TIME 1,0 /* time to switch channel (radio should be tansmitting after that) */
#define SWITCHBACK_TIME 0,100000 /* time to wait until switching back (latency of sound device shall be lower) */
#define TRENN_COUNT 5 /* min. 720 ms release 'Trennsignal' (according to FTZ 1727 Pfl 32 Clause 3.2.2.2.6) */
#define TRENN_COUNT 5 /* min. 720 ms release 'Trennsignal' (according to FTZ 1727 Pfl 32 Clause 3.2.2.2.6) */
#define METERING_DURATION 0.140 /* duration of metering pulse (according to FTZ 1727 Pfl 32 Clause 3.2.6.6.1) */
#define METERING_START 1.0 /* start metering 1 second after call start */
#define METERING_DURATION 0,140000 /* duration of metering pulse (according to FTZ 1727 Pfl 32 Clause 3.2.6.6.1) */
#define METERING_START 1,0 /* start metering 1 second after call start */
const char *bnetz_state_name(enum bnetz_state state)
{
@ -99,7 +100,7 @@ static void bnetz_new_state(bnetz_t *bnetz, enum bnetz_state new_state)
{
if (bnetz->state == new_state)
return;
PDEBUG_CHAN(DBNETZ, DEBUG_DEBUG, "State change: %s -> %s\n", bnetz_state_name(bnetz->state), bnetz_state_name(new_state));
LOGP_CHAN(DBNETZ, LOGL_DEBUG, "State change: %s -> %s\n", bnetz_state_name(bnetz->state), bnetz_state_name(new_state));
bnetz->state = new_state;
bnetz_display_status();
}
@ -133,7 +134,7 @@ static void switch_channel_19(bnetz_t *bnetz, int on)
fp = fopen(bnetz->paging_file, "w");
if (!fp) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to open file '%s' to switch channel 19!\n", bnetz->paging_file);
LOGP(DBNETZ, LOGL_ERROR, "Failed to open file '%s' to switch channel 19!\n", bnetz->paging_file);
return;
}
fprintf(fp, "%s\n", (on) ? bnetz->paging_on : bnetz->paging_off);
@ -162,22 +163,22 @@ int bnetz_create(const char *kanal, const char *device, int use_sdr, int sampler
int rc;
if (!(atoi(kanal) >= 1 && atoi(kanal) <= 39) && !(atoi(kanal) >= 50 && atoi(kanal) <= 86)) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Channel ('Kanal') number %s invalid.\n", kanal);
LOGP(DBNETZ, LOGL_ERROR, "Channel ('Kanal') number %s invalid.\n", kanal);
return -EINVAL;
}
if (atoi(kanal) == 19) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Selected calling channel ('Rufkanal') number %s can't be used as traffic channel.\n", kanal);
LOGP(DBNETZ, LOGL_ERROR, "Selected calling channel ('Rufkanal') number %s can't be used as traffic channel.\n", kanal);
return -EINVAL;
}
if (atoi(kanal) >= 38 && atoi(kanal) <= 39)
PDEBUG(DBNETZ, DEBUG_NOTICE, "Selected channel ('Kanal') number %s may not be supported by older B1-Network phones.\n", kanal);
LOGP(DBNETZ, LOGL_NOTICE, "Selected channel ('Kanal') number %s may not be supported by older B1-Network phones.\n", kanal);
if (atoi(kanal) >= 50)
PDEBUG(DBNETZ, DEBUG_NOTICE, "Selected channel ('Kanal') number %s belongs to B2-Network and is not supported by B1 phones.\n", kanal);
LOGP(DBNETZ, LOGL_NOTICE, "Selected channel ('Kanal') number %s belongs to B2-Network and is not supported by B1 phones.\n", kanal);
if ((gfs < 1 || gfs > 19)) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Given 'Gruppenfreisignal' %d invalid.\n", gfs);
LOGP(DBNETZ, LOGL_ERROR, "Given 'Gruppenfreisignal' %d invalid.\n", gfs);
return -EINVAL;
}
@ -199,7 +200,7 @@ int bnetz_create(const char *kanal, const char *device, int use_sdr, int sampler
p = strchr(paging_file, '=');
if (!p) {
error_paging:
PDEBUG(DBNETZ, DEBUG_ERROR, "Given paging file (to switch to channel 19) is missing parameters. Use <file>=<on>:<off> format!\n");
LOGP(DBNETZ, LOGL_ERROR, "Given paging file (to switch to channel 19) is missing parameters. Use <file>=<on>:<off> format!\n");
return -EINVAL;
}
*p++ = '\0';
@ -213,16 +214,16 @@ error_paging:
bnetz = calloc(1, sizeof(bnetz_t));
if (!bnetz) {
PDEBUG(DBNETZ, DEBUG_ERROR, "No memory!\n");
LOGP(DBNETZ, LOGL_ERROR, "No memory!\n");
return -ENOMEM;
}
PDEBUG(DBNETZ, DEBUG_DEBUG, "Creating 'B-Netz' instance for 'Kanal' = %s 'Gruppenfreisignal' = %d (sample rate %d).\n", kanal, gfs, samplerate);
LOGP(DBNETZ, LOGL_DEBUG, "Creating 'B-Netz' instance for 'Kanal' = %s 'Gruppenfreisignal' = %d (sample rate %d).\n", kanal, gfs, samplerate);
/* init general part of transceiver */
rc = sender_create(&bnetz->sender, kanal, bnetz_kanal2freq(atoi(kanal), 0), bnetz_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);
if (rc < 0) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
LOGP(DBNETZ, LOGL_ERROR, "Failed to init transceiver process!\n");
goto error;
}
bnetz->sender.ruffrequenz = bnetz_kanal2freq(19, 0);
@ -230,7 +231,7 @@ error_paging:
/* init audio processing */
rc = dsp_init_sender(bnetz, squelch_db);
if (rc < 0) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to init audio processing!\n");
LOGP(DBNETZ, LOGL_ERROR, "Failed to init audio processing!\n");
goto error;
}
@ -239,13 +240,13 @@ error_paging:
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);
osmo_timer_setup(&bnetz->timer, bnetz_timeout, bnetz);
/* go into idle state */
bnetz_go_idle(bnetz);
PDEBUG(DBNETZ, DEBUG_NOTICE, "Created 'Kanal' #%s\n", kanal);
PDEBUG(DBNETZ, DEBUG_NOTICE, " -> Using station ID (Gruppenfreisignal) %d\n", gfs);
LOGP(DBNETZ, LOGL_NOTICE, "Created 'Kanal' #%s\n", kanal);
LOGP(DBNETZ, LOGL_NOTICE, " -> Using station ID (Gruppenfreisignal) %d\n", gfs);
return 0;
@ -260,10 +261,10 @@ void bnetz_destroy(sender_t *sender)
{
bnetz_t *bnetz = (bnetz_t *) sender;
PDEBUG(DBNETZ, DEBUG_DEBUG, "Destroying 'B-Netz' instance for 'Kanal' = %s.\n", sender->kanal);
LOGP(DBNETZ, LOGL_DEBUG, "Destroying 'B-Netz' instance for 'Kanal' = %s.\n", sender->kanal);
switch_channel_19(bnetz, 0);
dsp_cleanup_sender(bnetz);
timer_exit(&bnetz->timer);
osmo_timer_del(&bnetz->timer);
sender_destroy(&bnetz->sender);
free(bnetz);
}
@ -271,9 +272,9 @@ void bnetz_destroy(sender_t *sender)
/* releaseing connection towards mobile station by sending idle digits. */
static void bnetz_go_idle(bnetz_t *bnetz)
{
timer_stop(&bnetz->timer);
osmo_timer_del(&bnetz->timer);
PDEBUG(DBNETZ, DEBUG_INFO, "Entering IDLE state on channel %s, sending 'Gruppenfreisignal' %d.\n", bnetz->sender.kanal, bnetz->gfs);
LOGP(DBNETZ, LOGL_INFO, "Entering IDLE state on channel %s, sending 'Gruppenfreisignal' %d.\n", bnetz->sender.kanal, bnetz->gfs);
bnetz->station_id[0] = '\0'; /* remove station ID before state change, so status is shown correctly */
bnetz_new_state(bnetz, BNETZ_FREI);
bnetz_set_dsp_mode(bnetz, DSP_MODE_TELEGRAMM);
@ -283,9 +284,9 @@ static void bnetz_go_idle(bnetz_t *bnetz)
/* Release connection towards mobile station by sending release digits. */
static void bnetz_release(bnetz_t *bnetz, int trenn_count)
{
timer_stop(&bnetz->timer);
osmo_timer_del(&bnetz->timer);
PDEBUG_CHAN(DBNETZ, DEBUG_INFO, "Entering release state, sending 'Trennsignal' (%d times).\n", trenn_count);
LOGP_CHAN(DBNETZ, LOGL_INFO, "Entering release state, sending 'Trennsignal' (%d times).\n", trenn_count);
bnetz->station_id[0] = '\0'; /* remove station ID before state change, so status is shown correctly */
bnetz_new_state(bnetz, BNETZ_TRENNEN);
bnetz_set_dsp_mode(bnetz, DSP_MODE_TELEGRAMM);
@ -296,14 +297,14 @@ static void bnetz_release(bnetz_t *bnetz, int trenn_count)
/* Enter paging state and transmit station ID. */
static void bnetz_page(bnetz_t *bnetz, const char *dial_string, int try)
{
PDEBUG_CHAN(DBNETZ, DEBUG_INFO, "Entering paging state (try %d), sending 'Selektivruf' to '%s'.\n", try, dial_string);
strcpy(bnetz->station_id, dial_string); /* set station ID before state change, so status is shown correctly */
LOGP_CHAN(DBNETZ, LOGL_INFO, "Entering paging state (try %d), sending 'Selektivruf' to '%s'.\n", try, dial_string);
memmove(bnetz->station_id, dial_string, strlen(dial_string) + 1); /* set station ID before state change, so status is shown correctly */
bnetz->station_id_pos = 0;
bnetz_new_state(bnetz, BNETZ_SELEKTIVRUF_EIN);
bnetz_set_dsp_mode(bnetz, DSP_MODE_0);
bnetz->page_mode = PAGE_MODE_NUMBER;
bnetz->page_try = try;
timer_start(&bnetz->timer, SWITCH19_TIME);
osmo_timer_schedule(&bnetz->timer, SWITCH19_TIME);
switch_channel_19(bnetz, 1);
}
@ -332,10 +333,10 @@ const char *bnetz_get_telegramm(bnetz_t *bnetz)
break;
case BNETZ_SELEKTIVRUF_EIN:
if (bnetz->page_mode == PAGE_MODE_KANALBEFEHL) {
PDEBUG_CHAN(DBNETZ, DEBUG_INFO, "Paging mobile station %s complete, waiting for answer.\n", bnetz->station_id);
LOGP_CHAN(DBNETZ, LOGL_INFO, "Paging mobile station %s complete, waiting for answer.\n", bnetz->station_id);
bnetz_new_state(bnetz, BNETZ_SELEKTIVRUF_AUS);
bnetz_set_dsp_mode(bnetz, DSP_MODE_SILENCE);
timer_start(&bnetz->timer, SWITCHBACK_TIME);
osmo_timer_schedule(&bnetz->timer, SWITCHBACK_TIME);
return NULL;
}
if (bnetz->station_id_pos == 5) {
@ -347,7 +348,7 @@ const char *bnetz_get_telegramm(bnetz_t *bnetz)
break;
case BNETZ_TRENNEN:
if (bnetz->trenn_count-- == 0) {
PDEBUG_CHAN(DBNETZ, DEBUG_DEBUG, "Maximum number of release digits sent, going idle.\n");
LOGP_CHAN(DBNETZ, LOGL_DEBUG, "Maximum number of release digits sent, going idle.\n");
bnetz_go_idle(bnetz);
return NULL;
}
@ -360,7 +361,7 @@ const char *bnetz_get_telegramm(bnetz_t *bnetz)
if (!it)
abort();
PDEBUG_CHAN(DBNETZ, DEBUG_DEBUG, "Sending telegramm '%s'.\n", it->description);
LOGP_CHAN(DBNETZ, LOGL_DEBUG, "Sending telegramm '%s'.\n", it->description);
return it->sequence;
}
@ -369,7 +370,7 @@ void bnetz_loss_indication(bnetz_t *bnetz, double loss_time)
{
if (bnetz->state == BNETZ_GESPRAECH
|| bnetz->state == BNETZ_RUFHALTUNG) {
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Detected loss of signal after %.1f seconds, releasing.\n", loss_time);
LOGP_CHAN(DBNETZ, LOGL_NOTICE, "Detected loss of signal after %.1f seconds, releasing.\n", loss_time);
bnetz_release(bnetz, TRENN_COUNT);
call_up_release(bnetz->callref, CAUSE_TEMPFAIL);
bnetz->callref = 0;
@ -380,9 +381,9 @@ void bnetz_loss_indication(bnetz_t *bnetz, double loss_time)
void bnetz_receive_tone(bnetz_t *bnetz, int bit)
{
if (bit >= 0)
PDEBUG_CHAN(DBNETZ, DEBUG_DEBUG, "Received continuous %d Hz tone.\n", (bit)?1950:2070);
LOGP_CHAN(DBNETZ, LOGL_DEBUG, "Received continuous %d Hz tone.\n", (bit)?1950:2070);
else
PDEBUG_CHAN(DBNETZ, DEBUG_DEBUG, "Continuous tone is gone.\n");
LOGP_CHAN(DBNETZ, LOGL_DEBUG, "Continuous tone is gone.\n");
if (bnetz->sender.loopback) {
return;
@ -391,11 +392,11 @@ void bnetz_receive_tone(bnetz_t *bnetz, int bit)
switch (bnetz->state) {
case BNETZ_FREI:
if (bit == 0) {
PDEBUG_CHAN(DBNETZ, DEBUG_INFO, "Received signal 'Kanalbelegung' from mobile station, sending signal 'Wahlabruf'.\n");
LOGP_CHAN(DBNETZ, LOGL_INFO, "Received signal 'Kanalbelegung' from mobile station, sending signal 'Wahlabruf'.\n");
bnetz_new_state(bnetz, BNETZ_WAHLABRUF);
bnetz->dial_mode = DIAL_MODE_START;
bnetz_set_dsp_mode(bnetz, DSP_MODE_1);
timer_start(&bnetz->timer, DIALING_TO);
osmo_timer_schedule(&bnetz->timer, DIALING_TO);
/* must reset, so we will not get corrupt first digit */
bnetz->rx_telegramm = bnetz->tone_detected * 0xffff;
break;
@ -403,24 +404,24 @@ void bnetz_receive_tone(bnetz_t *bnetz, int bit)
break;
case BNETZ_RUFBESTAETIGUNG:
if (bit == 1) {
PDEBUG_CHAN(DBNETZ, DEBUG_INFO, "Received signal 'Rufbestaetigung' from mobile station, sending signal 'Rufhaltung'. (call is ringing)\n");
timer_stop(&bnetz->timer);
LOGP_CHAN(DBNETZ, LOGL_INFO, "Received signal 'Rufbestaetigung' from mobile station, sending signal 'Rufhaltung'. (call is ringing)\n");
osmo_timer_del(&bnetz->timer);
bnetz_new_state(bnetz, BNETZ_RUFHALTUNG);
bnetz_set_dsp_mode(bnetz, DSP_MODE_1);
call_up_alerting(bnetz->callref);
timer_start(&bnetz->timer, ALERTING_TO);
osmo_timer_schedule(&bnetz->timer, ALERTING_TO);
break;
}
break;
case BNETZ_RUFHALTUNG:
if (bit == 0) {
PDEBUG_CHAN(DBNETZ, DEBUG_INFO, "Received signal 'Beginnsignal' from mobile station, call establised.\n");
timer_stop(&bnetz->timer);
LOGP_CHAN(DBNETZ, LOGL_INFO, "Received signal 'Beginnsignal' from mobile station, call establised.\n");
osmo_timer_del(&bnetz->timer);
bnetz_new_state(bnetz, BNETZ_GESPRAECH);
bnetz_set_dsp_mode(bnetz, DSP_MODE_AUDIO);
/* start metering pulses if forced */
if (bnetz->metering < 0)
timer_start(&bnetz->timer, METERING_START);
osmo_timer_schedule(&bnetz->timer, METERING_START);
call_up_answer(bnetz->callref, bnetz->station_id);
break;
}
@ -438,22 +439,22 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm)
it = bnetz_telegramm2digit(telegramm);
if (it) {
digit = it->digit;
PDEBUG(DBNETZ, (bnetz->sender.loopback) ? DEBUG_NOTICE : DEBUG_INFO, "Received telegramm '%s'\n", it->description);
LOGP(DBNETZ, (bnetz->sender.loopback) ? LOGL_NOTICE : LOGL_INFO, "Received telegramm '%s'\n", it->description);
} else {
PDEBUG(DBNETZ, DEBUG_DEBUG, "Received unknown telegramm digit '0x%04x' (might be radio noise)\n", telegramm);
LOGP(DBNETZ, LOGL_DEBUG, "Received unknown telegramm digit '0x%04x' (might be radio noise)\n", telegramm);
return;
}
if (bnetz->sender.loopback) {
if (digit >= '0' && digit <= '9') {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Round trip delay is %.3f seconds\n", get_time() - bnetz->loopback_time[digit - '0'] - 0.160);
LOGP(DBNETZ, LOGL_NOTICE, "Round trip delay is %.3f seconds\n", get_time() - bnetz->loopback_time[digit - '0'] - 0.160);
}
return;
}
switch (bnetz->state) {
case BNETZ_WAHLABRUF:
timer_start(&bnetz->timer, DIALING_TO2);
osmo_timer_schedule(&bnetz->timer, DIALING_TO2);
switch (bnetz->dial_mode) {
case DIAL_MODE_START:
switch (digit) {
@ -467,7 +468,7 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm)
bnetz->dial_type = DIAL_TYPE_METER_MUENZ;
break;
default:
PDEBUG(DBNETZ, DEBUG_NOTICE, "Received digit that is not a start digit ('Funkwahl'), releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Received digit that is not a start digit ('Funkwahl'), releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
@ -477,7 +478,7 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm)
break;
case DIAL_MODE_STATIONID:
if (digit < '0' || digit > '9') {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Received message that is not a valid station id digit, releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Received message that is not a valid station id digit, releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
@ -485,29 +486,29 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm)
/* update status while receiving station ID */
bnetz_display_status();
if (bnetz->dial_pos == 5) {
PDEBUG(DBNETZ, DEBUG_INFO, "Received station id from mobile phone: %s\n", bnetz->station_id);
LOGP(DBNETZ, LOGL_INFO, "Received station id from mobile phone: %s\n", bnetz->station_id);
bnetz->dial_mode = DIAL_MODE_NUMBER;
memset(bnetz->dial_number, 0, sizeof(bnetz->dial_number));
bnetz->dial_pos = 0;
/* reply station ID */
PDEBUG(DBNETZ, DEBUG_INFO, "Sending station id back to phone: %s.\n", bnetz->station_id);
LOGP(DBNETZ, LOGL_INFO, "Sending station id back to phone: %s.\n", bnetz->station_id);
bnetz_set_dsp_mode(bnetz, DSP_MODE_TELEGRAMM);
bnetz->station_id_pos = 0;
}
break;
case DIAL_MODE_NUMBER:
if (digit == 'e') {
PDEBUG(DBNETZ, DEBUG_INFO, "Received number from mobile phone: %s\n", bnetz->dial_number);
LOGP(DBNETZ, LOGL_INFO, "Received number from mobile phone: %s\n", bnetz->dial_number);
bnetz->dial_mode = DIAL_MODE_START2;
break;
}
if (digit < '0' || digit > '9') {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Received message that is not a valid number digit, releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Received message that is not a valid number digit, releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
if (bnetz->dial_pos == sizeof(bnetz->dial_number) - 1) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Received too many number digits, releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Received too many number digits, releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
@ -517,27 +518,27 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm)
switch (digit) {
case 's':
if (bnetz->dial_type != DIAL_TYPE_NOMETER) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Repeated start message ('Funkwahl') does not match first one (no metering support), releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Repeated start message ('Funkwahl') does not match first one (no metering support), releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
break;
case 'S':
if (bnetz->dial_type != DIAL_TYPE_METER) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Repeated start message ('Funkwahl') does not match first one (metering support), releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Repeated start message ('Funkwahl') does not match first one (metering support), releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
break;
case 'M':
if (bnetz->dial_type != DIAL_TYPE_METER_MUENZ) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Repeated start message ('Funkwahl') does not match first one (metering support, payphone), releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Repeated start message ('Funkwahl') does not match first one (metering support, payphone), releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
break;
default:
PDEBUG(DBNETZ, DEBUG_NOTICE, "Repeated digit is not a start digit ('Funkwahl'), releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Repeated digit is not a start digit ('Funkwahl'), releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
@ -546,12 +547,12 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm)
break;
case DIAL_MODE_STATIONID2:
if (digit < '0' || digit > '9') {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Received message that is not a valid station id digit, releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Received message that is not a valid station id digit, releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
if (bnetz->station_id[bnetz->dial_pos++] != digit) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Repeated station id does not match the first one, releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Repeated station id does not match the first one, releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
@ -567,43 +568,43 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm)
strcpy(dialing + 1, bnetz->dial_number);
if (bnetz->dial_pos != (int)strlen(bnetz->dial_number)) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Received too few repeated number digits, releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Received too few repeated number digits, releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
if (!strncmp(dialing, "0110", 4)) {
PDEBUG(DBNETZ, DEBUG_INFO, "Translating emergency number to '110'.\n");
LOGP(DBNETZ, LOGL_INFO, "Translating emergency number to '110'.\n");
strcpy(dialing, "110");
}
if (!strncmp(dialing, "0112", 4)) {
PDEBUG(DBNETZ, DEBUG_INFO, "Translating emergency number to '112'.\n");
LOGP(DBNETZ, LOGL_INFO, "Translating emergency number to '112'.\n");
strcpy(dialing, "112");
}
PDEBUG(DBNETZ, DEBUG_INFO, "Dialing complete %s->%s, call established.\n", bnetz->station_id, dialing);
timer_stop(&bnetz->timer);
LOGP(DBNETZ, LOGL_INFO, "Dialing complete %s->%s, call established.\n", bnetz->station_id, dialing);
osmo_timer_del(&bnetz->timer);
bnetz_set_dsp_mode(bnetz, DSP_MODE_AUDIO);
bnetz_new_state(bnetz, BNETZ_GESPRAECH);
/* start metering pulses if enabled and supported by phone or if forced */
if (bnetz->metering < 0 || (bnetz->metering > 0 && (bnetz->dial_type == DIAL_TYPE_METER || bnetz->dial_type == DIAL_TYPE_METER_MUENZ)))
timer_start(&bnetz->timer, METERING_START);
osmo_timer_schedule(&bnetz->timer, METERING_START);
/* setup call */
PDEBUG(DBNETZ, DEBUG_INFO, "Setup call to network.\n");
LOGP(DBNETZ, LOGL_INFO, "Setup call to network.\n");
bnetz->callref = call_up_setup(bnetz->station_id, dialing, OSMO_CC_NETWORK_BNETZ_MUENZ, (bnetz->dial_type == DIAL_TYPE_METER_MUENZ) ? "MUENZ" : "");
break;
}
if (digit < '0' || digit > '9') {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Received message that is not a valid number digit, releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Received message that is not a valid number digit, releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
if (bnetz->dial_pos == (int)strlen(bnetz->dial_number)) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Received too many number digits, releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Received too many number digits, releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
if (bnetz->dial_number[bnetz->dial_pos++] != digit) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Repeated number does not match the first one, releaseing.\n");
LOGP(DBNETZ, LOGL_NOTICE, "Repeated number does not match the first one, releaseing.\n");
bnetz_release(bnetz, TRENN_COUNT);
return;
}
@ -618,7 +619,7 @@ lets see, if noise will not generate a release signal....
return;
#endif
if (digit == 't') {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Received 'Schlusssignal' from mobile station\n");
LOGP(DBNETZ, LOGL_NOTICE, "Received 'Schlusssignal' from mobile station\n");
bnetz_release(bnetz, TRENN_COUNT);
call_up_release(bnetz->callref, CAUSE_NORMAL);
bnetz->callref = 0;
@ -637,32 +638,32 @@ static void bnetz_timeout(void *data)
switch (bnetz->state) {
case BNETZ_WAHLABRUF:
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Timeout while receiving call setup from mobile station, releasing.\n");
LOGP_CHAN(DBNETZ, LOGL_NOTICE, "Timeout while receiving call setup from mobile station, releasing.\n");
bnetz_release(bnetz, TRENN_COUNT);
break;
case BNETZ_SELEKTIVRUF_EIN:
PDEBUG_CHAN(DBNETZ, DEBUG_DEBUG, "Transmitter switched to channel 19, starting paging telegramms.\n");
LOGP_CHAN(DBNETZ, LOGL_DEBUG, "Transmitter switched to channel 19, starting paging telegramms.\n");
bnetz_set_dsp_mode(bnetz, DSP_MODE_TELEGRAMM);
break;
case BNETZ_SELEKTIVRUF_AUS:
PDEBUG_CHAN(DBNETZ, DEBUG_DEBUG, "Transmitter switched back to channel %s, waiting for paging response.\n", bnetz->sender.kanal);
LOGP_CHAN(DBNETZ, LOGL_DEBUG, "Transmitter switched back to channel %s, waiting for paging response.\n", bnetz->sender.kanal);
bnetz_new_state(bnetz, BNETZ_RUFBESTAETIGUNG);
switch_channel_19(bnetz, 0);
timer_start(&bnetz->timer, PAGING_TO);
osmo_timer_schedule(&bnetz->timer, PAGING_TO);
break;
case BNETZ_RUFBESTAETIGUNG:
if (bnetz->page_try == PAGE_TRIES) {
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Timeout while waiting for call acknowledge from mobile station, releasing.\n");
LOGP_CHAN(DBNETZ, LOGL_NOTICE, "Timeout while waiting for call acknowledge from mobile station, releasing.\n");
bnetz_release(bnetz, TRENN_COUNT);
call_up_release(bnetz->callref, CAUSE_OUTOFORDER);
bnetz->callref = 0;
break;
}
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Timeout while waiting for call acknowledge from mobile station, trying again.\n");
LOGP_CHAN(DBNETZ, LOGL_NOTICE, "Timeout while waiting for call acknowledge from mobile station, trying again.\n");
bnetz_page(bnetz, bnetz->station_id, bnetz->page_try + 1);
break;
case BNETZ_RUFHALTUNG:
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Timeout while waiting for answer of mobile station, releasing.\n");
LOGP_CHAN(DBNETZ, LOGL_NOTICE, "Timeout while waiting for answer of mobile station, releasing.\n");
bnetz_release(bnetz, TRENN_COUNT);
call_up_release(bnetz->callref, CAUSE_NOANSWER);
bnetz->callref = 0;
@ -672,12 +673,12 @@ static void bnetz_timeout(void *data)
case DSP_MODE_AUDIO:
/* turn on merting pulse */
bnetz_set_dsp_mode(bnetz, DSP_MODE_AUDIO_METER);
timer_start(&bnetz->timer, METERING_DURATION);
osmo_timer_schedule(&bnetz->timer, METERING_DURATION);
break;
case DSP_MODE_AUDIO_METER:
/* turn off and wait given seconds for next metering cycle */
bnetz_set_dsp_mode(bnetz, DSP_MODE_AUDIO);
timer_start(&bnetz->timer, (double)abs(bnetz->metering) - METERING_DURATION);
osmo_timer_schedule(&bnetz->timer, (double)abs(bnetz->metering) - METERING_DURATION);
break;
default:
break;
@ -701,7 +702,7 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
break;
}
if (sender) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Outgoing call to busy number, rejecting!\n");
LOGP(DBNETZ, LOGL_NOTICE, "Outgoing call to busy number, rejecting!\n");
return -CAUSE_BUSY;
}
@ -712,11 +713,11 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
break;
}
if (!sender) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Outgoing call, but no free channel, rejecting!\n");
LOGP(DBNETZ, LOGL_NOTICE, "Outgoing call, but no free channel, rejecting!\n");
return -CAUSE_NOCHANNEL;
}
PDEBUG_CHAN(DBNETZ, DEBUG_INFO, "Call to mobile station, paging station id '%s'\n", dialing);
LOGP_CHAN(DBNETZ, LOGL_INFO, "Call to mobile station, paging station id '%s'\n", dialing);
/* 3. trying to page mobile station */
bnetz->callref = callref;
@ -738,7 +739,7 @@ void call_down_disconnect(int callref, int cause)
sender_t *sender;
bnetz_t *bnetz;
PDEBUG(DBNETZ, DEBUG_INFO, "Call has been disconnected by network.\n");
LOGP(DBNETZ, LOGL_INFO, "Call has been disconnected by network.\n");
for (sender = sender_head; sender; sender = sender->next) {
bnetz = (bnetz_t *) sender;
@ -746,7 +747,7 @@ void call_down_disconnect(int callref, int cause)
break;
}
if (!sender) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Outgoing disconnect, but no callref!\n");
LOGP(DBNETZ, LOGL_NOTICE, "Outgoing disconnect, but no callref!\n");
call_up_release(callref, CAUSE_INVALCALLREF);
return;
}
@ -758,11 +759,11 @@ void call_down_disconnect(int callref, int cause)
case BNETZ_SELEKTIVRUF_EIN:
case BNETZ_SELEKTIVRUF_AUS:
case BNETZ_RUFBESTAETIGUNG:
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Outgoing disconnect, during paging, releasing!\n");
LOGP_CHAN(DBNETZ, LOGL_NOTICE, "Outgoing disconnect, during paging, releasing!\n");
bnetz_release(bnetz, TRENN_COUNT);
break;
case BNETZ_RUFHALTUNG:
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Outgoing disconnect, during alerting, releasing!\n");
LOGP_CHAN(DBNETZ, LOGL_NOTICE, "Outgoing disconnect, during alerting, releasing!\n");
bnetz_release(bnetz, TRENN_COUNT);
break;
default:
@ -780,7 +781,7 @@ void call_down_release(int callref, int __attribute__((unused)) cause)
sender_t *sender;
bnetz_t *bnetz;
PDEBUG(DBNETZ, DEBUG_INFO, "Call has been released by network, releasing call.\n");
LOGP(DBNETZ, LOGL_INFO, "Call has been released by network, releasing call.\n");
for (sender = sender_head; sender; sender = sender->next) {
bnetz = (bnetz_t *) sender;
@ -788,7 +789,7 @@ void call_down_release(int callref, int __attribute__((unused)) cause)
break;
}
if (!sender) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Outgoing release, but no callref!\n");
LOGP(DBNETZ, LOGL_NOTICE, "Outgoing release, but no callref!\n");
/* don't send release, because caller already released */
return;
}
@ -797,17 +798,17 @@ void call_down_release(int callref, int __attribute__((unused)) cause)
switch (bnetz->state) {
case BNETZ_GESPRAECH:
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Outgoing release, during call, releasing!\n");
LOGP_CHAN(DBNETZ, LOGL_NOTICE, "Outgoing release, during call, releasing!\n");
bnetz_release(bnetz, TRENN_COUNT);
break;
case BNETZ_SELEKTIVRUF_EIN:
case BNETZ_SELEKTIVRUF_AUS:
case BNETZ_RUFBESTAETIGUNG:
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Outgoing release, during paging, releasing!\n");
LOGP_CHAN(DBNETZ, LOGL_NOTICE, "Outgoing release, during paging, releasing!\n");
bnetz_release(bnetz, TRENN_COUNT);
break;
case BNETZ_RUFHALTUNG:
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Outgoing release, during alerting, releasing!\n");
LOGP_CHAN(DBNETZ, LOGL_NOTICE, "Outgoing release, during alerting, releasing!\n");
bnetz_release(bnetz, TRENN_COUNT);
break;
default:

View File

@ -1,7 +1,7 @@
#include "../libsquelch/squelch.h"
#include "../libfsk/fsk.h"
#include "../libmobile/sender.h"
#include "../libtimer/timer.h"
#include <osmocom/core/timer.h>
/* fsk modes of transmission */
enum dsp_mode {
@ -74,7 +74,7 @@ typedef struct bnetz {
int station_id_pos; /* position while transmitting */
enum page_mode page_mode; /* sub state while paging */
int page_try; /* try number (1 or 2) */
struct timer timer;
struct osmo_timer_list timer;
int trenn_count; /* count number of release messages */
/* display measurements */

View File

@ -26,7 +26,7 @@
#include "../libsample/sample.h"
#include "../libfsk/fsk.h"
#include "../libwave/wave.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#ifdef HAVE_ALSA
#include "../libsound/sound.h"
#endif
@ -161,13 +161,13 @@ static int fsk_send_bit(void __attribute__((unused)) *inst)
if (!tx_telegramm || tx_telegramm_pos == 16) {
switch (funkwahl[digit_pos]) {
case '\0':
PDEBUG(DBNETZ, DEBUG_INFO, "Done sending dialing sequence\n");
LOGP(DBNETZ, LOGL_INFO, "Done sending dialing sequence\n");
tx_mode = TX_MODE_SILENCE;
tx_silence_count = 0;
return -1;
case 'w':
if (!tx_telegramm)
PDEBUG(DBNETZ, DEBUG_INFO, "Sending channel allocation tone ('Kanalbelegung')\n");
LOGP(DBNETZ, LOGL_INFO, "Sending channel allocation tone ('Kanalbelegung')\n");
tx_telegramm = "0000000000000000";
tx_telegramm_pos = 0;
digit_pos++;
@ -175,23 +175,23 @@ static int fsk_send_bit(void __attribute__((unused)) *inst)
default:
switch (funkwahl[digit_pos]) {
case 's':
PDEBUG(DBNETZ, DEBUG_INFO, "Sending start digit (no charging meater on board)\n");
LOGP(DBNETZ, LOGL_INFO, "Sending start digit (no charging meater on board)\n");
break;
case 'S':
PDEBUG(DBNETZ, DEBUG_INFO, "Sending start digit (with charging meater on board)\n");
LOGP(DBNETZ, LOGL_INFO, "Sending start digit (with charging meater on board)\n");
break;
case 'M':
PDEBUG(DBNETZ, DEBUG_INFO, "Sending start digit (Phone is a coin box.)\n");
LOGP(DBNETZ, LOGL_INFO, "Sending start digit (Phone is a coin box.)\n");
break;
case 'e':
PDEBUG(DBNETZ, DEBUG_INFO, "Sending stop digit\n");
LOGP(DBNETZ, LOGL_INFO, "Sending stop digit\n");
break;
default:
PDEBUG(DBNETZ, DEBUG_INFO, "Sending digit '%c'\n", funkwahl[digit_pos]);
LOGP(DBNETZ, LOGL_INFO, "Sending digit '%c'\n", funkwahl[digit_pos]);
}
impulstelegramm = bnetz_digit2telegramm(funkwahl[digit_pos]);
if (!impulstelegramm) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Illegal digit '%c', please fix!\n", funkwahl[digit_pos]);
LOGP(DBNETZ, LOGL_ERROR, "Illegal digit '%c', please fix!\n", funkwahl[digit_pos]);
abort();
}
tx_telegramm = impulstelegramm->sequence;
@ -252,7 +252,7 @@ static void process_signal(int buffer_size)
count = dsp_samplerate / 1000;
#endif
if (count < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count);
LOGP(DDSP, LOGL_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count);
break;
}
@ -267,7 +267,7 @@ static void process_signal(int buffer_size)
/* write audio */
rc = sound_write(audio, samples, power, count, NULL, NULL, 1);
if (rc < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to write TX data to audio device (rc = %d)\n", rc);
LOGP(DDSP, LOGL_ERROR, "Failed to write TX data to audio device (rc = %d)\n", rc);
break;
}
#endif
@ -340,7 +340,7 @@ int main(int argc, char *argv[])
/* init fsk */
if (fsk_mod_init(&fsk_mod, NULL, fsk_send_bit, dsp_samplerate, BIT_RATE, F0, F1, 1.0, 0, 0) < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "FSK init failed!\n");
LOGP(DDSP, LOGL_ERROR, "FSK init failed!\n");
goto exit;
}
@ -348,7 +348,7 @@ int main(int argc, char *argv[])
/* init sound */
audio = sound_open(dsp_audiodev, NULL, NULL, NULL, 1, 0.0, dsp_samplerate, buffer_size, 1.0, 1.0, 4000.0, 2.0);
if (!audio) {
PDEBUG(DBNETZ, DEBUG_ERROR, "No sound device!\n");
LOGP(DBNETZ, LOGL_ERROR, "No sound device!\n");
goto exit;
}
#endif
@ -357,13 +357,13 @@ int main(int argc, char *argv[])
if (write_tx_wave) {
rc = wave_create_record(&wave_tx_rec, write_tx_wave, dsp_samplerate, 1, 1.0);
if (rc < 0) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
LOGP(DBNETZ, LOGL_ERROR, "Failed to create WAVE recoding instance!\n");
goto exit;
}
}
#ifndef HAVE_ALSA
else {
PDEBUG(DBNETZ, DEBUG_ERROR, "No sound support compiled in, so you need to write to a wave file. See help!\n");
LOGP(DBNETZ, LOGL_ERROR, "No sound support compiled in, so you need to write to a wave file. See help!\n");
goto exit;
}
#endif
@ -373,7 +373,7 @@ int main(int argc, char *argv[])
sound_start(audio);
#endif
PDEBUG(DBNETZ, DEBUG_ERROR, "Start audio after pause...\n");
LOGP(DBNETZ, LOGL_ERROR, "Start audio after pause...\n");
process_signal(buffer_size);

View File

@ -26,7 +26,7 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "bnetz.h"
#include "dsp.h"
@ -70,7 +70,7 @@ void dsp_init(void)
{
int i;
PDEBUG(DDSP, DEBUG_DEBUG, "Generating sine table for metering tone.\n");
LOGP(DDSP, LOGL_DEBUG, "Generating sine table for metering tone.\n");
for (i = 0; i < 65536; i++)
dsp_metering[i] = sin((double)i / 65536.0 * 2.0 * PI) * TX_PEAK_METER;
}
@ -81,10 +81,10 @@ static void fsk_receive_bit(void *inst, int bit, double quality, double level);
/* Init transceiver instance. */
int dsp_init_sender(bnetz_t *bnetz, double squelch_db)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for 'Sender'.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Init DSP for 'Sender'.\n");
if (TONE_DETECT_CNT > sizeof(bnetz->rx_tone_quality) / sizeof(bnetz->rx_tone_quality[0])) {
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "buffer for tone quality is too small, please fix!\n");
LOGP_CHAN(DDSP, LOGL_ERROR, "buffer for tone quality is too small, please fix!\n");
return -EINVAL;
}
@ -94,15 +94,15 @@ int dsp_init_sender(bnetz_t *bnetz, double squelch_db)
/* set modulation parameters */
sender_set_fm(&bnetz->sender, MAX_DEVIATION, MAX_MODULATION, SPEECH_DEVIATION, MAX_DISPLAY);
PDEBUG(DDSP, DEBUG_DEBUG, "Using FSK level of %.3f (%.3f KHz deviation @ 2000 Hz)\n", TX_PEAK_FSK, 4.0);
LOGP(DDSP, LOGL_DEBUG, "Using FSK level of %.3f (%.3f KHz deviation @ 2000 Hz)\n", TX_PEAK_FSK, 4.0);
/* init fsk */
if (fsk_mod_init(&bnetz->fsk_mod, bnetz, fsk_send_bit, bnetz->sender.samplerate, BIT_RATE, F0, F1, TX_PEAK_FSK, 0, 0) < 0) {
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "FSK init failed!\n");
LOGP_CHAN(DDSP, LOGL_ERROR, "FSK init failed!\n");
return -EINVAL;
}
if (fsk_demod_init(&bnetz->fsk_demod, bnetz, fsk_receive_bit, bnetz->sender.samplerate, BIT_RATE, F0, F1, BIT_ADJUST) < 0) {
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "FSK init failed!\n");
LOGP_CHAN(DDSP, LOGL_ERROR, "FSK init failed!\n");
return -EINVAL;
}
@ -124,7 +124,7 @@ int dsp_init_sender(bnetz_t *bnetz, double squelch_db)
/* Cleanup transceiver instance. */
void dsp_cleanup_sender(bnetz_t *bnetz)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for 'Sender'.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Cleanup DSP for 'Sender'.\n");
fsk_mod_cleanup(&bnetz->fsk_mod);
fsk_demod_cleanup(&bnetz->fsk_demod);
@ -148,7 +148,7 @@ static void fsk_receive_tone(bnetz_t *bnetz, int tone, int goodtone, double leve
/* set duration to TONE_DETECT_CNT, because it took that long to detect the tone */
bnetz->tone_duration = TONE_DETECT_CNT;
bnetz->tone_detected = tone;
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Detecting continuous tone: F%d Level=%3.0f%% (threshold %3.0f%%) standard deviation=%.0f%% (threshold=%.0f%%) Quality=%3.0f%%\n", bnetz->tone_detected, level_avg * 100.0, TONE_LEVEL_TH * 100.0, level_stddev / level_avg * 100.0, TONE_STDDEV_TH * 100.0, quality_avg * 100.0);
LOGP_CHAN(DDSP, LOGL_INFO, "Detecting continuous tone: F%d Level=%3.0f%% (threshold %3.0f%%) standard deviation=%.0f%% (threshold=%.0f%%) Quality=%3.0f%%\n", bnetz->tone_detected, level_avg * 100.0, TONE_LEVEL_TH * 100.0, level_stddev / level_avg * 100.0, TONE_STDDEV_TH * 100.0, quality_avg * 100.0);
bnetz_receive_tone(bnetz, bnetz->tone_detected);
}
}
@ -158,7 +158,7 @@ static void fsk_receive_tone(bnetz_t *bnetz, int tone, int goodtone, double leve
bnetz->tone_count++;
if (bnetz->tone_count == TONE_LOST_CNT) {
/* subtract TONE_LOST_CNT from duration, because it took that long to detect loss of tone */
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Lost F%d tone after %.2f seconds.\n", bnetz->tone_detected, (double)(bnetz->tone_duration - TONE_LOST_CNT) / 100.0);
LOGP_CHAN(DDSP, LOGL_INFO, "Lost F%d tone after %.2f seconds.\n", bnetz->tone_detected, (double)(bnetz->tone_duration - TONE_LOST_CNT) / 100.0);
bnetz->tone_detected = -1;
bnetz_receive_tone(bnetz, -1);
}
@ -250,7 +250,7 @@ static void fsk_receive_bit(void *inst, int bit, double quality, double level)
j++;
}
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "FSK Valid bits: %d/%d Level: %.0f%% (threshold %.0f%%) Stddev: %.0f%% (threshold %.0f%%)\n", j, 16, level_avg * 100.0, TONE_LEVEL_TH * 100.0, level_stddev / level_avg * 100.0, TONE_STDDEV_TH * 100.0);
LOGP_CHAN(DDSP, LOGL_DEBUG, "FSK Valid bits: %d/%d Level: %.0f%% (threshold %.0f%%) Stddev: %.0f%% (threshold %.0f%%)\n", j, 16, level_avg * 100.0, TONE_LEVEL_TH * 100.0, level_stddev / level_avg * 100.0, TONE_STDDEV_TH * 100.0);
/* drop any telegramm that is too bad */
if (level_stddev / level_avg > TONE_STDDEV_TH || j < 16)
@ -261,7 +261,7 @@ static void fsk_receive_bit(void *inst, int bit, double quality, double level)
display_measurements_update(bnetz->dmp_frame_stddev, level_stddev / level_avg * 100.0, 0.0);
display_measurements_update(bnetz->dmp_frame_quality, quality_avg * 100.0, 0.0);
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Telegramm RX Level: average=%.0f%% (threshold %.0f%%) standard deviation=%.0f%% (threshold %.0f%%) Quality: %.0f%%\n", level_avg * 100.0, TONE_LEVEL_TH * 100.0, level_stddev / level_avg * 100.0, TONE_STDDEV_TH * 100.0, quality_avg * 100.0);
LOGP_CHAN(DDSP, LOGL_INFO, "Telegramm RX Level: average=%.0f%% (threshold %.0f%%) standard deviation=%.0f%% (threshold %.0f%%) Quality: %.0f%%\n", level_avg * 100.0, TONE_LEVEL_TH * 100.0, level_stddev / level_avg * 100.0, TONE_STDDEV_TH * 100.0, quality_avg * 100.0);
/* receive telegramm */
bnetz_receive_telegramm(bnetz, bnetz->rx_telegramm);
@ -320,7 +320,7 @@ static int fsk_send_bit(void *inst)
/* request frame */
bnetz->tx_telegramm = bnetz_get_telegramm(bnetz);
if (!bnetz->tx_telegramm) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Stop sending 'Telegramm'.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Stop sending 'Telegramm'.\n");
return -1;
}
bnetz->tx_telegramm_pos = 0;
@ -423,7 +423,7 @@ void bnetz_set_dsp_mode(bnetz_t *bnetz, enum dsp_mode mode)
fsk_mod_reset(&bnetz->fsk_mod);
}
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "DSP mode %s -> %s\n", bnetz_dsp_mode_name(bnetz->dsp_mode), bnetz_dsp_mode_name(mode));
LOGP_CHAN(DDSP, LOGL_DEBUG, "DSP mode %s -> %s\n", bnetz_dsp_mode_name(bnetz->dsp_mode), bnetz_dsp_mode_name(mode));
bnetz->dsp_mode = mode;
}

View File

@ -24,7 +24,7 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/main_mobile.h"
#include "../anetz/freiton.h"
@ -218,6 +218,7 @@ fail:
bnetz_destroy(sender_head);
/* exits */
main_mobile_exit();
fm_exit();
options_free();

View File

@ -24,14 +24,10 @@ cnetz_LDADD = \
../anetz/libgermanton.a \
libcnetztones.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/libcompandor/libcompandor.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libselect/libselect.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libscrambler/libscrambler.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
@ -39,8 +35,10 @@ cnetz_LDADD = \
$(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

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
#include "../libcompandor/compandor.h"
#include "../libtimer/timer.h"
#include <osmocom/core/timer.h>
#include "../libmobile/sender.h"
#include "../libscrambler/scrambler.h"
typedef struct cnetz cnetz_t;
@ -40,9 +40,9 @@ enum cnetz_state {
#define N_AFKT 6 /* number of release frames to send during concentrated signaling */
#define N_AFV 4 /* number of release frames to send during distributed signaling */
#define N 3 /* now many times we repeat a message on OgK */
#define T_VAG2 180 /* time on outgoing queue */
#define T_VAK 60 /* time on incoming queue */
#define T_AP 750 /* Time to wait for SIM card's authentication reply */
#define T_VAG2 180,0 /* time on outgoing queue */
#define T_VAK 60,0 /* time on incoming queue */
#define T_AP 0,750000 /* Time to wait for SIM card's authentication reply */
/* clear causes */
#define CNETZ_CAUSE_GASSENBESETZT 0 /* network congested */

View File

@ -22,7 +22,8 @@
#include <stdlib.h>
#include <string.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/get_time.h"
#include "cnetz.h"
#include "database.h"
#include "sysinfo.h"
@ -45,7 +46,7 @@ typedef struct cnetz_database {
int eingebucht; /* set if still available */
double last_seen;
int busy; /* set if currently in a call */
struct timer timer; /* timer for next availability check */
struct osmo_timer_list timer; /* timer for next availability check */
int retry; /* counts number of retries */
} cnetz_db_t;
@ -72,14 +73,14 @@ static void remove_db(cnetz_db_t *db)
while (*dbp && *dbp != db)
dbp = &((*dbp)->next);
if (!(*dbp)) {
PDEBUG(DDB, DEBUG_ERROR, "Subscriber not in list, please fix!!\n");
LOGP(DDB, LOGL_ERROR, "Subscriber not in list, please fix!!\n");
abort();
}
*dbp = db->next;
PDEBUG(DDB, DEBUG_INFO, "Removing subscriber '%d,%d,%05d' from database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
LOGP(DDB, LOGL_INFO, "Removing subscriber '%d,%d,%05d' from database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
timer_exit(&db->timer);
osmo_timer_del(&db->timer);
free(db);
}
@ -90,15 +91,15 @@ static void db_timeout(void *data)
cnetz_db_t *db = data;
int rc;
PDEBUG(DDB, DEBUG_INFO, "Check, if subscriber '%d,%d,%05d' is still available.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
LOGP(DDB, LOGL_INFO, "Check, if subscriber '%d,%d,%05d' is still available.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
rc = cnetz_meldeaufruf(db->futln_nat, db->futln_fuvst, db->futln_rest, db->ogk_kanal);
if (rc < 0) {
/* OgK is used for speech, but this never happens in a real
* network. We just assume that the phone has responded and
* assume we had a response. */
PDEBUG(DDB, DEBUG_INFO, "OgK busy, so we assume a positive response.\n");
timer_start(&db->timer, si.meldeinterval); /* when to check avaiability again */
LOGP(DDB, LOGL_INFO, "OgK busy, so we assume a positive response.\n");
osmo_timer_schedule(&db->timer, si.meldeinterval,0); /* when to check avaiability again */
db->retry = 0;
}
}
@ -120,10 +121,10 @@ int update_db(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest, int o
if (!db) {
db = calloc(1, sizeof(*db));
if (!db) {
PDEBUG(DDB, DEBUG_ERROR, "No memory!\n");
LOGP(DDB, LOGL_ERROR, "No memory!\n");
return 0;
}
timer_init(&db->timer, db_timeout, db);
osmo_timer_setup(&db->timer, db_timeout, db);
db->eingebucht = 1;
db->futln_nat = futln_nat;
@ -136,7 +137,7 @@ int update_db(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest, int o
dbp = &((*dbp)->next);
*dbp = db;
PDEBUG(DDB, DEBUG_INFO, "Adding subscriber '%d,%d,%05d' to database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
LOGP(DDB, LOGL_INFO, "Adding subscriber '%d,%d,%05d' to database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
}
if (ogk_kanal)
@ -150,23 +151,23 @@ int update_db(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest, int o
db->busy = busy;
if (busy) {
PDEBUG(DDB, DEBUG_INFO, "Subscriber '%d,%d,%05d' on OGK channel #%d is busy now.\n", db->futln_nat, db->futln_fuvst, db->futln_rest, db->ogk_kanal);
timer_stop(&db->timer);
LOGP(DDB, LOGL_INFO, "Subscriber '%d,%d,%05d' on OGK channel #%d is busy now.\n", db->futln_nat, db->futln_fuvst, db->futln_rest, db->ogk_kanal);
osmo_timer_del(&db->timer);
} else if (!failed) {
PDEBUG(DDB, DEBUG_INFO, "Subscriber '%d,%d,%05d' on OGK channel #%d is idle now.\n", db->futln_nat, db->futln_fuvst, db->futln_rest, db->ogk_kanal);
timer_start(&db->timer, si.meldeinterval); /* when to check avaiability (again) */
LOGP(DDB, LOGL_INFO, "Subscriber '%d,%d,%05d' on OGK channel #%d is idle now.\n", db->futln_nat, db->futln_fuvst, db->futln_rest, db->ogk_kanal);
osmo_timer_schedule(&db->timer, si.meldeinterval,0); /* when to check avaiability (again) */
db->retry = 0;
db->eingebucht = 1;
db->last_seen = get_time();
} else {
db->retry++;
PDEBUG(DDB, DEBUG_NOTICE, "Paging subscriber '%d,%d,%05d' on OGK channel #%d failed (try %d of %s).\n", db->futln_nat, db->futln_fuvst, db->futln_rest, db->ogk_kanal, db->retry, print_meldeaufrufe(si.meldeaufrufe));
LOGP(DDB, LOGL_NOTICE, "Paging subscriber '%d,%d,%05d' on OGK channel #%d failed (try %d of %s).\n", db->futln_nat, db->futln_fuvst, db->futln_rest, db->ogk_kanal, db->retry, print_meldeaufrufe(si.meldeaufrufe));
if (si.meldeaufrufe && db->retry == si.meldeaufrufe) {
PDEBUG(DDB, DEBUG_INFO, "Marking subscriber as gone.\n");
LOGP(DDB, LOGL_INFO, "Marking subscriber as gone.\n");
db->eingebucht = 0;
return db->extended;
}
timer_start(&db->timer, (si.meldeinterval < MELDE_WIEDERHOLUNG) ? si.meldeinterval : MELDE_WIEDERHOLUNG); /* when to do retry */
osmo_timer_schedule(&db->timer, (si.meldeinterval < MELDE_WIEDERHOLUNG) ? si.meldeinterval : MELDE_WIEDERHOLUNG,0); /* when to do retry */
}
if (futelg_bit)
@ -211,18 +212,18 @@ void dump_db(void)
int last;
char attached[16];
PDEBUG(DDB, DEBUG_NOTICE, "Dump of subscriber database:\n");
LOGP(DDB, LOGL_NOTICE, "Dump of subscriber database:\n");
if (!db) {
PDEBUG(DDB, DEBUG_NOTICE, " - No subscribers attached!\n");
LOGP(DDB, LOGL_NOTICE, " - No subscribers attached!\n");
return;
}
PDEBUG(DDB, DEBUG_NOTICE, "Subscriber\tAttached\tBusy\t\tLast seen\tMeldeaufrufe\n");
PDEBUG(DDB, DEBUG_NOTICE, "-------------------------------------------------------------------------------\n");
LOGP(DDB, LOGL_NOTICE, "Subscriber\tAttached\tBusy\t\tLast seen\tMeldeaufrufe\n");
LOGP(DDB, LOGL_NOTICE, "-------------------------------------------------------------------------------\n");
while (db) {
last = (db->busy) ? 0 : (uint32_t)(now - db->last_seen);
sprintf(attached, "YES (OGK %d)", db->ogk_kanal);
PDEBUG(DDB, DEBUG_NOTICE, "%d,%d,%05d\t%s\t%s\t\t%02d:%02d:%02d \t%d/%s\n", db->futln_nat, db->futln_fuvst, db->futln_rest, (db->eingebucht) ? attached : "-no-\t", (db->busy) ? "YES" : "-no-", last / 3600, (last / 60) % 60, last % 60, db->retry, print_meldeaufrufe(si.meldeaufrufe));
LOGP(DDB, LOGL_NOTICE, "%d,%d,%05d\t%s\t%s\t\t%02d:%02d:%02d \t%d/%s\n", db->futln_nat, db->futln_fuvst, db->futln_rest, (db->eingebucht) ? attached : "-no-\t", (db->busy) ? "YES" : "-no-", last / 3600, (last / 60) % 60, last % 60, db->retry, print_meldeaufrufe(si.meldeaufrufe));
db = db->next;
}
}

View File

@ -26,8 +26,9 @@
#include <math.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/get_time.h"
#include "cnetz.h"
#include "sysinfo.h"
#include "telegramm.h"
@ -84,7 +85,7 @@ static void dsp_init_ramp(cnetz_t *cnetz)
double c;
int i;
PDEBUG(DDSP, DEBUG_DEBUG, "Generating smooth ramp table.\n");
LOGP(DDSP, LOGL_DEBUG, "Generating smooth ramp table.\n");
for (i = 0; i < 256; i++) {
/* use square-root of cosine ramp. tests showed that phones are more
* happy with that. (This is not correct pulse shaping!) */
@ -104,7 +105,7 @@ int dsp_init_sender(cnetz_t *cnetz, int measure_speed, double clock_speed[2], en
int rc = 0;
double size;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init FSK for 'Sender'.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Init FSK for 'Sender'.\n");
/* set modulation parameters */
sender_set_fm(&cnetz->sender, MAX_DEVIATION, MAX_MODULATION, speech_deviation, MAX_DISPLAY);
@ -115,20 +116,20 @@ int dsp_init_sender(cnetz_t *cnetz, int measure_speed, double clock_speed[2], en
}
if (clock_speed[0] > 1000 || clock_speed[0] < -1000 || clock_speed[1] > 1000 || clock_speed[1] < -1000) {
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "Clock speed %.1f,%.1f ppm out of range! Please use range between +-1000 ppm!\n", clock_speed[0], clock_speed[1]);
LOGP_CHAN(DDSP, LOGL_ERROR, "Clock speed %.1f,%.1f ppm out of range! Please use range between +-1000 ppm!\n", clock_speed[0], clock_speed[1]);
return -EINVAL;
}
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Using clock speed of %.1f ppm (RX) and %.1f ppm (TX) to correct sound card's clock.\n", clock_speed[0], clock_speed[1]);
LOGP_CHAN(DDSP, LOGL_INFO, "Using clock speed of %.1f ppm (RX) and %.1f ppm (TX) to correct sound card's clock.\n", clock_speed[0], clock_speed[1]);
cnetz->fsk_bitduration = (double)cnetz->sender.samplerate / ((double)BITRATE / (1.0 + clock_speed[1] / 1000000.0));
cnetz->fsk_tx_bitstep = 1.0 / cnetz->fsk_bitduration;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Use %.4f samples for one bit duration @ %d.\n", cnetz->fsk_bitduration, cnetz->sender.samplerate);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Use %.4f samples for one bit duration @ %d.\n", cnetz->fsk_bitduration, cnetz->sender.samplerate);
size = cnetz->fsk_bitduration * (double)BLOCK_BITS * 16.0; /* 16 blocks for distributed frames */
cnetz->fsk_tx_buffer_size = size * 1.1; /* more to compensate clock speed */
cnetz->fsk_tx_buffer = calloc(sizeof(sample_t), cnetz->fsk_tx_buffer_size);
if (!cnetz->fsk_tx_buffer) {
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "No memory!\n");
LOGP_CHAN(DDSP, LOGL_ERROR, "No memory!\n");
rc = -ENOMEM;
goto error;
}
@ -143,7 +144,7 @@ int dsp_init_sender(cnetz_t *cnetz, int measure_speed, double clock_speed[2], en
/* create speech buffer */
cnetz->dsp_speech_buffer = calloc(sizeof(sample_t), (int)(cnetz->fsk_bitduration * 70.0)); /* more to compensate clock speed. we just need it to fill 62 bits (60 bits, including pause bits). */
if (!cnetz->dsp_speech_buffer) {
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "No memory!\n");
LOGP_CHAN(DDSP, LOGL_ERROR, "No memory!\n");
rc = -ENOMEM;
goto error;
}
@ -169,7 +170,7 @@ int dsp_init_sender(cnetz_t *cnetz, int measure_speed, double clock_speed[2], en
#ifdef TEST_SCRAMBLE
rc = jitter_create(&scrambler_test_jb, "scramble", cnetz->sender.samplerate, sizeof(sample_t), JITTER_AUDIO);
if (rc < 0) {
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "Failed to init jitter buffer for scrambler test!\n");
LOGP_CHAN(DDSP, LOGL_ERROR, "Failed to init jitter buffer for scrambler test!\n");
exit(0);
}
scrambler_setup(&scrambler_test_scrambler1, cnetz->sender.samplerate);
@ -188,7 +189,7 @@ error:
void dsp_cleanup_sender(cnetz_t *cnetz)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup FSK for 'Sender'.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Cleanup FSK for 'Sender'.\n");
if (cnetz->fsk_tx_buffer) {
free(cnetz->fsk_tx_buffer);
@ -256,7 +257,7 @@ void calc_clock_speed(cnetz_t *cnetz, double samples, int tx, int result)
speed_ppm_avg[index] += cs->speed_ppm[index][(cs->idx[index] - i - 1) & 0xff];
speed_ppm_avg[index] /= (double)cs->num[index];
}
PDEBUG_CHAN(DDSP, DEBUG_NOTICE, "Clock: RX=%.3f TX=%.3f; Signal: RX=%.3f TX=%.3f ppm\n", speed_ppm_avg[0], speed_ppm_avg[1], speed_ppm_avg[2], speed_ppm_avg[3]);
LOGP_CHAN(DDSP, LOGL_NOTICE, "Clock: RX=%.3f TX=%.3f; Signal: RX=%.3f TX=%.3f ppm\n", speed_ppm_avg[0], speed_ppm_avg[1], speed_ppm_avg[2], speed_ppm_avg[3]);
}
static int fsk_nothing_encode(cnetz_t *cnetz)
@ -642,10 +643,10 @@ again:
* because one has a phase wrap before and the other after a sample.
* then we do it next super frame cycle */
if (master->frame_last_scount == cnetz->fsk_tx_scount) {
PDEBUG(DDSP, DEBUG_DEBUG, "Sync phase of slave to master: master=%.15f, slave=%.15f, diff=%.15f\n", master->frame_last_phase, cnetz->fsk_tx_phase, master->frame_last_phase - cnetz->fsk_tx_phase);
LOGP(DDSP, LOGL_DEBUG, "Sync phase of slave to master: master=%.15f, slave=%.15f, diff=%.15f\n", master->frame_last_phase, cnetz->fsk_tx_phase, master->frame_last_phase - cnetz->fsk_tx_phase);
cnetz->fsk_tx_phase = master->frame_last_phase;
} else {
PDEBUG(DDSP, DEBUG_DEBUG, "Not sync phase of slave to master: Sample counts during frame change are different, ignoring this time!\n");
LOGP(DDSP, LOGL_DEBUG, "Not sync phase of slave to master: Sample counts during frame change are different, ignoring this time!\n");
}
}
}
@ -654,7 +655,7 @@ again:
if (cnetz->sched_dsp_mode_ts >= 0 && cnetz->sched_r_m == 0) {
if (cnetz->sched_dsp_mode_ts == cnetz->sched_ts) {
/* OgK / SpK(K) / SpK(V) */
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Now switching channel mode to %s at timeslot %d\n", cnetz_dsp_mode_name(cnetz->sched_dsp_mode), cnetz->sched_dsp_mode_ts);
LOGP_CHAN(DDSP, LOGL_INFO, "Now switching channel mode to %s at timeslot %d\n", cnetz_dsp_mode_name(cnetz->sched_dsp_mode), cnetz->sched_dsp_mode_ts);
cnetz->sched_dsp_mode_ts = -1;
cnetz_set_dsp_mode(cnetz, cnetz->sched_dsp_mode);
}
@ -671,14 +672,14 @@ again:
cnetz->sched_last_ts = cnetz->sched_ts;
bits = cnetz_encode_telegramm(cnetz);
if (bits) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Rufblock' at timeslot %d\n", cnetz->sched_ts);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Transmitting 'Rufblock' at timeslot %d\n", cnetz->sched_ts);
fsk_block_encode(cnetz, bits, 1);
} else
fsk_nothing_encode(cnetz);
} else {
bits = cnetz_encode_telegramm(cnetz);
if (bits) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Meldeblock' at timeslot %d\n", cnetz->sched_ts);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Transmitting 'Meldeblock' at timeslot %d\n", cnetz->sched_ts);
fsk_block_encode(cnetz, bits, 1);
} else
fsk_nothing_encode(cnetz);
@ -690,7 +691,7 @@ again:
case DSP_MODE_SPK_K:
bits = cnetz_encode_telegramm(cnetz);
if (bits) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Konzentrierte Signalisierung' at timeslot %d.%d\n", cnetz->sched_ts, cnetz->sched_r_m * 5);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Transmitting 'Konzentrierte Signalisierung' at timeslot %d.%d\n", cnetz->sched_ts, cnetz->sched_r_m * 5);
fsk_block_encode(cnetz, bits, 0);
} else
fsk_nothing_encode(cnetz);
@ -698,7 +699,7 @@ again:
case DSP_MODE_SPK_V:
bits = cnetz_encode_telegramm(cnetz);
if (bits) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Verteilte Signalisierung' starting at timeslot %d\n", cnetz->sched_ts);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Transmitting 'Verteilte Signalisierung' starting at timeslot %d\n", cnetz->sched_ts);
fsk_distributed_encode(cnetz, bits);
} else
fsk_nothing_encode(cnetz);
@ -860,7 +861,7 @@ void unshrink_speech(cnetz_t *cnetz, sample_t *speech_buffer, int count)
void cnetz_set_dsp_mode(cnetz_t *cnetz, enum dsp_mode mode)
{
if (mode != cnetz->dsp_mode) {
PDEBUG_CHAN(DDSP, DEBUG_INFO, "DSP mode %s -> %s\n", cnetz_dsp_mode_name(cnetz->dsp_mode), cnetz_dsp_mode_name(mode));
LOGP_CHAN(DDSP, LOGL_INFO, "DSP mode %s -> %s\n", cnetz_dsp_mode_name(cnetz->dsp_mode), cnetz_dsp_mode_name(mode));
cnetz->dsp_mode = mode;
}
/* we must get rid of partly received frame */
@ -870,10 +871,10 @@ void cnetz_set_dsp_mode(cnetz_t *cnetz, enum dsp_mode mode)
void cnetz_set_sched_dsp_mode(cnetz_t *cnetz, enum dsp_mode mode, int timeslot)
{
if (cnetz->sched_dsp_mode_ts < 0 && mode == cnetz->dsp_mode) {
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Schedule DSP mode %s not required, we are already in that mode\n", cnetz_dsp_mode_name(mode));
LOGP_CHAN(DDSP, LOGL_INFO, "Schedule DSP mode %s not required, we are already in that mode\n", cnetz_dsp_mode_name(mode));
return;
}
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Schedule DSP mode %s -> %s at timeslot %d\n", cnetz_dsp_mode_name(cnetz->dsp_mode), cnetz_dsp_mode_name(mode), timeslot);
LOGP_CHAN(DDSP, LOGL_INFO, "Schedule DSP mode %s -> %s at timeslot %d\n", cnetz_dsp_mode_name(cnetz->dsp_mode), cnetz_dsp_mode_name(mode), timeslot);
cnetz->sched_dsp_mode = mode;
cnetz->sched_dsp_mode_ts = timeslot;
}

View File

@ -132,7 +132,7 @@ static int debug = 0;
#include <string.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "cnetz.h"
#include "dsp.h"
#include "telegramm.h"
@ -143,7 +143,7 @@ int fsk_fm_init(fsk_fm_demod_t *fsk, cnetz_t *cnetz, int samplerate, double bitr
memset(fsk, 0, sizeof(*fsk));
if (samplerate < 48000) {
PDEBUG(DDSP, DEBUG_ERROR, "Sample rate must be at least 48000 Hz!\n");
LOGP(DDSP, LOGL_ERROR, "Sample rate must be at least 48000 Hz!\n");
return -1;
}
@ -152,13 +152,13 @@ int fsk_fm_init(fsk_fm_demod_t *fsk, cnetz_t *cnetz, int samplerate, double bitr
switch (demod) {
case FSK_DEMOD_SLOPE:
PDEBUG(DDSP, DEBUG_INFO, "Detecting level change by looking at slope (good for sound cards)\n");
LOGP(DDSP, LOGL_INFO, "Detecting level change by looking at slope (good for sound cards)\n");
break;
case FSK_DEMOD_LEVEL:
PDEBUG(DDSP, DEBUG_INFO, "Detecting level change by looking zero crosssing (good for SDR)\n");
LOGP(DDSP, LOGL_INFO, "Detecting level change by looking zero crosssing (good for SDR)\n");
break;
default:
PDEBUG(DDSP, DEBUG_ERROR, "Wrong demod type, please fix!\n");
LOGP(DDSP, LOGL_ERROR, "Wrong demod type, please fix!\n");
abort();
}
@ -166,7 +166,7 @@ int fsk_fm_init(fsk_fm_demod_t *fsk, cnetz_t *cnetz, int samplerate, double bitr
half = (int)((double)samplerate / bitrate / 2.0 + 0.5);
fsk->bit_buffer_spl = calloc(sizeof(fsk->bit_buffer_spl[0]), len);
if (!fsk->bit_buffer_spl) {
PDEBUG(DDSP, DEBUG_ERROR, "No mem!\n");
LOGP(DDSP, LOGL_ERROR, "No mem!\n");
goto error;
}
@ -177,7 +177,7 @@ int fsk_fm_init(fsk_fm_demod_t *fsk, cnetz_t *cnetz, int samplerate, double bitr
fsk->speech_size = samplerate * 60 / bitrate + 10; /* 60 bits duration, add 10 to be safe */
fsk->speech_buffer = calloc(sizeof(fsk->speech_buffer[0]), fsk->speech_size);
if (!fsk->speech_buffer) {
PDEBUG(DDSP, DEBUG_ERROR, "No mem!\n");
LOGP(DDSP, LOGL_ERROR, "No mem!\n");
goto error;
}

View File

@ -24,7 +24,7 @@
#include <errno.h>
#include "../libsample/sample.h"
#include "../libmobile/main_mobile.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../anetz/freiton.h"
#include "../anetz/besetztton.h"
@ -700,6 +700,7 @@ fail:
cnetz_destroy(sender_head);
/* exits */
main_mobile_exit();
fm_exit();
options_free();

View File

@ -27,7 +27,7 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "cnetz.h"
#include "dsp.h"
#include "sysinfo.h"
@ -510,13 +510,13 @@ static int encode_dialstring(uint64_t *value, const char *number)
max = strlen(number);
if (max > 16) {
PDEBUG(DFRAME, DEBUG_NOTICE, "Given number '%s' has more than 16 digits\n", number);
LOGP(DFRAME, LOGL_NOTICE, "Given number '%s' has more than 16 digits\n", number);
return -EINVAL;
}
if (max == 16) {
if (number[0] != '0') {
PDEBUG(DFRAME, DEBUG_NOTICE, "Given 16 digit number '%s' does not start with '0'\n", number);
LOGP(DFRAME, LOGL_NOTICE, "Given 16 digit number '%s' does not start with '0'\n", number);
return -EINVAL;
}
*value = 0;
@ -575,7 +575,7 @@ int match_fuz(telegramm_t *telegramm)
if (telegramm->fuz_nationalitaet != si.fuz_nat
|| telegramm->fuz_fuvst_nr != si.fuz_fuvst
|| telegramm->fuz_rest_nr != si.fuz_rest) {
PDEBUG(DFRAME, DEBUG_NOTICE, "Ignoring message from mobile phone %d,%d,%d: Cell 'Funkzelle' does not match!\n", telegramm->futln_nationalitaet, telegramm->futln_heimat_fuvst_nr, telegramm->futln_rest_nr);
LOGP(DFRAME, LOGL_NOTICE, "Ignoring message from mobile phone %d,%d,%d: Cell 'Funkzelle' does not match!\n", telegramm->futln_nationalitaet, telegramm->futln_heimat_fuvst_nr, telegramm->futln_rest_nr);
return 0;
}
@ -587,7 +587,7 @@ int match_futln(telegramm_t *telegramm, uint8_t futln_nat, uint8_t futln_fuvst,
if (telegramm->futln_nationalitaet != futln_nat
|| telegramm->futln_heimat_fuvst_nr != futln_fuvst
|| telegramm->futln_rest_nr != futln_rest) {
PDEBUG(DFRAME, DEBUG_NOTICE, "Ignoring message from mobile phone %d,%d,%d: Mobile station 'Funktelefongeraet' does not match!\n", telegramm->futln_nationalitaet, telegramm->futln_heimat_fuvst_nr, telegramm->futln_rest_nr);
LOGP(DFRAME, LOGL_NOTICE, "Ignoring message from mobile phone %d,%d,%d: Mobile station 'Funktelefongeraet' does not match!\n", telegramm->futln_nationalitaet, telegramm->futln_heimat_fuvst_nr, telegramm->futln_rest_nr);
return 0;
}
@ -600,19 +600,19 @@ static void debug_parameter(char digit, uint64_t value)
parameter = get_parameter(digit);
if (!parameter) {
PDEBUG(DFRAME, DEBUG_ERROR, "Digit '%c' not found in definition_parameter list, please fix!\n", digit);
LOGP(DFRAME, LOGL_ERROR, "Digit '%c' not found in definition_parameter list, please fix!\n", digit);
abort();
}
if (parameter->value_names)
PDEBUG(DFRAME, DEBUG_DEBUG, " (%c) %s : %s\n", digit, parameter->param_name, parameter->value_names[value]);
LOGP(DFRAME, LOGL_DEBUG, " (%c) %s : %s\n", digit, parameter->param_name, parameter->value_names[value]);
else if (parameter->bits == 64)
PDEBUG(DFRAME, DEBUG_DEBUG, " (%c) %s : 0x%016" PRIx64 "\n", digit, parameter->param_name, value);
LOGP(DFRAME, LOGL_DEBUG, " (%c) %s : 0x%016" PRIx64 "\n", digit, parameter->param_name, value);
else if (digit == 'X') {
char wahlziffern[17];
decode_dialstring(wahlziffern, value);
PDEBUG(DFRAME, DEBUG_DEBUG, " (%c) %s : '%s'\n", digit, parameter->param_name, wahlziffern);
LOGP(DFRAME, LOGL_DEBUG, " (%c) %s : '%s'\n", digit, parameter->param_name, wahlziffern);
} else
PDEBUG(DFRAME, DEBUG_DEBUG, " (%c) %s : %" PRIu64 "\n", digit, parameter->param_name, value);
LOGP(DFRAME, LOGL_DEBUG, " (%c) %s : %" PRIu64 "\n", digit, parameter->param_name, value);
}
/* encode telegram to 70 bits
@ -628,12 +628,12 @@ static char *assemble_telegramm(const telegramm_t *telegramm, int debug)
int rc;
if (telegramm->opcode >= 64) {
PDEBUG(DFRAME, DEBUG_ERROR, "Opcode '0x%x' exceeds bit range, please fix!\n", telegramm->opcode);
LOGP(DFRAME, LOGL_ERROR, "Opcode '0x%x' exceeds bit range, please fix!\n", telegramm->opcode);
abort();
}
if (debug)
PDEBUG(DFRAME, DEBUG_INFO, "Coding %s %s\n", definition_opcode[telegramm->opcode].message_name, definition_opcode[telegramm->opcode].message_text);
LOGP(DFRAME, LOGL_INFO, "Coding %s %s\n", definition_opcode[telegramm->opcode].message_name, definition_opcode[telegramm->opcode].message_text);
/* copy opcode */
for (i = 0; i < 6; i++)
@ -717,7 +717,7 @@ static char *assemble_telegramm(const telegramm_t *telegramm, int debug)
case 'X':
rc = encode_dialstring(&value, telegramm->wahlziffern);
if (rc < 0) {
PDEBUG(DFRAME, DEBUG_ERROR, "Illegal dial string '%s', please fix!\n", telegramm->wahlziffern);
LOGP(DFRAME, LOGL_ERROR, "Illegal dial string '%s', please fix!\n", telegramm->wahlziffern);
abort();
}
break;
@ -806,10 +806,10 @@ static char *assemble_telegramm(const telegramm_t *telegramm, int debug)
value = telegramm->illegaler_opcode;
break;
default:
PDEBUG(DFRAME, DEBUG_ERROR, "Parameter '%c' does not exist, please fix!\n", parameter);
LOGP(DFRAME, LOGL_ERROR, "Parameter '%c' does not exist, please fix!\n", parameter);
abort();
}
if (debug && debuglevel <= DEBUG_DEBUG)
if (debug && loglevel <= LOGL_DEBUG)
debug_parameter(parameter, value);
val = value;
for (j = 0; string[63 - i - j] == parameter; j++) {
@ -817,14 +817,14 @@ static char *assemble_telegramm(const telegramm_t *telegramm, int debug)
val >>= 1;
}
if (val)
PDEBUG(DFRAME, DEBUG_ERROR, "Parameter '%c' value '0x%" PRIx64 "' exceeds bit range!\n", parameter, value);
LOGP(DFRAME, LOGL_ERROR, "Parameter '%c' value '0x%" PRIx64 "' exceeds bit range!\n", parameter, value);
i += j - 1;
}
bits[70] = '\0';
if (debug) {
PDEBUG(DFRAME, DEBUG_DEBUG, "OOOOOO%s\n", string);
PDEBUG(DFRAME, DEBUG_DEBUG, "%s\n", bits);
LOGP(DFRAME, LOGL_DEBUG, "OOOOOO%s\n", string);
LOGP(DFRAME, LOGL_DEBUG, "%s\n", bits);
}
return bits;
@ -848,7 +848,7 @@ static void disassemble_telegramm(telegramm_t *telegramm, const char *bits, int
value = (value << 1) | (bits[i] == '1');
telegramm->opcode = value;
PDEBUG(DFRAME, DEBUG_INFO, "Decoding %s %s\n", definition_opcode[telegramm->opcode].message_name, definition_opcode[telegramm->opcode].message_text);
LOGP(DFRAME, LOGL_INFO, "Decoding %s %s\n", definition_opcode[telegramm->opcode].message_name, definition_opcode[telegramm->opcode].message_text);
/* copy parameters */
if (auth && bits[1]) /* auth flag and chip card flag */
@ -864,7 +864,7 @@ static void disassemble_telegramm(telegramm_t *telegramm, const char *bits, int
value = (value >> 1) | ((uint64_t)(bits[69 - i - j] == '1') << 63);
value >>= 64 - j;
i += j - 1;
if (debuglevel <= DEBUG_DEBUG)
if (loglevel <= LOGL_DEBUG)
debug_parameter(parameter, value);
switch (parameter) {
case 'A':
@ -1021,18 +1021,18 @@ static void disassemble_telegramm(telegramm_t *telegramm, const char *bits, int
telegramm->illegaler_opcode = value;
break;
default:
PDEBUG(DFRAME, DEBUG_ERROR, "Parameter '%c' does not exist, please fix!\n", parameter);
LOGP(DFRAME, LOGL_ERROR, "Parameter '%c' does not exist, please fix!\n", parameter);
abort();
}
}
if (debuglevel <= DEBUG_DEBUG) {
if (loglevel <= LOGL_DEBUG) {
char debug_bits[71];
memcpy(debug_bits, bits, 70);
debug_bits[70] = '\0';
PDEBUG(DFRAME, DEBUG_DEBUG, "OOOOOO%s\n", string);
PDEBUG(DFRAME, DEBUG_DEBUG, "%s\n", debug_bits);
LOGP(DFRAME, LOGL_DEBUG, "OOOOOO%s\n", string);
LOGP(DFRAME, LOGL_DEBUG, "%s\n", debug_bits);
}
}
@ -1392,11 +1392,11 @@ static const char *decode(const char *input, int *_bit_errors)
fail_str[10] = '\0';
if (failed)
PDEBUG(DFRAME, DEBUG_DEBUG, "Received Telegram with these block errors: '%s' (X = uncorrectable)\n", fail_str);
LOGP(DFRAME, LOGL_DEBUG, "Received Telegram with these block errors: '%s' (X = uncorrectable)\n", fail_str);
else if (warn)
PDEBUG(DFRAME, DEBUG_DEBUG, "Received Telegram with these block errors: '%s' (1 / 2 = correctable)\n", fail_str);
LOGP(DFRAME, LOGL_DEBUG, "Received Telegram with these block errors: '%s' (1 / 2 = correctable)\n", fail_str);
else
PDEBUG(DFRAME, DEBUG_DEBUG, "Received Telegram with no block errors.\n");
LOGP(DFRAME, LOGL_DEBUG, "Received Telegram with no block errors.\n");
if (failed)
return NULL;
@ -1496,13 +1496,13 @@ void cnetz_decode_telegramm(cnetz_t *cnetz, const char *bits, double level, doub
break;
}
if (i == 70) {
PDEBUG(DFRAME, DEBUG_INFO, "Ignoring mysterious unmodulated telegramm (noise from phone's transmitter)\n");
LOGP(DFRAME, LOGL_INFO, "Ignoring mysterious unmodulated telegramm (noise from phone's transmitter)\n");
return;
}
PDEBUG_CHAN(DDSP, DEBUG_INFO, "RF level: %.1f dB RX Level: %.0f%% Standard deviation: %.0f%% Sync Time: %.2f (TS %.2f) %s\n", cnetz->rf_level_db, fabs(level) / cnetz->fsk_deviation * 100.0, stddev / fabs(level) * 100.0, sync_time, sync_time / 396.0, (level < 0) ? "NEGATIVE (phone's mode)" : "POSITIVE (base station's mode)");
LOGP_CHAN(DDSP, LOGL_INFO, "RF level: %.1f dB RX Level: %.0f%% Standard deviation: %.0f%% Sync Time: %.2f (TS %.2f) %s\n", cnetz->rf_level_db, fabs(level) / cnetz->fsk_deviation * 100.0, stddev / fabs(level) * 100.0, sync_time, sync_time / 396.0, (level < 0) ? "NEGATIVE (phone's mode)" : "POSITIVE (base station's mode)");
if (bit_errors)
PDEBUG_CHAN(DDSP, DEBUG_INFO, " -> Frame has %d bit errors.\n", bit_errors);
LOGP_CHAN(DDSP, LOGL_INFO, " -> Frame has %d bit errors.\n", bit_errors);
disassemble_telegramm(&telegramm, bits, si.authentifikationsbit);
opcode = telegramm.opcode;
@ -1510,18 +1510,18 @@ void cnetz_decode_telegramm(cnetz_t *cnetz, const char *bits, double level, doub
telegramm.sync_time = sync_time;
if (cnetz->sender.loopback) {
PDEBUG(DFRAME, DEBUG_NOTICE, "Received Telegramm in loopback test mode (opcode %d = %s)\n", opcode, definition_opcode[opcode].message_name);
LOGP(DFRAME, LOGL_NOTICE, "Received Telegramm in loopback test mode (opcode %d = %s)\n", opcode, definition_opcode[opcode].message_name);
cnetz_sync_frame(cnetz, sync_time, -1);
return;
}
if (opcode >= 32) {
PDEBUG(DFRAME, DEBUG_NOTICE, "Received Telegramm that is not used by mobile station, ignoring! (opcode %d = %s)\n", opcode, definition_opcode[opcode].message_name);
LOGP(DFRAME, LOGL_NOTICE, "Received Telegramm that is not used by mobile station, ignoring! (opcode %d = %s)\n", opcode, definition_opcode[opcode].message_name);
return;
}
if (definition_opcode[opcode].block == BLOCK_I) {
PDEBUG(DFRAME, DEBUG_NOTICE, "Received Telegramm that is an illegal opcode, ignoring! (opcode %d = %s)\n", opcode, definition_opcode[opcode].message_name);
LOGP(DFRAME, LOGL_NOTICE, "Received Telegramm that is an illegal opcode, ignoring! (opcode %d = %s)\n", opcode, definition_opcode[opcode].message_name);
return;
}
@ -1544,7 +1544,7 @@ void cnetz_decode_telegramm(cnetz_t *cnetz, const char *bits, double level, doub
switch (cnetz->dsp_mode) {
case DSP_MODE_OGK:
if (definition_opcode[opcode].block != BLOCK_R && definition_opcode[opcode].block != BLOCK_M) {
PDEBUG(DFRAME, DEBUG_NOTICE, "Received Telegramm that is not used OgK channel signaling, ignoring! (opcode %d = %s)\n", opcode, definition_opcode[opcode].message_name);
LOGP(DFRAME, LOGL_NOTICE, "Received Telegramm that is not used OgK channel signaling, ignoring! (opcode %d = %s)\n", opcode, definition_opcode[opcode].message_name);
return;
}
/* determine block by last timeslot sent and by message type
@ -1557,14 +1557,14 @@ void cnetz_decode_telegramm(cnetz_t *cnetz, const char *bits, double level, doub
break;
case DSP_MODE_SPK_K:
if (definition_opcode[opcode].block != BLOCK_K) {
PDEBUG(DFRAME, DEBUG_NOTICE, "Received Telegramm that is not used for concentrated signaling, ignoring! (opcode %d = %s)\n", opcode, definition_opcode[opcode].message_name);
LOGP(DFRAME, LOGL_NOTICE, "Received Telegramm that is not used for concentrated signaling, ignoring! (opcode %d = %s)\n", opcode, definition_opcode[opcode].message_name);
return;
}
cnetz_receive_telegramm_spk_k(cnetz, &telegramm);
break;
case DSP_MODE_SPK_V:
if (definition_opcode[opcode].block != BLOCK_V) {
PDEBUG(DFRAME, DEBUG_NOTICE, "Received Telegramm that is not used for distributed signaling, ignoring! (opcode %d = %s)\n", opcode, definition_opcode[opcode].message_name);
LOGP(DFRAME, LOGL_NOTICE, "Received Telegramm that is not used for distributed signaling, ignoring! (opcode %d = %s)\n", opcode, definition_opcode[opcode].message_name);
return;
}
cnetz_receive_telegramm_spk_v(cnetz, &telegramm);
@ -1622,7 +1622,7 @@ const char *cnetz_encode_telegramm(cnetz_t *cnetz)
cnetz->sched_lr_debugged = 1;
if (opcode == OPCODE_MLR_M && !cnetz->sched_mlr_debugged) {
cnetz->sched_mlr_debugged = 1;
PDEBUG(DFRAME, DEBUG_INFO, "Subsequent IDLE frames are not show, to prevent flooding the output.\n");
LOGP(DFRAME, LOGL_INFO, "Subsequent IDLE frames are not show, to prevent flooding the output.\n");
}
return bits;

View File

@ -22,7 +22,7 @@
#include <stdlib.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "cnetz.h"
@ -54,7 +54,7 @@ transaction_t *create_transaction(cnetz_t *cnetz, uint64_t state, uint8_t futln_
if ((trans->state & state & (TRANS_EM | TRANS_UM | TRANS_VWG | TRANS_ATQ_IDLE))) {
if (!isnan(trans->rf_level_db) && !isnan(rf_level_db) && trans->cnetz->kanal != cnetz->kanal) {
if (rf_level_db > trans->rf_level_db) {
PDEBUG(DTRANS, DEBUG_NOTICE, "Found already pending transaction for subscriber '%s' on channel #%d, but this message on channel #%d is stronger, so we move to that channel!\n", rufnummer, trans->cnetz->kanal, cnetz->kanal);
LOGP(DTRANS, LOGL_NOTICE, "Found already pending transaction for subscriber '%s' on channel #%d, but this message on channel #%d is stronger, so we move to that channel!\n", rufnummer, trans->cnetz->kanal, cnetz->kanal);
trans->rf_level_db = rf_level_db;
unlink_transaction(trans);
link_transaction(trans, cnetz);
@ -62,14 +62,14 @@ transaction_t *create_transaction(cnetz_t *cnetz, uint64_t state, uint8_t futln_
return trans;
}
if (rf_level_db < trans->rf_level_db) {
PDEBUG(DTRANS, DEBUG_NOTICE, "Found already pending transaction for subscriber '%s' on channel #%d, but this message on channel #%d is weaker, so we ignore that channel!\n", rufnummer, trans->cnetz->kanal, cnetz->kanal);
LOGP(DTRANS, LOGL_NOTICE, "Found already pending transaction for subscriber '%s' on channel #%d, but this message on channel #%d is weaker, so we ignore that channel!\n", rufnummer, trans->cnetz->kanal, cnetz->kanal);
return trans;
}
}
PDEBUG(DTRANS, DEBUG_NOTICE, "Found already pending transaction for subscriber '%s' on channel #%d, but this message on channel #%d is also received. Try to avoid multiple OgK channels!\n", rufnummer, trans->cnetz->kanal, cnetz->kanal);
LOGP(DTRANS, LOGL_NOTICE, "Found already pending transaction for subscriber '%s' on channel #%d, but this message on channel #%d is also received. Try to avoid multiple OgK channels!\n", rufnummer, trans->cnetz->kanal, cnetz->kanal);
return trans;
}
PDEBUG(DTRANS, DEBUG_NOTICE, "Found already pending transaction for subscriber '%s', deleting!\n", rufnummer);
LOGP(DTRANS, LOGL_NOTICE, "Found already pending transaction for subscriber '%s', deleting!\n", rufnummer);
destroy_transaction(trans);
if (old_cnetz) /* should be... */
cnetz_go_idle(old_cnetz);
@ -79,11 +79,11 @@ transaction_t *create_transaction(cnetz_t *cnetz, uint64_t state, uint8_t futln_
trans = calloc(1, sizeof(*trans));
if (!trans) {
PDEBUG(DTRANS, DEBUG_ERROR, "No memory!\n");
LOGP(DTRANS, LOGL_ERROR, "No memory!\n");
return NULL;
}
timer_init(&trans->timer, transaction_timeout, trans);
osmo_timer_setup(&trans->timer, transaction_timeout, trans);
trans_new_state(trans, state);
trans->futln_nat = futln_nat;
@ -96,7 +96,7 @@ transaction_t *create_transaction(cnetz_t *cnetz, uint64_t state, uint8_t futln_
trans->mt_call = 1;
const char *rufnummer = transaction2rufnummer(trans);
PDEBUG(DTRANS, DEBUG_INFO, "Created transaction for subscriber '%s'\n", rufnummer);
LOGP(DTRANS, LOGL_INFO, "Created transaction for subscriber '%s'\n", rufnummer);
link_transaction(trans, cnetz);
@ -119,9 +119,9 @@ void destroy_transaction(transaction_t *trans)
unlink_transaction(trans);
const char *rufnummer = transaction2rufnummer(trans);
PDEBUG(DTRANS, DEBUG_INFO, "Destroying transaction for subscriber '%s'\n", rufnummer);
LOGP(DTRANS, LOGL_INFO, "Destroying transaction for subscriber '%s'\n", rufnummer);
timer_exit(&trans->timer);
osmo_timer_del(&trans->timer);
trans_new_state(trans, 0);
@ -134,7 +134,7 @@ void link_transaction(transaction_t *trans, cnetz_t *cnetz)
transaction_t **transp;
/* attach to end of list, so first transaction is served first */
PDEBUG(DTRANS, DEBUG_DEBUG, "Linking transaction %p to cnetz %p\n", trans, cnetz);
LOGP(DTRANS, LOGL_DEBUG, "Linking transaction %p to cnetz %p\n", trans, cnetz);
trans->cnetz = cnetz;
trans->next = NULL;
transp = &cnetz->trans_list;
@ -150,12 +150,12 @@ void unlink_transaction(transaction_t *trans)
transaction_t **transp;
/* unlink */
PDEBUG(DTRANS, DEBUG_DEBUG, "Unlinking transaction %p from cnetz %p\n", trans, trans->cnetz);
LOGP(DTRANS, LOGL_DEBUG, "Unlinking transaction %p from cnetz %p\n", trans, trans->cnetz);
transp = &trans->cnetz->trans_list;
while (*transp && *transp != trans)
transp = &((*transp)->next);
if (!(*transp)) {
PDEBUG(DTRANS, DEBUG_ERROR, "Transaction not in list, please fix!!\n");
LOGP(DTRANS, LOGL_ERROR, "Transaction not in list, please fix!!\n");
abort();
}
*transp = trans->next;
@ -170,7 +170,7 @@ transaction_t *search_transaction(cnetz_t *cnetz, uint64_t state_mask)
while (trans) {
if ((trans->state & state_mask)) {
const char *rufnummer = transaction2rufnummer(trans);
PDEBUG(DTRANS, DEBUG_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer);
LOGP(DTRANS, LOGL_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer);
return trans;
}
trans = trans->next;
@ -188,7 +188,7 @@ transaction_t *search_transaction_number(cnetz_t *cnetz, uint8_t futln_nat, uint
&& trans->futln_fuvst == futln_fuvst
&& trans->futln_rest == futln_rest) {
const char *rufnummer = transaction2rufnummer(trans);
PDEBUG(DTRANS, DEBUG_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer);
LOGP(DTRANS, LOGL_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer);
return trans;
}
trans = trans->next;
@ -224,7 +224,7 @@ transaction_t *search_transaction_callref(cnetz_t *cnetz, int callref)
while (trans) {
if (trans->callref == callref) {
const char *rufnummer = transaction2rufnummer(trans);
PDEBUG(DTRANS, DEBUG_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer);
LOGP(DTRANS, LOGL_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer);
return trans;
}
trans = trans->next;
@ -262,7 +262,7 @@ transaction_t *search_transaction_queue(void)
if (found) {
const char *rufnummer = transaction2rufnummer(found);
PDEBUG(DTRANS, DEBUG_DEBUG, "Found oldest transaction in queue for subscriber '%s'\n", rufnummer);
LOGP(DTRANS, LOGL_DEBUG, "Found oldest transaction in queue for subscriber '%s'\n", rufnummer);
return found;
}
@ -386,7 +386,7 @@ const char *trans_short_state_name(uint64_t state)
void trans_new_state(transaction_t *trans, uint64_t state)
{
PDEBUG(DTRANS, DEBUG_INFO, "Transaction (%s) state %s -> %s\n", transaction2rufnummer(trans), trans_state_name(trans->state), trans_state_name(state));
LOGP(DTRANS, LOGL_INFO, "Transaction (%s) state %s -> %s\n", transaction2rufnummer(trans), trans_state_name(trans->state), trans_state_name(state));
trans->state = state;
/* in case of a queue, set new positon */
if (!trans->queue_position && (state == TRANS_MO_QUEUE || state == TRANS_MT_QUEUE))
@ -398,12 +398,12 @@ void cnetz_flush_other_transactions(cnetz_t *cnetz, transaction_t *trans)
{
/* flush after this very trans */
while (trans->next) {
PDEBUG(DTRANS, DEBUG_NOTICE, "Kicking other pending transaction\n");
LOGP(DTRANS, LOGL_NOTICE, "Kicking other pending transaction\n");
destroy_transaction(trans->next);
}
/* flush before this very trans */
while (cnetz->trans_list != trans) {
PDEBUG(DTRANS, DEBUG_NOTICE, "Kicking other pending transaction\n");
LOGP(DTRANS, LOGL_NOTICE, "Kicking other pending transaction\n");
destroy_transaction(cnetz->trans_list);
}
}

View File

@ -50,7 +50,7 @@ typedef struct transaction {
int8_t release_cause; /* reason for release, (c-netz coding) */
int try; /* counts resending messages */
int repeat; /* counts repeating messages */
struct timer timer; /* for varous timeouts */
struct osmo_timer_list timer; /* for varous timeouts */
int mo_call; /* flags a moile originating call */
int mt_call; /* flags a moile terminating call */
int page_failed; /* failed to get a response from MS */

View File

@ -12,15 +12,15 @@ datenklo_SOURCES = \
datenklo_LDADD = \
$(COMMON_LA) \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libfsk/libfsk.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libfm/libfm.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/liblogging/liblogging.a \
$(LIBOSMOCORE_LIBS) \
$(ALSA_LIBS) \
$(FUSE_LIBS) \
-lm

View File

@ -75,12 +75,14 @@
#include <string.h>
#include <errno.h>
#include <math.h>
#include "../libdebug/debug.h"
#include "../libtimer/timer.h"
#include "../liblogging/logging.h"
#include <osmocom/core/timer.h>
#include "../libsample/sample.h"
#include "../libfsk/fsk.h"
#include "am791x.h"
#define FLOAT_TO_TIMEOUT(f) floor(f), ((f) - floor(f)) * 1000000
#define db2level(db) pow(10, (double)(db) / 20.0)
#define level2db(level) (20 * log10(level))
@ -373,19 +375,19 @@ static int fsk_send_bit(void *inst)
/* main channel returns TD */
if (!am791x->block_td) {
#ifdef HEAVY_DEBUG
PDEBUG(DDSP, DEBUG_DEBUG, "Modulating bit '%d' for MAIN channel\n", bit);
LOGP(DDSP, LOGL_DEBUG, "Modulating bit '%d' for MAIN channel\n", bit);
#endif
return bit;
}
/* back channel returns BTD */
if (!am791x->block_btd) {
#ifdef HEAVY_DEBUG
PDEBUG(DDSP, DEBUG_DEBUG, "Modulating bit '%d' for BACK channel\n", bbit);
LOGP(DDSP, LOGL_DEBUG, "Modulating bit '%d' for BACK channel\n", bbit);
#endif
return bbit;
}
#ifdef HEAVY_DEBUG
PDEBUG(DDSP, DEBUG_DEBUG, "Modulating bit '1', because TD & BTD is ignored\n");
LOGP(DDSP, LOGL_DEBUG, "Modulating bit '1', because TD & BTD is ignored\n");
#endif
return 1;
}
@ -399,7 +401,7 @@ static void fsk_receive_bit(void *inst, int bit, double quality, double level)
int *block, *cd;
#ifdef HEAVY_DEBUG
PDEBUG(DDSP, DEBUG_DEBUG, "Demodulated bit '%d' (level = %.0f dBm, quality = %%%.0f)\n", bit, level2db(level), quality * 100.0);
LOGP(DDSP, LOGL_DEBUG, "Demodulated bit '%d' (level = %.0f dBm, quality = %%%.0f)\n", bit, level2db(level), quality * 100.0);
#endif
if (!am791x->rx_back_channel) {
@ -416,12 +418,12 @@ static void fsk_receive_bit(void *inst, int bit, double quality, double level)
handle_rx_state(am791x);
} else
if (!(*block) && !(*cd) && level > am791x->cd_on && quality >= RX_QUALITY) {
PDEBUG(DDSP, DEBUG_DEBUG, "Good quality (level = %.0f dBm, quality = %%%.0f)\n", level2db(level), quality * 100.0);
LOGP(DDSP, LOGL_DEBUG, "Good quality (level = %.0f dBm, quality = %%%.0f)\n", level2db(level), quality * 100.0);
*cd = 1;
handle_rx_state(am791x);
} else
if (*cd && (level < am791x->cd_off || quality < RX_QUALITY)) {
PDEBUG(DDSP, DEBUG_DEBUG, "Bad quality (level = %.0f dBm, quality = %%%.0f)\n", level2db(level), quality * 100.0);
LOGP(DDSP, LOGL_DEBUG, "Bad quality (level = %.0f dBm, quality = %%%.0f)\n", level2db(level), quality * 100.0);
*cd = 0;
handle_rx_state(am791x);
}
@ -437,24 +439,24 @@ static void fsk_receive_bit(void *inst, int bit, double quality, double level)
/* main channel forwards bit to RD */
if (!am791x->block_rd) {
#ifdef HEAVY_DEBUG
PDEBUG(DDSP, DEBUG_DEBUG, " -> Forwarding bit '%d' to MAIN channel\n", bit);
LOGP(DDSP, LOGL_DEBUG, " -> Forwarding bit '%d' to MAIN channel\n", bit);
#endif
am791x->rd_cb(am791x->inst, bit, quality * 100.0, level2db(level));
} else {
#ifdef HEAVY_DEBUG
PDEBUG(DDSP, DEBUG_DEBUG, " -> Forwarding bit '1' to MAIN channel, because RD is set to MARK\n");
LOGP(DDSP, LOGL_DEBUG, " -> Forwarding bit '1' to MAIN channel, because RD is set to MARK\n");
#endif
am791x->rd_cb(am791x->inst, 1, NAN, NAN);
}
/* main channel forwards bit to RD */
if (!am791x->block_brd) {
#ifdef HEAVY_DEBUG
PDEBUG(DDSP, DEBUG_DEBUG, " -> Forwarding bit '%d' to BACK channel\n", bit);
LOGP(DDSP, LOGL_DEBUG, " -> Forwarding bit '%d' to BACK channel\n", bit);
#endif
am791x->brd_cb(am791x->inst, bit, quality * 100.0, level2db(level));
} else {
#ifdef HEAVY_DEBUG
PDEBUG(DDSP, DEBUG_DEBUG, " -> Forwarding bit '1' to BACK channel, because BRD is set to MARK\n");
LOGP(DDSP, LOGL_DEBUG, " -> Forwarding bit '1' to BACK channel, because BRD is set to MARK\n");
#endif
am791x->brd_cb(am791x->inst, 1, NAN, NAN);
}
@ -529,9 +531,9 @@ static void set_filters(am791x_t *am791x)
/* transmitter used */
if (f0_tx > 0 && am791x->f0_tx == 0) {
PDEBUG(DDSP, DEBUG_DEBUG, "Setting modulator to %s channel's frequencies (F0 = %d, F1 = %d), baudrate %.0f\n", name_tx, f0_tx, f1_tx, am791x->tx_baud);
LOGP(DDSP, LOGL_DEBUG, "Setting modulator to %s channel's frequencies (F0 = %d, F1 = %d), baudrate %.0f\n", name_tx, f0_tx, f1_tx, am791x->tx_baud);
if (fsk_mod_init(&am791x->fsk_tx, am791x, fsk_send_bit, am791x->samplerate, am791x->tx_baud, (double)f0_tx, (double)f1_tx, am791x->tx_level, 0, 1) < 0)
PDEBUG(DDSP, DEBUG_ERROR, "FSK RX init failed!\n");
LOGP(DDSP, LOGL_ERROR, "FSK RX init failed!\n");
else {
am791x->f0_tx = f0_tx;
am791x->f1_tx = f1_tx;
@ -548,9 +550,9 @@ static void set_filters(am791x_t *am791x)
/* receiver used */
if (f0_rx > 0 && am791x->f0_rx == 0) {
PDEBUG(DDSP, DEBUG_DEBUG, "Setting demodulator to %s channel's frequencies (F0 = %d, F1 = %d), baudrate %.0f\n", name_rx, f0_rx, f1_rx, am791x->rx_baud);
LOGP(DDSP, LOGL_DEBUG, "Setting demodulator to %s channel's frequencies (F0 = %d, F1 = %d), baudrate %.0f\n", name_rx, f0_rx, f1_rx, am791x->rx_baud);
if (fsk_demod_init(&am791x->fsk_rx, am791x, fsk_receive_bit, am791x->samplerate, am791x->rx_baud, (double)f0_rx, (double)f1_rx, BIT_ADJUST) < 0)
PDEBUG(DDSP, DEBUG_ERROR, "FSK RX init failed!\n");
LOGP(DDSP, LOGL_ERROR, "FSK RX init failed!\n");
else {
am791x->f0_rx = f0_rx;
am791x->f1_rx = f1_rx;
@ -562,14 +564,14 @@ static void set_filters(am791x_t *am791x)
static void new_tx_state(am791x_t *am791x, enum am791x_st state)
{
if (am791x->tx_state != state)
PDEBUG(DAM791X, DEBUG_DEBUG, "Change TX state %s -> %s\n", am791x_state_names[am791x->tx_state], am791x_state_names[state]);
LOGP(DAM791X, LOGL_DEBUG, "Change TX state %s -> %s\n", am791x_state_names[am791x->tx_state], am791x_state_names[state]);
am791x->tx_state = state;
}
static void new_rx_state(am791x_t *am791x, enum am791x_st state)
{
if (am791x->rx_state != state)
PDEBUG(DAM791X, DEBUG_DEBUG, "Change RX state %s -> %s\n", am791x_state_names[am791x->rx_state], am791x_state_names[state]);
LOGP(DAM791X, LOGL_DEBUG, "Change RX state %s -> %s\n", am791x_state_names[am791x->rx_state], am791x_state_names[state]);
am791x->rx_state = state;
}
@ -577,7 +579,7 @@ static void new_rx_state(am791x_t *am791x, enum am791x_st state)
static void set_flag(int *flag_p, int value, const char *name)
{
if (*flag_p != value) {
PDEBUG(DAM791X, DEBUG_DEBUG, " -> %s\n", name);
LOGP(DAM791X, LOGL_DEBUG, " -> %s\n", name);
*flag_p = value;
}
}
@ -588,7 +590,7 @@ static void set_flag(int *flag_p, int value, const char *name)
static void go_main_channel_tx(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Enable transmitter on main channel\n");
LOGP(DAM791X, LOGL_DEBUG, "Enable transmitter on main channel\n");
/* only block RD, if not full duplex and not 4-wire (loopback mode) */
if (!am791x->fullduplex && !am791x->loopback_main) {
@ -599,7 +601,7 @@ static void go_main_channel_tx(am791x_t *am791x)
/* activate TD now and set CTS timer (RCON) */
set_flag(&am791x->block_td, 0, "TD RELEASED");
set_flag(&am791x->tx_silence, 0, "RESET SILENCE");
timer_start(&am791x->tx_timer, am791x->t_rcon);
osmo_timer_schedule(&am791x->tx_timer, FLOAT_TO_TIMEOUT(am791x->t_rcon));
new_tx_state(am791x, AM791X_STATE_RCON);
set_filters(am791x);
/* check CD to be blocked */
@ -613,7 +615,7 @@ static void go_main_channel_tx(am791x_t *am791x)
static void rcon_release_rts(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "RTS was released\n");
LOGP(DAM791X, LOGL_DEBUG, "RTS was released\n");
set_flag(&am791x->block_td, 1, "TD IGNORED");
set_flag(&am791x->tx_silence, 1, "SET SILENCE");
@ -629,7 +631,7 @@ static void rcon_release_rts(am791x_t *am791x)
static void rcon_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Transmission started\n");
LOGP(DAM791X, LOGL_DEBUG, "Transmission started\n");
new_tx_state(am791x, AM791X_STATE_DATA);
/* CTS on */
@ -638,7 +640,7 @@ static void rcon_done(am791x_t *am791x)
static void tx_data_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "RTS was released\n");
LOGP(DAM791X, LOGL_DEBUG, "RTS was released\n");
new_tx_state(am791x, AM791X_STATE_RCOFF);
set_flag(&am791x->block_td, 1, "TD IGNORED");
@ -650,12 +652,12 @@ static void tx_data_done(am791x_t *am791x)
if (!am791x->fullduplex) {
set_flag(&am791x->squelch, 1, "SET SQUELCH (ON)");
}
timer_start(&am791x->tx_timer, am791x->t_rcoff);
osmo_timer_schedule(&am791x->tx_timer, FLOAT_TO_TIMEOUT(am791x->t_rcoff));
}
static void rcoff_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Transmission over\n");
LOGP(DAM791X, LOGL_DEBUG, "Transmission over\n");
/* CTS off */
am791x->cts_cb(am791x->inst, 0);
@ -665,17 +667,17 @@ static void rcoff_done(am791x_t *am791x)
return;
}
if (!am791x->sto) {
timer_start(&am791x->tx_timer, am791x->t_sq - am791x->t_rcoff);
osmo_timer_schedule(&am791x->tx_timer, FLOAT_TO_TIMEOUT(am791x->t_sq - am791x->t_rcoff));
new_tx_state(am791x, AM791X_STATE_SQ_OFF);
return;
}
timer_start(&am791x->tx_timer, am791x->t_sto - am791x->t_rcoff);
osmo_timer_schedule(&am791x->tx_timer, FLOAT_TO_TIMEOUT(am791x->t_sto - am791x->t_rcoff));
new_tx_state(am791x, AM791X_STATE_STO_OFF);
}
static void sq_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Squelch over\n");
LOGP(DAM791X, LOGL_DEBUG, "Squelch over\n");
set_flag(&am791x->block_cd, 0, "CD RELEASED");
new_tx_state(am791x, AM791X_STATE_INIT);
@ -690,16 +692,16 @@ static void sq_done(am791x_t *am791x)
static void sto_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "STO over\n");
LOGP(DAM791X, LOGL_DEBUG, "STO over\n");
set_flag(&am791x->tx_sto, 0, "stop STO");
timer_start(&am791x->tx_timer, am791x->t_sq - am791x->t_sto);
osmo_timer_schedule(&am791x->tx_timer, FLOAT_TO_TIMEOUT(am791x->t_sq - am791x->t_sto));
new_tx_state(am791x, AM791X_STATE_SQ_OFF);
}
static void go_back_channel_tx(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Enable transmitter on back channel\n");
LOGP(DAM791X, LOGL_DEBUG, "Enable transmitter on back channel\n");
if (!am791x->loopback_back) {
set_flag(&am791x->block_brd, 1, "BRD = MARK");
@ -709,7 +711,7 @@ static void go_back_channel_tx(am791x_t *am791x)
/* activate BTD now and set BCTS timer (BRCON) */
set_flag(&am791x->block_btd, 0, "BTD RELEASED");
set_flag(&am791x->tx_silence, 0, "RESET SILENCE");
timer_start(&am791x->tx_timer, am791x->t_brcon);
osmo_timer_schedule(&am791x->tx_timer, FLOAT_TO_TIMEOUT(am791x->t_brcon));
new_tx_state(am791x, AM791X_STATE_BRCON);
set_filters(am791x);
/* check BCD to be blocked */
@ -723,7 +725,7 @@ static void go_back_channel_tx(am791x_t *am791x)
static void brcon_release_brts(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "BRTS was released\n");
LOGP(DAM791X, LOGL_DEBUG, "BRTS was released\n");
set_flag(&am791x->tx_silence, 1, "SET SILENCE");
new_tx_state(am791x, AM791X_STATE_INIT);
@ -732,7 +734,7 @@ static void brcon_release_brts(am791x_t *am791x)
static void brcon_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Transmission started\n");
LOGP(DAM791X, LOGL_DEBUG, "Transmission started\n");
new_tx_state(am791x, AM791X_STATE_BDATA);
/* BCTS on */
@ -741,16 +743,16 @@ static void brcon_done(am791x_t *am791x)
static void tx_bdata_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "BRTS was released\n");
LOGP(DAM791X, LOGL_DEBUG, "BRTS was released\n");
set_flag(&am791x->block_btd, 1, "BTD IGNORED");
set_flag(&am791x->tx_silence, 1, "SET SILENCE");
timer_start(&am791x->tx_timer, am791x->t_brcoff);
osmo_timer_schedule(&am791x->tx_timer, FLOAT_TO_TIMEOUT(am791x->t_brcoff));
}
static void brcoff_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Transmission over\n");
LOGP(DAM791X, LOGL_DEBUG, "Transmission over\n");
/* BCTS off */
am791x->bcts_cb(am791x->inst, 0);
@ -791,7 +793,7 @@ static void handle_tx_state(am791x_t *am791x)
rcon_release_rts(am791x);
break;
}
if (!timer_running(&am791x->tx_timer)) {
if (!osmo_timer_pending(&am791x->tx_timer)) {
rcon_done(am791x);
break;
}
@ -803,19 +805,19 @@ static void handle_tx_state(am791x_t *am791x)
}
break;
case AM791X_STATE_RCOFF:
if (!timer_running(&am791x->tx_timer)) {
if (!osmo_timer_pending(&am791x->tx_timer)) {
rcoff_done(am791x);
break;
}
break;
case AM791X_STATE_STO_OFF:
if (!timer_running(&am791x->tx_timer)) {
if (!osmo_timer_pending(&am791x->tx_timer)) {
sto_done(am791x);
break;
}
break;
case AM791X_STATE_SQ_OFF:
if (!timer_running(&am791x->tx_timer)) {
if (!osmo_timer_pending(&am791x->tx_timer)) {
sq_done(am791x);
break;
}
@ -826,7 +828,7 @@ static void handle_tx_state(am791x_t *am791x)
brcon_release_brts(am791x);
break;
}
if (!timer_running(&am791x->tx_timer)) {
if (!osmo_timer_pending(&am791x->tx_timer)) {
brcon_done(am791x);
break;
}
@ -838,27 +840,27 @@ static void handle_tx_state(am791x_t *am791x)
}
break;
case AM791X_STATE_BRCOFF:
if (!timer_running(&am791x->tx_timer)) {
if (!osmo_timer_pending(&am791x->tx_timer)) {
brcoff_done(am791x);
break;
}
break;
default:
PDEBUG(DAM791X, DEBUG_ERROR, "State %s not handled!\n", am791x_state_names[am791x->rx_state]);
LOGP(DAM791X, LOGL_ERROR, "State %s not handled!\n", am791x_state_names[am791x->rx_state]);
}
}
static void go_main_channel_rx(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Enable receiver on main channel\n");
LOGP(DAM791X, LOGL_DEBUG, "Enable receiver on main channel\n");
timer_start(&am791x->rx_timer, am791x->t_cdon);
osmo_timer_schedule(&am791x->rx_timer, FLOAT_TO_TIMEOUT(am791x->t_cdon));
new_rx_state(am791x, AM791X_STATE_CDON);
}
static void cdon_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Reception started\n");
LOGP(DAM791X, LOGL_DEBUG, "Reception started\n");
set_flag(&am791x->block_rd, 0, "RD RELEASED");
new_rx_state(am791x, AM791X_STATE_DATA);
@ -872,23 +874,23 @@ static void cdon_done(am791x_t *am791x)
static void cdon_no_cd(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Carrier is gone\n");
LOGP(DAM791X, LOGL_DEBUG, "Carrier is gone\n");
timer_stop(&am791x->rx_timer);
osmo_timer_del(&am791x->rx_timer);
new_rx_state(am791x, AM791X_STATE_INIT);
}
static void rx_data_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Carrier lost\n");
LOGP(DAM791X, LOGL_DEBUG, "Carrier lost\n");
timer_start(&am791x->rx_timer, am791x->t_cdoff);
osmo_timer_schedule(&am791x->rx_timer, FLOAT_TO_TIMEOUT(am791x->t_cdoff));
new_rx_state(am791x, AM791X_STATE_CDOFF);
}
static void cdoff_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Reception finished\n");
LOGP(DAM791X, LOGL_DEBUG, "Reception finished\n");
set_flag(&am791x->block_rd, 1, "RD = MARK");
new_rx_state(am791x, AM791X_STATE_INIT);
@ -902,23 +904,23 @@ static void cdoff_done(am791x_t *am791x)
static void cdoff_cd(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Carrier recovered\n");
LOGP(DAM791X, LOGL_DEBUG, "Carrier recovered\n");
timer_stop(&am791x->rx_timer);
osmo_timer_del(&am791x->rx_timer);
new_rx_state(am791x, AM791X_STATE_DATA);
}
static void go_back_channel_rx(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Enable receiver on back channel\n");
LOGP(DAM791X, LOGL_DEBUG, "Enable receiver on back channel\n");
timer_start(&am791x->rx_timer, am791x->t_bcdon);
osmo_timer_schedule(&am791x->rx_timer, FLOAT_TO_TIMEOUT(am791x->t_bcdon));
new_rx_state(am791x, AM791X_STATE_BCDON);
}
static void bcdon_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Carrier was detected\n");
LOGP(DAM791X, LOGL_DEBUG, "Carrier was detected\n");
set_flag(&am791x->block_brd, 0, "BRD RELEASED");
new_rx_state(am791x, AM791X_STATE_BDATA);
@ -932,23 +934,23 @@ static void bcdon_done(am791x_t *am791x)
static void bcdon_no_cd(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Carrier is gone\n");
LOGP(DAM791X, LOGL_DEBUG, "Carrier is gone\n");
timer_stop(&am791x->rx_timer);
osmo_timer_del(&am791x->rx_timer);
new_rx_state(am791x, AM791X_STATE_INIT);
}
static void rx_bdata_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Carrier lost\n");
LOGP(DAM791X, LOGL_DEBUG, "Carrier lost\n");
timer_start(&am791x->rx_timer, am791x->t_bcdoff);
osmo_timer_schedule(&am791x->rx_timer, FLOAT_TO_TIMEOUT(am791x->t_bcdoff));
new_rx_state(am791x, AM791X_STATE_BCDOFF);
}
static void bcdoff_done(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Reception finished\n");
LOGP(DAM791X, LOGL_DEBUG, "Reception finished\n");
if (!am791x->bell_202)
set_flag(&am791x->block_brd, 1, "BRD = MARK");
@ -963,9 +965,9 @@ static void bcdoff_done(am791x_t *am791x)
static void bcdoff_cd(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Carrier recovered\n");
LOGP(DAM791X, LOGL_DEBUG, "Carrier recovered\n");
timer_stop(&am791x->rx_timer);
osmo_timer_del(&am791x->rx_timer);
new_rx_state(am791x, AM791X_STATE_BDATA);
}
@ -992,7 +994,7 @@ static void handle_rx_state(am791x_t *am791x)
break;
/* all main channel states ... */
case AM791X_STATE_CDON:
if (!timer_running(&am791x->rx_timer)) {
if (!osmo_timer_pending(&am791x->rx_timer)) {
cdon_done(am791x);
break;
}
@ -1008,7 +1010,7 @@ static void handle_rx_state(am791x_t *am791x)
}
break;
case AM791X_STATE_CDOFF:
if (!timer_running(&am791x->rx_timer)) {
if (!osmo_timer_pending(&am791x->rx_timer)) {
cdoff_done(am791x);
break;
}
@ -1019,7 +1021,7 @@ static void handle_rx_state(am791x_t *am791x)
break;
/* all back channel states ... */
case AM791X_STATE_BCDON:
if (!timer_running(&am791x->rx_timer)) {
if (!osmo_timer_pending(&am791x->rx_timer)) {
bcdon_done(am791x);
break;
}
@ -1035,7 +1037,7 @@ static void handle_rx_state(am791x_t *am791x)
}
break;
case AM791X_STATE_BCDOFF:
if (!timer_running(&am791x->rx_timer)) {
if (!osmo_timer_pending(&am791x->rx_timer)) {
bcdoff_done(am791x);
break;
}
@ -1045,7 +1047,7 @@ static void handle_rx_state(am791x_t *am791x)
}
break;
default:
PDEBUG(DAM791X, DEBUG_ERROR, "State %s not handled!\n", am791x_state_names[am791x->rx_state]);
LOGP(DAM791X, LOGL_ERROR, "State %s not handled!\n", am791x_state_names[am791x->rx_state]);
}
}
@ -1086,10 +1088,10 @@ int am791x_init(am791x_t *am791x, void *inst, enum am791x_type type, uint8_t mc,
memset(am791x, 0, sizeof(*am791x));
/* init timers */
timer_init(&am791x->tx_timer, tx_timeout, am791x);
timer_init(&am791x->rx_timer, rx_timeout, am791x);
osmo_timer_setup(&am791x->tx_timer, tx_timeout, am791x);
osmo_timer_setup(&am791x->rx_timer, rx_timeout, am791x);
PDEBUG(DAM791X, DEBUG_DEBUG, "Initializing instance of AM791%d:\n", type);
LOGP(DAM791X, LOGL_DEBUG, "Initializing instance of AM791%d:\n", type);
am791x->inst = inst;
am791x->type = type;
@ -1119,13 +1121,13 @@ int am791x_init(am791x_t *am791x, void *inst, enum am791x_type type, uint8_t mc,
/* exit routine, must be called when exit */
void am791x_exit(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Exit instance of AM791%d:\n", am791x->type);
LOGP(DAM791X, LOGL_DEBUG, "Exit instance of AM791%d:\n", am791x->type);
/* bring to reset state, be sure to clean FSK processes */
am791x_reset(am791x);
timer_exit(&am791x->tx_timer);
timer_exit(&am791x->rx_timer);
osmo_timer_del(&am791x->tx_timer);
osmo_timer_del(&am791x->rx_timer);
}
/* get some default baud rate for each mode, before IOCTL sets it (if it sets it) */
@ -1149,8 +1151,8 @@ int am791x_mc(am791x_t *am791x, uint8_t mc, int samplerate, double tx_baud, doub
if (!((am791x->type) ? am791x_modes[mc].sup_7911 : am791x_modes[mc].sup_7910))
rc = -EINVAL;
PDEBUG(DAM791X, DEBUG_INFO, "Setting mode %d: %s\n", mc, am791x_modes[mc].description);
PDEBUG(DAM791X, DEBUG_DEBUG, " -> Baud rate: %.1f/%.1f\n", rx_baud, tx_baud);
LOGP(DAM791X, LOGL_INFO, "Setting mode %d: %s\n", mc, am791x_modes[mc].description);
LOGP(DAM791X, LOGL_DEBUG, " -> Baud rate: %.1f/%.1f\n", rx_baud, tx_baud);
am791x->mc = mc;
am791x->samplerate = samplerate;
@ -1187,10 +1189,10 @@ int am791x_mc(am791x_t *am791x, uint8_t mc, int samplerate, double tx_baud, doub
/* reset at any time, may be called any time by upper layer */
void am791x_reset(am791x_t *am791x)
{
PDEBUG(DAM791X, DEBUG_INFO, "Reset!\n");
LOGP(DAM791X, LOGL_INFO, "Reset!\n");
timer_stop(&am791x->tx_timer);
timer_stop(&am791x->rx_timer);
osmo_timer_del(&am791x->tx_timer);
osmo_timer_del(&am791x->rx_timer);
if (am791x->f0_tx) {
fsk_mod_cleanup(&am791x->fsk_tx);
@ -1228,7 +1230,7 @@ void am791x_reset(am791x_t *am791x)
/* change input lines */
void am791x_dtr(am791x_t *am791x, int dtr)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Terminal is%s ready!\n", (dtr) ? "" : " not");
LOGP(DAM791X, LOGL_DEBUG, "Terminal is%s ready!\n", (dtr) ? "" : " not");
/* set filters, if DTR becomes on */
if (!am791x->line_dtr && dtr) {
@ -1242,7 +1244,7 @@ void am791x_dtr(am791x_t *am791x, int dtr)
void am791x_rts(am791x_t *am791x, int rts)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Terminal %s RTS.\n", (rts) ? "sets" : "clears");
LOGP(DAM791X, LOGL_DEBUG, "Terminal %s RTS.\n", (rts) ? "sets" : "clears");
am791x->line_rts = rts;
handle_state(am791x);
@ -1250,7 +1252,7 @@ void am791x_rts(am791x_t *am791x, int rts)
void am791x_brts(am791x_t *am791x, int rts)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Terminal %s BRTS.\n", (rts) ? "sets" : "clears");
LOGP(DAM791X, LOGL_DEBUG, "Terminal %s BRTS.\n", (rts) ? "sets" : "clears");
am791x->line_brts = rts;
handle_state(am791x);
@ -1258,7 +1260,7 @@ void am791x_brts(am791x_t *am791x, int rts)
void am791x_ring(am791x_t *am791x, int ring)
{
PDEBUG(DAM791X, DEBUG_DEBUG, "Terminal %s RING.\n", (ring) ? "sets" : "clears");
LOGP(DAM791X, LOGL_DEBUG, "Terminal %s RING.\n", (ring) ? "sets" : "clears");
am791x->line_ring = ring;
handle_state(am791x);

View File

@ -67,7 +67,7 @@ typedef struct am791x {
int f0_rx, f1_rx;
/* timers */
struct timer tx_timer, rx_timer;
struct osmo_timer_list tx_timer, rx_timer;
double t_rcon;
double t_rcoff;
double t_brcon;

View File

@ -32,12 +32,14 @@
#include <fcntl.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libtimer/timer.h"
#include <osmocom/core/select.h>
#include <osmocom/core/timer.h>
#include "../libfsk/fsk.h"
#include "../libsound/sound.h"
#include "../libwave/wave.h"
#include "../libdisplay/display.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/get_time.c"
#include "device.h"
#include "am791x.h"
#include "uart.h"
@ -217,7 +219,7 @@ static void cts(void *inst, int cts)
return;
if (datenklo->auto_rts) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Received CTS=%d in Automatic RTS Mode.\n", cts);
LOGP(DDATENKLO, LOGL_INFO, "Received CTS=%d in Automatic RTS Mode.\n", cts);
datenklo->auto_rts_cts = cts;
return;
}
@ -226,7 +228,7 @@ static void cts(void *inst, int cts)
datenklo->lines |= TIOCM_CTS;
else
datenklo->lines &= ~TIOCM_CTS;
PDEBUG(DDATENKLO, DEBUG_INFO, "Indicating to terminal that CTS is %s\n", (cts) ? "on" : "off");
LOGP(DDATENKLO, LOGL_INFO, "Indicating to terminal that CTS is %s\n", (cts) ? "on" : "off");
}
/* modem changes CTS state (back channel) */
@ -238,7 +240,7 @@ static void bcts(void *inst, int cts)
return;
if (datenklo->auto_rts) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Received BCTS=%d in Automatic RTS Mode.\n", cts);
LOGP(DDATENKLO, LOGL_INFO, "Received BCTS=%d in Automatic RTS Mode.\n", cts);
datenklo->auto_rts_cts = cts;
return;
}
@ -247,7 +249,7 @@ static void bcts(void *inst, int cts)
datenklo->lines |= TIOCM_CTS;
else
datenklo->lines &= ~TIOCM_CTS;
PDEBUG(DDATENKLO, DEBUG_INFO, "Indicating to terminal that BCTS is %s\n", (cts) ? "on" : "off");
LOGP(DDATENKLO, LOGL_INFO, "Indicating to terminal that BCTS is %s\n", (cts) ? "on" : "off");
}
/* modem changes CD state */
@ -259,7 +261,7 @@ static void cd(void *inst, int cd)
return;
if (datenklo->auto_rts) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Received CD=%d in Automatic RTS Mode.\n", cd);
LOGP(DDATENKLO, LOGL_INFO, "Received CD=%d in Automatic RTS Mode.\n", cd);
datenklo->auto_rts_cd = cd;
return;
}
@ -268,7 +270,7 @@ static void cd(void *inst, int cd)
datenklo->lines |= TIOCM_CD;
else
datenklo->lines &= ~TIOCM_CD;
PDEBUG(DDATENKLO, DEBUG_INFO, "Indicating to terminal that CD is %s\n", (cd) ? "on" : "off");
LOGP(DDATENKLO, LOGL_INFO, "Indicating to terminal that CD is %s\n", (cd) ? "on" : "off");
}
/* modem changes CD state (back channel) */
@ -280,7 +282,7 @@ static void bcd(void *inst, int cd)
return;
if (datenklo->auto_rts) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Received BCD=%d in Automatic RTS Mode.\n", cd);
LOGP(DDATENKLO, LOGL_INFO, "Received BCD=%d in Automatic RTS Mode.\n", cd);
datenklo->auto_rts_cd = cd;
return;
}
@ -289,7 +291,7 @@ static void bcd(void *inst, int cd)
datenklo->lines |= TIOCM_CD;
else
datenklo->lines &= ~TIOCM_CD;
PDEBUG(DDATENKLO, DEBUG_INFO, "Indicating to terminal that BCD is %s\n", (cd) ? "on" : "off");
LOGP(DDATENKLO, LOGL_INFO, "Indicating to terminal that BCD is %s\n", (cd) ? "on" : "off");
}
/* modem request bit */
@ -405,7 +407,7 @@ static int tx(void *inst)
if (datenklo->onlcr_char) {
datenklo->onlcr_char = 0;
data = '\n';
PDEBUG(DDATENKLO, DEBUG_DEBUG, "ONLCR: sending NL\n");
LOGP(DDATENKLO, LOGL_DEBUG, "ONLCR: sending NL\n");
goto out;
}
@ -414,7 +416,7 @@ again:
if (fill == (size_t)datenklo->tx_fifo_full) {
/* tell cuse to write again */
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Set POLLOUT!\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Set POLLOUT!\n");
datenklo->revents |= POLLOUT;
device_set_poll_events(datenklo->device, datenklo->revents);
}
@ -424,12 +426,12 @@ again:
datenklo->auto_rts_on = 0;
if (datenklo->tcsetsw) {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Transmission finished, applying termios now.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Transmission finished, applying termios now.\n");
memcpy(&datenklo->termios, &datenklo->tcsetsw_termios, sizeof(datenklo->termios));
if (datenklo->tcsetsw == 2) {
flush_rx(datenklo);
if ((datenklo->revents & POLLIN)) {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Reset POLLIN (flushed)\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Reset POLLIN (flushed)\n");
datenklo->revents &= ~POLLIN;
device_set_poll_events(datenklo->device, datenklo->revents);
}
@ -450,26 +452,26 @@ again:
/* process output features */
if (datenklo->opost) {
if (datenklo->olcuc) {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "OLCUC: 0x%02x -> 0x%02x\n", data, toupper(data));
LOGP(DDATENKLO, LOGL_DEBUG, "OLCUC: 0x%02x -> 0x%02x\n", data, toupper(data));
data = toupper(data);
}
if (datenklo->onlret && data == '\r') {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "ONLRET: ignore CR\n");
LOGP(DDATENKLO, LOGL_DEBUG, "ONLRET: ignore CR\n");
goto again;
}
if (datenklo->ocrnl && data == '\r') {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "OCRNL: CR -> NL\n");
LOGP(DDATENKLO, LOGL_DEBUG, "OCRNL: CR -> NL\n");
data = '\n';
}
if (datenklo->onlcr && data == '\n') {
datenklo->onlcr_char = 1;
data = '\r';
PDEBUG(DDATENKLO, DEBUG_DEBUG, "ONLCR: sending CR\n");
LOGP(DDATENKLO, LOGL_DEBUG, "ONLCR: sending CR\n");
}
}
out:
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Transmitting byte 0x%02x to UART.\n", data);
LOGP(DDATENKLO, LOGL_DEBUG, "Transmitting byte 0x%02x to UART.\n", data);
return data;
}
@ -480,35 +482,35 @@ static void rx(void *inst, int data, uint32_t __attribute__((unused)) flags)
datenklo_t *datenklo = (datenklo_t *)inst;
size_t space;
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Received byte 0x%02x ('%c') from UART.\n", data, (data >= 32 && data <= 126) ? data : '.');
LOGP(DDATENKLO, LOGL_DEBUG, "Received byte 0x%02x ('%c') from UART.\n", data, (data >= 32 && data <= 126) ? data : '.');
/* process input features */
if (datenklo->ignbrk && (flags & UART_BREAK)) {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "IGNBRK: ignore BREAK\n");
LOGP(DDATENKLO, LOGL_DEBUG, "IGNBRK: ignore BREAK\n");
return;
}
if (datenklo->istrip && (data & 0x80)) {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "ISTRIP: 0x%02x -> 0x%02x\n", data, data & 0x7f);
LOGP(DDATENKLO, LOGL_DEBUG, "ISTRIP: 0x%02x -> 0x%02x\n", data, data & 0x7f);
data &= 0x7f;
}
if (datenklo->inlcr && data == '\n') {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "INLCR: NL -> CR\n");
LOGP(DDATENKLO, LOGL_DEBUG, "INLCR: NL -> CR\n");
data = '\r';
}
if (datenklo->igncr && data == '\r') {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "IGNCR: ignore CR\n");
LOGP(DDATENKLO, LOGL_DEBUG, "IGNCR: ignore CR\n");
return;
}
if (datenklo->icrnl && data == '\r') {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "ICRNL: CR -> NL\n");
LOGP(DDATENKLO, LOGL_DEBUG, "ICRNL: CR -> NL\n");
data = '\n';
}
if (datenklo->iuclc) {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "IUCLC: 0x%02x -> 0x%02x\n", data, tolower(data));
LOGP(DDATENKLO, LOGL_DEBUG, "IUCLC: 0x%02x -> 0x%02x\n", data, tolower(data));
data = tolower(data);
}
if (datenklo->echo) {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "ECHO: write to output\n");
LOGP(DDATENKLO, LOGL_DEBUG, "ECHO: write to output\n");
space = (datenklo->tx_fifo_out - datenklo->tx_fifo_in - 1 + datenklo->tx_fifo_size) % datenklo->tx_fifo_size;
if (space) {
datenklo->tx_fifo[datenklo->tx_fifo_in++] = data;
@ -519,7 +521,7 @@ static void rx(void *inst, int data, uint32_t __attribute__((unused)) flags)
/* empty buffer gets data */
if (datenklo->rx_fifo_out == datenklo->rx_fifo_in) {
/* tell cuse to read again */
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Set POLLIN!\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Set POLLIN!\n");
datenklo->revents |= POLLIN;
device_set_poll_events(datenklo->device, datenklo->revents);
}
@ -528,13 +530,13 @@ static void rx(void *inst, int data, uint32_t __attribute__((unused)) flags)
if (!space) {
err_overflow:
PDEBUG(DDATENKLO, DEBUG_NOTICE, "RX buffer overflow, dropping!\n");
LOGP(DDATENKLO, LOGL_NOTICE, "RX buffer overflow, dropping!\n");
return;
}
if (datenklo->parmrk) {
if ((flags & (UART_BREAK | UART_PARITY_ERROR))) {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "PARMRK: 0x%02x -> 0xff,0x00,0x%02x\n", data, data);
LOGP(DDATENKLO, LOGL_DEBUG, "PARMRK: 0x%02x -> 0xff,0x00,0x%02x\n", data, data);
if (space < 3)
goto err_overflow;
datenklo->rx_fifo[datenklo->rx_fifo_in++] = 0xff;
@ -544,7 +546,7 @@ static void rx(void *inst, int data, uint32_t __attribute__((unused)) flags)
datenklo->rx_fifo_in %= datenklo->rx_fifo_size;
space--;
} else if (data == 0xff) {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "PARMRK: 0xff -> 0xff,0xff\n");
LOGP(DDATENKLO, LOGL_DEBUG, "PARMRK: 0xff -> 0xff,0xff\n");
if (space < 2)
goto err_overflow;
datenklo->rx_fifo[datenklo->rx_fifo_in++] = 0xff;
@ -567,18 +569,18 @@ static void set_lines(datenklo_t *datenklo, int new)
int old = datenklo->lines;
if (!(old & TIOCM_DTR) && (new & TIOCM_DTR)) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Terminal turns DTR on\n");
LOGP(DDATENKLO, LOGL_INFO, "Terminal turns DTR on\n");
flush_tx(datenklo);
flush_rx(datenklo);
am791x_dtr(&datenklo->am791x, 1);
}
if ((old & TIOCM_DTR) && !(new & TIOCM_DTR)) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Terminal turns DTR off\n");
LOGP(DDATENKLO, LOGL_INFO, "Terminal turns DTR off\n");
am791x_dtr(&datenklo->am791x, 0);
}
if (!(old & TIOCM_RTS) && (new & TIOCM_RTS)) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Terminal turns RTS on\n");
LOGP(DDATENKLO, LOGL_INFO, "Terminal turns RTS on\n");
if (datenklo->auto_rts)
new |= TIOCM_CTS | TIOCM_CD;
else {
@ -589,7 +591,7 @@ static void set_lines(datenklo_t *datenklo, int new)
}
}
if ((old & TIOCM_RTS) && !(new & TIOCM_RTS)) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Terminal turns RTS off\n");
LOGP(DDATENKLO, LOGL_INFO, "Terminal turns RTS off\n");
if (datenklo->auto_rts)
new &= ~(TIOCM_CTS | TIOCM_CD);
else {
@ -609,7 +611,7 @@ static void process_auto_rts(datenklo_t *datenklo)
if (!datenklo->auto_rts)
return;
if (datenklo->auto_rts_on && !datenklo->auto_rts_rts && !datenklo->auto_rts_cd) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Automatically raising RTS.\n");
LOGP(DDATENKLO, LOGL_INFO, "Automatically raising RTS.\n");
datenklo->auto_rts_rts = 1;
if (!datenklo->tx_back)
am791x_rts(&datenklo->am791x, 1);
@ -617,7 +619,7 @@ static void process_auto_rts(datenklo_t *datenklo)
am791x_brts(&datenklo->am791x, 1);
}
if (!datenklo->auto_rts_on && datenklo->auto_rts_rts) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Automatically dropping RTS.\n");
LOGP(DDATENKLO, LOGL_INFO, "Automatically dropping RTS.\n");
datenklo->auto_rts_rts = 0;
if (!datenklo->tx_back)
am791x_rts(&datenklo->am791x, 0);
@ -634,7 +636,7 @@ static ssize_t dk_ioctl_get(void *inst, int cmd, void *buf, size_t out_bufsz)
ssize_t rc = 0;
#ifdef HEAVY_DEBUG
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Device has been read for ioctl (cmd = %d, size = %zu).\n", cmd, out_bufsz);
LOGP(DDATENKLO, LOGL_DEBUG, "Device has been read for ioctl (cmd = %d, size = %zu).\n", cmd, out_bufsz);
#endif
switch (cmd) {
@ -643,7 +645,7 @@ static ssize_t dk_ioctl_get(void *inst, int cmd, void *buf, size_t out_bufsz)
if (!out_bufsz)
break;
#ifdef HEAVY_DEBUG
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal requests termios.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal requests termios.\n");
#endif
memcpy(buf, &datenklo->termios, rc);
break;
@ -652,7 +654,7 @@ static ssize_t dk_ioctl_get(void *inst, int cmd, void *buf, size_t out_bufsz)
if (!out_bufsz)
break;
#ifdef HEAVY_DEBUG
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal requests line states.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal requests line states.\n");
#endif
status = datenklo->lines | TIOCM_LE | TIOCM_DSR;
memcpy(buf, &status, rc);
@ -662,7 +664,7 @@ static ssize_t dk_ioctl_get(void *inst, int cmd, void *buf, size_t out_bufsz)
if (!out_bufsz)
break;
#ifdef HEAVY_DEBUG
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal requests window size.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal requests window size.\n");
#endif
struct winsize *winsize = (struct winsize *)buf;
winsize->ws_row = 25;
@ -677,7 +679,7 @@ static ssize_t dk_ioctl_get(void *inst, int cmd, void *buf, size_t out_bufsz)
status = (datenklo->rx_fifo_in - datenklo->rx_fifo_out + datenklo->rx_fifo_size) % datenklo->rx_fifo_size;
memcpy(buf, &status, rc);
#ifdef HEAVY_DEBUG
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal requests RX buffer fill states.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal requests RX buffer fill states.\n");
#endif
break;
case TIOCOUTQ:
@ -685,7 +687,7 @@ static ssize_t dk_ioctl_get(void *inst, int cmd, void *buf, size_t out_bufsz)
if (!out_bufsz)
break;
#ifdef HEAVY_DEBUG
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal requests TX buffer fill states.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal requests TX buffer fill states.\n");
#endif
status = (datenklo->tx_fifo_in - datenklo->tx_fifo_out + datenklo->tx_fifo_size) % datenklo->tx_fifo_size;
memcpy(buf, &status, rc);
@ -786,15 +788,15 @@ static void set_termios(datenklo_t *datenklo, const void *buf)
new_echo = !!(datenklo->termios.c_lflag & ECHO);
if (old_baud != new_baud && (!datenklo->force_tx_baud || !datenklo->force_rx_baud)) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Terminal changes baud rate to %.1f Baud.\n", new_baud);
LOGP(DDATENKLO, LOGL_INFO, "Terminal changes baud rate to %.1f Baud.\n", new_baud);
if ((datenklo->lines & TIOCM_DTR) && !new_baud) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Baudrate is set to 0, we drop DTR\n");
LOGP(DDATENKLO, LOGL_INFO, "Baudrate is set to 0, we drop DTR\n");
am791x_dtr(&datenklo->am791x, 0);
}
datenklo->baudrate = new_baud;
am791x_mc(&datenklo->am791x, datenklo->mc, datenklo->samplerate, tx_baud_rate(datenklo), rx_baud_rate(datenklo));
if ((datenklo->lines & TIOCM_DTR) && !old_baud) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Baudrate is set from 0, we raise DTR\n");
LOGP(DDATENKLO, LOGL_INFO, "Baudrate is set from 0, we raise DTR\n");
am791x_dtr(&datenklo->am791x, 1);
}
}
@ -802,10 +804,10 @@ static void set_termios(datenklo_t *datenklo, const void *buf)
if (old_databits != new_databits
|| old_parity != new_parity
|| old_stopbits != new_stopbits) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Terminal changes serial mode to %d%c%d.\n", cflag2databits(datenklo->termios.c_cflag), parity2char(cflag2parity(datenklo->termios.c_cflag)), cflag2stopbits(datenklo->termios.c_cflag));
LOGP(DDATENKLO, LOGL_INFO, "Terminal changes serial mode to %d%c%d.\n", cflag2databits(datenklo->termios.c_cflag), parity2char(cflag2parity(datenklo->termios.c_cflag)), cflag2stopbits(datenklo->termios.c_cflag));
rc = uart_init(&datenklo->uart, datenklo, cflag2databits(datenklo->termios.c_cflag), cflag2parity(datenklo->termios.c_cflag), cflag2stopbits(datenklo->termios.c_cflag), tx, rx);
if (rc < 0)
PDEBUG(DDATENKLO, DEBUG_ERROR, "Failed to initialize UART.\n");
LOGP(DDATENKLO, LOGL_ERROR, "Failed to initialize UART.\n");
}
if (old_stopbits != new_stopbits
@ -835,8 +837,8 @@ static void set_termios(datenklo_t *datenklo, const void *buf)
datenklo->onlret = new_onlret;
datenklo->olcuc = new_olcuc;
datenklo->echo = new_echo;
PDEBUG(DDATENKLO, DEBUG_INFO, "Terminal sets serial flags:\n");
PDEBUG(DDATENKLO, DEBUG_INFO, "%cignbrk %cparmrk %cistrip %cinlcr %cigncr %cicrnl %ciuclc %copost %conlcr %cocrnl %conlret %colcuc %cecho\n",
LOGP(DDATENKLO, LOGL_INFO, "Terminal sets serial flags:\n");
LOGP(DDATENKLO, LOGL_INFO, "%cignbrk %cparmrk %cistrip %cinlcr %cigncr %cicrnl %ciuclc %copost %conlcr %cocrnl %conlret %colcuc %cecho\n",
(datenklo->ignbrk) ? '+' : '-',
(datenklo->parmrk) ? '+' : '-',
(datenklo->istrip) ? '+' : '-',
@ -862,7 +864,7 @@ static ssize_t dk_ioctl_set(void *inst, int cmd, const void *buf, size_t in_bufs
size_t space;
#ifdef HEAVY_DEBUG
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Device has been written for ioctl (cmd = %d, size = %zu).\n", cmd, in_bufsz);
LOGP(DDATENKLO, LOGL_DEBUG, "Device has been written for ioctl (cmd = %d, size = %zu).\n", cmd, in_bufsz);
#endif
switch (cmd) {
@ -870,7 +872,7 @@ static ssize_t dk_ioctl_set(void *inst, int cmd, const void *buf, size_t in_bufs
rc = sizeof(datenklo->termios);
if (!in_bufsz)
break;
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal sets termios now.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal sets termios now.\n");
set_termios(datenklo, buf);
break;
case TCSETSW:
@ -878,9 +880,9 @@ static ssize_t dk_ioctl_set(void *inst, int cmd, const void *buf, size_t in_bufs
rc = sizeof(datenklo->termios);
if (!in_bufsz)
break;
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal sets termios after draining output buffer.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal sets termios after draining output buffer.\n");
if (1 || datenklo->tx_fifo_out == datenklo->tx_fifo_in) {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Output buffer empty, applying termios now.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Output buffer empty, applying termios now.\n");
set_termios(datenklo, buf);
break;
}
@ -895,12 +897,12 @@ static ssize_t dk_ioctl_set(void *inst, int cmd, const void *buf, size_t in_bufs
if (!in_bufsz)
break;
memcpy(&status, buf, rc);
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal flushes buffer (status = %d).\n", status);
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal flushes buffer (status = %d).\n", status);
if (status == TCIOFLUSH || status == TCOFLUSH) {
flush_tx(datenklo);
if (!(datenklo->revents & POLLOUT)) {
/* tell cuse to write again */
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Set POLLOUT (flushed)\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Set POLLOUT (flushed)\n");
datenklo->revents |= POLLOUT;
device_set_poll_events(datenklo->device, datenklo->revents);
}
@ -908,7 +910,7 @@ static ssize_t dk_ioctl_set(void *inst, int cmd, const void *buf, size_t in_bufs
if (status == TCIOFLUSH || status == TCIFLUSH) {
flush_rx(datenklo);
if ((datenklo->revents & POLLIN)) {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Reset POLLIN (flushed)\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Reset POLLIN (flushed)\n");
datenklo->revents &= ~POLLIN;
device_set_poll_events(datenklo->device, datenklo->revents);
}
@ -916,7 +918,7 @@ static ssize_t dk_ioctl_set(void *inst, int cmd, const void *buf, size_t in_bufs
break;
case TCSBRK:
rc = 0;
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal sends break\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal sends break\n");
datenklo->break_bits = tx_baud_rate(datenklo) * 3 / 10;
break;
case TCSBRKP:
@ -924,7 +926,7 @@ static ssize_t dk_ioctl_set(void *inst, int cmd, const void *buf, size_t in_bufs
if (!in_bufsz)
break;
memcpy(&status, buf, rc);
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal sends break (duration = %d).\n", status);
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal sends break (duration = %d).\n", status);
if (status == 0)
status = 3;
if (status > 30)
@ -933,12 +935,12 @@ static ssize_t dk_ioctl_set(void *inst, int cmd, const void *buf, size_t in_bufs
break;
case TIOCSBRK:
rc = 0;
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal turns break on\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal turns break on\n");
datenklo->break_on = 1;
break;
case TIOCCBRK:
rc = 0;
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal turns break off\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal turns break off\n");
datenklo->break_on = 0;
break;
case TIOCMBIS:
@ -946,7 +948,7 @@ static ssize_t dk_ioctl_set(void *inst, int cmd, const void *buf, size_t in_bufs
if (!in_bufsz)
break;
memcpy(&status, buf, rc);
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal sets line status (0x%x).\n", status);
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal sets line status (0x%x).\n", status);
status = datenklo->lines | status;
set_lines(datenklo, status);
break;
@ -955,7 +957,7 @@ static ssize_t dk_ioctl_set(void *inst, int cmd, const void *buf, size_t in_bufs
if (!in_bufsz)
break;
memcpy(&status, buf, rc);
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal clears line status (0x%x).\n", status);
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal clears line status (0x%x).\n", status);
status = datenklo->lines & ~status;
set_lines(datenklo, status);
break;
@ -964,30 +966,30 @@ static ssize_t dk_ioctl_set(void *inst, int cmd, const void *buf, size_t in_bufs
if (!in_bufsz)
break;
memcpy(&status, buf, rc);
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal specifies line status (0x%x).\n", status);
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal specifies line status (0x%x).\n", status);
set_lines(datenklo, status);
break;
case TIOCGSID:
PDEBUG(DDATENKLO, DEBUG_DEBUG, "TIOGSID -> ENOTTY\n");
LOGP(DDATENKLO, LOGL_DEBUG, "TIOGSID -> ENOTTY\n");
rc = -ENOTTY;
break;
case TIOCGPGRP:
PDEBUG(DDATENKLO, DEBUG_DEBUG, "TIOCGPGRP -> ENOTTY\n");
LOGP(DDATENKLO, LOGL_DEBUG, "TIOCGPGRP -> ENOTTY\n");
rc = -ENOTTY;
break;
case TIOCSCTTY:
PDEBUG(DDATENKLO, DEBUG_DEBUG, "TIOCSCTTY -> ENOTTY\n");
LOGP(DDATENKLO, LOGL_DEBUG, "TIOCSCTTY -> ENOTTY\n");
rc = -ENOTTY;
break;
case TIOCSPGRP:
PDEBUG(DDATENKLO, DEBUG_DEBUG, "TIOCSPGRP -> ENOTTY\n");
LOGP(DDATENKLO, LOGL_DEBUG, "TIOCSPGRP -> ENOTTY\n");
rc = -ENOTTY;
break;
case TIOCSWINSZ:
rc = sizeof(struct winsize);
if (!in_bufsz)
break;
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal sets window size.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal sets window size.\n");
break;
case TCXONC:
rc = sizeof(status);
@ -996,15 +998,15 @@ static ssize_t dk_ioctl_set(void *inst, int cmd, const void *buf, size_t in_bufs
memcpy(&status, buf, rc);
switch (status) {
case TCOOFF:
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal turns off output.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal turns off output.\n");
datenklo->output_off = 1;
break;
case TCOON:
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal turns on output.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal turns on output.\n");
datenklo->output_off = 0;
break;
case TCIOFF:
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal turns off input.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal turns off input.\n");
space = (datenklo->rx_fifo_out - datenklo->rx_fifo_in - 1 + datenklo->rx_fifo_size) % datenklo->rx_fifo_size;
if (space < 1)
break;
@ -1012,7 +1014,7 @@ static ssize_t dk_ioctl_set(void *inst, int cmd, const void *buf, size_t in_bufs
datenklo->rx_fifo_in %= datenklo->rx_fifo_size;
break;
case TCION:
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Terminal turns on input.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Terminal turns on input.\n");
space = (datenklo->rx_fifo_out - datenklo->rx_fifo_in - 1 + datenklo->rx_fifo_size) % datenklo->rx_fifo_size;
if (space < 1)
break;
@ -1034,12 +1036,12 @@ static int dk_open(void *inst, int flags)
datenklo_t *datenklo = (datenklo_t *)inst;
if (datenklo->open_count) {
PDEBUG(DDATENKLO, DEBUG_NOTICE, "Device is busy.\n");
LOGP(DDATENKLO, LOGL_NOTICE, "Device is busy.\n");
return -EBUSY;
}
datenklo->open_count++;
datenklo->flags = flags;
PDEBUG(DDATENKLO, DEBUG_INFO, "Device has been opened.\n");
LOGP(DDATENKLO, LOGL_INFO, "Device has been opened.\n");
int status = datenklo->lines | TIOCM_DTR | TIOCM_RTS;
set_lines(datenklo, status);
@ -1051,7 +1053,7 @@ static void dk_close(void *inst)
{
datenklo_t *datenklo = (datenklo_t *)inst;
PDEBUG(DDATENKLO, DEBUG_INFO, "Device has been closed.\n");
LOGP(DDATENKLO, LOGL_INFO, "Device has been closed.\n");
datenklo->open_count--;
int status = datenklo->lines & ~(TIOCM_DTR | TIOCM_RTS);
set_lines(datenklo, status);
@ -1071,7 +1073,7 @@ static void debug_data(const char *buf, int count)
count--;
}
text[i] = '\0';
PDEBUG(DDATENKLO, DEBUG_DEBUG, " \"%s\"\n", text);
LOGP(DDATENKLO, LOGL_DEBUG, " \"%s\"\n", text);
}
}
@ -1091,7 +1093,7 @@ static ssize_t dk_read(void *inst, char *buf, size_t size, int flags)
if (vmin && vtime) {
/* first: start timer */
if (!datenklo->vtimeout)
timer_start(&datenklo->vtimer, (double)vtime * 0.1);
osmo_timer_schedule(&datenklo->vtimer, vtime/10,(vtime % 10) * 100000);
/* no data: block (in blocking IO) */
if (fill == 0) {
/* special value to tell device there is no data right now, we have to block */
@ -1104,7 +1106,7 @@ static ssize_t dk_read(void *inst, char *buf, size_t size, int flags)
}
/* enough data or timeout or nonblocking IO: stop timer and return what we have */
datenklo->vtimeout = 0;
timer_stop(&datenklo->vtimer);
osmo_timer_del(&datenklo->vtimer);
}
/* both MIN and TIME are zero */
if (!vmin && !vtime) {
@ -1117,7 +1119,7 @@ static ssize_t dk_read(void *inst, char *buf, size_t size, int flags)
if (!vmin && vtime) {
/* first: start timer */
if (!datenklo->vtimeout)
timer_start(&datenklo->vtimer, (double)vtime * 0.1);
osmo_timer_schedule(&datenklo->vtimer, vtime/10,(vtime % 10) * 100000);
if (fill == 0) {
/* no data and no timeout: block (in blocking IO) */
if (!datenklo->vtimeout) {
@ -1130,7 +1132,7 @@ static ssize_t dk_read(void *inst, char *buf, size_t size, int flags)
}
/* data: stop timer and return what we have */
datenklo->vtimeout = 0;
timer_stop(&datenklo->vtimer);
osmo_timer_del(&datenklo->vtimer);
}
/* MIN is nonzero, TIME is zero */
if (vmin && !vtime) {
@ -1142,7 +1144,7 @@ static ssize_t dk_read(void *inst, char *buf, size_t size, int flags)
/* enough data in buffer: return what we have */
}
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Device has been read from. (fill = %zu)\n", fill);
LOGP(DDATENKLO, LOGL_DEBUG, "Device has been read from. (fill = %zu)\n", fill);
/* get data from fifo */
count = 0;
@ -1160,7 +1162,7 @@ static ssize_t dk_read(void *inst, char *buf, size_t size, int flags)
if (!fill) {
/* tell cuse not to read anymore */
if ((datenklo->revents & POLLIN)) {
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Reset POLLIN (now empty)!\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Reset POLLIN (now empty)!\n");
datenklo->revents &= ~POLLIN;
device_set_poll_events(datenklo->device, datenklo->revents);
}
@ -1177,17 +1179,17 @@ static ssize_t dk_write(void *inst, const char *buf, size_t size, int __attribut
size_t i;
if (!(datenklo->lines & TIOCM_DTR)) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Dropping data, DTR is off!\n");
LOGP(DDATENKLO, LOGL_INFO, "Dropping data, DTR is off!\n");
return -EIO;
}
if (!(datenklo->lines & TIOCM_RTS)) {
PDEBUG(DDATENKLO, DEBUG_INFO, "Dropping data, RTS is off!\n");
LOGP(DDATENKLO, LOGL_INFO, "Dropping data, RTS is off!\n");
return -EIO;
}
if (size > (size_t)datenklo->tx_fifo_size - 1) {
PDEBUG(DDATENKLO, DEBUG_NOTICE, "Device sends us too many data. (size = %zu)\n", size);
LOGP(DDATENKLO, LOGL_NOTICE, "Device sends us too many data. (size = %zu)\n", size);
return -EIO;
}
@ -1199,7 +1201,7 @@ static ssize_t dk_write(void *inst, const char *buf, size_t size, int __attribut
return -EAGAIN;
}
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Device has been written to. (space = %zu)\n", space);
LOGP(DDATENKLO, LOGL_DEBUG, "Device has been written to. (space = %zu)\n", space);
debug_data(buf, size);
if (datenklo->auto_rts)
@ -1215,7 +1217,7 @@ static ssize_t dk_write(void *inst, const char *buf, size_t size, int __attribut
if ((datenklo->revents & POLLOUT) && fill >= (size_t)datenklo->tx_fifo_full) {
/* tell cuse not to write */
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Reset POLLOUT (buffer full)\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Reset POLLOUT (buffer full)\n");
datenklo->revents &= ~POLLOUT;
device_set_poll_events(datenklo->device, datenklo->revents);
}
@ -1227,7 +1229,7 @@ static void dk_flush_tx(void *inst)
{
datenklo_t *datenklo = (datenklo_t *)inst;
PDEBUG(DDATENKLO, DEBUG_INFO, "Terminal sends interrupt while writing, flushing TX buffer\n");
LOGP(DDATENKLO, LOGL_INFO, "Terminal sends interrupt while writing, flushing TX buffer\n");
flush_tx(datenklo);
}
@ -1270,7 +1272,7 @@ static void vtime_timeout(void *data)
void datenklo_init_global(void)
{
if (pthread_mutex_init(&mutex, NULL)) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "Failed to init mutex.\n");
LOGP(DDATENKLO, LOGL_ERROR, "Failed to init mutex.\n");
exit(0);
}
}
@ -1282,7 +1284,7 @@ int datenklo_init(datenklo_t *datenklo, const char *dev_name, enum am791x_type a
tcflag_t flag;
cc_t *cc;
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Creating Datenklo instance.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Creating Datenklo instance.\n");
memset(datenklo, 0, sizeof(*datenklo));
@ -1332,7 +1334,7 @@ int datenklo_init(datenklo_t *datenklo, const char *dev_name, enum am791x_type a
datenklo->device = device_init(datenklo, dev_name, dk_open, dk_close, dk_read, dk_write, dk_ioctl_get, dk_ioctl_set, dk_flush_tx, dk_lock, dk_unlock);
if (!datenklo->device) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "Failed to attach virtual device '%s' using cuse.\n", dev_name);
LOGP(DDATENKLO, LOGL_ERROR, "Failed to attach virtual device '%s' using cuse.\n", dev_name);
rc = -errno;
goto error;
}
@ -1342,7 +1344,7 @@ int datenklo_init(datenklo_t *datenklo, const char *dev_name, enum am791x_type a
datenklo->baudrate = cflag2baud(datenklo->termios.c_cflag);
rc = am791x_init(&datenklo->am791x, datenklo, am791x_type, datenklo->mc, datenklo->samplerate, tx_baud_rate(datenklo), rx_baud_rate(datenklo), cts, bcts, cd, bcd, td, btd, rd, brd);
if (rc < 0) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "Failed to initialize AM791X modem chip.\n");
LOGP(DDATENKLO, LOGL_ERROR, "Failed to initialize AM791X modem chip.\n");
goto error;
}
@ -1352,16 +1354,16 @@ int datenklo_init(datenklo_t *datenklo, const char *dev_name, enum am791x_type a
datenklo->tx_fifo = calloc(datenklo->tx_fifo_size, 1);
datenklo->rx_fifo = calloc(datenklo->rx_fifo_size, 1);
if (!datenklo->tx_fifo || !datenklo->rx_fifo) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "No mem!\n");
LOGP(DDATENKLO, LOGL_ERROR, "No mem!\n");
rc = -ENOMEM;
goto error;
}
timer_init(&datenklo->vtimer, vtime_timeout, datenklo);
osmo_timer_setup(&datenklo->vtimer, vtime_timeout, datenklo);
rc = uart_init(&datenklo->uart, datenklo, cflag2databits(datenklo->termios.c_cflag), cflag2parity(datenklo->termios.c_cflag), cflag2stopbits(datenklo->termios.c_cflag), tx, rx);
if (rc < 0) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "Failed to initialize UART.\n");
LOGP(DDATENKLO, LOGL_ERROR, "Failed to initialize UART.\n");
goto error;
}
@ -1397,7 +1399,7 @@ int datenklo_open_audio(datenklo_t *datenklo, const char *audiodev, int buffer,
/* init sound */
datenklo->audio = sound_open(audiodev, NULL, NULL, NULL, channels, 0.0, datenklo->samplerate, datenklo->buffer_size, 1.0, 1.0, 4000.0, 2.0);
if (!datenklo->audio) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "No sound device!\n");
LOGP(DDATENKLO, LOGL_ERROR, "No sound device!\n");
return -EIO;
}
#endif
@ -1405,28 +1407,28 @@ int datenklo_open_audio(datenklo_t *datenklo, const char *audiodev, int buffer,
if (write_rx_wave) {
rc = wave_create_record(&datenklo->wave_rx_rec, write_rx_wave, datenklo->samplerate, channels, 1.0);
if (rc < 0) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
LOGP(DDATENKLO, LOGL_ERROR, "Failed to create WAVE recoding instance!\n");
return rc;
}
}
if (write_tx_wave) {
rc = wave_create_record(&datenklo->wave_tx_rec, write_tx_wave, datenklo->samplerate, channels, 1.0);
if (rc < 0) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
LOGP(DDATENKLO, LOGL_ERROR, "Failed to create WAVE recoding instance!\n");
return rc;
}
}
if (read_rx_wave) {
rc = wave_create_playback(&datenklo->wave_rx_play, read_rx_wave, &datenklo->samplerate, &channels, 1.0);
if (rc < 0) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "Failed to create WAVE playback instance!\n");
LOGP(DDATENKLO, LOGL_ERROR, "Failed to create WAVE playback instance!\n");
return rc;
}
}
if (read_tx_wave) {
rc = wave_create_playback(&datenklo->wave_tx_play, read_tx_wave, &datenklo->samplerate, &channels, 1.0);
if (rc < 0) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "Failed to create WAVE playback instance!\n");
LOGP(DDATENKLO, LOGL_ERROR, "Failed to create WAVE playback instance!\n");
return rc;
}
}
@ -1521,14 +1523,14 @@ void datenklo_main(datenklo_t *datenklo, int loopback)
process_auto_rts(datenklo->slave);
/* process timers */
process_timer();
osmo_select_main(1);
#ifdef HAVE_ALSA
count = sound_read(datenklo->audio, samples, datenklo->buffer_size, num_chan, rf_level_db);
if (count < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to read RX data from audio device (rc = %d)\n", count);
LOGP(DDSP, LOGL_ERROR, "Failed to read RX data from audio device (rc = %d)\n", count);
if (count == -EPIPE) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "Trying to recover!\n");
LOGP(DDATENKLO, LOGL_ERROR, "Trying to recover!\n");
continue;
}
break;
@ -1561,9 +1563,9 @@ void datenklo_main(datenklo_t *datenklo, int loopback)
count = samplerate / 1000;
#endif
if (count < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count);
LOGP(DDSP, LOGL_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count);
if (count == -EPIPE) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "Trying to recover!\n");
LOGP(DDATENKLO, LOGL_ERROR, "Trying to recover!\n");
continue;
}
break;
@ -1611,9 +1613,9 @@ void datenklo_main(datenklo_t *datenklo, int loopback)
/* write audio */
rc = sound_write(datenklo->audio, samples, power, count, NULL, NULL, num_chan);
if (rc < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to write TX data to audio device (rc = %d)\n", rc);
LOGP(DDSP, LOGL_ERROR, "Failed to write TX data to audio device (rc = %d)\n", rc);
if (rc == -EPIPE) {
PDEBUG(DDATENKLO, DEBUG_ERROR, "Trying to recover!\n");
LOGP(DDATENKLO, LOGL_ERROR, "Trying to recover!\n");
continue;
}
break;
@ -1625,8 +1627,6 @@ next_char:
switch (c) {
case 3:
/* quit */
if (clear_console_text)
clear_console_text();
printf("CTRL+c received, quitting!\n");
quit = 1;
goto next_char;
@ -1655,10 +1655,6 @@ next_char:
pthread_mutex_lock(&mutex);
}
/* get rid of last entry */
if (clear_console_text)
clear_console_text();
/* reset terminal */
tcsetattr(0, TCSANOW, &term_orig);
@ -1674,9 +1670,9 @@ next_char:
/* cleanup function */
void datenklo_exit(datenklo_t *datenklo)
{
PDEBUG(DDATENKLO, DEBUG_DEBUG, "Destroying Datenklo instance.\n");
LOGP(DDATENKLO, LOGL_DEBUG, "Destroying Datenklo instance.\n");
timer_exit(&datenklo->vtimer);
osmo_timer_del(&datenklo->vtimer);
/* exit device */
if (datenklo->device)

View File

@ -52,7 +52,7 @@ typedef struct datenklo {
int auto_rts_cts; /* CTS was indicated */
int auto_rts_cd; /* CD was indicated */
int output_off; /* output stopped by flow control */
struct timer vtimer; /* VTIME timer */
struct osmo_timer_list vtimer; /* VTIME timer */
int vtimeout; /* when timeout has fired */
/* data fifos */

View File

@ -27,7 +27,7 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#define __USE_GNU
#include <pthread.h>
#include <signal.h>
@ -122,7 +122,7 @@ static void cuse_read_interrupt(fuse_req_t req, void *data)
if (!device->read_locked)
device->lock_cb();
PDEBUG(DDEVICE, DEBUG_DEBUG, "%s received interrupt from client!\n", device->name);
LOGP(DDEVICE, LOGL_DEBUG, "%s received interrupt from client!\n", device->name);
if (device->read_req) {
device->read_req = NULL;
@ -167,7 +167,7 @@ static void cuse_device_read(fuse_req_t req, size_t size, off_t off, struct fuse
if (device->read_req) {
device->unlock_cb();
PDEBUG(DDEVICE, DEBUG_ERROR, "%s: Got another read(), while first read() has not been replied, please fix.\n", device->name);
LOGP(DDEVICE, LOGL_ERROR, "%s: Got another read(), while first read() has not been replied, please fix.\n", device->name);
fuse_reply_err(req, EBUSY);
return;
}
@ -182,7 +182,7 @@ static void cuse_device_read(fuse_req_t req, size_t size, off_t off, struct fuse
/* this means that we block until modem's read() returns 0 or positive value (in nonblocking io, we return -EAGAIN) */
if (!(fi->flags & O_NONBLOCK) && count == -EAGAIN) {
PDEBUG(DDEVICE, DEBUG_DEBUG, "%s has no data available, waiting for data, timer or interrupt.\n", device->name);
LOGP(DDEVICE, LOGL_DEBUG, "%s has no data available, waiting for data, timer or interrupt.\n", device->name);
device->read_req = req;
device->read_size = size;
@ -216,7 +216,7 @@ static void cuse_write_interrupt(fuse_req_t req, void *data)
if (!device->write_locked)
device->lock_cb();
PDEBUG(DDEVICE, DEBUG_DEBUG, "%s received interrupt from client!\n", device->name);
LOGP(DDEVICE, LOGL_DEBUG, "%s received interrupt from client!\n", device->name);
if (device->write_req) {
device->write_req = NULL;
@ -262,7 +262,7 @@ static void cuse_device_write(fuse_req_t req, const char *buf, size_t size, off_
if (device->write_req) {
device->unlock_cb();
PDEBUG(DDEVICE, DEBUG_ERROR, "%s: Got another write(), while first write() has not been replied, please fix.\n", device->name);
LOGP(DDEVICE, LOGL_ERROR, "%s: Got another write(), while first write() has not been replied, please fix.\n", device->name);
fuse_reply_err(req, EBUSY);
return;
}
@ -271,13 +271,13 @@ static void cuse_device_write(fuse_req_t req, const char *buf, size_t size, off_
/* this means that we block until modem's write() returns 0 or positive value (in nonblocking io, we return -EAGAIN) */
if (!(fi->flags & O_NONBLOCK) && count == -EAGAIN) {
PDEBUG(DDEVICE, DEBUG_DEBUG, "%s has no buffer space available, waiting for space or interrupt.\n", device->name);
LOGP(DDEVICE, LOGL_DEBUG, "%s has no buffer space available, waiting for space or interrupt.\n", device->name);
device->write_req = req;
device->write_size = size;
device->write_buf = malloc(size);
if (!buf) {
PDEBUG(DDEVICE, DEBUG_ERROR, "No memory!\n");
LOGP(DDEVICE, LOGL_ERROR, "No memory!\n");
exit(0);
}
memcpy(device->write_buf, buf, size);
@ -376,7 +376,7 @@ static void cuse_device_ioctl(fuse_req_t req, int cmd, void *arg, struct fuse_fi
}
break;
default:
PDEBUG(DDEVICE, DEBUG_NOTICE, "%s: receives unknown ioctl: 0x%x\n", device->name, cmd);
LOGP(DDEVICE, LOGL_NOTICE, "%s: receives unknown ioctl: 0x%x\n", device->name, cmd);
fuse_reply_err(req, EINVAL);
}
}
@ -432,7 +432,7 @@ static void cuse_device_flush(fuse_req_t req, struct fuse_file_info *fi)
(void)req;
(void)fi;
device_t *device = get_device_by_thread();
PDEBUG(DDEVICE, DEBUG_NOTICE, "%s: unhandled flush\n", device->name);
LOGP(DDEVICE, LOGL_NOTICE, "%s: unhandled flush\n", device->name);
}
static void cuse_device_fsync(fuse_req_t req, int datasync, struct fuse_file_info *fi)
@ -441,7 +441,7 @@ static void cuse_device_fsync(fuse_req_t req, int datasync, struct fuse_file_inf
(void)datasync;
(void)fi;
device_t *device = get_device_by_thread();
PDEBUG(DDEVICE, DEBUG_NOTICE, "%s: unhandled fsync\n", device->name);
LOGP(DDEVICE, LOGL_NOTICE, "%s: unhandled fsync\n", device->name);
}
@ -478,9 +478,9 @@ static void *device_child(void *arg)
device->thread_started = 1;
PDEBUG(DDEVICE, DEBUG_INFO, "Device '%s' started.\n", device->name);
LOGP(DDEVICE, LOGL_INFO, "Device '%s' started.\n", device->name);
cuse_lowlevel_main(argc, argv, &ci, &cuse_device_clop, NULL);
PDEBUG(DDEVICE, DEBUG_INFO, "Device '%s' terminated.\n", device->name);
LOGP(DDEVICE, LOGL_INFO, "Device '%s' terminated.\n", device->name);
device->thread_stopped = 1;
@ -496,7 +496,7 @@ void *device_init(void *inst, const char *name, int (*open)(void *inst, int flag
device = calloc(1, sizeof(*device));
if (!device) {
PDEBUG(DDEVICE, DEBUG_ERROR, "No memory!\n");
LOGP(DDEVICE, LOGL_ERROR, "No memory!\n");
errno = ENOMEM;
goto error;
}
@ -514,7 +514,7 @@ void *device_init(void *inst, const char *name, int (*open)(void *inst, int flag
rc = pthread_create(&device->thread, NULL, device_child, device);
if (rc < 0) {
PDEBUG(DDEVICE, DEBUG_ERROR, "Failed to create device thread!\n");
LOGP(DDEVICE, LOGL_ERROR, "Failed to create device thread!\n");
errno = -rc;
goto error;
}

View File

@ -26,9 +26,9 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libtimer/timer.h"
#include <osmocom/core/timer.h>
#include "../liboptions/options.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libfsk/fsk.h"
#include "../libwave/wave.h"
#include "../libdisplay/display.h"
@ -80,6 +80,7 @@ void print_help(const char *arg0)
printf(" --config [~/]<path to config file>\n");
printf(" Give a config file to use. If it starts with '~/', path is at home dir.\n");
printf(" Each line in config file is one option, '-' or '--' must not be given!\n");
logging_print_help();
printf(" -T --am791x-type 7910 | 7911\n");
printf(" Give modem chip type. (Default = 791%d)\n", am791x_type);
printf(" -M --mc <mode>\n");
@ -158,13 +159,11 @@ static int handle_options(int short_option, int argi, char **argv)
print_help(argv[0]);
return 0;
case 'v':
if (!strcasecmp(argv[argi], "list")) {
debug_list_cat();
rc = parse_logging_opt(argv[argi]);
if (rc > 0)
return 0;
}
rc = parse_debug_opt(argv[argi]);
if (rc < 0) {
fprintf(stderr, "Failed to parse debug option, please use -h for help.\n");
fprintf(stderr, "Failed to parse logging option, please use -h for help.\n");
return rc;
}
break;
@ -265,6 +264,8 @@ int main(int argc, char *argv[])
int rc, argi;
int i;
logging_init();
/* handle options / config file */
add_options();
rc = options_config_file(argc, argv, "~/.osmocom/analog/datenklo.conf", handle_options);
@ -325,3 +326,5 @@ fail:
return 0;
}
void osmo_cc_set_log_cat(void) {}

View File

@ -21,7 +21,7 @@
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "uart.h"
static uint32_t calc_parity(uint32_t data, uint8_t data_bits, enum uart_parity parity)
@ -56,13 +56,13 @@ int uart_init(uart_t *uart, void *inst, uint8_t data_bits, enum uart_parity pari
uart->rx_cb = rx_cb;
uart->data_bits = data_bits;
if (uart->data_bits > 9) {
PDEBUG(DUART, DEBUG_ERROR, "Illegal number of data bits, please fix!\n");
LOGP(DUART, LOGL_ERROR, "Illegal number of data bits, please fix!\n");
abort();
}
uart->parity = parity;
uart->stop_bits = stop_bits;
if (uart->stop_bits < 1 || uart->stop_bits > 2) {
PDEBUG(DUART, DEBUG_ERROR, "Illegal number of stop bits, please fix!\n");
LOGP(DUART, LOGL_ERROR, "Illegal number of stop bits, please fix!\n");
abort();
}
uart->tx_pos = -1;

View File

@ -13,13 +13,14 @@ dcf77_SOURCES = \
dcf77_LDADD = \
$(COMMON_LA) \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libdisplay/libdisplay.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/liblogging/liblogging.a \
$(LIBOSMOCORE_LIBS) \
$(ALSA_LIBS) \
-lm
endif

View File

@ -26,7 +26,7 @@
#include <inttypes.h>
#include <stdlib.h>
#include <math.h>
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "dcf77.h"
#include "weather.h"
@ -380,7 +380,7 @@ dcf77_t *dcf77_create(int samplerate, int use_tx, int use_rx, int test_tone)
dcf77 = calloc(1, sizeof(*dcf77));
if (!dcf77) {
PDEBUG(DDCF77, DEBUG_ERROR, "No mem!\n");
LOGP(DDCF77, LOGL_ERROR, "No mem!\n");
return NULL;
}
tx = &dcf77->tx;
@ -429,7 +429,7 @@ dcf77_t *dcf77_create(int samplerate, int use_tx, int use_rx, int test_tone)
rx->delay_size = ceil((double)SAMPLE_CLOCK * 0.1);
rx->delay_buffer = calloc(rx->delay_size, sizeof(*rx->delay_buffer));
if (!rx->delay_buffer) {
PDEBUG(DDCF77, DEBUG_ERROR, "No mem!\n");
LOGP(DDCF77, LOGL_ERROR, "No mem!\n");
return NULL;
}
@ -444,9 +444,9 @@ dcf77_t *dcf77_create(int samplerate, int use_tx, int use_rx, int test_tone)
}
if (tx->enable)
PDEBUG(DDCF77, DEBUG_INFO, "DCF77 transmitter has been created.\n");
LOGP(DDCF77, LOGL_INFO, "DCF77 transmitter has been created.\n");
if (rx->enable)
PDEBUG(DDCF77, DEBUG_INFO, "DCF77 receiver has been created.\n");
LOGP(DDCF77, LOGL_INFO, "DCF77 receiver has been created.\n");
#if 0
void rx_frame_test(dcf77_t *dcf77, const char *string);
@ -467,7 +467,7 @@ void dcf77_destroy(dcf77_t *dcf77)
free(dcf77);
}
PDEBUG(DDCF77, DEBUG_INFO, "DCF77 has been destroyed.\n");
LOGP(DDCF77, LOGL_INFO, "DCF77 has been destroyed.\n");
}
static void display_weather_temperature(const char *desc, uint32_t weather)
@ -512,7 +512,7 @@ time_t dcf77_start_weather(time_t timestamp, int region, int offset)
hour = (19 + (region - 60) / 20) % 24;
}
min = (region % 20) * 3;
PDEBUG(DDCF77, DEBUG_INFO, "Setting UTC time for region %d to %02d:%02d minutes.\n", region, hour, min);
LOGP(DDCF77, LOGL_INFO, "Setting UTC time for region %d to %02d:%02d minutes.\n", region, hour, min);
/* reset to 0:00 UTC at same day */
timestamp -= (timestamp % 86400);
@ -521,7 +521,7 @@ time_t dcf77_start_weather(time_t timestamp, int region, int offset)
timestamp += hour * 3600 + min * 60;
/* substract offset */
PDEBUG(DDCF77, DEBUG_INFO, "Setting timestamp offset to %d minutes.\n", offset);
LOGP(DDCF77, LOGL_INFO, "Setting timestamp offset to %d minutes.\n", offset);
timestamp -= 60 * offset;
return timestamp;
@ -576,7 +576,7 @@ static uint64_t generate_weather(time_t timestamp, int minute, int utc_hour, int
/* generate weather data */
timestamp -= 120;
weather = 0;
PDEBUG(DFRAME, DEBUG_INFO, "Encoding weather for dataset %d/480\n", dataset);
LOGP(DFRAME, LOGL_INFO, "Encoding weather for dataset %d/480\n", dataset);
printf("Peparing Weather INFO\n");
printf("---------------------\n");
printf("Time (UTC): %02d:%02d\n", (int)(timestamp / 3600) % 24, (int)(timestamp / 60) % 60);
@ -694,14 +694,14 @@ static uint16_t tx_weather(dcf77_tx_t *tx, time_t timestamp, int minute, int hou
utc_hour += 24;
/* in index 0 we transmit minute + 1 (next minute), so we substract 1 */
tx->weather_cipher = generate_weather(timestamp, (minute + 59) % 60, utc_hour, tx->weather_day, tx->weather_night, tx->extreme, tx->rain, tx->wind_dir, tx->wind_bft, tx->temperature_day, tx->temperature_night);
PDEBUG(DFRAME, DEBUG_INFO, "Transmitting first chunk of weather info.\n");
LOGP(DFRAME, LOGL_INFO, "Transmitting first chunk of weather info.\n");
chunk = (tx->weather_cipher & 0x3f) << 1; /* bit 2-7 */
chunk |= (tx->weather_cipher & 0x0fc0) << 2; /* bit 9-14 */
tx->weather_cipher >>= 12;
return chunk;
}
PDEBUG(DFRAME, DEBUG_INFO, "Transmitting %s chunk of weather info.\n", (index == 1) ? "second" : "third");
LOGP(DFRAME, LOGL_INFO, "Transmitting %s chunk of weather info.\n", (index == 1) ? "second" : "third");
chunk = tx->weather_cipher & 0x3fff;
tx->weather_cipher >>= 14;
return chunk;
@ -759,7 +759,7 @@ static char tx_symbol(dcf77_t *dcf77, time_t timestamp, int second)
else
zone = 2;
PDEBUG(DDCF77, DEBUG_NOTICE, "The time transmitting: %s %s %d %02d:%02d:%02d %s %02d\n", week_day[wday], month_name[tm->tm_mon + 1], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, time_zone[zone], tm->tm_year + 1900);
LOGP(DDCF77, LOGL_NOTICE, "The time transmitting: %s %s %d %02d:%02d:%02d %s %02d\n", week_day[wday], month_name[tm->tm_mon + 1], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, time_zone[zone], tm->tm_year + 1900);
if ((tm->tm_isdst > 0) != (isdst_next_hour > 0))
frame |= (uint64_t)1 << 16;
@ -808,9 +808,9 @@ static char tx_symbol(dcf77_t *dcf77, time_t timestamp, int second)
tx->data_string[j++] = '0' + ((frame >> i) & 1);
}
tx->data_string[j] = '\0';
PDEBUG(DDSP, DEBUG_INFO, "Start transmission of frame:\n");
PDEBUG(DDSP, DEBUG_INFO, "0 Wetterdaten Info 1 Minute P StundeP Tag WoT Monat Jahr P\n");
PDEBUG(DDSP, DEBUG_INFO, "%s\n", tx->data_string);
LOGP(DDSP, LOGL_INFO, "Start transmission of frame:\n");
LOGP(DDSP, LOGL_INFO, "0 Wetterdaten Info 1 Minute P StundeP Tag WoT Monat Jahr P\n");
LOGP(DDSP, LOGL_INFO, "%s\n", tx->data_string);
}
if (second == 59)
@ -818,7 +818,7 @@ static char tx_symbol(dcf77_t *dcf77, time_t timestamp, int second)
else
symbol = ((tx->data_frame >> second) & 1) + '0';
PDEBUG(DDSP, DEBUG_DEBUG, "Trasmitting symbol '%c' (Bit %d)\n", symbol, second);
LOGP(DDSP, LOGL_DEBUG, "Trasmitting symbol '%c' (Bit %d)\n", symbol, second);
return symbol;
}
@ -910,7 +910,7 @@ static void display_weather(uint32_t weather, int minute, int utc_hour)
int dataset = ((utc_hour + 2) % 24) * 20 + (minute / 3); /* data sets since 22:00 UTC */
int value;
PDEBUG(DFRAME, DEBUG_INFO, "Decoding weather for dataset %d/480\n", dataset);
LOGP(DFRAME, LOGL_INFO, "Decoding weather for dataset %d/480\n", dataset);
printf("Received Weather INFO\n");
printf("---------------------\n");
printf("Time (UTC): %02d:%02d\n", utc_hour, minute);
@ -985,7 +985,7 @@ static void rx_weather(dcf77_rx_t *rx, int minute, int hour, int zone, uint64_t
int32_t weather;
if (rx->weather_index == 0 && index != 0) {
PDEBUG(DFRAME, DEBUG_INFO, "Skipping weather info chunk, waiting for new start of weather info.\n");
LOGP(DFRAME, LOGL_INFO, "Skipping weather info chunk, waiting for new start of weather info.\n");
return;
}
@ -995,15 +995,15 @@ static void rx_weather(dcf77_rx_t *rx, int minute, int hour, int zone, uint64_t
rx->weather_cipher |= (frame >> 3) & 0x0fc0; /* bit 9-14 */
rx->weather_index++;
if (((frame & 0x0002)) || ((frame & 0x0100)) || !rx->weather_cipher) {
PDEBUG(DFRAME, DEBUG_INFO, "There is no weather info in this received minute.\n");
LOGP(DFRAME, LOGL_INFO, "There is no weather info in this received minute.\n");
rx_weather_reset(rx);
return;
}
PDEBUG(DFRAME, DEBUG_INFO, "Got first chunk of weather info.\n");
LOGP(DFRAME, LOGL_INFO, "Got first chunk of weather info.\n");
return;
}
if (rx->weather_index == 1 && index == 1) {
PDEBUG(DFRAME, DEBUG_INFO, "Got second chunk of weather info.\n");
LOGP(DFRAME, LOGL_INFO, "Got second chunk of weather info.\n");
rx->weather_cipher |= (frame << 11) & 0x3fff000; /* bit 1-14 */
rx->weather_key |= (frame >> 21) & 0x7f;
rx->weather_key |= ((frame >> 29) & 0x3f) << 8;
@ -1015,11 +1015,11 @@ static void rx_weather(dcf77_rx_t *rx, int minute, int hour, int zone, uint64_t
return;
}
if (rx->weather_index == 2 && index == 2) {
PDEBUG(DFRAME, DEBUG_INFO, "Got third chunk of weather info.\n");
LOGP(DFRAME, LOGL_INFO, "Got third chunk of weather info.\n");
rx->weather_cipher |= (frame << 25) & 0xfffc000000; /* bit 1-14 */
weather = weather_decode(rx->weather_cipher, rx->weather_key);
if (weather < 0)
PDEBUG(DFRAME, DEBUG_NOTICE, "Failed to decrypt weather info, checksum error.\n");
LOGP(DFRAME, LOGL_NOTICE, "Failed to decrypt weather info, checksum error.\n");
else {
/* convert hour to UTC */
utc_hour = hour - 1;
@ -1035,7 +1035,7 @@ static void rx_weather(dcf77_rx_t *rx, int minute, int hour, int zone, uint64_t
}
rx_weather_reset(rx);
PDEBUG(DFRAME, DEBUG_INFO, "Got weather info chunk out of order, waiting for new start of weather info.\n");
LOGP(DFRAME, LOGL_INFO, "Got weather info chunk out of order, waiting for new start of weather info.\n");
}
/* decode time from received data */
@ -1050,14 +1050,14 @@ static void rx_frame(dcf77_rx_t *rx, uint64_t frame)
int year_one, year_ten, year = -1;
uint64_t p;
PDEBUG(DFRAME, DEBUG_INFO, "Bit 0 is '0'? : %s\n", ((frame >> 0) & 1) ? "no" : "yes");
PDEBUG(DFRAME, DEBUG_INFO, "Bits 1..14 : 0x%04x\n", (int)(frame >> 1) & 0x3fff);
PDEBUG(DFRAME, DEBUG_INFO, "Call Bit : %d\n", (int)(frame >> 15) & 1);
PDEBUG(DFRAME, DEBUG_INFO, "Change Time Zone : %s\n", ((frame >> 16) & 1) ? "yes" : "no");
LOGP(DFRAME, LOGL_INFO, "Bit 0 is '0'? : %s\n", ((frame >> 0) & 1) ? "no" : "yes");
LOGP(DFRAME, LOGL_INFO, "Bits 1..14 : 0x%04x\n", (int)(frame >> 1) & 0x3fff);
LOGP(DFRAME, LOGL_INFO, "Call Bit : %d\n", (int)(frame >> 15) & 1);
LOGP(DFRAME, LOGL_INFO, "Change Time Zone : %s\n", ((frame >> 16) & 1) ? "yes" : "no");
zone = ((frame >> 17) & 3);
PDEBUG(DFRAME, DEBUG_INFO, "Time Zone : %s\n", time_zone[zone]);
PDEBUG(DFRAME, DEBUG_INFO, "Add Leap Second : %s\n", ((frame >> 19) & 1) ? "yes" : "no");
PDEBUG(DFRAME, DEBUG_INFO, "Bit 20 is '1'? : %s\n", ((frame >> 20) & 1) ? "yes" : "no");
LOGP(DFRAME, LOGL_INFO, "Time Zone : %s\n", time_zone[zone]);
LOGP(DFRAME, LOGL_INFO, "Add Leap Second : %s\n", ((frame >> 19) & 1) ? "yes" : "no");
LOGP(DFRAME, LOGL_INFO, "Bit 20 is '1'? : %s\n", ((frame >> 20) & 1) ? "yes" : "no");
minute_one = (frame >> 21 & 0xf);
minute_ten = ((frame >> 25) & 0x7);
@ -1066,10 +1066,10 @@ static void rx_frame(dcf77_rx_t *rx, uint64_t frame)
p = p ^ (p >> 2);
p = p ^ (p >> 1);
if (minute_one > 9 || minute_ten > 5 || (p & 1))
PDEBUG(DFRAME, DEBUG_INFO, "Minute : ???\n");
LOGP(DFRAME, LOGL_INFO, "Minute : ???\n");
else {
minute = minute_ten * 10 + minute_one;
PDEBUG(DFRAME, DEBUG_INFO, "Minute : %02d\n", minute);
LOGP(DFRAME, LOGL_INFO, "Minute : %02d\n", minute);
}
hour_one = (frame >> 29 & 0xf);
@ -1079,10 +1079,10 @@ static void rx_frame(dcf77_rx_t *rx, uint64_t frame)
p = p ^ (p >> 2);
p = p ^ (p >> 1);
if (hour_one > 9 || hour_ten > 2 || (hour_ten == 2 && hour_one > 3) || (p & 1))
PDEBUG(DFRAME, DEBUG_INFO, "Hour : ???\n");
LOGP(DFRAME, LOGL_INFO, "Hour : ???\n");
else {
hour = hour_ten * 10 + hour_one;
PDEBUG(DFRAME, DEBUG_INFO, "Hour : %02d\n", hour);
LOGP(DFRAME, LOGL_INFO, "Hour : %02d\n", hour);
}
day_one = (frame >> 36 & 0xf);
@ -1099,34 +1099,34 @@ static void rx_frame(dcf77_rx_t *rx, uint64_t frame)
p = p ^ (p >> 2);
p = p ^ (p >> 1);
if (day_one > 9 || day_ten > 3 || (day_ten == 3 && day_one > 1) || (day_ten == 0 && day_one == 0) || (p & 1))
PDEBUG(DFRAME, DEBUG_INFO, "Day : ???\n");
LOGP(DFRAME, LOGL_INFO, "Day : ???\n");
else {
day = day_ten * 10 + day_one;
PDEBUG(DFRAME, DEBUG_INFO, "Day : %d\n", day);
LOGP(DFRAME, LOGL_INFO, "Day : %d\n", day);
}
if (wday < 1 || wday > 7 || (p & 1)) {
PDEBUG(DFRAME, DEBUG_INFO, "Week Day : ???\n");
LOGP(DFRAME, LOGL_INFO, "Week Day : ???\n");
wday = -1;
} else
PDEBUG(DFRAME, DEBUG_INFO, "Week Day : %s\n", week_day[wday]);
LOGP(DFRAME, LOGL_INFO, "Week Day : %s\n", week_day[wday]);
if (month_one > 9 || month_ten > 1 || (month_ten == 1 && month_one > 2) || (month_ten == 0 && month_one == 0) || (p & 1))
PDEBUG(DFRAME, DEBUG_INFO, "Month : ???\n");
LOGP(DFRAME, LOGL_INFO, "Month : ???\n");
else {
month = month_ten * 10 + month_one;
PDEBUG(DFRAME, DEBUG_INFO, "Month : %d\n", month);
LOGP(DFRAME, LOGL_INFO, "Month : %d\n", month);
}
if (year_one > 9 || year_ten > 9 || (p & 1))
PDEBUG(DFRAME, DEBUG_INFO, "Year : ???\n");
LOGP(DFRAME, LOGL_INFO, "Year : ???\n");
else {
year = year_ten * 10 + year_one;
PDEBUG(DFRAME, DEBUG_INFO, "Year : %02d\n", year);
LOGP(DFRAME, LOGL_INFO, "Year : %02d\n", year);
}
if (minute >= 0 && hour >= 0 && day >= 0 && wday >= 0 && month >= 0 && year >= 0) {
PDEBUG(DDCF77, DEBUG_NOTICE, "The received time is: %s %s %d %02d:%02d:00 %s 20%02d\n", week_day[wday], month_name[month], day, hour, minute, time_zone[zone], year);
LOGP(DDCF77, LOGL_NOTICE, "The received time is: %s %s %d %02d:%02d:00 %s 20%02d\n", week_day[wday], month_name[month], day, hour, minute, time_zone[zone], year);
rx_weather(rx, minute, hour, zone, frame);
} else {
PDEBUG(DDCF77, DEBUG_NOTICE, "The received time is invalid!\n");
LOGP(DDCF77, LOGL_NOTICE, "The received time is invalid!\n");
rx_weather_reset(rx);
}
}
@ -1151,11 +1151,11 @@ static void rx_symbol(dcf77_t *dcf77, char symbol)
dcf77_rx_t *rx = &dcf77->rx;
double second = -NAN;
PDEBUG(DDSP, DEBUG_DEBUG, "Received symbol '%c'\n", symbol);
LOGP(DDSP, LOGL_DEBUG, "Received symbol '%c'\n", symbol);
if (!rx->data_receive) {
if (symbol == 'm') {
PDEBUG(DDSP, DEBUG_INFO, "Reception of frame has started\n");
LOGP(DDSP, LOGL_INFO, "Reception of frame has started\n");
rx->data_receive = 1;
rx->data_index = 0;
rx->string_index = 0;
@ -1167,20 +1167,20 @@ static void rx_symbol(dcf77_t *dcf77, char symbol)
rx->data_string[rx->string_index] = '\0';
rx->data_index = 0;
rx->string_index = 0;
PDEBUG(DDSP, DEBUG_INFO, "Received complete frame:\n");
PDEBUG(DDSP, DEBUG_INFO, "0 Wetterdaten Info 1 Minute P StundeP Tag WoT Monat Jahr P\n");
PDEBUG(DDSP, DEBUG_INFO, "%s\n", rx->data_string);
LOGP(DDSP, LOGL_INFO, "Received complete frame:\n");
LOGP(DDSP, LOGL_INFO, "0 Wetterdaten Info 1 Minute P StundeP Tag WoT Monat Jahr P\n");
LOGP(DDSP, LOGL_INFO, "%s\n", rx->data_string);
rx_frame(rx, rx->data_frame);
second = 0;
} else {
PDEBUG(DDSP, DEBUG_INFO, "Short read, frame too short\n");
LOGP(DDSP, LOGL_INFO, "Short read, frame too short\n");
rx->data_index = 0;
rx->string_index = 0;
rx_weather_reset(rx);
}
} else {
if (rx->data_index == 59) {
PDEBUG(DDSP, DEBUG_INFO, "Long read, frame too long\n");
LOGP(DDSP, LOGL_INFO, "Long read, frame too long\n");
rx->data_receive = 0;
rx_weather_reset(rx);
} else {
@ -1312,5 +1312,3 @@ void dcf77_decode(dcf77_t *dcf77, sample_t *samples, int length)
}
}

View File

@ -28,7 +28,7 @@
#include <sched.h>
#include <time.h>
#include <math.h>
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../liboptions/options.h"
#include "../libsample/sample.h"
#include "../libsound/sound.h"
@ -146,7 +146,7 @@ void print_help(void)
printf(" --config [~/]<path to config file>\n");
printf(" Give a config file to use. If it starts with '~/', path is at home dir.\n");
printf(" Each line in config file is one option, '-' or '--' must not be given!\n");
debug_print_help();
logging_print_help();
printf(" -a --audio-device hw:<card>,<device>\n");
printf(" Sound card and device number (default = '%s')\n", dsp_device);
printf(" -s --samplerate <rate>\n");
@ -253,13 +253,11 @@ static int handle_options(int short_option, int argi, char **argv)
print_help();
return 0;
case 'v':
if (!strcasecmp(argv[argi], "list")) {
debug_list_cat();
rc = parse_logging_opt(argv[argi]);
if (rc > 0)
return 0;
}
rc = parse_debug_opt(argv[argi]);
if (rc < 0) {
fprintf(stderr, "Failed to parse debug option, please use -h for help.\n");
fprintf(stderr, "Failed to parse logging option, please use -h for help.\n");
return rc;
}
break;
@ -416,14 +414,14 @@ static int get_char()
int soundif_open(const char *audiodev, int samplerate, int buffer_size)
{
if (!audiodev || !audiodev[0]) {
PDEBUG(DDSP, DEBUG_ERROR, "No audio device given!\n");
LOGP(DDSP, LOGL_ERROR, "No audio device given!\n");
return -EINVAL;
}
/* open audiodev */
soundif = sound_open(audiodev, NULL, NULL, NULL, (double_amplitude) ? 2 : 1, 0.0, samplerate, buffer_size, 1.0, 1.0, 0.0, 2.0);
if (!soundif) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to open sound device!\n");
LOGP(DDSP, LOGL_ERROR, "Failed to open sound device!\n");
return -EIO;
}
@ -433,7 +431,7 @@ int soundif_open(const char *audiodev, int samplerate, int buffer_size)
void soundif_start(void)
{
sound_start(soundif);
PDEBUG(DDSP, DEBUG_DEBUG, "Starting audio stream!\n");
LOGP(DDSP, LOGL_DEBUG, "Starting audio stream!\n");
}
void soundif_close(void)
@ -456,7 +454,7 @@ void soundif_work(int buffer_size)
/* encode and write */
count = sound_get_tosend(soundif, buffer_size);
if (count < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count);
LOGP(DDSP, LOGL_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count);
return;
}
if (count) {
@ -467,7 +465,7 @@ void soundif_work(int buffer_size)
}
rc = sound_write(soundif, samples, NULL, count, NULL, NULL, (double_amplitude) ? 2 : 1);
if (rc < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to write TX data to audio device (rc = %d)\n", rc);
LOGP(DDSP, LOGL_ERROR, "Failed to write TX data to audio device (rc = %d)\n", rc);
return;
}
}
@ -475,7 +473,7 @@ void soundif_work(int buffer_size)
/* read */
count = sound_read(soundif, samples, buffer_size, 1, rf_level_db);
if (count < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to read from audio device (rc = %d)!\n", count);
LOGP(DDSP, LOGL_ERROR, "Failed to read from audio device (rc = %d)!\n", count);
return;
}
@ -491,6 +489,8 @@ int main(int argc, char *argv[])
double begin_time, now, sleep;
char c;
logging_init();
/* handle options / config file */
add_options();
rc = options_config_file(argc, argv, "~/.osmocom/dcf77/dcf77.conf", handle_options);
@ -642,3 +642,5 @@ error:
return 0;
}
void osmo_cc_set_log_cat(void) {}

View File

@ -7,7 +7,7 @@ https://github.com/tobozo/esp32-dcf77-weatherman/blob/master/dcf77.cpp
#include <stdio.h>
#include <stdint.h>
#include <endian.h>
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "weather.h"
/// Container zum Konvertieren zwischen 4 Bytes und Uint.
@ -536,9 +536,9 @@ int32_t weather_decode(uint64_t cipher, uint64_t key)
weather = GetWeatherFromPlain(PlainBytes);
#ifdef DEBUG_CIPER
printf("cipher=%s\n", debug_hex(CipherBytes, 5));
printf("key =%s\n", debug_hex(KeyBytes, 5));
printf("plain =%s\n", debug_hex(PlainBytes, 5));
printf("cipher=%s\n", osmo_hexdump(CipherBytes, 5));
printf("key =%s\n", osmo_hexdump(KeyBytes, 5));
printf("plain =%s\n", osmo_hexdump(PlainBytes, 5));
if (weather < 0)
printf("weather=error\n");
else
@ -569,9 +569,9 @@ uint64_t weather_encode(uint32_t weather, uint64_t key)
CipherBytes = Encrypt(PlainBytes, KeyBytes);
#ifdef DEBUG_CIPER
printf("plain =%s\n", debug_hex(PlainBytes, 5));
printf("key =%s\n", debug_hex(KeyBytes, 5));
printf("cipher=%s\n", debug_hex(CipherBytes, 5));
printf("plain =%s\n", osmo_hexdump(PlainBytes, 5));
printf("key =%s\n", osmo_hexdump(KeyBytes, 5));
printf("cipher=%s\n", osmo_hexdump(CipherBytes, 5));
#endif
for (i = 0; i < 5; i++)

View File

@ -16,13 +16,9 @@ eurosignal_LDADD = \
$(COMMON_LA) \
../anetz/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/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libselect/libselect.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfsk/libfsk.a \
@ -30,8 +26,10 @@ eurosignal_LDADD = \
$(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

View File

@ -26,7 +26,7 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "eurosignal.h"
#include "dsp.h"
@ -105,11 +105,11 @@ void dsp_init(int samplerate)
{
int i;
PDEBUG(DDSP, DEBUG_DEBUG, "Generating phase shiftings for tones.\n");
LOGP(DDSP, LOGL_DEBUG, "Generating phase shiftings for tones.\n");
for (i = 0; dsp_digits[i].digit; i++)
dsp_digits[i].phaseshift65536 = 65536.0 / ((double)samplerate / dsp_digits[i].frequency);
PDEBUG(DDSP, DEBUG_DEBUG, "Generating sine table for tones.\n");
LOGP(DDSP, LOGL_DEBUG, "Generating sine table for tones.\n");
for (i = 0; i < 65536; i++)
dsp_tone[i] = sin((double)i / 65536.0 * 2.0 * PI);
}
@ -119,7 +119,7 @@ int dsp_init_sender(euro_t *euro, int samplerate, int fm)
{
int rc = 0;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for 'Sender'.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Init DSP for 'Sender'.\n");
/* set modulation parameters */
if (fm)
@ -154,7 +154,7 @@ error:
/* Cleanup transceiver instance. */
void dsp_cleanup_sender(euro_t *euro)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for 'Sender'.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Cleanup DSP for 'Sender'.\n");
/* cleanup demodulator */
fm_demod_exit(&euro->rx_demod);
@ -201,7 +201,7 @@ static void tone_decode(euro_t *euro, sample_t *samples, int length)
case 'I':
/* pause tone */
if (euro->rx_digit_count == DIGIT_DETECT) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Detected Idle tone, starting.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Detected Idle tone, starting.\n");
euro->rx_digit_receiving = 1;
euro->rx_digit_index = 0;
euro->rx_timeout_count = 0;
@ -213,7 +213,7 @@ static void tone_decode(euro_t *euro, sample_t *samples, int length)
break;
if (euro->rx_digit_count == DIGIT_DETECT) {
/* out of range tone */
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Detected tone out of range, aborting.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Detected tone out of range, aborting.\n");
euro->rx_digit_receiving = 0;
}
break;
@ -225,7 +225,7 @@ static void tone_decode(euro_t *euro, sample_t *samples, int length)
if (euro->rx_digit_count == DIGIT_DETECT) {
double level;
level = sqrt(I[i] * I[i] + Q[i] * Q[i]) * 2;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Detected digit '%s' (level = %.0f%%)\n", digit_to_name(digit), level * 100.0);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Detected digit '%s' (level = %.0f%%)\n", digit_to_name(digit), level * 100.0);
display_measurements_update(euro->dmp_tone_level, level * 100.0, 0.0);
euro->rx_digits[euro->rx_digit_index] = digit;
euro->rx_digit_index++;
@ -243,7 +243,7 @@ static void tone_decode(euro_t *euro, sample_t *samples, int length)
if (euro->rx_digit_receiving && euro->rx_digit_index) {
euro->rx_timeout_count++;
if (euro->rx_timeout_count == TIMEOUT_DETECT) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Timeout receiving, aborting.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Timeout receiving, aborting.\n");
euro->rx_digit_receiving = 0;
}
}
@ -280,18 +280,18 @@ static void tone_send(euro_t *euro, sample_t *samples, int length)
euro->tx_time -= PAUSE_DURATION;
euro_get_id(euro, euro->tx_digits);
euro->tx_digit_index = 0;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Sending digit '%s'\n", digit_to_name(euro->tx_digits[0]));
LOGP_CHAN(DDSP, LOGL_DEBUG, "Sending digit '%s'\n", digit_to_name(euro->tx_digits[0]));
euro->tx_phaseshift65536 = digit_to_phaseshift65536(euro->tx_digits[0]);
}
} else {
if (euro->tx_time >= DIGIT_DURATION) {
euro->tx_time -= DIGIT_DURATION;
if (++euro->tx_digit_index == 6) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Sending Idle tone'\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Sending Idle tone'\n");
euro->tx_digits[0] = '\0';
euro->tx_phaseshift65536 = digit_to_phaseshift65536('I');
} else {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Sending digit '%s'\n", digit_to_name(euro->tx_digits[euro->tx_digit_index]));
LOGP_CHAN(DDSP, LOGL_DEBUG, "Sending digit '%s'\n", digit_to_name(euro->tx_digits[euro->tx_digit_index]));
euro->tx_phaseshift65536 = digit_to_phaseshift65536(euro->tx_digits[euro->tx_digit_index]);
}
}

View File

@ -26,22 +26,22 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include <osmocom/cc/message.h>
#include "eurosignal.h"
#include "dsp.h"
/* announcement timers */
#define ANSWER_TIME 1.0 /* wait after answer */
#define OOO_TIME 3.8 /* announcement 1.7 s, pause 2.1 s */
#define UNASSIGNED_TIME1 2.2 /* announcement 2.2 s s */
#define UNASSIGNED_TIME2 2.9 /* announcement 2.2 s, pause 0.7 s */
#define DEGRADED_TIME 4.95 /* announcement 2.25 s, pause 2.7 s */
#define ACKNOWLEDGE_TIME1 2.8 /* announcement 1.7 s, pause 1.1 s */
#define ACKNOWLEDGE_TIME2 4.6 /* announcement 1.7 s, pause 2.9 s */
#define BEEP_TIME 4.0 /* beep after answer */
#define ANSWER_TIME 1,0 /* wait after answer */
#define OOO_TIME 3,800000 /* announcement 1.7 s, pause 2.1 s */
#define UNASSIGNED_TIME1 2,200000 /* announcement 2.2 s s */
#define UNASSIGNED_TIME2 2,900000 /* announcement 2.2 s, pause 0.7 s */
#define DEGRADED_TIME 4,950000 /* announcement 2.25 s, pause 2.7 s */
#define ACKNOWLEDGE_TIME1 2,800000 /* announcement 1.7 s, pause 1.1 s */
#define ACKNOWLEDGE_TIME2 4,600000 /* announcement 1.7 s, pause 2.9 s */
#define BEEP_TIME 4,000000 /* beep after answer */
/* these calls are not associated with a transmitter */
euro_call_t *ooo_call_list = NULL;
@ -149,7 +149,7 @@ static void call_new_state(euro_call_t *call, enum euro_call_state new_state)
{
if (call->state == new_state)
return;
PDEBUG(DEURO, DEBUG_DEBUG, "State change: %s -> %s\n", call_state_name(call->state), call_state_name(new_state));
LOGP(DEURO, LOGL_DEBUG, "State change: %s -> %s\n", call_state_name(call->state), call_state_name(new_state));
call->state = new_state;
euro_display_status();
}
@ -243,29 +243,29 @@ int euro_create(const char *kanal, const char *device, int use_sdr, int samplera
int rc;
if (euro_kanal2freq(kanal, 0) == 0.0) {
PDEBUG(DEURO, DEBUG_ERROR, "Channel ('Kanal') number %s invalid, use 'list' to get a list.\n", kanal);
LOGP(DEURO, LOGL_ERROR, "Channel ('Kanal') number %s invalid, use 'list' to get a list.\n", kanal);
return -EINVAL;
}
euro = calloc(1, sizeof(*euro));
if (!euro) {
PDEBUG(DEURO, DEBUG_ERROR, "No memory!\n");
LOGP(DEURO, LOGL_ERROR, "No memory!\n");
return -ENOMEM;
}
PDEBUG(DEURO, DEBUG_DEBUG, "Creating 'Eurosignal' instance for 'Kanal' = %s (sample rate %d).\n", kanal, samplerate);
LOGP(DEURO, LOGL_DEBUG, "Creating 'Eurosignal' instance for 'Kanal' = %s (sample rate %d).\n", kanal, samplerate);
/* init general part of transceiver */
rc = sender_create(&euro->sender, kanal, euro_kanal2freq(kanal, fm), euro_kanal2freq(kanal, fm), device, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DEURO, DEBUG_ERROR, "Failed to init transceiver process!\n");
LOGP(DEURO, LOGL_ERROR, "Failed to init transceiver process!\n");
goto error;
}
/* init audio processing */
rc = dsp_init_sender(euro, samplerate, fm);
if (rc < 0) {
PDEBUG(DEURO, DEBUG_ERROR, "Failed to init audio processing!\n");
LOGP(DEURO, LOGL_ERROR, "Failed to init audio processing!\n");
goto error;
}
@ -279,7 +279,7 @@ int euro_create(const char *kanal, const char *device, int use_sdr, int samplera
euro_display_status();
PDEBUG(DEURO, DEBUG_NOTICE, "Created 'Kanal' %s\n", kanal);
LOGP(DEURO, LOGL_NOTICE, "Created 'Kanal' %s\n", kanal);
return 0;
@ -294,7 +294,7 @@ void euro_destroy(sender_t *sender)
{
euro_t *euro = (euro_t *) sender;
PDEBUG(DEURO, DEBUG_DEBUG, "Destroying 'Eurosignal' instance for 'Kanal' = %s.\n", sender->kanal);
LOGP(DEURO, LOGL_DEBUG, "Destroying 'Eurosignal' instance for 'Kanal' = %s.\n", sender->kanal);
while (euro->call_list)
euro_call_destroy(euro->call_list);
@ -308,12 +308,12 @@ static euro_call_t *euro_call_create(euro_t *euro, uint32_t callref, const char
{
euro_call_t *call, **callp;
PDEBUG(DEURO, DEBUG_INFO, "Creating call instance to page ID '%s'.\n", id);
LOGP(DEURO, LOGL_INFO, "Creating call instance to page ID '%s'.\n", id);
/* create */
call = calloc(1, sizeof(*call));
if (!call) {
PDEBUG(DEURO, DEBUG_ERROR, "No mem!\n");
LOGP(DEURO, LOGL_ERROR, "No mem!\n");
abort();
}
@ -322,8 +322,8 @@ static euro_call_t *euro_call_create(euro_t *euro, uint32_t callref, const char
strcpy(call->station_id, id);
if (euro)
call->page_count = euro->repeat;
timer_init(&call->timer, call_timeout, call);
timer_start(&call->timer, ANSWER_TIME);
osmo_timer_setup(&call->timer, call_timeout, call);
osmo_timer_schedule(&call->timer, ANSWER_TIME);
/* link */
call->euro = euro;
@ -347,7 +347,7 @@ static void euro_call_destroy(euro_call_t *call)
(*callp) = call->next;
/* cleanup */
timer_exit(&call->timer);
osmo_timer_del(&call->timer);
/* destroy */
free(call);
@ -364,12 +364,12 @@ void euro_get_id(euro_t *euro, char *id)
if (euro->scan_from < euro->scan_to) {
sprintf(id, "%06d", euro->scan_from++);
PDEBUG_CHAN(DEURO, DEBUG_NOTICE, "Transmitting ID '%s'.\n", id);
LOGP_CHAN(DEURO, LOGL_NOTICE, "Transmitting ID '%s'.\n", id);
goto encode;
}
if (euro->sender.loopback) {
PDEBUG_CHAN(DEURO, DEBUG_NOTICE, "Transmitting test ID '123456'.\n");
LOGP_CHAN(DEURO, LOGL_NOTICE, "Transmitting test ID '123456'.\n");
memcpy(id, "123456", 6);
goto encode;
}
@ -377,7 +377,7 @@ void euro_get_id(euro_t *euro, char *id)
for (call = euro->call_list; call; call = call->next) {
if ((call->state == EURO_CALL_ACKNOWLEDGE || call->state == EURO_CALL_RELEASED) && call->page_count) {
call->page_count--;
PDEBUG_CHAN(DEURO, DEBUG_NOTICE, "Transmitting ID '%s'.\n", call->station_id);
LOGP_CHAN(DEURO, LOGL_NOTICE, "Transmitting ID '%s'.\n", call->station_id);
memcpy(id, call->station_id, 6);
if (call->page_count == 0 && call->state == EURO_CALL_RELEASED)
euro_call_destroy(call);
@ -400,15 +400,15 @@ void euro_get_id(euro_t *euro, char *id)
memcpy(id, euro->random_id, 6);
euro->random_count--;
if (id[0] == 'R') {
PDEBUG_CHAN(DEURO, DEBUG_NOTICE, "Randomly transmitting Idle sequence.\n");
LOGP_CHAN(DEURO, LOGL_NOTICE, "Randomly transmitting Idle sequence.\n");
return;
}
PDEBUG_CHAN(DEURO, DEBUG_NOTICE, "Randomly transmitting ID '%s'.\n", euro->random_id);
LOGP_CHAN(DEURO, LOGL_NOTICE, "Randomly transmitting ID '%s'.\n", euro->random_id);
goto encode;
}
if (!call) {
PDEBUG_CHAN(DEURO, DEBUG_DEBUG, "Transmitting Idle sequence.\n");
LOGP_CHAN(DEURO, LOGL_DEBUG, "Transmitting Idle sequence.\n");
memcpy(id, "RIIIII", 6);
return;
}
@ -432,7 +432,7 @@ void euro_receive_id(euro_t *euro, char *id)
int count = 0;
if (id[0] == 'R') {
PDEBUG_CHAN(DEURO, DEBUG_DEBUG, "Received Idle sequence'\n");
LOGP_CHAN(DEURO, LOGL_DEBUG, "Received Idle sequence'\n");
return;
}
@ -444,7 +444,7 @@ void euro_receive_id(euro_t *euro, char *id)
/* loopback display */
if (euro->sender.loopback) {
PDEBUG_CHAN(DEURO, DEBUG_NOTICE, "Received ID '%s'\n", id);
LOGP_CHAN(DEURO, LOGL_NOTICE, "Received ID '%s'\n", id);
return;
}
@ -452,12 +452,12 @@ void euro_receive_id(euro_t *euro, char *id)
if (id_list) {
count = search_id(id);
if (!count) {
PDEBUG_CHAN(DEURO, DEBUG_INFO, "Received ID '%s' is not for us.\n", id);
LOGP_CHAN(DEURO, LOGL_INFO, "Received ID '%s' is not for us.\n", id);
return;
}
}
PDEBUG_CHAN(DEURO, DEBUG_NOTICE, "Received ID '%s'\n", id);
LOGP_CHAN(DEURO, LOGL_NOTICE, "Received ID '%s'\n", id);
/* we want to send beep via MNCC */
if (id_list) {
@ -475,7 +475,7 @@ void euro_receive_id(euro_t *euro, char *id)
return;
/* create call and send setup */
PDEBUG_CHAN(DEURO, DEBUG_INFO, "Sending setup towards network.'\n");
LOGP_CHAN(DEURO, LOGL_INFO, "Sending setup towards network.'\n");
sprintf(dialing, "%d", count);
callref = call_up_setup(call->station_id, dialing, OSMO_CC_NETWORK_EUROSIGNAL_NONE, "");
call = euro_call_create(NULL, callref, id);
@ -557,43 +557,43 @@ static void call_timeout(void *data)
case EURO_CALL_ANSWER:
/* if no station is linked to the call, we are out-of-order */
if (!call->euro) {
PDEBUG(DEURO, DEBUG_INFO, "Station is unavailable, playing announcement.\n");
LOGP(DEURO, LOGL_INFO, "Station is unavailable, playing announcement.\n");
call->announcement_spl = es_ges_spl;
call->announcement_size = es_ges_size;
call->announcement_index = 0;
timer_start(&call->timer, OOO_TIME);
osmo_timer_schedule(&call->timer, OOO_TIME);
call_new_state(call, EURO_CALL_OUTOFORDER);
break;
}
/* if subcriber list is available, but ID is not found, we are unassigned */
if (id_list && !search_id(call->station_id)) {
PDEBUG(DEURO, DEBUG_INFO, "Subscriber unknown, playing announcement.\n");
LOGP(DEURO, LOGL_INFO, "Subscriber unknown, playing announcement.\n");
call->announcement_spl = es_kaudn_spl;
call->announcement_size = es_kaudn_size;
call->announcement_index = 0;
call->announcement_count = 1;
timer_start(&call->timer, UNASSIGNED_TIME1);
osmo_timer_schedule(&call->timer, UNASSIGNED_TIME1);
call_new_state(call, EURO_CALL_UNASSIGNED);
break;
}
/* if station is degraded, play that announcement */
if (call->euro->degraded) {
PDEBUG(DEURO, DEBUG_INFO, "Station is degraded, playing announcement.\n");
LOGP(DEURO, LOGL_INFO, "Station is degraded, playing announcement.\n");
call->announcement_spl = es_teilges_spl;
call->announcement_size = es_teilges_size;
call->announcement_index = 0;
timer_start(&call->timer, DEGRADED_TIME);
osmo_timer_schedule(&call->timer, DEGRADED_TIME);
call_new_state(call, EURO_CALL_DEGRADED);
break;
}
/* fall through */
case EURO_CALL_DEGRADED:
PDEBUG(DEURO, DEBUG_INFO, "Station acknowledges, playing announcement.\n");
LOGP(DEURO, LOGL_INFO, "Station acknowledges, playing announcement.\n");
call->announcement_spl = es_mitte_spl;
call->announcement_size = es_mitte_size;
call->announcement_index = 0;
call->announcement_count = 1;
timer_start(&call->timer, ACKNOWLEDGE_TIME1);
osmo_timer_schedule(&call->timer, ACKNOWLEDGE_TIME1);
call_new_state(call, EURO_CALL_ACKNOWLEDGE);
break;
case EURO_CALL_ACKNOWLEDGE:
@ -602,22 +602,22 @@ static void call_timeout(void *data)
call->announcement_size = es_mitte_size;
call->announcement_index = 0;
call->announcement_count = 2;
timer_start(&call->timer, ACKNOWLEDGE_TIME2);
osmo_timer_schedule(&call->timer, ACKNOWLEDGE_TIME2);
break;
}
if (call->page_count) {
PDEBUG(DEURO, DEBUG_INFO, "Announcement played, receiver has not been paged yet, releasing call.\n");
LOGP(DEURO, LOGL_INFO, "Announcement played, receiver has not been paged yet, releasing call.\n");
call_up_release(call->callref, CAUSE_NORMAL);
call->callref = 0;
call_new_state(call, EURO_CALL_RELEASED);
break;
}
PDEBUG(DEURO, DEBUG_INFO, "Announcement played, receiver has been paged, releasing call.\n");
LOGP(DEURO, LOGL_INFO, "Announcement played, receiver has been paged, releasing call.\n");
call_up_release(call->callref, CAUSE_NORMAL);
euro_call_destroy(call);
break;
case EURO_CALL_OUTOFORDER:
PDEBUG(DEURO, DEBUG_INFO, "Announcement played, releasing call.\n");
LOGP(DEURO, LOGL_INFO, "Announcement played, releasing call.\n");
call_up_release(call->callref, CAUSE_NORMAL);
euro_call_destroy(call);
break;
@ -627,18 +627,18 @@ static void call_timeout(void *data)
call->announcement_size = es_kaudn_size;
call->announcement_index = 0;
call->announcement_count = 2;
timer_start(&call->timer, UNASSIGNED_TIME2);
osmo_timer_schedule(&call->timer, UNASSIGNED_TIME2);
break;
}
PDEBUG(DEURO, DEBUG_INFO, "Announcement played, playing again.\n");
LOGP(DEURO, LOGL_INFO, "Announcement played, playing again.\n");
call->announcement_spl = es_kaudn_spl;
call->announcement_size = es_kaudn_size;
call->announcement_index = 0;
call->announcement_count = 1;
timer_start(&call->timer, UNASSIGNED_TIME1);
osmo_timer_schedule(&call->timer, UNASSIGNED_TIME1);
break;
case EURO_CALL_BEEPING:
PDEBUG(DEURO, DEBUG_INFO, "Beep played, releasing.\n");
LOGP(DEURO, LOGL_INFO, "Beep played, releasing.\n");
call_up_release(call->callref, CAUSE_NORMAL);
call->callref = 0;
euro_call_destroy(call);
@ -670,9 +670,9 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
/* just (ab)use busy signal when no station is available */
if (!sender) {
if (channel)
PDEBUG(DEURO, DEBUG_NOTICE, "Cannot page receiver, because given station not available, rejecting!\n");
LOGP(DEURO, LOGL_NOTICE, "Cannot page receiver, because given station not available, rejecting!\n");
else
PDEBUG(DEURO, DEBUG_NOTICE, "Cannot page receiver, no station not available, rejecting!\n");
LOGP(DEURO, LOGL_NOTICE, "Cannot page receiver, no station not available, rejecting!\n");
euro = NULL;
}
@ -688,19 +688,19 @@ void call_down_answer(int __attribute__((unused)) callref)
{
euro_call_t *call;
PDEBUG(DEURO, DEBUG_INFO, "Call has been answered by network.\n");
LOGP(DEURO, LOGL_INFO, "Call has been answered by network.\n");
for (call = ooo_call_list; call; call = call->next) {
if (call->callref == callref)
break;
}
if (!call) {
PDEBUG(DEURO, DEBUG_NOTICE, "Answer from network, but no callref!\n");
LOGP(DEURO, LOGL_NOTICE, "Answer from network, but no callref!\n");
call_up_release(callref, CAUSE_INVALCALLREF);
return;
}
timer_start(&call->timer, BEEP_TIME);
osmo_timer_schedule(&call->timer, BEEP_TIME);
}
static void _release(int callref, int __attribute__((unused)) cause)
@ -709,7 +709,7 @@ static void _release(int callref, int __attribute__((unused)) cause)
euro_t *euro;
euro_call_t *call;
PDEBUG(DEURO, DEBUG_INFO, "Call has been disconnected by network.\n");
LOGP(DEURO, LOGL_INFO, "Call has been disconnected by network.\n");
for (sender = sender_head; sender; sender = sender->next) {
euro = (euro_t *) sender;
@ -727,7 +727,7 @@ static void _release(int callref, int __attribute__((unused)) cause)
}
}
if (!call) {
PDEBUG(DEURO, DEBUG_NOTICE, "Outgoing disconnect, but no callref!\n");
LOGP(DEURO, LOGL_NOTICE, "Outgoing disconnect, but no callref!\n");
call_up_release(callref, CAUSE_INVALCALLREF);
return;
}

View File

@ -1,6 +1,6 @@
#include "../libfm/fm.h"
#include "../libmobile/sender.h"
#include "../libtimer/timer.h"
#include <osmocom/core/timer.h>
/* current state of transmitter */
enum euro_health_state {
@ -30,7 +30,7 @@ typedef struct euro_call {
int callref; /* call reference */
char station_id[7]; /* current station ID */
int page_count; /* number of transmissions left */
struct timer timer;
struct osmo_timer_list timer;
enum euro_call_state state; /* current state */
int announcement_count; /* used to replay annoucements */
int16_t *announcement_spl; /* current sample */

View File

@ -23,7 +23,7 @@
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/main_mobile.h"
#include "../liboptions/options.h"
@ -247,6 +247,7 @@ fail:
euro_destroy(sender_head);
/* exits */
main_mobile_exit();
fm_exit();
euro_exit();

View File

@ -12,22 +12,20 @@ bin_PROGRAMS = \
$(COMMON_LA) \
../anetz/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/libtimer/libtimer.a \
$(top_builddir)/src/libselect/libselect.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

View File

@ -26,7 +26,7 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "fuenf.h"
#include "dsp.h"
@ -106,7 +106,7 @@ int dsp_init_sender(fuenf_t *fuenf, int samplerate, double max_deviation, double
sample_t *spl;
int len;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for transceiver.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Init DSP for transceiver.\n");
/* set modulation parameters */
sender_set_fm(&fuenf->sender, max_deviation, MAX_MODULATION, signal_deviation, MAX_DISPLAY);
@ -129,7 +129,7 @@ int dsp_init_sender(fuenf_t *fuenf, int samplerate, double max_deviation, double
len = (int)(8000.0 * (1.0 / RX_TOL_TONE_FREQ) + 0.5);
spl = calloc(1, len * sizeof(*spl));
if (!spl) {
PDEBUG(DDSP, DEBUG_ERROR, "No memory!\n");
LOGP(DDSP, LOGL_ERROR, "No memory!\n");
goto error;
}
fuenf->rx_tone_filter_spl = spl;
@ -154,7 +154,7 @@ error:
/* Cleanup transceiver instance. */
void dsp_cleanup_sender(fuenf_t *fuenf)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for transceiver.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Cleanup DSP for transceiver.\n");
/* free tone buffers */
if (fuenf->rx_tone_filter_spl)
@ -228,7 +228,7 @@ static void digit_decode(fuenf_t *fuenf, sample_t *samples, int length)
break;
/* check if we have enought silence */
if (fuenf->rx_digit_count == RX_MIN_PREAMBLE) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Detected silence, waiting for digits.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Detected silence, waiting for digits.\n");
fuenf->rx_state = RX_STATE_IDLE;
break;
}
@ -237,7 +237,7 @@ static void digit_decode(fuenf_t *fuenf, sample_t *samples, int length)
/* wait for digit */
if (d < 0)
break;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "We have some tone, start receiving digits.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "We have some tone, start receiving digits.\n");
fuenf->rx_callsign_count = 0;
fuenf->rx_callsign[fuenf->rx_callsign_count] = d;
fuenf->rx_state = RX_STATE_DIGIT;
@ -247,18 +247,18 @@ static void digit_decode(fuenf_t *fuenf, sample_t *samples, int length)
if (!change) {
if (fuenf->rx_digit_count == RX_LEN_DIGIT_TH) {
if (d < 0) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Not enough digits received, waiting for next transmission.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Not enough digits received, waiting for next transmission.\n");
fuenf->rx_function = 0;
fuenf->rx_function_count = 0;
fuenf->rx_state = RX_STATE_RESET;
break;
}
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Detected digit #%d (amplitude = %.0f%%)\n", d + 1, sqrt(a) * 100.0);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Detected digit #%d (amplitude = %.0f%%)\n", d + 1, sqrt(a) * 100.0);
display_measurements_update(fuenf->dmp_digit_level, sqrt(a) * 100.0, 0.0);
break;
}
if (fuenf->rx_digit_count == RX_LEN_DIGIT_MAX) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Detected digit too long, waiting for next transmission.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Detected digit too long, waiting for next transmission.\n");
fuenf->rx_state = RX_STATE_RESET;
break;
}
@ -272,7 +272,7 @@ static void digit_decode(fuenf_t *fuenf, sample_t *samples, int length)
}
/* if counter (when changed) was too low */
if (change_count < RX_LEN_DIGIT_MIN) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Detected digit too short, waiting for next transmission.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Detected digit too short, waiting for next transmission.\n");
fuenf->rx_state = RX_STATE_RESET;
break;
}
@ -284,7 +284,7 @@ static void digit_decode(fuenf_t *fuenf, sample_t *samples, int length)
for (i = 0; i < 5; i++) {
if (fuenf->rx_callsign[i] == REPEAT_DIGIT) {
if (i == 0) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "First digit is a repeat digit, this is not allowed, waiting for next transmission.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "First digit is a repeat digit, this is not allowed, waiting for next transmission.\n");
fuenf->rx_state = RX_STATE_RESET;
break;
}
@ -298,7 +298,7 @@ static void digit_decode(fuenf_t *fuenf, sample_t *samples, int length)
fuenf->rx_callsign[i] = '\0';
if (i < 5)
break;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Complete call sign '%s' received, waiting for signal tone(s).\n", fuenf->rx_callsign);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Complete call sign '%s' received, waiting for signal tone(s).\n", fuenf->rx_callsign);
fuenf_rx_callsign(fuenf, fuenf->rx_callsign);
fuenf->rx_function_count = 0; /* must reset, so we can detect timeout */
fuenf->rx_state = RX_STATE_WAIT_SIGNAL;
@ -362,7 +362,7 @@ static void tone_decode(fuenf_t *fuenf, sample_t *samples, int length)
/* wait for signal */
if (!funktion) {
if (fuenf->rx_function_count >= RX_WAIT_TONE_MAX) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "There is no double tone, waiting for next transmission.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "There is no double tone, waiting for next transmission.\n");
fuenf->rx_state = RX_STATE_RESET;
break;
}
@ -376,13 +376,13 @@ static void tone_decode(fuenf_t *fuenf, sample_t *samples, int length)
case RX_STATE_SIGNAL:
/* if signal ceases too early */
if (funktion != fuenf->rx_function) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Signal tones ceased to early, waiting for next transmission.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Signal tones ceased to early, waiting for next transmission.\n");
fuenf->rx_state = RX_STATE_RESET;
break;
}
if (fuenf->rx_function_count >= RX_LEN_TONE_MIN) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Detected tones %.0f+%.0f Hz (amplitude = %.0f%%+%.0f%%)\n", tone_freq[tone1], tone_freq[tone2], fuenf->rx_tone_levels[tone1] * 100.0, fuenf->rx_tone_levels[tone2] * 100.0);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Signal tones detected, done, waiting for next transmission.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Detected tones %.0f+%.0f Hz (amplitude = %.0f%%+%.0f%%)\n", tone_freq[tone1], tone_freq[tone2], fuenf->rx_tone_levels[tone1] * 100.0, fuenf->rx_tone_levels[tone2] * 100.0);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Signal tones detected, done, waiting for next transmission.\n");
fuenf_rx_function(fuenf, fuenf->rx_function);
fuenf->rx_state = RX_STATE_RESET;
break;
@ -435,11 +435,11 @@ int dsp_setup(fuenf_t *fuenf, const char *rufzeichen, enum fuenf_funktion funkti
fuenf->tx_seq_length = 0;
if (strlen(rufzeichen) != 5) {
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "Given call sign has invalid length.\n");
LOGP_CHAN(DDSP, LOGL_ERROR, "Given call sign has invalid length.\n");
return -EINVAL;
}
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Generating sequence for call sign '%s' and function code '%d'.\n", rufzeichen, funktion);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Generating sequence for call sign '%s' and function code '%d'.\n", rufzeichen, funktion);
/* add preamble */
seq[index].phasestep1 = 0;
@ -451,7 +451,7 @@ int dsp_setup(fuenf_t *fuenf, const char *rufzeichen, enum fuenf_funktion funkti
tone_index = index;
for (i = 0; rufzeichen[i]; i++) {
if (rufzeichen[i] < '0' || rufzeichen[i] > '9') {
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "Given call sign has invalid digit '%c'.\n", rufzeichen[i]);
LOGP_CHAN(DDSP, LOGL_ERROR, "Given call sign has invalid digit '%c'.\n", rufzeichen[i]);
return -EINVAL;
}
if (rufzeichen[i] == '0')
@ -461,9 +461,9 @@ int dsp_setup(fuenf_t *fuenf, const char *rufzeichen, enum fuenf_funktion funkti
/* use repeat digit, if two subsequent digits are the same */
if (i > 0 && seq[index - 1].phasestep1 == seq[index].phasestep1) {
seq[index].phasestep1 = 2.0 * M_PI * digit_freq[REPEAT_DIGIT] * fuenf->sample_duration;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, " -> Adding digit '%c' as tone with %.0f Hz.\n", rufzeichen[i], digit_freq[REPEAT_DIGIT]);
LOGP_CHAN(DDSP, LOGL_DEBUG, " -> Adding digit '%c' as tone with %.0f Hz.\n", rufzeichen[i], digit_freq[REPEAT_DIGIT]);
} else
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, " -> Adding digit '%c' as tone with %.0f Hz.\n", rufzeichen[i], digit_freq[rufzeichen[i] - '0']);
LOGP_CHAN(DDSP, LOGL_DEBUG, " -> Adding digit '%c' as tone with %.0f Hz.\n", rufzeichen[i], digit_freq[rufzeichen[i] - '0']);
seq[index].phasestep2 = 0;
seq[index].duration = TX_LEN_DIGIT;
index++;
@ -493,7 +493,7 @@ int dsp_setup(fuenf_t *fuenf, const char *rufzeichen, enum fuenf_funktion funkti
#ifndef DEBUG
if (funktion == FUENF_FUNKTION_RUF) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, " -> Adding call signal of %.0f Hz.\n", digit_freq[REPEAT_DIGIT]);
LOGP_CHAN(DDSP, LOGL_DEBUG, " -> Adding call signal of %.0f Hz.\n", digit_freq[REPEAT_DIGIT]);
for (i = 0; i < TX_NUM_KANAL; i++) {
/* add tone (double volume) */
seq[index].phasestep1 = 2.0 * M_PI * digit_freq[REPEAT_DIGIT] * fuenf->sample_duration;
@ -522,7 +522,7 @@ int dsp_setup(fuenf_t *fuenf, const char *rufzeichen, enum fuenf_funktion funkti
if (signals[i].funktion == funktion)
break;
}
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, " -> Adding call signal of %.0f Hz and %.0f Hz.\n", tone_freq[signals[i].tone1], tone_freq[signals[i].tone2]);
LOGP_CHAN(DDSP, LOGL_DEBUG, " -> Adding call signal of %.0f Hz and %.0f Hz.\n", tone_freq[signals[i].tone1], tone_freq[signals[i].tone2]);
seq[index].phasestep1 = 2.0 * M_PI * tone_freq[signals[i].tone1] * fuenf->sample_duration;
seq[index].phasestep2 = 2.0 * M_PI * tone_freq[signals[i].tone2] * fuenf->sample_duration;
seq[index].duration = TX_LEN_SIGNAL;
@ -532,7 +532,7 @@ int dsp_setup(fuenf_t *fuenf, const char *rufzeichen, enum fuenf_funktion funkti
/* check array overflow, if it did not already crashed before */
if (index > (int)(sizeof(fuenf->tx_seq) / sizeof(fuenf->tx_seq[0]))) {
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "Array size of tx_seq too small, please fix!\n");
LOGP_CHAN(DDSP, LOGL_ERROR, "Array size of tx_seq too small, please fix!\n");
abort();
}

View File

@ -26,10 +26,10 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include <osmocom/cc/message.h>
#include "../liboptions/options.h"
#include "fuenf.h"
#include "dsp.h"
@ -149,7 +149,7 @@ void fuenf_new_state(fuenf_t *fuenf, enum fuenf_state new_state)
{
if (fuenf->state == new_state)
return;
PDEBUG_CHAN(DFUENF, DEBUG_DEBUG, "State change: %s -> %s\n", fuenf_state_name[fuenf->state], fuenf_state_name[new_state]);
LOGP_CHAN(DFUENF, LOGL_DEBUG, "State change: %s -> %s\n", fuenf_state_name[fuenf->state], fuenf_state_name[new_state]);
fuenf->state = new_state;
fuenf_display_status();
}
@ -160,13 +160,13 @@ static int fuenf_scan_or_loopback(fuenf_t *fuenf)
if (fuenf->scan_from < fuenf->scan_to) {
sprintf(rufzeichen, "%05d", fuenf->scan_from++);
PDEBUG_CHAN(DFUENF, DEBUG_NOTICE, "Transmitting ID '%s'.\n", rufzeichen);
LOGP_CHAN(DFUENF, LOGL_NOTICE, "Transmitting ID '%s'.\n", rufzeichen);
dsp_setup(fuenf, rufzeichen, fuenf->default_funktion);
return 1;
}
if (fuenf->sender.loopback) {
PDEBUG(DFUENF, DEBUG_INFO, "Sending 5-Ton-Ruf for loopback test.\n");
LOGP(DFUENF, LOGL_INFO, "Sending 5-Ton-Ruf for loopback test.\n");
dsp_setup(fuenf, "10357", FUENF_FUNKTION_FEUER);
return 1;
}
@ -182,23 +182,23 @@ int fuenf_create(const char *kanal, double frequency, const char *device, int us
fuenf = calloc(1, sizeof(*fuenf));
if (!fuenf) {
PDEBUG(DFUENF, DEBUG_ERROR, "No memory!\n");
LOGP(DFUENF, LOGL_ERROR, "No memory!\n");
return -ENOMEM;
}
PDEBUG(DFUENF, DEBUG_DEBUG, "Creating '5-Ton-Folge' instance for 'Kanal' = %s (sample rate %d).\n", kanal, samplerate);
LOGP(DFUENF, LOGL_DEBUG, "Creating '5-Ton-Folge' instance for 'Kanal' = %s (sample rate %d).\n", kanal, samplerate);
/* init general part of transceiver */
rc = sender_create(&fuenf->sender, kanal, frequency, frequency, device, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DFUENF, DEBUG_ERROR, "Failed to init transceiver process!\n");
LOGP(DFUENF, LOGL_ERROR, "Failed to init transceiver process!\n");
goto error;
}
/* init audio processing */
rc = dsp_init_sender(fuenf, samplerate, max_deviation, signal_deviation);
if (rc < 0) {
PDEBUG(DFUENF, DEBUG_ERROR, "Failed to init audio processing!\n");
LOGP(DFUENF, LOGL_ERROR, "Failed to init audio processing!\n");
goto error;
}
@ -210,7 +210,7 @@ int fuenf_create(const char *kanal, double frequency, const char *device, int us
fuenf_display_status();
PDEBUG(DFUENF, DEBUG_NOTICE, "Created 'Kanal' %s\n", kanal);
LOGP(DFUENF, LOGL_NOTICE, "Created 'Kanal' %s\n", kanal);
/* start scanning, if enabled, otherwise send loopback sequence, if enabled */
fuenf_scan_or_loopback(fuenf);
@ -228,7 +228,7 @@ void fuenf_destroy(sender_t *sender)
{
fuenf_t *fuenf = (fuenf_t *) sender;
PDEBUG(DFUENF, DEBUG_DEBUG, "Destroying '5-Ton-Folge' instance for 'Kanal' = %s.\n", sender->kanal);
LOGP(DFUENF, LOGL_DEBUG, "Destroying '5-Ton-Folge' instance for 'Kanal' = %s.\n", sender->kanal);
dsp_cleanup_sender(fuenf);
sender_destroy(&fuenf->sender);
@ -238,7 +238,7 @@ void fuenf_destroy(sender_t *sender)
/* call sign was transmitted */
void fuenf_tx_done(fuenf_t *fuenf)
{
PDEBUG_CHAN(DFUENF, DEBUG_INFO, "Done sending 5-Ton-Ruf.\n");
LOGP_CHAN(DFUENF, LOGL_INFO, "Done sending 5-Ton-Ruf.\n");
/* start scanning, if enabled, otherwise send loopback sequence, if enabled */
if (fuenf_scan_or_loopback(fuenf)) {
@ -247,7 +247,7 @@ void fuenf_tx_done(fuenf_t *fuenf)
/* go talker state */
if (fuenf->callref && fuenf->tx_funktion == FUENF_FUNKTION_RUF) {
PDEBUG_CHAN(DFUENF, DEBUG_INFO, "Caller may talk now.\n");
LOGP_CHAN(DFUENF, LOGL_INFO, "Caller may talk now.\n");
fuenf_new_state(fuenf, FUENF_STATE_DURCHSAGE);
return;
}
@ -255,19 +255,19 @@ void fuenf_tx_done(fuenf_t *fuenf)
/* go idle */
fuenf_new_state(fuenf, FUENF_STATE_IDLE);
if (fuenf->callref) {
PDEBUG_CHAN(DFUENF, DEBUG_INFO, "Releasing call toward network.\n");
LOGP_CHAN(DFUENF, LOGL_INFO, "Releasing call toward network.\n");
call_up_release(fuenf->callref, CAUSE_NORMAL);
}
}
void fuenf_rx_callsign(fuenf_t *fuenf, const char *callsign)
{
PDEBUG_CHAN(DFUENF, DEBUG_INFO, "Received 5-Ton-Ruf with call sign '%s'.\n", callsign);
LOGP_CHAN(DFUENF, LOGL_INFO, "Received 5-Ton-Ruf with call sign '%s'.\n", callsign);
}
void fuenf_rx_function(fuenf_t *fuenf, enum fuenf_funktion funktion)
{
PDEBUG_CHAN(DFUENF, DEBUG_INFO, "Received function '%s'.\n", fuenf_funktion_name[funktion]);
LOGP_CHAN(DFUENF, LOGL_INFO, "Received function '%s'.\n", fuenf_funktion_name[funktion]);
}
void call_down_clock(void)
@ -298,9 +298,9 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
}
if (!sender) {
if (channel)
PDEBUG(DFUENF, DEBUG_NOTICE, "Cannot page, because given station not available, rejecting!\n");
LOGP(DFUENF, LOGL_NOTICE, "Cannot page, because given station not available, rejecting!\n");
else
PDEBUG(DFUENF, DEBUG_NOTICE, "Cannot page, no trasmitting station idle, rejecting!\n");
LOGP(DFUENF, LOGL_NOTICE, "Cannot page, no trasmitting station idle, rejecting!\n");
return -CAUSE_NOCHANNEL;
}
@ -335,7 +335,7 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
return -CAUSE_INVALNUMBER;
}
PDEBUG_CHAN(DFUENF, DEBUG_INFO, "Sending 5-Ton-Ruf with call sign '%s' and function '%s'.\n", rufzeichen, fuenf_funktion_name[funktion]);
LOGP_CHAN(DFUENF, LOGL_INFO, "Sending 5-Ton-Ruf with call sign '%s' and function '%s'.\n", rufzeichen, fuenf_funktion_name[funktion]);
dsp_setup(fuenf, rufzeichen, funktion);
@ -357,7 +357,7 @@ static void _release(int __attribute__((unused)) callref, int __attribute__((unu
sender_t *sender;
fuenf_t *fuenf;
PDEBUG(DFUENF, DEBUG_INFO, "Call has been disconnected by network.\n");
LOGP(DFUENF, LOGL_INFO, "Call has been disconnected by network.\n");
for (sender = sender_head; sender; sender = sender->next) {
fuenf = (fuenf_t *) sender;
@ -365,7 +365,7 @@ static void _release(int __attribute__((unused)) callref, int __attribute__((unu
break;
}
if (!sender) {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Outgoing release, but no callref!\n");
LOGP(DBNETZ, LOGL_NOTICE, "Outgoing release, but no callref!\n");
/* don't send release, because caller already released */
return;
}

View File

@ -27,7 +27,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/main_mobile.h"
#include "../liboptions/options.h"
@ -259,6 +259,7 @@ fail:
fuenf_destroy(sender_head);
/* exits */
main_mobile_exit();
fm_exit();
fuenf_exit();

View File

@ -15,14 +15,10 @@ fuvst_LDADD = \
../anetz/libgermanton.a \
../cnetz/libcnetztones.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/libcompandor/libcompandor.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libselect/libselect.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfm/libfm.a \
@ -32,8 +28,10 @@ fuvst_LDADD = \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/liblogging/liblogging.a \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOCC_LIBS) \
$(ALSA_LIBS) \
-lm
@ -42,14 +40,10 @@ fuvst_sniffer_SOURCES = \
fuvst_sniffer_LDADD = \
$(COMMON_LA) \
$(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/libcompandor/libcompandor.a \
$(top_builddir)/src/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libselect/libselect.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfm/libfm.a \
@ -59,8 +53,10 @@ fuvst_sniffer_LDADD = \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libsound/libsound.a \
$(top_builddir)/src/libg711/libg711.a \
$(top_builddir)/src/libaaimage/libaaimage.a \
$(top_builddir)/src/liblogging/liblogging.a \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOCC_LIBS) \
$(ALSA_LIBS) \
-lm

View File

@ -35,12 +35,14 @@
#include <time.h>
#include <inttypes.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../liboptions/options.h"
#include "../libmobile/call.h"
#include "../libmobile/cause.h"
#include "../libtimer/timer.h"
#include "../libosmocc/message.h"
#include "../libmobile/get_time.h"
#include <osmocom/core/timer.h>
#include <osmocom/core/utils.h>
#include <osmocom/cc/message.h>
#include "fuvst.h"
/* digital loopback test */
@ -120,21 +122,21 @@ int config_file(const char *filename)
uint8_t byte;
if (!fp) {
PDEBUG(DTRANS, DEBUG_ERROR, "Failed to open data base file: '%s'\n", filename);
LOGP(DTRANS, LOGL_ERROR, "Failed to open data base file: '%s'\n", filename);
return -EIO;
}
rc = fread(conf.data, 1, sizeof(conf.data), fp);
if (rc < (int)sizeof(conf.data)) {
fclose(fp);
PDEBUG(DTRANS, DEBUG_ERROR, "Data base file shorter than %d bytes. This seems not to be a valid config file.\n", (int)sizeof(conf.data));
LOGP(DTRANS, LOGL_ERROR, "Data base file shorter than %d bytes. This seems not to be a valid config file.\n", (int)sizeof(conf.data));
return -EIO;
}
rc = fread(&byte, 1, 1, fp);
if (rc == 1) {
fclose(fp);
PDEBUG(DTRANS, DEBUG_ERROR, "Data base file larger than %d bytes. (Don't use the EEPROM config format, use the MSC config format.)\n", (int)sizeof(conf.data));
LOGP(DTRANS, LOGL_ERROR, "Data base file larger than %d bytes. (Don't use the EEPROM config format, use the MSC config format.)\n", (int)sizeof(conf.data));
return -EIO;
}
@ -156,10 +158,10 @@ static void config_send(uint8_t ident, uint8_t job, uint16_t offset, uint16_t le
uint32_t checksum = 0;
uint8_t rc = 1; /* Auftrag angenommen */
PDEBUG(DCNETZ, DEBUG_NOTICE, "MSC requests data base block. (offset=%d, length=%d)\n", offset, length);
LOGP(DCNETZ, LOGL_NOTICE, "MSC requests data base block. (offset=%d, length=%d)\n", offset, length);
if (!conf.loaded) {
PDEBUG(DCNETZ, DEBUG_ERROR, "MSC requests data base, but no file name given. Please give file name!\n");
LOGP(DCNETZ, LOGL_ERROR, "MSC requests data base, but no file name given. Please give file name!\n");
error:
/* return error */
len = encode_xedbu_1(&opcode, &data, 16, job, 0);
@ -168,7 +170,7 @@ error:
}
if (offset + length > sizeof(conf.data)) {
PDEBUG(DCNETZ, DEBUG_ERROR, "Requested date out of range!\n");
LOGP(DCNETZ, LOGL_ERROR, "Requested date out of range!\n");
goto error;
}
@ -262,7 +264,7 @@ void add_emergency(const char *number)
emerg = calloc(1, sizeof(*emerg));
if (!emerg) {
PDEBUG(DTRANS, DEBUG_ERROR, "No memory!\n");
LOGP(DTRANS, LOGL_ERROR, "No memory!\n");
return;
}
@ -288,7 +290,7 @@ static int check_emerg(const char *number)
if (!emerg)
return 0;
PDEBUG(DCNETZ, DEBUG_NOTICE, "Emergency call, matching prefix '%s' in list of emergency numbers.\n", emerg->number);
LOGP(DCNETZ, LOGL_NOTICE, "Emergency call, matching prefix '%s' in list of emergency numbers.\n", emerg->number);
return 1;
}
@ -337,12 +339,12 @@ static void remove_db(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_res
while (*dbp && *dbp != db)
dbp = &((*dbp)->next);
if (!(*dbp)) {
PDEBUG(DDB, DEBUG_ERROR, "Subscriber not in list, please fix!!\n");
LOGP(DDB, LOGL_ERROR, "Subscriber not in list, please fix!!\n");
abort();
}
*dbp = db->next;
PDEBUG(DDB, DEBUG_INFO, "Removing subscriber '%d,%d,%d' from database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
LOGP(DDB, LOGL_INFO, "Removing subscriber '%d,%d,%d' from database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
/* remove */
free(db);
@ -353,7 +355,7 @@ static void flush_db(void)
cnetz_db_t *db;
while ((db = cnetz_db_head)) {
PDEBUG(DDB, DEBUG_INFO, "Removing subscriber '%d,%d,%d' from database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
LOGP(DDB, LOGL_INFO, "Removing subscriber '%d,%d,%d' from database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
cnetz_db_head = db->next;
free(db);
}
@ -370,7 +372,7 @@ static void add_db(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest,
/* add */
db = calloc(1, sizeof(*db));
if (!db) {
PDEBUG(DDB, DEBUG_ERROR, "No memory!\n");
LOGP(DDB, LOGL_ERROR, "No memory!\n");
return;
}
db->futln_nat = futln_nat;
@ -378,7 +380,7 @@ static void add_db(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest,
db->futln_rest = futln_rest;
db->chip = chip;
PDEBUG(DDB, DEBUG_INFO, "Adding subscriber '%d,%d,%d' to database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
LOGP(DDB, LOGL_INFO, "Adding subscriber '%d,%d,%d' to database.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
/* attach to end of list */
dbp = &cnetz_db_head;
@ -392,7 +394,7 @@ static void add_db(uint8_t futln_nat, uint8_t futln_fuvst, uint16_t futln_rest,
*/
/* Release timeout */
#define RELEASE_TO 3.0
#define RELEASE_TO 3,0
/* BSC originated Ident-Numbers */
#define IDENT_BSC_FROM 0x9f
@ -425,7 +427,7 @@ typedef struct transaction {
fuvst_t *spk; /* assigned SPK */
char number[17]; /* dialed by mobile */
int sonderruf; /* an emergency call */
struct timer timer; /* release timer */
struct osmo_timer_list timer; /* release timer */
} transaction_t;
transaction_t *trans_list = NULL;
@ -500,7 +502,7 @@ static void new_call_state(transaction_t *trans, enum call_state new_state)
{
if (trans->state == new_state)
return;
PDEBUG(DTRANS, DEBUG_INFO, "State change: %s -> %s\n", state_name(trans->state), state_name(new_state));
LOGP(DTRANS, LOGL_INFO, "State change: %s -> %s\n", state_name(trans->state), state_name(new_state));
trans->state = new_state;
display_status();
}
@ -514,7 +516,7 @@ transaction_t *search_transaction_number(uint8_t futln_nat, uint8_t futln_fuvst,
&& trans->futln_fuvst == futln_fuvst
&& trans->futln_rest == futln_rest) {
const char *rufnummer = transaction2rufnummer(trans);
PDEBUG(DTRANS, DEBUG_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer);
LOGP(DTRANS, LOGL_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer);
return trans;
}
trans = trans->next;
@ -530,7 +532,7 @@ transaction_t *search_transaction_ident(uint8_t ident)
while (trans) {
if (trans->ident == ident) {
const char *rufnummer = transaction2rufnummer(trans);
PDEBUG(DTRANS, DEBUG_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer);
LOGP(DTRANS, LOGL_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer);
return trans;
}
trans = trans->next;
@ -549,7 +551,7 @@ transaction_t *search_transaction_callref(int callref)
while (trans) {
if (trans->callref == callref) {
const char *rufnummer = transaction2rufnummer(trans);
PDEBUG(DTRANS, DEBUG_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer);
LOGP(DTRANS, LOGL_DEBUG, "Found transaction for subscriber '%s'\n", rufnummer);
return trans;
}
trans = trans->next;
@ -564,9 +566,9 @@ static void destroy_transaction(transaction_t *trans)
transaction_t **transp;
const char *rufnummer = transaction2rufnummer(trans);
PDEBUG(DTRANS, DEBUG_INFO, "Destroying transaction for subscriber '%s'\n", rufnummer);
LOGP(DTRANS, LOGL_INFO, "Destroying transaction for subscriber '%s'\n", rufnummer);
timer_exit(&trans->timer);
osmo_timer_del(&trans->timer);
/* check for old callref (before removal) then detach SPK
* if SPK has been reused by BS, our old callref will not match,
@ -580,7 +582,7 @@ static void destroy_transaction(transaction_t *trans)
while (*transp && *transp != trans)
transp = &((*transp)->next);
if (!(*transp)) {
PDEBUG(DTRANS, DEBUG_ERROR, "Transaction not in list, please fix!!\n");
LOGP(DTRANS, LOGL_ERROR, "Transaction not in list, please fix!!\n");
abort();
}
*transp = trans->next;
@ -595,7 +597,7 @@ void trans_timeout(void *data)
{
transaction_t *trans = data;
PDEBUG(DTRANS, DEBUG_NOTICE, "Releasing transaction due to timeout.\n");
LOGP(DTRANS, LOGL_NOTICE, "Releasing transaction due to timeout.\n");
if (trans->callref)
call_up_release(trans->callref, CAUSE_NORMAL);
trans->callref = 0;
@ -611,7 +613,7 @@ static transaction_t *create_transaction(uint8_t ident, uint8_t futln_nat, uint8
trans = search_transaction_number(futln_nat, futln_fuvst, futln_rest);
if (trans && mo) {
const char *rufnummer = transaction2rufnummer(trans);
PDEBUG(DTRANS, DEBUG_NOTICE, "Found already pending transaction for subscriber '%s', dropping that!\n", rufnummer);
LOGP(DTRANS, LOGL_NOTICE, "Found already pending transaction for subscriber '%s', dropping that!\n", rufnummer);
if (trans->callref)
call_up_release(trans->callref, CAUSE_NORMAL);
trans->callref = 0;
@ -620,13 +622,13 @@ static transaction_t *create_transaction(uint8_t ident, uint8_t futln_nat, uint8
}
if (trans) {
const char *rufnummer = transaction2rufnummer(trans);
PDEBUG(DTRANS, DEBUG_NOTICE, "Found already pending transaction for subscriber '%s', we are busy!\n", rufnummer);
LOGP(DTRANS, LOGL_NOTICE, "Found already pending transaction for subscriber '%s', we are busy!\n", rufnummer);
return NULL;
}
trans = calloc(1, sizeof(*trans));
if (!trans) {
PDEBUG(DTRANS, DEBUG_ERROR, "No memory!\n");
LOGP(DTRANS, LOGL_ERROR, "No memory!\n");
return NULL;
}
@ -636,10 +638,10 @@ static transaction_t *create_transaction(uint8_t ident, uint8_t futln_nat, uint8
trans->futln_fuvst = futln_fuvst;
trans->futln_rest = futln_rest;
timer_init(&trans->timer, trans_timeout, trans);
osmo_timer_setup(&trans->timer, trans_timeout, trans);
const char *rufnummer = transaction2rufnummer(trans);
PDEBUG(DTRANS, DEBUG_INFO, "Creating transaction for subscriber '%s'\n", rufnummer);
LOGP(DTRANS, LOGL_INFO, "Creating transaction for subscriber '%s'\n", rufnummer);
/* attach to end of list, so first transaction is served first */
transp = &trans_list;
@ -763,14 +765,14 @@ static int message_send(uint8_t ident, uint8_t opcode, uint8_t *data, int len)
if (!zzk)
zzk = get_zzk(0);
if (!zzk) {
PDEBUG(DCNETZ, DEBUG_ERROR, "No ZZK or link down!\n");
LOGP(DCNETZ, LOGL_ERROR, "No ZZK or link down!\n");
return -EIO;
}
uint8_t buffer[len + 2];
if (debuglevel == DEBUG_DEBUG || opcode != OPCODE_XEDBU)
PDEBUG(DCNETZ, DEBUG_INFO, "TX Message to BS: link=%s ident=0x%02x OP=%02XH %s\n", zzk->sender.kanal, ident, opcode, debug_hex(data, len));
if (loglevel == LOGL_DEBUG || opcode != OPCODE_XEDBU)
LOGP(DCNETZ, LOGL_INFO, "TX Message to BS: link=%s ident=0x%02x OP=%02XH %s\n", zzk->sender.kanal, ident, opcode, osmo_hexdump(data, len));
/* assemble Ident, swap Opcode and add data */
slc = ident & 0xf;
@ -808,25 +810,25 @@ static void release_for_emergency(void)
/* found idle channel */
if (sender) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "Emergency call received. We have a free channel available.\n");
LOGP(DCNETZ, LOGL_NOTICE, "Emergency call received. We have a free channel available.\n");
return;
}
/* found no normal call (no emergency) */
if (!last_trans) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "Emergency call received. We cannot free a channel, because there is no non-emergency call.\n");
LOGP(DCNETZ, LOGL_NOTICE, "Emergency call received. We cannot free a channel, because there is no non-emergency call.\n");
return;
}
/* releasing the last call in list */
PDEBUG(DCNETZ, DEBUG_NOTICE, "Emergency call received. We free a channel.\n");
LOGP(DCNETZ, LOGL_NOTICE, "Emergency call received. We free a channel.\n");
len = encode_aau(&opcode, &data, trans->spk_nr, 0, cnetz_cause2futln(CAUSE_NORMAL));
message_send(trans->ident, opcode, data, len);
call_up_release(trans->callref, CAUSE_NORMAL);
trans->callref = 0;
new_call_state(trans, STATE_RELEASE);
timer_start(&trans->timer, RELEASE_TO);
osmo_timer_schedule(&trans->timer, RELEASE_TO);
}
/* MTP data message from lower layer */
@ -851,8 +853,8 @@ static void message_receive(fuvst_t *zzk, uint8_t ident, uint8_t opcode, uint8_t
int i, num;
char number[17];
if (debuglevel == DEBUG_DEBUG || opcode != OPCODE_YLSMF)
PDEBUG(DCNETZ, DEBUG_INFO, "RX Message from BS: link=%s ident=0x%02x OP=%02XH %s\n", zzk->sender.kanal, ident, opcode, debug_hex(data, len));
if (loglevel == LOGL_DEBUG || opcode != OPCODE_YLSMF)
LOGP(DCNETZ, LOGL_INFO, "RX Message from BS: link=%s ident=0x%02x OP=%02XH %s\n", zzk->sender.kanal, ident, opcode, osmo_hexdump(data, len));
switch (opcode) {
case OPCODE_SWAF: /* BS restarts */
@ -866,7 +868,7 @@ static void message_receive(fuvst_t *zzk, uint8_t ident, uint8_t opcode, uint8_t
message_send(5, opcode, NULL, 0);
#endif
if (warmstart) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "Forcing a warm start and load the config...\n");
LOGP(DCNETZ, LOGL_NOTICE, "Forcing a warm start and load the config...\n");
warmstart = 0;
len = encode_yaaau(&opcode, &data, 42);
message_send(0, opcode, data, len);
@ -932,11 +934,11 @@ static void message_receive(fuvst_t *zzk, uint8_t ident, uint8_t opcode, uint8_t
break;
case OPCODE_GVAF: /* MO call */
decode_gvaf(data, len, &T, &U, &N, number);
PDEBUG(DCNETZ, DEBUG_INFO, "Call from mobile.\n");
LOGP(DCNETZ, LOGL_INFO, "Call from mobile.\n");
goto outgoing;
case OPCODE_GVWAF: /* MO call (queue) */
decode_gvaf(data, len, &T, &U, &N, number);
PDEBUG(DCNETZ, DEBUG_INFO, "Call from mobile (queue).\n");
LOGP(DCNETZ, LOGL_INFO, "Call from mobile (queue).\n");
outgoing:
trans = create_transaction(ident, N, U, T, 1);
if (!trans) {
@ -958,7 +960,7 @@ outgoing:
trans = search_transaction_ident(ident);
if (!trans)
break;
PDEBUG(DCNETZ, DEBUG_INFO, "Call to mobile is alerting (queue).\n");
LOGP(DCNETZ, LOGL_INFO, "Call to mobile is alerting (queue).\n");
new_call_state(trans, STATE_MT_QUEUE);
if (trans->callref)
call_up_alerting(trans->callref);
@ -968,7 +970,7 @@ outgoing:
trans = search_transaction_ident(ident);
if (!trans)
break;
PDEBUG(DCNETZ, DEBUG_INFO, "Call to mobile has been answered.\n");
LOGP(DCNETZ, LOGL_INFO, "Call to mobile has been answered.\n");
new_call_state(trans, STATE_MT_CONNECT);
if (trans->callref)
call_up_answer(trans->callref, transaction2rufnummer(trans));
@ -986,7 +988,7 @@ outgoing:
trans->spk_nr = Q;
/* SPK not exist, release */
if (!trans->spk) {
PDEBUG(DCNETZ, DEBUG_ERROR, "SpK '%d' requested by BS not configured, please configure all SpK that base station has available!\n", Q);
LOGP(DCNETZ, LOGL_ERROR, "SpK '%d' requested by BS not configured, please configure all SpK that base station has available!\n", Q);
len = encode_stnqu(&opcode, &data, Q);
message_send(ident, opcode, data, len);
if (trans->callref)
@ -1002,22 +1004,22 @@ outgoing:
message_send(ident, opcode, data, len);
/* no callref == outgoing call */
if (!trans->callref) {
PDEBUG(DCNETZ, DEBUG_INFO, "Setup call to network. (Ident = %d, FuTln=%s, number=%s)\n", ident, transaction2rufnummer(trans), trans->number);
LOGP(DCNETZ, LOGL_INFO, "Setup call to network. (Ident = %d, FuTln=%s, number=%s)\n", ident, transaction2rufnummer(trans), trans->number);
trans->callref = trans->old_callref = call_up_setup(transaction2rufnummer(trans), trans->number, OSMO_CC_NETWORK_CNETZ_NONE, "");
} else {
PDEBUG(DCNETZ, DEBUG_NOTICE, "Call to mobile is alerting.\n");
LOGP(DCNETZ, LOGL_NOTICE, "Call to mobile is alerting.\n");
new_call_state(trans, STATE_MT_ALERTING);
call_up_alerting(trans->callref);
}
trans->spk->callref = trans->callref;
PDEBUG(DCNETZ, DEBUG_INFO, "Assigned SpK %d to call.\n", trans->spk_nr);
LOGP(DCNETZ, LOGL_INFO, "Assigned SpK %d to call.\n", trans->spk_nr);
break;
case OPCODE_APF: /* auth response */
decode_apf(data, len, &Q, &a);
break;
case OPCODE_FAF: /* MCID request */
decode_faf(data, len);
PDEBUG(DCNETZ, DEBUG_NOTICE, "Fangen (MCID) was activated by BS.\n");
LOGP(DCNETZ, LOGL_NOTICE, "Fangen (MCID) was activated by BS.\n");
break;
case OPCODE_NAF: /* incoming release (before SPK assignment) */
decode_naf(data, len, &X);
@ -1027,7 +1029,7 @@ outgoing:
trans = search_transaction_ident(ident);
if (!trans)
break;
PDEBUG(DCNETZ, DEBUG_NOTICE, "Call released by BS.\n");
LOGP(DCNETZ, LOGL_NOTICE, "Call released by BS.\n");
new_call_state(trans, STATE_RELEASE);
if (trans->callref)
call_up_release(trans->callref, cnetz_fufst2cause(X));
@ -1057,7 +1059,7 @@ outgoing:
message_send(ident, opcode, data, len);
if (trans->callref)
call_up_release(trans->callref, cnetz_fufst2cause(X));
PDEBUG(DCNETZ, DEBUG_NOTICE, "Call released by BS.\n");
LOGP(DCNETZ, LOGL_NOTICE, "Call released by BS.\n");
new_call_state(trans, STATE_RELEASE);
trans->callref = 0;
destroy_transaction(trans);
@ -1087,7 +1089,7 @@ outgoing:
message_send(ident, opcode, data, len);
break;
default:
PDEBUG(DCNETZ, DEBUG_INFO, "RX Message from BS with unknown OPcode: %02XH\n", opcode);
LOGP(DCNETZ, LOGL_INFO, "RX Message from BS with unknown OPcode: %02XH\n", opcode);
}
}
@ -1123,25 +1125,25 @@ static void mtp_receive(void *inst, enum mtp_prim prim, uint8_t slc, uint8_t *da
default:
cause_text = "MTP link '%s' failed! Trying again.\n";
}
PDEBUG(DCNETZ, DEBUG_NOTICE, cause_text, zzk->sender.kanal);
LOGP(DCNETZ, LOGL_NOTICE, cause_text, zzk->sender.kanal);
mtp_send(&zzk->mtp, MTP_PRIM_START, 0, NULL, 0);
zzk->link = 0;
display_status();
break;
case MTP_PRIM_IN_SERVICE:
PDEBUG(DCNETZ, DEBUG_NOTICE, "Link '%s' established.\n", zzk->sender.kanal);
LOGP(DCNETZ, LOGL_NOTICE, "Link '%s' established.\n", zzk->sender.kanal);
zzk->link = 1;
display_status();
break;
case MTP_PRIM_REMOTE_PROCESSOR_OUTAGE:
PDEBUG(DCNETZ, DEBUG_NOTICE, "Link '%s' indicates remote processor outage.\n", zzk->sender.kanal);
LOGP(DCNETZ, LOGL_NOTICE, "Link '%s' indicates remote processor outage.\n", zzk->sender.kanal);
break;
case MTP_PRIM_REMOTE_PROCESSOR_RECOVERED:
PDEBUG(DCNETZ, DEBUG_NOTICE, "Link '%s' indicates remote processor outage is recovered.\n", zzk->sender.kanal);
LOGP(DCNETZ, LOGL_NOTICE, "Link '%s' indicates remote processor outage is recovered.\n", zzk->sender.kanal);
break;
case MTP_PRIM_DATA:
if (len < 2) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "No Opcode, message too short!\n");
LOGP(DCNETZ, LOGL_NOTICE, "No Opcode, message too short!\n");
return;
}
@ -1172,17 +1174,17 @@ int fuvst_create(const char *kanal, enum fuvst_chan_type chan_type, const char *
fuvst = calloc(1, sizeof(fuvst_t));
if (!fuvst) {
PDEBUG(DCNETZ, DEBUG_ERROR, "No memory!\n");
LOGP(DCNETZ, LOGL_ERROR, "No memory!\n");
return -ENOMEM;
}
PDEBUG(DCNETZ, DEBUG_DEBUG, "Creating 'C-Netz' instance for 'Kanal' = %s (sample rate %d).\n", chan_name, samplerate);
LOGP(DCNETZ, LOGL_DEBUG, "Creating 'C-Netz' instance for 'Kanal' = %s (sample rate %d).\n", chan_name, samplerate);
/* init general part of transceiver */
/* do not enable emphasis, since it is done by fuvst code, not by common sender code */
rc = sender_create(&fuvst->sender, options_strdup(chan_name), 0, 0, audiodev, 0, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DCNETZ, DEBUG_ERROR, "Failed to init transceiver process!\n");
LOGP(DCNETZ, LOGL_ERROR, "Failed to init transceiver process!\n");
goto error;
}
fuvst->chan_num = atoi(kanal);
@ -1208,7 +1210,7 @@ int fuvst_create(const char *kanal, enum fuvst_chan_type chan_type, const char *
goto error;
}
PDEBUG(DCNETZ, DEBUG_NOTICE, "Created 'Kanal' %s\n", chan_name);
LOGP(DCNETZ, LOGL_NOTICE, "Created 'Kanal' %s\n", chan_name);
display_status();
@ -1225,7 +1227,7 @@ void fuvst_destroy(sender_t *sender)
{
fuvst_t *fuvst = (fuvst_t *) sender;
PDEBUG(DCNETZ, DEBUG_DEBUG, "Destroying 'C-Netz' instance for 'Kanal' = %s.\n", sender->kanal);
LOGP(DCNETZ, LOGL_DEBUG, "Destroying 'C-Netz' instance for 'Kanal' = %s.\n", sender->kanal);
if (fuvst->chan_type == CHAN_TYPE_ZZK) {
mtp_exit(&fuvst->mtp);
@ -1325,19 +1327,19 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
/* 2. base station ready? */
if (!base_station_ready) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "Outgoing call not possible, base station not ready, rejecting!\n");
LOGP(DCNETZ, LOGL_NOTICE, "Outgoing call not possible, base station not ready, rejecting!\n");
return -CAUSE_TEMPFAIL;
}
/* 3. create transaction */
ident = get_free_ident();
if (!ident) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "Outgoing call not possible, no free Ident code?? What the hack?\n");
LOGP(DCNETZ, LOGL_NOTICE, "Outgoing call not possible, no free Ident code?? What the hack?\n");
return -CAUSE_TEMPFAIL;
}
trans = create_transaction(ident, futln_nat, futln_fuvst, futln_rest, 0);
if (!trans) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "Outgoing call not possible, Transaction already exists: Subscriber busy!\n");
LOGP(DCNETZ, LOGL_NOTICE, "Outgoing call not possible, Transaction already exists: Subscriber busy!\n");
return -CAUSE_BUSY;
}
trans->callref = trans->old_callref = callref;
@ -1345,7 +1347,7 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
/* 4. start call */
len = encode_kvau(&opcode, &data, futln_rest, futln_fuvst, futln_nat, 0, authentication);
message_send(trans->ident, opcode, data, len);
PDEBUG(DCNETZ, DEBUG_INFO, "Send call for mobile towards BS. (Ident = %d, FuTln=%s)\n", ident, transaction2rufnummer(trans));
LOGP(DCNETZ, LOGL_INFO, "Send call for mobile towards BS. (Ident = %d, FuTln=%s)\n", ident, transaction2rufnummer(trans));
new_call_state(trans, STATE_MT);
return 0;
@ -1359,7 +1361,7 @@ void call_down_answer(int callref)
trans = search_transaction_callref(callref);
if (!trans) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "Answer to unknown callref.\n");
LOGP(DCNETZ, LOGL_NOTICE, "Answer to unknown callref.\n");
return;
}
@ -1387,7 +1389,7 @@ static void _disconnect_release(transaction_t *trans, int callref, int cause)
call_up_release(callref, cause);
trans->callref = 0;
new_call_state(trans, STATE_RELEASE);
timer_start(&trans->timer, RELEASE_TO);
osmo_timer_schedule(&trans->timer, RELEASE_TO);
}
/* Call control sends disconnect (with tones).
@ -1398,11 +1400,11 @@ void call_down_disconnect(int callref, int cause)
{
transaction_t *trans;
PDEBUG(DCNETZ, DEBUG_INFO, "Call has been disconnected by network.\n");
LOGP(DCNETZ, LOGL_INFO, "Call has been disconnected by network.\n");
trans = search_transaction_callref(callref);
if (!trans) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "Outgoing disconnect to unknown callref.\n");
LOGP(DCNETZ, LOGL_NOTICE, "Outgoing disconnect to unknown callref.\n");
call_up_release(callref, CAUSE_INVALCALLREF);
return;
}
@ -1422,11 +1424,11 @@ void call_down_release(int callref, int cause)
{
transaction_t *trans;
PDEBUG(DCNETZ, DEBUG_INFO, "Call has been released by network.\n");
LOGP(DCNETZ, LOGL_INFO, "Call has been released by network.\n");
trans = search_transaction_callref(callref);
if (!trans) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "Outgoing released to unknown callref.\n");
LOGP(DCNETZ, LOGL_NOTICE, "Outgoing released to unknown callref.\n");
call_up_release(callref, CAUSE_INVALCALLREF);
return;
}
@ -1438,14 +1440,14 @@ void dump_info(void)
{
cnetz_db_t *db = cnetz_db_head;
PDEBUG(DDB, DEBUG_NOTICE, "Dump of subscriber database:\n");
LOGP(DDB, LOGL_NOTICE, "Dump of subscriber database:\n");
if (!db) {
PDEBUG(DDB, DEBUG_NOTICE, " - No subscribers attached!\n");
LOGP(DDB, LOGL_NOTICE, " - No subscribers attached!\n");
return;
}
while (db) {
PDEBUG(DDB, DEBUG_NOTICE, " - Subscriber '%d,%d,%d' is attached.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
LOGP(DDB, LOGL_NOTICE, " - Subscriber '%d,%d,%d' is attached.\n", db->futln_nat, db->futln_fuvst, db->futln_rest);
db = db->next;
}
}

View File

@ -23,10 +23,10 @@
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/main_mobile.h"
#include "../libtimer/timer.h"
#include <osmocom/core/timer.h>
#include "../liboptions/options.h"
#include "../libfm/fm.h"
#include "../anetz/freiton.h"
@ -293,6 +293,7 @@ fail:
fuvst_destroy(sender_head);
/* exits */
main_mobile_exit();
// zeit_exit();
fm_exit();

View File

@ -23,7 +23,8 @@
#include <string.h>
#include <time.h>
#include <inttypes.h>
#include "../libdebug/debug.h"
#include <osmocom/core/utils.h>
#include "../liblogging/logging.h"
#include "mup.h"
#include "systemmeldungen.h"
@ -291,7 +292,7 @@ static const char *futln_cause(uint8_t Y)
void decode_swaf(uint8_t *data, int len, uint8_t *V, uint8_t *N, uint8_t *U, uint8_t *F, uint8_t *C, uint8_t *B)
{
if (len < 6) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
@ -302,7 +303,7 @@ void decode_swaf(uint8_t *data, int len, uint8_t *V, uint8_t *N, uint8_t *U, uin
*C = data[4];
*B = data[5];
PDEBUG(DMUP, DEBUG_INFO, "(BS SWAF) Wiederanlauf der BS: version=%d (%s) FuFSt=%d,%d,%d chip=%d (%s) beacon=%d (%s)\n", *V, version_string(*V), *N, *U, *F, *C, chip_string(*C), *B, beacon_string(*B));
LOGP(DMUP, LOGL_INFO, "(BS SWAF) Wiederanlauf der BS: version=%d (%s) FuFSt=%d,%d,%d chip=%d (%s) beacon=%d (%s)\n", *V, version_string(*V), *N, *U, *F, *C, chip_string(*C), *B, beacon_string(*B));
}
/* ack to base station boot */
@ -310,7 +311,7 @@ int encode_swqu(uint8_t *opcode, uint8_t **data, uint8_t A)
{
static uint8_t buffer[1];
PDEBUG(DMUP, DEBUG_INFO, "(MSC SWQU) Wiederanlaufquittung des MSC: aktivdatei=%d (%s)\n", A, aktivdatei_string(A));
LOGP(DMUP, LOGL_INFO, "(MSC SWQU) Wiederanlaufquittung des MSC: aktivdatei=%d (%s)\n", A, aktivdatei_string(A));
*opcode = OPCODE_SWQU;
buffer[0] = A;
@ -323,7 +324,7 @@ int encode_swqu(uint8_t *opcode, uint8_t **data, uint8_t A)
void decode_suaf(uint8_t *data, int len, uint8_t *V, uint8_t *N, uint8_t *U, uint8_t *F, uint8_t *C, uint8_t *B)
{
if (len < 6) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
@ -334,7 +335,7 @@ void decode_suaf(uint8_t *data, int len, uint8_t *V, uint8_t *N, uint8_t *U, uin
*C = data[4];
*B = data[5];
PDEBUG(DMUP, DEBUG_INFO, "(BS SUAF) Datum-Uhrzeit-Anforderung der BS: version=%d (%s) FuFSt=%d,%d,%d chip=%d (%s) beacon=%d (%s)\n", *V, version_string(*V), *N, *U, *F, *C, chip_string(*C), *B, beacon_string(*B));
LOGP(DMUP, LOGL_INFO, "(BS SUAF) Datum-Uhrzeit-Anforderung der BS: version=%d (%s) FuFSt=%d,%d,%d chip=%d (%s) beacon=%d (%s)\n", *V, version_string(*V), *N, *U, *F, *C, chip_string(*C), *B, beacon_string(*B));
}
/* ack to time request */
@ -355,7 +356,7 @@ int encode_suqu(uint8_t *opcode, uint8_t **data, uint8_t Q, uint8_t N, time_t no
m = tm->tm_min;
s = tm->tm_sec;
PDEBUG(DMUP, DEBUG_INFO, "(MSC SUQU) Datum-Uhrzeit-Quittung des MSC: Q=%d (%s) Widerholung=%d (%s) Wochentag=%d (%s) Datum: %d.%d.%d %d:%02d:%02d\n", Q, qualitaet_string(Q), N, wiederholung_string(N), W, woche_string(W), D, M, J, h, m, s);
LOGP(DMUP, LOGL_INFO, "(MSC SUQU) Datum-Uhrzeit-Quittung des MSC: Q=%d (%s) Widerholung=%d (%s) Wochentag=%d (%s) Datum: %d.%d.%d %d:%02d:%02d\n", Q, qualitaet_string(Q), N, wiederholung_string(N), W, woche_string(W), D, M, J, h, m, s);
*opcode = OPCODE_SUQU;
buffer[0] = Q | (N << 1) | (R << 2);
@ -380,7 +381,7 @@ void decode_sssaf(uint8_t *data, int len)
int i, start_i = 0, stop_i = 0;
if (len < 11) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
@ -388,9 +389,9 @@ void decode_sssaf(uint8_t *data, int len)
A = data[1] | (data[2] << 8);
E = data[3] | (data[4] << 8);
PDEBUG(DMUP, DEBUG_INFO, "(BS SSSAF) Sprechkanal-Sammel-Sperrauftrag der BS: Liste-Ende=%d Anfang=%d Ende=%d\n", E_, A, E);
LOGP(DMUP, LOGL_INFO, "(BS SSSAF) Sprechkanal-Sammel-Sperrauftrag der BS: Liste-Ende=%d Anfang=%d Ende=%d\n", E_, A, E);
if (E - A + 1 > 6 * 8) {
PDEBUG(DMUP, DEBUG_INFO, " -> Bereich zu gross für Nachricht!\n");
LOGP(DMUP, LOGL_INFO, " -> Bereich zu gross für Nachricht!\n");
return;
}
if ((int)E - (int)A < 0)
@ -411,9 +412,9 @@ void decode_sssaf(uint8_t *data, int len)
if (i > 0 && S != last_S) {
end:
if (start_i == stop_i)
PDEBUG(DMUP, DEBUG_INFO, " -> SpK #%d=%d (%s)\n", start_i + A, last_S, (last_S) ? "gesperrt" : "frei");
LOGP(DMUP, LOGL_INFO, " -> SpK #%d=%d (%s)\n", start_i + A, last_S, (last_S) ? "gesperrt" : "frei");
else
PDEBUG(DMUP, DEBUG_INFO, " -> SpK #%d..%d=%d (%s)\n", start_i + A, stop_i + A, last_S, (last_S) ? "gesperrt" : "frei");
LOGP(DMUP, LOGL_INFO, " -> SpK #%d..%d=%d (%s)\n", start_i + A, stop_i + A, last_S, (last_S) ? "gesperrt" : "frei");
/* new start */
start_i = stop_i = i;
}
@ -425,20 +426,20 @@ end:
void encode_sssqu(uint8_t *opcode)
{
*opcode = OPCODE_SSSQU;
PDEBUG(DMUP, DEBUG_INFO, "(MSC SSSQU) Sprechkanal-Sammel-Sperrquittung des MSC\n");
LOGP(DMUP, LOGL_INFO, "(MSC SSSQU) Sprechkanal-Sammel-Sperrquittung des MSC\n");
}
/* base station locks a voice channel */
void decode_ssaf(uint8_t *data, int len, uint8_t *S)
{
if (len < 1) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
*S = data[0];
PDEBUG(DMUP, DEBUG_INFO, "(BS SSAF) Sprechkanal-Sperr-Auftrag der BS: SPK=%d\n", *S);
LOGP(DMUP, LOGL_INFO, "(BS SSAF) Sprechkanal-Sperr-Auftrag der BS: SPK=%d\n", *S);
}
/* ack to lockeed voice channel */
@ -446,7 +447,7 @@ int encode_ssqu(uint8_t *opcode, uint8_t **data, uint8_t S)
{
static uint8_t buffer[1];
PDEBUG(DMUP, DEBUG_INFO, "(MSC SSQU) Sprechkanal-Sperr-Quittung von der MSC: SPK=%d\n", S);
LOGP(DMUP, LOGL_INFO, "(MSC SSQU) Sprechkanal-Sperr-Quittung von der MSC: SPK=%d\n", S);
*opcode = OPCODE_SSQU;
buffer[0] = S;
@ -459,13 +460,13 @@ int encode_ssqu(uint8_t *opcode, uint8_t **data, uint8_t S)
void decode_sfaf(uint8_t *data, int len, uint8_t *S)
{
if (len < 1) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
*S = data[0];
PDEBUG(DMUP, DEBUG_INFO, "(BS SFAF) Sprechkanal-Freigabe-Auftrag der BS: SPK=%d\n", *S);
LOGP(DMUP, LOGL_INFO, "(BS SFAF) Sprechkanal-Freigabe-Auftrag der BS: SPK=%d\n", *S);
}
/* ack to unlockeed voice channel */
@ -473,7 +474,7 @@ int encode_sfqu(uint8_t *opcode, uint8_t **data, uint8_t S)
{
static uint8_t buffer[1];
PDEBUG(DMUP, DEBUG_INFO, "(MSC SFQU) Sprechkanal-Freigabe-Quittung von der MSC: SPK=%d\n", S);
LOGP(DMUP, LOGL_INFO, "(MSC SFQU) Sprechkanal-Freigabe-Quittung von der MSC: SPK=%d\n", S);
*opcode = OPCODE_SFQU;
buffer[0] = S;
@ -485,13 +486,13 @@ int encode_sfqu(uint8_t *opcode, uint8_t **data, uint8_t S)
/* base station ready */
void decode_svaf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len)
{
PDEBUG(DMUP, DEBUG_INFO, "(BS SVAF) Vermittlungsfaehig-Auftrag der BS\n");
LOGP(DMUP, LOGL_INFO, "(BS SVAF) Vermittlungsfaehig-Auftrag der BS\n");
}
/* ack to base station ready */
int encode_svqu(uint8_t *opcode, uint8_t **data)
{
PDEBUG(DMUP, DEBUG_INFO, "(MSC SVQU) Vermittlungsfaehig-Quittung des MSC\n");
LOGP(DMUP, LOGL_INFO, "(MSC SVQU) Vermittlungsfaehig-Quittung des MSC\n");
*opcode = OPCODE_SVQU;
*data = NULL;
@ -501,13 +502,13 @@ int encode_svqu(uint8_t *opcode, uint8_t **data)
/* base station requests alarm messages */
void decode_ylsaf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len)
{
PDEBUG(DMUP, DEBUG_INFO, "(BS YLSAF) Systemmeldungsanforderung an MSC\n");
LOGP(DMUP, LOGL_INFO, "(BS YLSAF) Systemmeldungsanforderung an MSC\n");
}
/* ack to base stations alarm request */
int encode_ylsmu(uint8_t *opcode, uint8_t **data)
{
PDEBUG(DMUP, DEBUG_INFO, "(MSC YLSMU) Systemmeldungsbestaetigung vom MSC\n");
LOGP(DMUP, LOGL_INFO, "(MSC YLSMU) Systemmeldungsbestaetigung vom MSC\n");
*opcode = OPCODE_YLSMU;
*data = NULL;
@ -518,7 +519,7 @@ int encode_ylsmu(uint8_t *opcode, uint8_t **data)
void decode_ylsmf(uint8_t *data, int len, uint8_t *N, uint8_t *C, struct SysMeld *SM)
{
if (len < 9) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
@ -578,7 +579,7 @@ void decode_ylsmf(uint8_t *data, int len, uint8_t *N, uint8_t *C, struct SysMeld
indizien[strlen(indizien)] = ' ';
}
PDEBUG(DMUP, DEBUG_INFO, "SM: %03d %02d.%02d %02d:%02d %s%02d %c H\"%04X %02d H\"%sH\"%02X%02X%02X%02X\n", *C,
LOGP(DMUP, LOGL_INFO, "SM: %03d %02d.%02d %02d:%02d %s%02d %c H\"%04X %02d H\"%sH\"%02X%02X%02X%02X\n", *C,
SM->Monat, SM->Tag, SM->Stunde, SM->Minute,
einrichtrungstyp_string(SM->Einrichtungstyp), SM->Einrichtungsnr,
SM->ASCII_Typ ? : '0', SM->Systemmeldungsnr,
@ -590,13 +591,13 @@ void decode_ylsmf(uint8_t *data, int len, uint8_t *N, uint8_t *C, struct SysMeld
/* base station ends list of alarm messages */
void decode_ylsef(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len)
{
PDEBUG(DMUP, DEBUG_INFO, "(BS YLSEF) Systemmeldungsuebertragungsende an MSC\n");
LOGP(DMUP, LOGL_INFO, "(BS YLSEF) Systemmeldungsuebertragungsende an MSC\n");
}
/* base station requests billing info */
void decode_stdaf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len)
{
PDEBUG(DMUP, DEBUG_INFO, "(BS STDAF) Tarifdatenauftrag der BS\n");
LOGP(DMUP, LOGL_INFO, "(BS STDAF) Tarifdatenauftrag der BS\n");
}
/* reply to billing info */
@ -606,7 +607,7 @@ int encode_xgtau(uint8_t *opcode, uint8_t **data, uint8_t Z, uint32_t T, uint8_t
// Example from UeLE-ROM = { 0xff, 0x00, 0x01, 0xec, 0x3f, 0x01, 0x31, 0x1c, 0x03 };
// { 0xff, 0x00, 0x01, 0xec, 0x3f, 0x01, 0x41, 0x1c, 0x03 };
PDEBUG(DMUP, DEBUG_INFO, "(MSC XGTAU) Tarifdatensignalisierung vom MSC\n");
LOGP(DMUP, LOGL_INFO, "(MSC XGTAU) Tarifdatensignalisierung vom MSC\n");
*opcode = OPCODE_XGTAU;
buffer[0] = 0xff;
@ -627,7 +628,7 @@ int encode_xgtau(uint8_t *opcode, uint8_t **data, uint8_t Z, uint32_t T, uint8_t
void decode_ebaf(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N, uint16_t *s, uint8_t *u, uint8_t *b, uint8_t *l)
{
if (len < 6) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
@ -639,13 +640,13 @@ void decode_ebaf(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N, ui
*b = (data[5] >> 6) & 0x1;
*l = data[5] >> 7;
PDEBUG(DMUP, DEBUG_INFO, "(BS EBAF) Einbuchauftrag: FuTln=%d,%d,%d (0161-%d%d%05d)\n", *N, *U, *T, *N, *U, *T);
LOGP(DMUP, LOGL_INFO, "(BS EBAF) Einbuchauftrag: FuTln=%d,%d,%d (0161-%d%d%05d)\n", *N, *U, *T, *N, *U, *T);
}
/* ack to inscription */
int encode_ebpqu(uint8_t *opcode, uint8_t **data)
{
PDEBUG(DMUP, DEBUG_INFO, "(MSC EBPQU) Einbuchungs-Positiv-Quittiung vom MSC\n");
LOGP(DMUP, LOGL_INFO, "(MSC EBPQU) Einbuchungs-Positiv-Quittiung vom MSC\n");
*opcode = OPCODE_EBPQU;
*data = NULL;
@ -656,7 +657,7 @@ int encode_ebpqu(uint8_t *opcode, uint8_t **data)
void decode_abaf(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N)
{
if (len < 3) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
@ -664,7 +665,7 @@ void decode_abaf(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N)
*U = data[2] & 0x1f;
*N = data[2] >> 5;
PDEBUG(DMUP, DEBUG_INFO, "(BS ABAF) Ausbuchung-Auftrag der BS: FuTln=%d,%d,%d (0161-%d%d%05d)\n", *N, *U, *T, *N, *U, *T);
LOGP(DMUP, LOGL_INFO, "(BS ABAF) Ausbuchung-Auftrag der BS: FuTln=%d,%d,%d (0161-%d%d%05d)\n", *N, *U, *T, *N, *U, *T);
}
static char digit2char[16] = "0123456789a*#bcd";
@ -675,7 +676,7 @@ void _decode_outgoing(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *
int i;
if (len < 11) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
@ -709,14 +710,14 @@ void decode_gvaf(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N, ch
{
_decode_outgoing(data, len, T, U , N, number);
PDEBUG(DMUP, DEBUG_INFO, "(BS GVAF) Gehender Verbindungs-Auftrag der BS: FuTln=%d,%d,%d (0161-%d%d%05d) number=%s\n", *N, *U, *T, *N, *U, *T, number);
LOGP(DMUP, LOGL_INFO, "(BS GVAF) Gehender Verbindungs-Auftrag der BS: FuTln=%d,%d,%d (0161-%d%d%05d) number=%s\n", *N, *U, *T, *N, *U, *T, number);
}
void decode_gvwaf(uint8_t *data, int len, uint16_t *T, uint8_t *U, uint8_t *N, char *number)
{
_decode_outgoing(data, len, T, U , N, number);
PDEBUG(DMUP, DEBUG_INFO, "(BS GVWAF) Gehender Verbindungs-Warteschlange-Auftrag der BS: FuTln=%d,%d,%d (0161-%d%d%05d) number=%s\n", *N, *U, *T, *N, *U, *T, number);
LOGP(DMUP, LOGL_INFO, "(BS GVWAF) Gehender Verbindungs-Warteschlange-Auftrag der BS: FuTln=%d,%d,%d (0161-%d%d%05d) number=%s\n", *N, *U, *T, *N, *U, *T, number);
}
/* ack to MO call */
@ -724,7 +725,7 @@ int encode_gvpqu(uint8_t *opcode, uint8_t **data, uint8_t P, uint8_t e)
{
static uint8_t buffer[2];
PDEBUG(DMUP, DEBUG_INFO, "(MSC GVPQU) Verbindungs-Positiv-Quittiung vom MSC: Prio=%d (%s) AP-Pruefung=%d\n", P, prio_string(P), e);
LOGP(DMUP, LOGL_INFO, "(MSC GVPQU) Verbindungs-Positiv-Quittiung vom MSC: Prio=%d (%s) AP-Pruefung=%d\n", P, prio_string(P), e);
*opcode = OPCODE_GVNQU;
buffer[0] = P;
@ -739,7 +740,7 @@ int encode_gvnqu(uint8_t *opcode, uint8_t **data, uint8_t X, uint8_t Y)
{
static uint8_t buffer[2];
PDEBUG(DMUP, DEBUG_INFO, "(MSC GVNQU) Verbindungs-Negativ-Quittiung vom MSC: Grund=%d (%s) Grund(FuTlg)=%d (%s)\n", X, fufst_cause(X), Y, futln_cause(Y));
LOGP(DMUP, LOGL_INFO, "(MSC GVNQU) Verbindungs-Negativ-Quittiung vom MSC: Grund=%d (%s) Grund(FuTlg)=%d (%s)\n", X, fufst_cause(X), Y, futln_cause(Y));
*opcode = OPCODE_GVNQU;
buffer[0] = X;
@ -754,7 +755,7 @@ int encode_kvau(uint8_t *opcode, uint8_t **data, uint16_t T, uint8_t U, uint8_t
{
static uint8_t buffer[5];
PDEBUG(DMUP, DEBUG_INFO, "(MSC KVAU) Kommender Verbindungs-Auftrag vom MSC: FuTln=%d,%d,%d (0161-%d%d%05d) Rufzeitbegrenzung=%d (%s) AP-Pruefung=%d\n", N, U, T, N, U, T, F, rufzeit_string(F), e);
LOGP(DMUP, LOGL_INFO, "(MSC KVAU) Kommender Verbindungs-Auftrag vom MSC: FuTln=%d,%d,%d (0161-%d%d%05d) Rufzeitbegrenzung=%d (%s) AP-Pruefung=%d\n", N, U, T, N, U, T, F, rufzeit_string(F), e);
*opcode = OPCODE_KVAU;
buffer[0] = T;
@ -770,20 +771,20 @@ int encode_kvau(uint8_t *opcode, uint8_t **data, uint16_t T, uint8_t U, uint8_t
/* ack to MT call on queue */
void decode_kvwqf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len)
{
PDEBUG(DMUP, DEBUG_INFO, "(BS KVWQF) Kommende Verbindungs-Warteschalngen-Quittung der BS\n");
LOGP(DMUP, LOGL_INFO, "(BS KVWQF) Kommende Verbindungs-Warteschalngen-Quittung der BS\n");
}
/* answer of MT call */
void decode_kvbaf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len)
{
PDEBUG(DMUP, DEBUG_INFO, "(BS KVBAF) Kommende Verbindungs-Beginn-Auftrag der BS\n");
LOGP(DMUP, LOGL_INFO, "(BS KVBAF) Kommende Verbindungs-Beginn-Auftrag der BS\n");
}
/* loop test request */
void decode_staf(uint8_t *data, int len, uint8_t *Q, uint8_t *V, uint8_t *e, uint64_t *n)
{
if (len < 10) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
@ -799,7 +800,7 @@ void decode_staf(uint8_t *data, int len, uint8_t *Q, uint8_t *V, uint8_t *e, uin
*n |= (uint64_t)data[8] << 48;
*n |= (uint64_t)data[9] << 56;
PDEBUG(DMUP, DEBUG_INFO, "(BS STAF) Schleifentest-Auftrag der BS: SPK=%d Typ=%d (%s) AP-Pruefung=%d Random=0x%016" PRIx64 "\n", *Q, *V, typ_string(*V), *e, *n);
LOGP(DMUP, LOGL_INFO, "(BS STAF) Schleifentest-Auftrag der BS: SPK=%d Typ=%d (%s) AP-Pruefung=%d Random=0x%016" PRIx64 "\n", *Q, *V, typ_string(*V), *e, *n);
}
/* loop test positive */
@ -807,7 +808,7 @@ int encode_stpqu(uint8_t *opcode, uint8_t **data, uint8_t Q, uint8_t A, uint8_t
{
static uint8_t buffer[7];
PDEBUG(DMUP, DEBUG_INFO, "(MSC STPQU) Schleifentest-Positiv-Quittiung vom MSC: SPK=%d\n", Q);
LOGP(DMUP, LOGL_INFO, "(MSC STPQU) Schleifentest-Positiv-Quittiung vom MSC: SPK=%d\n", Q);
*opcode = OPCODE_STPQU;
buffer[0] = Q;
@ -827,7 +828,7 @@ int encode_stnqu(uint8_t *opcode, uint8_t **data, uint8_t Q)
{
static uint8_t buffer[1];
PDEBUG(DMUP, DEBUG_INFO, "(MSC STNQU) Schleifentest-Negativ-Quittiung vom MSC: SPK=%d\n", Q);
LOGP(DMUP, LOGL_INFO, "(MSC STNQU) Schleifentest-Negativ-Quittiung vom MSC: SPK=%d\n", Q);
*opcode = OPCODE_STNQU;
buffer[0] = Q;
@ -840,7 +841,7 @@ int encode_stnqu(uint8_t *opcode, uint8_t **data, uint8_t Q)
void decode_apf(uint8_t *data, int len, uint8_t *Q, uint64_t *a)
{
if (len < 9) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
@ -854,7 +855,7 @@ void decode_apf(uint8_t *data, int len, uint8_t *Q, uint64_t *a)
*a |= (uint64_t)data[7] << 48;
*a |= (uint64_t)data[8] << 56;
PDEBUG(DMUP, DEBUG_INFO, "(BS APF) Autorisierunsparameter FUKO: SPK=%d AP=0x%016" PRIx64 "\n", *Q, *a);
LOGP(DMUP, LOGL_INFO, "(BS APF) Autorisierunsparameter FUKO: SPK=%d AP=0x%016" PRIx64 "\n", *Q, *a);
}
/* start metering pulses (answer to call) */
@ -862,7 +863,7 @@ int encode_gstau(uint8_t *opcode, uint8_t **data, uint8_t Q, uint16_t G, uint8_t
{
static uint8_t buffer[6];
PDEBUG(DMUP, DEBUG_INFO, "(MSC GSTAU) Gebuehren-Start-Auftrag vom MSC: SPK=%d\n", Q);
LOGP(DMUP, LOGL_INFO, "(MSC GSTAU) Gebuehren-Start-Auftrag vom MSC: SPK=%d\n", Q);
*opcode = OPCODE_GSTAU;
buffer[0] = Q;
@ -879,26 +880,26 @@ int encode_gstau(uint8_t *opcode, uint8_t **data, uint8_t Q, uint16_t G, uint8_t
/* MCID */
void decode_faf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len)
{
PDEBUG(DMUP, DEBUG_INFO, "(BS FAF) Fang-Auftrag der BS\n");
LOGP(DMUP, LOGL_INFO, "(BS FAF) Fang-Auftrag der BS\n");
}
/* release by base station (before SPK assignment) */
void decode_naf(uint8_t *data, int len, uint8_t *X)
{
if (len < 1) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
*X = data[0];
PDEBUG(DMUP, DEBUG_INFO, "(BS AAF) Negativ-Auftrag der BS: Grund=%d (%s)\n", *X, fufst_cause(*X));
LOGP(DMUP, LOGL_INFO, "(BS AAF) Negativ-Auftrag der BS: Grund=%d (%s)\n", *X, fufst_cause(*X));
}
/* release by base station ack (before SPK assignment) */
int encode_equ(uint8_t *opcode, uint8_t **data)
{
PDEBUG(DMUP, DEBUG_INFO, "(MSC AQU) Ende-Quittung vom MSC\n");
LOGP(DMUP, LOGL_INFO, "(MSC AQU) Ende-Quittung vom MSC\n");
*opcode = OPCODE_EQU;
*data = NULL;
@ -909,14 +910,14 @@ int encode_equ(uint8_t *opcode, uint8_t **data)
void decode_aaf(uint8_t *data, int len, uint8_t *Q, uint8_t *X)
{
if (len < 2) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
*Q = data[0];
*X = data[1];
PDEBUG(DMUP, DEBUG_INFO, "(BS AAF) Ausloese-Auftrag der BS: SPK=%d, Grund=%d (%s)\n", *Q, *X, fufst_cause(*X));
LOGP(DMUP, LOGL_INFO, "(BS AAF) Ausloese-Auftrag der BS: SPK=%d, Grund=%d (%s)\n", *Q, *X, fufst_cause(*X));
}
/* release by base station ack (after SPK assignment) */
@ -924,7 +925,7 @@ int encode_aqu(uint8_t *opcode, uint8_t **data, uint8_t Q)
{
static uint8_t buffer[1];
PDEBUG(DMUP, DEBUG_INFO, "(MSC AQU) Ausloese-Quittung vom MSC: SPK=%d\n", Q);
LOGP(DMUP, LOGL_INFO, "(MSC AQU) Ausloese-Quittung vom MSC: SPK=%d\n", Q);
*opcode = OPCODE_AQU;
buffer[0] = Q;
@ -938,7 +939,7 @@ int encode_nau(uint8_t *opcode, uint8_t **data, uint8_t X, uint8_t Y)
{
static uint8_t buffer[2];
PDEBUG(DMUP, DEBUG_INFO, "(MSC NAU) Negativ-Auftrag vom MSC: Grund=%d (%s) Grund(FuTlg)=%d (%s)\n", X, fufst_cause(X), Y, futln_cause(Y));
LOGP(DMUP, LOGL_INFO, "(MSC NAU) Negativ-Auftrag vom MSC: Grund=%d (%s) Grund(FuTlg)=%d (%s)\n", X, fufst_cause(X), Y, futln_cause(Y));
*opcode = OPCODE_NAU;
buffer[0] = X;
@ -951,7 +952,7 @@ int encode_nau(uint8_t *opcode, uint8_t **data, uint8_t X, uint8_t Y)
/* release by network ack (before SPK assignment) */
void decode_eqf(uint8_t __attribute__((unused)) *data, int __attribute__((unused)) len)
{
PDEBUG(DMUP, DEBUG_INFO, "(BS EQF) Ende-Quittung der BS\n");
LOGP(DMUP, LOGL_INFO, "(BS EQF) Ende-Quittung der BS\n");
}
/* release by network (after SPK assignment) */
@ -959,7 +960,7 @@ int encode_aau(uint8_t *opcode, uint8_t **data, uint8_t Q, uint8_t X, uint8_t Y)
{
static uint8_t buffer[3];
PDEBUG(DMUP, DEBUG_INFO, "(MSC AAU) Ausloese-Auftrag vom MSC: SPK=%d, Grund=%d (%s) Grund(FuTlg)=%d (%s)\n", Q, X, fufst_cause(X), Y, futln_cause(Y));
LOGP(DMUP, LOGL_INFO, "(MSC AAU) Ausloese-Auftrag vom MSC: SPK=%d, Grund=%d (%s) Grund(FuTlg)=%d (%s)\n", Q, X, fufst_cause(X), Y, futln_cause(Y));
*opcode = OPCODE_AAU;
buffer[0] = Q;
@ -974,20 +975,20 @@ int encode_aau(uint8_t *opcode, uint8_t **data, uint8_t Q, uint8_t X, uint8_t Y)
void decode_aqf(uint8_t *data, int len, uint8_t *Q)
{
if (len < 1) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
*Q = data[0];
PDEBUG(DMUP, DEBUG_INFO, "(BS AQF) Ausloese-Quittung der BS: SPK=%d\n", *Q);
LOGP(DMUP, LOGL_INFO, "(BS AQF) Ausloese-Quittung der BS: SPK=%d\n", *Q);
}
/* request data base block */
void decode_xadbf(uint8_t *data, int len, uint8_t *PJ, uint16_t *D, uint16_t *L)
{
if (len < 6) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
@ -995,7 +996,7 @@ void decode_xadbf(uint8_t *data, int len, uint8_t *PJ, uint16_t *D, uint16_t *L)
*D = data[2] | (data[3] << 8);
*L = data[4] | (data[5] << 8);
PDEBUG(DMUP, DEBUG_INFO, "(BS XADBF) Auftragssign. Anfordern BS-DB-Datenblock am MSC: job=%d, offset=0x%02x length=0x%02x\n", *PJ, *D, *L);
LOGP(DMUP, LOGL_INFO, "(BS XADBF) Auftragssign. Anfordern BS-DB-Datenblock am MSC: job=%d, offset=0x%02x length=0x%02x\n", *PJ, *D, *L);
}
/* transfer data base block */
@ -1003,7 +1004,7 @@ int encode_xedbu_1(uint8_t *opcode, uint8_t **data, uint8_t R, uint8_t PJ, uint1
{
static uint8_t buffer[4];
PDEBUG(DMUP, DEBUG_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (header): return=%d job=%d frames=%d\n", R, PJ, A);
LOGP(DMUP, LOGL_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (header): return=%d job=%d frames=%d\n", R, PJ, A);
*opcode = OPCODE_XEDBU;
buffer[0] = R;
@ -1018,10 +1019,10 @@ int encode_xedbu_2(uint8_t *opcode, uint8_t **data, uint8_t S, uint8_t PJ, uint8
{
static uint8_t buffer[11];
if (debuglevel == DEBUG_DEBUG)
PDEBUG(DMUP, DEBUG_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (data): count=%d job=%d data=%s\n", S, PJ, debug_hex(P, 9));
if (loglevel == LOGL_DEBUG)
LOGP(DMUP, LOGL_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (data): count=%d job=%d data=%s\n", S, PJ, osmo_hexdump(P, 9));
else if (S == 1)
PDEBUG(DMUP, DEBUG_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (data): Messages are not shown, due to heavy debug output!\n");
LOGP(DMUP, LOGL_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (data): Messages are not shown, due to heavy debug output!\n");
*opcode = OPCODE_XEDBU;
buffer[0] = S;
@ -1035,7 +1036,7 @@ int encode_xedbu_3(uint8_t *opcode, uint8_t **data, uint8_t S, uint8_t PJ, uint1
{
static uint8_t buffer[9];
PDEBUG(DMUP, DEBUG_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (footer): count=%d job=%d offset=0x%02x length=0x%02x checksum=0x%06x\n", S, PJ, D, L, CS);
LOGP(DMUP, LOGL_INFO, "(MSC XEDBU) Ergebnissignal. Transfer BS-DB-Datenblock (footer): count=%d job=%d offset=0x%02x length=0x%02x checksum=0x%06x\n", S, PJ, D, L, CS);
*opcode = OPCODE_XEDBU;
buffer[0] = S;
@ -1057,7 +1058,7 @@ int encode_yaaau(uint8_t *opcode, uint8_t **data, uint8_t J)
{
static uint8_t buffer[2];
PDEBUG(DMUP, DEBUG_INFO, "(MSC YAAAU) Auftrag Initialisieren BS des MSC: job=%d\n", J);
LOGP(DMUP, LOGL_INFO, "(MSC YAAAU) Auftrag Initialisieren BS des MSC: job=%d\n", J);
*opcode = OPCODE_YAAAU;
buffer[0] = 0xff;
@ -1072,7 +1073,7 @@ int encode_swau(uint8_t *opcode, uint8_t **data, uint8_t V)
{
static uint8_t buffer[1];
PDEBUG(DMUP, DEBUG_INFO, "(MSC SWAU) Wiederanlaufauftrag des MSC: version=%d (%s)\n", V, version_string(V));
LOGP(DMUP, LOGL_INFO, "(MSC SWAU) Wiederanlaufauftrag des MSC: version=%d (%s)\n", V, version_string(V));
*opcode = OPCODE_SWAU;
buffer[0] = V;
@ -1085,7 +1086,7 @@ int encode_swau(uint8_t *opcode, uint8_t **data, uint8_t V)
void decode_swqf(uint8_t *data, int len, uint8_t *V, uint8_t *N, uint8_t *U, uint8_t *F, uint8_t *C, uint8_t *B)
{
if (len < 6) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return;
}
@ -1096,14 +1097,14 @@ void decode_swqf(uint8_t *data, int len, uint8_t *V, uint8_t *N, uint8_t *U, uin
*C = data[4];
*B = data[5];
PDEBUG(DMUP, DEBUG_INFO, "(BS SWQF) Wiederanlauf-Quittung der BS: version=%d (%s) FuFSt=%d,%d,%d chip=%d (%s) beacon=%d (%s)\n", *V, version_string(*V), *N, *U, *F, *C, chip_string(*C), *B, beacon_string(*B));
LOGP(DMUP, LOGL_INFO, "(BS SWQF) Wiederanlauf-Quittung der BS: version=%d (%s) FuFSt=%d,%d,%d chip=%d (%s) beacon=%d (%s)\n", *V, version_string(*V), *N, *U, *F, *C, chip_string(*C), *B, beacon_string(*B));
}
/* request "Aktivdatei" (inscripted substribers) */
void encode_sadau(uint8_t *opcode)
{
*opcode = OPCODE_SADAU;
PDEBUG(DMUP, DEBUG_INFO, "(MSC SADAU) Aktivdatei-Auftrag vom MSC\n");
LOGP(DMUP, LOGL_INFO, "(MSC SADAU) Aktivdatei-Auftrag vom MSC\n");
}
/* ack "Aktivdatei" */
@ -1112,7 +1113,7 @@ int decode_sadqf(uint8_t *data, int len, uint16_t *S, uint8_t *E, uint8_t *l, ui
int i, n = 0;
if (len < 11) {
PDEBUG(DMUP, DEBUG_NOTICE, "Message too short!\n");
LOGP(DMUP, LOGL_NOTICE, "Message too short!\n");
return 0;
}
@ -1127,9 +1128,9 @@ int decode_sadqf(uint8_t *data, int len, uint16_t *S, uint8_t *E, uint8_t *l, ui
n++;
}
PDEBUG(DMUP, DEBUG_INFO, "(BS SADQF) Aktivdateiquittung der BS:\n");
LOGP(DMUP, LOGL_INFO, "(BS SADQF) Aktivdateiquittung der BS:\n");
for (i = 0; i < n; i++)
PDEBUG(DMUP, DEBUG_INFO, " %d: FuTln=%d,%d,%d (0161-%d%d%05d)\n", i + 1, N[i], U[i], T[i], N[i], U[i], T[i]);
LOGP(DMUP, LOGL_INFO, " %d: FuTln=%d,%d,%d (0161-%d%d%05d)\n", i + 1, N[i], U[i], T[i], N[i], U[i], T[i]);
return n;
}

View File

@ -23,8 +23,9 @@
#include <string.h>
#include <errno.h>
#include "../libsample/sample.h"
#include "../libtimer/timer.h"
#include "../libdebug/debug.h"
#include <osmocom/core/timer.h>
#include <osmocom/core/utils.h>
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/main_mobile.h"
#include "../liboptions/options.h"
@ -72,7 +73,7 @@ static void receive_fisu(mtp_t *mtp, uint8_t bsn, uint8_t bib, uint8_t fsn, uint
{
sniffer_t *sniffer = (sniffer_t *)mtp->inst;
PDEBUG(DMTP3, (fsn == sniffer->last_fsn) ? DEBUG_INFO : DEBUG_NOTICE, "%s FISU Frame: FSN=%d FIB=%d BSN=%d BIB=%d\n", mtp->name, fsn, fib, bsn, bib);
LOGP(DMTP3, (fsn == sniffer->last_fsn) ? LOGL_INFO : LOGL_NOTICE, "%s FISU Frame: FSN=%d FIB=%d BSN=%d BIB=%d\n", mtp->name, fsn, fib, bsn, bib);
/* store current FSN */
sniffer->last_fsn = fsn;
@ -83,7 +84,7 @@ static void receive_lssu(mtp_t *mtp, uint8_t fsn, uint8_t bib, uint8_t status)
{
sniffer_t *sniffer = (sniffer_t *)mtp->inst;
PDEBUG(DMTP3, DEBUG_INFO, "%s LSSU Frame: FSN=%d BIB=%d status=%d\n", mtp->name, fsn, bib, status);
LOGP(DMTP3, LOGL_INFO, "%s LSSU Frame: FSN=%d BIB=%d status=%d\n", mtp->name, fsn, bib, status);
/* store initial FSN */
sniffer->last_fsn = fsn;
@ -98,17 +99,17 @@ static void receive_msu(mtp_t *mtp, uint8_t bsn, uint8_t bib, uint8_t fsn, uint8
uint8_t ident, opcode;
if (len < 4) {
PDEBUG(DMTP3, DEBUG_NOTICE, "Short frame from layer 2 (len=%d)\n", len);
LOGP(DMTP3, LOGL_NOTICE, "Short frame from layer 2 (len=%d)\n", len);
return;
}
if (fsn == sniffer->last_fsn) {
PDEBUG(DMTP3, DEBUG_INFO, "%s MSU Frame: FSN=%d FIB=%d BSN=%d BIB=%d data: %02x %s\n", mtp->name, fsn, fib, bsn, bib, sio, debug_hex(data, len));
LOGP(DMTP3, LOGL_INFO, "%s MSU Frame: FSN=%d FIB=%d BSN=%d BIB=%d data: %02x %s\n", mtp->name, fsn, fib, bsn, bib, sio, osmo_hexdump(data, len));
return;
}
if (len < 6) {
PDEBUG(DMTP3, DEBUG_NOTICE, "Frame from layer 2 too short to carry an Opcode (len=%d)\n", len);
LOGP(DMTP3, LOGL_NOTICE, "Frame from layer 2 too short to carry an Opcode (len=%d)\n", len);
return;
}
@ -126,9 +127,9 @@ static void receive_msu(mtp_t *mtp, uint8_t bsn, uint8_t bib, uint8_t fsn, uint8
len -= 6;
if (sio == 0xcd)
PDEBUG(DMTP3, DEBUG_NOTICE, "%s MuP Frame: FSN=%d FIB=%d BSN=%d BIB=%d SIO=0x%02x DCP=%d OCP=%d Ident=0x%02x OP=%02XH %s\n", mtp->name, fsn, fib, bsn, bib, sio, dcp, ocp, ident, opcode, debug_hex(data, len));
LOGP(DMTP3, LOGL_NOTICE, "%s MuP Frame: FSN=%d FIB=%d BSN=%d BIB=%d SIO=0x%02x DCP=%d OCP=%d Ident=0x%02x OP=%02XH %s\n", mtp->name, fsn, fib, bsn, bib, sio, dcp, ocp, ident, opcode, osmo_hexdump(data, len));
else
PDEBUG(DMTP3, DEBUG_NOTICE, "%s MSU Frame: FSN=%d FIB=%d BSN=%d BIB=%d SIO=0x%02x DCP=%d OCP=%d SLC=%d H2/H1=0x%02x %02x %s\n", mtp->name, fsn, fib, bsn, bib, sio, dcp, ocp, slc, h2h1, data[-1], debug_hex(data, len));
LOGP(DMTP3, LOGL_NOTICE, "%s MSU Frame: FSN=%d FIB=%d BSN=%d BIB=%d SIO=0x%02x DCP=%d OCP=%d SLC=%d H2/H1=0x%02x %02x %s\n", mtp->name, fsn, fib, bsn, bib, sio, dcp, ocp, slc, h2h1, data[-1], osmo_hexdump(data, len));
/* store current FSN */
sniffer->last_fsn = fsn;
@ -158,7 +159,7 @@ void sniffer_destroy(sender_t *sender)
{
sniffer_t *sniffer = (sniffer_t *) sender;
PDEBUG(DCNETZ, DEBUG_DEBUG, "Destroying 'Sniffer' instance for 'Kanal' = %s.\n", sender->kanal);
LOGP(DCNETZ, LOGL_DEBUG, "Destroying 'Sniffer' instance for 'Kanal' = %s.\n", sender->kanal);
mtp_exit(&sniffer->mtp);
@ -202,11 +203,11 @@ int main(int argc, char *argv[])
if (num_device <= 1)
dsp_device[1] = dsp_device[0];
for (i = 0; i < num_kanal; i++) {
PDEBUG(DCNETZ, DEBUG_DEBUG, "Creating 'Sniffer' instance for 'Kanal' = %s (sample rate %d).\n", kanal[i], dsp_samplerate);
LOGP(DCNETZ, LOGL_DEBUG, "Creating 'Sniffer' instance for 'Kanal' = %s (sample rate %d).\n", kanal[i], dsp_samplerate);
sniffer = calloc(1, sizeof(sniffer_t));
if (!sniffer) {
PDEBUG(DCNETZ, DEBUG_ERROR, "No memory!\n");
LOGP(DCNETZ, LOGL_ERROR, "No memory!\n");
goto fail;
}
rc = sender_create(&sniffer->sender, kanal[i], 131, 131, dsp_device[i], 0, dsp_samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
@ -234,6 +235,7 @@ fail:
sniffer_destroy(sender_head);
/* exits */
main_mobile_exit();
fm_exit();
return 0;

View File

@ -1,6 +1,6 @@
#include <stdlib.h>
#include <inttypes.h>
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "systemmeldungen.h"
static struct systemmeldungen {
@ -21894,8 +21894,8 @@ void print_systemmeldung(uint16_t code, int bytes, uint8_t *ind)
if (i == ii)
return;
PDEBUG(DMUP, DEBUG_INFO, " -> %s\n", systemmeldungen[i].desc);
LOGP(DMUP, LOGL_INFO, " -> %s\n", systemmeldungen[i].desc);
for (j = 0; j < systemmeldungen[i].bytes; j++)
PDEBUG(DMUP, DEBUG_INFO, " Byte %d = %02Xh: %s\n", j, ind[j], systemmeldungen[i].ind[j]);
LOGP(DMUP, LOGL_INFO, " Byte %d = %02Xh: %s\n", j, ind[j], systemmeldungen[i].ind[j]);
}

View File

@ -12,21 +12,19 @@ golay_LDADD = \
$(COMMON_LA) \
../amps/libusatone.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/libjitter/libjitter.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libselect/libselect.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

View File

@ -27,7 +27,7 @@
#include <math.h>
#include <sys/param.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "golay.h"
#include "dsp.h"
@ -39,7 +39,7 @@ static void dsp_init_ramp(gsc_t *gsc)
double c;
int i;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Generating cosine shaped ramp table.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Generating cosine shaped ramp table.\n");
for (i = 0; i < 256; i++) {
/* This is mathematically incorrect... */
if (i < 64)
@ -58,7 +58,7 @@ int dsp_init_sender(gsc_t *gsc, int samplerate, double deviation, double polarit
{
int rc;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for transceiver.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Init DSP for transceiver.\n");
/* set modulation parameters */
// NOTE: baudrate equals modulation, because we have a raised cosine ramp of beta = 0.5
@ -66,12 +66,12 @@ int dsp_init_sender(gsc_t *gsc, int samplerate, double deviation, double polarit
gsc->fsk_bitduration = (double)samplerate / 600.0;
gsc->fsk_bitstep = 1.0 / gsc->fsk_bitduration;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Use %.4f samples for one bit duration @ %d.\n", gsc->fsk_bitduration, gsc->sender.samplerate);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Use %.4f samples for one bit duration @ %d.\n", gsc->fsk_bitduration, gsc->sender.samplerate);
gsc->fsk_tx_buffer_size = gsc->fsk_bitduration + 10; /* 1 bit, add some extra to prevent short buffer due to rounding */
gsc->fsk_tx_buffer = calloc(sizeof(sample_t), gsc->fsk_tx_buffer_size);
if (!gsc->fsk_tx_buffer) {
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "No memory!\n");
LOGP_CHAN(DDSP, LOGL_ERROR, "No memory!\n");
rc = -ENOMEM;
goto error;
}
@ -93,7 +93,7 @@ error:
/* Cleanup transceiver instance. */
void dsp_cleanup_sender(gsc_t *gsc)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for transceiver.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Cleanup DSP for transceiver.\n");
if (gsc->fsk_tx_buffer) {
free(gsc->fsk_tx_buffer);
@ -202,7 +202,7 @@ again:
}
samplerate_upsample(&gsc->wave_tx_upsample, wave_samples[0], wave_num, samples, length);
if (!gsc->wave_tx_play.left) {
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Voice message sent.\n");
LOGP_CHAN(DDSP, LOGL_INFO, "Voice message sent.\n");
wave_destroy_playback(&gsc->wave_tx_play);
return;
}
@ -221,9 +221,9 @@ again:
rc = wave_create_playback(&gsc->wave_tx_play, gsc->wave_tx_filename, &gsc->wave_tx_samplerate, &gsc->wave_tx_channels, gsc->fsk_deviation);
if (rc < 0) {
gsc->wave_tx_play.left = 0;
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "Failed to open wave file '%s' for voice message.\n", gsc->wave_tx_filename);
LOGP_CHAN(DDSP, LOGL_ERROR, "Failed to open wave file '%s' for voice message.\n", gsc->wave_tx_filename);
} else {
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Sending wave file '%s' for voice message after 2 seconds.\n", gsc->wave_tx_filename);
LOGP_CHAN(DDSP, LOGL_INFO, "Sending wave file '%s' for voice message after 2 seconds.\n", gsc->wave_tx_filename);
init_samplerate(&gsc->wave_tx_upsample, gsc->wave_tx_samplerate, gsc->sender.samplerate, VOICE_BANDWIDTH);
}
}

View File

@ -34,7 +34,7 @@
#include <sys/types.h>
#include <sys/param.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/main_mobile.h"
#include "../libmobile/cause.h"
@ -49,30 +49,30 @@ int golay_create(const char *kanal, double frequency, const char *device, int us
gsc = calloc(1, sizeof(*gsc));
if (!gsc) {
PDEBUG(DGOLAY, DEBUG_ERROR, "No memory!\n");
LOGP(DGOLAY, LOGL_ERROR, "No memory!\n");
return -ENOMEM;
}
PDEBUG(DGOLAY, DEBUG_DEBUG, "Creating 'GOLAY' instance for frequency = %s (sample rate %d).\n", kanal, samplerate);
LOGP(DGOLAY, LOGL_DEBUG, "Creating 'GOLAY' instance for frequency = %s (sample rate %d).\n", kanal, samplerate);
/* init general part of transceiver */
rc = sender_create(&gsc->sender, kanal, frequency, frequency, device, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DGOLAY, DEBUG_ERROR, "Failed to init transceiver process!\n");
LOGP(DGOLAY, LOGL_ERROR, "Failed to init transceiver process!\n");
goto error;
}
/* init audio processing */
rc = dsp_init_sender(gsc, samplerate, deviation, polarity);
if (rc < 0) {
PDEBUG(DGOLAY, DEBUG_ERROR, "Failed to init audio processing!\n");
LOGP(DGOLAY, LOGL_ERROR, "Failed to init audio processing!\n");
goto error;
}
gsc->tx = 1;
gsc->default_message = message;
PDEBUG(DGOLAY, DEBUG_NOTICE, "Created transmitter for frequency %s\n", kanal);
LOGP(DGOLAY, LOGL_NOTICE, "Created transmitter for frequency %s\n", kanal);
return 0;
@ -89,7 +89,7 @@ void golay_destroy(sender_t *sender)
{
gsc_t *gsc = (gsc_t *) sender;
PDEBUG(DGOLAY, DEBUG_DEBUG, "Destroying 'GOLAY' instance for frequency = %s.\n", sender->kanal);
LOGP(DGOLAY, LOGL_DEBUG, "Destroying 'GOLAY' instance for frequency = %s.\n", sender->kanal);
while (gsc->msg_list)
golay_msg_destroy(gsc, gsc->msg_list);
@ -104,11 +104,11 @@ static gsc_msg_t *golay_msg_create(gsc_t *gsc, const char *address, const char *
gsc_msg_t *msg, **msgp;
if (strlen(address) != sizeof(msg->address) - 1) {
PDEBUG(DGOLAY, DEBUG_NOTICE, "Address has incorrect length, cannot page!\n");
LOGP(DGOLAY, LOGL_NOTICE, "Address has incorrect length, cannot page!\n");
return NULL;
}
if (strlen(text) > sizeof(msg->data) - 1) {
PDEBUG(DGOLAY, DEBUG_NOTICE, "Given test is too long, cannot page!\n");
LOGP(DGOLAY, LOGL_NOTICE, "Given test is too long, cannot page!\n");
return NULL;
}
@ -126,18 +126,18 @@ static gsc_msg_t *golay_msg_create(gsc_t *gsc, const char *address, const char *
case '9': type = TYPE_TONE; break;
case '0': type = TYPE_TONE; break;
default:
PDEBUG(DGOLAY, DEBUG_NOTICE, "Illegal function suffix '%c' in last address digit.\n", address[6]);
LOGP(DGOLAY, LOGL_NOTICE, "Illegal function suffix '%c' in last address digit.\n", address[6]);
return NULL;
}
} else
PDEBUG(DGOLAY, DEBUG_INFO, "Overriding message type as defined by sender.\n");
LOGP(DGOLAY, LOGL_INFO, "Overriding message type as defined by sender.\n");
PDEBUG(DGOLAY, DEBUG_INFO, "Creating msg instance to page address '%s'.\n", address);
LOGP(DGOLAY, LOGL_INFO, "Creating msg instance to page address '%s'.\n", address);
/* create */
msg = calloc(1, sizeof(*msg));
if (!msg) {
PDEBUG(DGOLAY, DEBUG_ERROR, "No mem!\n");
LOGP(DGOLAY, LOGL_ERROR, "No mem!\n");
abort();
}
@ -281,27 +281,27 @@ static char encode_alpha(char c)
switch (c) {
case 0x0a:
case 0x0d:
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> CR/LF character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> CR/LF character.\n");
c = 0x3c;
break;
case '{':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> '%c' character.\n", c);
LOGP(DGOLAY, LOGL_DEBUG, " -> '%c' character.\n", c);
c = 0x3b;
break;
case '}':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> '%c' character.\n", c);
LOGP(DGOLAY, LOGL_DEBUG, " -> '%c' character.\n", c);
c = 0x3d;
break;
case '\\':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> '%c' character.\n", c);
LOGP(DGOLAY, LOGL_DEBUG, " -> '%c' character.\n", c);
c = 0x20;
break;
default:
if (c < 0x20 || c > 0x5d) {
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> ' ' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> ' ' character.\n");
c = 0x20;
} else {
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> '%c' character.\n", c);
LOGP(DGOLAY, LOGL_DEBUG, " -> '%c' character.\n", c);
c = c - 0x20;
}
}
@ -314,93 +314,93 @@ static char encode_numeric(char c)
switch (c) {
case 'u':
case 'U':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'U' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'U' character.\n");
c = 0xb;
break;
case ' ':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> '%c' character.\n", c);
LOGP(DGOLAY, LOGL_DEBUG, " -> '%c' character.\n", c);
c = 0xc;
break;
case '-':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> '%c' character.\n", c);
LOGP(DGOLAY, LOGL_DEBUG, " -> '%c' character.\n", c);
c = 0xd;
break;
case '=':
case '*':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> '*' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> '*' character.\n");
c = 0xe;
break;
case 'a':
case 'A':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'A' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'A' character.\n");
c = 0xf0;
break;
case 'b':
case 'B':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'B' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'B' character.\n");
c = 0xf1;
break;
case 'c':
case 'C':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'C' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'C' character.\n");
c = 0xf2;
break;
case 'd':
case 'D':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'D' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'D' character.\n");
c = 0xf3;
break;
case 'e':
case 'E':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'E' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'E' character.\n");
c = 0xf4;
break;
case 'f':
case 'F':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'F' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'F' character.\n");
c = 0xf6;
break;
case 'g':
case 'G':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'G' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'G' character.\n");
c = 0xf7;
break;
case 'h':
case 'H':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'H' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'H' character.\n");
c = 0xf8;
break;
case 'j':
case 'J':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'J' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'J' character.\n");
c = 0xf9;
break;
case 'l':
case 'L':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'L' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'L' character.\n");
c = 0xfb;
break;
case 'n':
case 'N':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'N' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'N' character.\n");
c = 0xfc;
break;
case 'p':
case 'P':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'P' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'P' character.\n");
c = 0xfd;
break;
case 'r':
case 'R':
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> 'r' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> 'r' character.\n");
c = 0xfe;
break;
default:
if (c >= '0' && c <= '9') {
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> '%c' character.\n", c);
LOGP(DGOLAY, LOGL_DEBUG, " -> '%c' character.\n", c);
c = c - '0';
} else {
PDEBUG(DGOLAY, DEBUG_DEBUG, " -> ' ' character.\n");
LOGP(DGOLAY, LOGL_DEBUG, " -> ' ' character.\n");
c = 0xc;
}
}
@ -419,7 +419,7 @@ static int encode_address(const char *code, int *preamble, uint16_t *word1, uint
break;
}
if (code[i]) {
PDEBUG(DGOLAY, DEBUG_NOTICE, "Invalid functional address character. Only 0..9 are allowed.\n");
LOGP(DGOLAY, LOGL_NOTICE, "Invalid functional address character. Only 0..9 are allowed.\n");
return -EINVAL;
}
@ -457,7 +457,7 @@ static int encode_address(const char *code, int *preamble, uint16_t *word1, uint
break;
}
if (i < 16) {
PDEBUG(DGOLAY, DEBUG_NOTICE, "Functional address has invlid value '%03d' for last three characters.\n", a2a1a0);
LOGP(DGOLAY, LOGL_NOTICE, "Functional address has invlid value '%03d' for last three characters.\n", a2a1a0);
return -EINVAL;
}
} else {
@ -466,7 +466,7 @@ static int encode_address(const char *code, int *preamble, uint16_t *word1, uint
break;
}
if (i < 7) {
PDEBUG(DGOLAY, DEBUG_NOTICE, "Functional address has invlid value '%03d' for last three characters.\n", a2a1a0);
LOGP(DGOLAY, LOGL_NOTICE, "Functional address has invlid value '%03d' for last three characters.\n", a2a1a0);
return -EINVAL;
}
}
@ -528,7 +528,7 @@ static int queue_batch(gsc_t *gsc, const char *address, enum gsc_msg_type type,
/* check address length */
if (!address || strlen(address) != 7) {
PDEBUG(DGOLAY, DEBUG_NOTICE, "Invalid functional address '%s' size. Only 7 digits are allowed.\n", address);
LOGP(DGOLAY, LOGL_NOTICE, "Invalid functional address '%s' size. Only 7 digits are allowed.\n", address);
return -EINVAL;
}
@ -550,24 +550,24 @@ static int queue_batch(gsc_t *gsc, const char *address, enum gsc_msg_type type,
case '9': function = 0; break;
case '0': function = 1; break;
default:
PDEBUG(DGOLAY, DEBUG_NOTICE, "Illegal function suffix '%c' in last address digit.\n", address[6]);
LOGP(DGOLAY, LOGL_NOTICE, "Illegal function suffix '%c' in last address digit.\n", address[6]);
return -EINVAL;
}
switch (type) {
case TYPE_ALPHA:
case TYPE_NUMERIC:
PDEBUG(DGOLAY, DEBUG_INFO, "Coding text message for functional address '%s' and message '%s'.\n", address, message);
LOGP(DGOLAY, LOGL_INFO, "Coding text message for functional address '%s' and message '%s'.\n", address, message);
break;
case TYPE_VOICE:
PDEBUG(DGOLAY, DEBUG_INFO, "Coding voice message for functional address %s with wave file '%s'.\n", address, message);
LOGP(DGOLAY, LOGL_INFO, "Coding voice message for functional address %s with wave file '%s'.\n", address, message);
break;
default:
PDEBUG(DGOLAY, DEBUG_INFO, "Coding tone only message for functional address %s.\n", address);
LOGP(DGOLAY, LOGL_INFO, "Coding tone only message for functional address %s.\n", address);
}
/* encode preamble and store */
PDEBUG(DGOLAY, DEBUG_DEBUG, "Encoding preamble '%d'.\n", preamble);
LOGP(DGOLAY, LOGL_DEBUG, "Encoding preamble '%d'.\n", preamble);
golay = calc_golay(preamble_values[preamble]);
queue_comma(gsc, 28, golay & 1);
for (i = 0; i < 18; i++) {
@ -575,7 +575,7 @@ static int queue_batch(gsc_t *gsc, const char *address, enum gsc_msg_type type,
}
/* encode start code and store */
PDEBUG(DGOLAY, DEBUG_DEBUG, "Encoding start code.\n");
LOGP(DGOLAY, LOGL_DEBUG, "Encoding start code.\n");
golay = calc_golay(start_code);
queue_comma(gsc, 28, golay & 1);
queue_dup(gsc, golay, 23);
@ -584,7 +584,7 @@ static int queue_batch(gsc_t *gsc, const char *address, enum gsc_msg_type type,
queue_dup(gsc, golay, 23);
/* encode address and store */
PDEBUG(DGOLAY, DEBUG_DEBUG, "Encoding address words '%d' and '%d'.\n", word1, word2);
LOGP(DGOLAY, LOGL_DEBUG, "Encoding address words '%d' and '%d'.\n", word1, word2);
golay = calc_golay(word1);
if (function & 0x2)
golay ^= 0x7fffff;
@ -599,10 +599,10 @@ static int queue_batch(gsc_t *gsc, const char *address, enum gsc_msg_type type,
/* encode message */
switch (type) {
case TYPE_ALPHA:
PDEBUG(DGOLAY, DEBUG_DEBUG, "Encoding %d alphanumeric digits.\n", (int)strlen(message));
LOGP(DGOLAY, LOGL_DEBUG, "Encoding %d alphanumeric digits.\n", (int)strlen(message));
for (i = 0; *message; i++) {
if (i == MAX_ADB) {
PDEBUG(DGOLAY, DEBUG_NOTICE, "Message overflows %d characters, cropping message.\n", MAX_ADB * 8);
LOGP(DGOLAY, LOGL_NOTICE, "Message overflows %d characters, cropping message.\n", MAX_ADB * 8);
}
for (j = 0; *message && j < 8; j++) {
msg[j] = encode_alpha(*message++);
@ -635,11 +635,11 @@ static int queue_batch(gsc_t *gsc, const char *address, enum gsc_msg_type type,
}
break;
case TYPE_NUMERIC:
PDEBUG(DGOLAY, DEBUG_DEBUG, "Encoding %d numeric digits.\n", (int)strlen(message));
LOGP(DGOLAY, LOGL_DEBUG, "Encoding %d numeric digits.\n", (int)strlen(message));
shifted = 0;
for (i = 0; *message; i++) {
if (i == MAX_NDB) {
PDEBUG(DGOLAY, DEBUG_NOTICE, "Message overflows %d characters, cropping message.\n", MAX_NDB * 12);
LOGP(DGOLAY, LOGL_NOTICE, "Message overflows %d characters, cropping message.\n", MAX_NDB * 12);
}
for (j = 0; *message && j < 12; j++) {
/* get next digit or shifted digit */
@ -690,7 +690,7 @@ static int queue_batch(gsc_t *gsc, const char *address, enum gsc_msg_type type,
/* store bit number for activation code. this is used to play the AC again after voice message. */
gsc->bit_ac = gsc->bit_num;
/* encode activation code and store */
PDEBUG(DGOLAY, DEBUG_DEBUG, "Encoding activation code.\n");
LOGP(DGOLAY, LOGL_DEBUG, "Encoding activation code.\n");
golay = calc_golay(activation_code);
queue_comma(gsc, 28, golay & 1);
queue_dup(gsc, golay, 23);
@ -700,13 +700,13 @@ static int queue_batch(gsc_t *gsc, const char *address, enum gsc_msg_type type,
break;
default:
/* encode comma after message and store */
PDEBUG(DGOLAY, DEBUG_DEBUG, "Encoding 'comma' sequence after message.\n");
LOGP(DGOLAY, LOGL_DEBUG, "Encoding 'comma' sequence after message.\n");
queue_comma(gsc, 121 * 8, 1);
}
/* check overflow */
if (gsc->bit_overflow) {
PDEBUG(DGOLAY, DEBUG_ERROR, "Bit stream (%d bits) overflows bit buffer size (%d bits), please fix!\n", gsc->bit_num, (int)sizeof(gsc->bit));
LOGP(DGOLAY, LOGL_ERROR, "Bit stream (%d bits) overflows bit buffer size (%d bits), please fix!\n", gsc->bit_num, (int)sizeof(gsc->bit));
return -EOVERFLOW;
}
@ -741,7 +741,7 @@ int8_t get_bit(gsc_t *gsc)
return 2;
}
queue_reset(gsc);
PDEBUG(DGOLAY, DEBUG_INFO, "Done transmitting message.\n");
LOGP(DGOLAY, LOGL_INFO, "Done transmitting message.\n");
goto next_msg;
}
return gsc->bit[gsc->bit_index++];
@ -757,7 +757,7 @@ next_msg:
/* encode first message in queue */
rc = queue_batch(gsc, msg->address, msg->type, msg->data);
if (rc >= 0)
PDEBUG(DGOLAY, DEBUG_INFO, "Transmitting message to address '%s'.\n", msg->address);
LOGP(DGOLAY, LOGL_INFO, "Transmitting message to address '%s'.\n", msg->address);
golay_msg_destroy(gsc, msg);
if (rc < 0)
goto next_msg;
@ -823,9 +823,9 @@ int call_down_setup(int __attribute__((unused)) callref, const char *caller_id,
}
if (!sender) {
if (channel)
PDEBUG(DGOLAY, DEBUG_NOTICE, "Cannot page, because given station not available, rejecting!\n");
LOGP(DGOLAY, LOGL_NOTICE, "Cannot page, because given station not available, rejecting!\n");
else
PDEBUG(DGOLAY, DEBUG_NOTICE, "Cannot page, no trasmitting station available, rejecting!\n");
LOGP(DGOLAY, LOGL_NOTICE, "Cannot page, no trasmitting station available, rejecting!\n");
return -CAUSE_NOCHANNEL;
}
@ -852,7 +852,7 @@ void call_down_answer(int __attribute__((unused)) callref)
static void _release(int __attribute__((unused)) callref, int __attribute__((unused)) cause)
{
PDEBUG(DGOLAY, DEBUG_INFO, "Call has been disconnected by network.\n");
LOGP(DGOLAY, LOGL_INFO, "Call has been disconnected by network.\n");
}
void call_down_disconnect(int callref, int cause)

View File

@ -27,7 +27,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "../libmobile/main_mobile.h"
#include "../liboptions/options.h"
@ -172,7 +172,7 @@ static void myhandler(void)
if (tx)
golay_msg_send(buffer);
else
PDEBUG(DGOLAY, DEBUG_ERROR, "Failed to send message, transmitter is not enabled!\n");
LOGP(DGOLAY, LOGL_ERROR, "Failed to send message, transmitter is not enabled!\n");
}
}
}
@ -294,6 +294,7 @@ fail:
golay_destroy(sender_head);
/* exits */
main_mobile_exit();
fm_exit();
options_free();

View File

@ -13,22 +13,20 @@ imts_LDADD = \
$(COMMON_LA) \
../amps/libusatone.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/libjitter/libjitter.a \
$(top_builddir)/src/libsquelch/libsquelch.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libselect/libselect.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
imts_dialer_SOURCES = \
@ -37,9 +35,10 @@ imts_dialer_SOURCES = \
imts_dialer_LDADD = \
$(COMMON_LA) \
$(top_builddir)/src/liboptions/liboptions.a \
$(top_builddir)/src/libdebug/libdebug.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/liblogging/liblogging.a \
$(LIBOSMOCORE_LIBS) \
-lm
if HAVE_ALSA

View File

@ -26,7 +26,7 @@
#include <errno.h>
#include "../libsample/sample.h"
#include "../libwave/wave.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#ifdef HAVE_ALSA
#include "../libsound/sound.h"
#endif
@ -186,7 +186,7 @@ static void process_signal(int buffer_size)
count = dsp_samplerate / 1000;
#endif
if (count < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count);
LOGP(DDSP, LOGL_ERROR, "Failed to get number of samples in buffer (rc = %d)!\n", count);
break;
}
@ -201,7 +201,7 @@ static void process_signal(int buffer_size)
/* write audio */
rc = sound_write(audio, samples, power, count, NULL, NULL, 1);
if (rc < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to write TX data to audio device (rc = %d)\n", rc);
LOGP(DDSP, LOGL_ERROR, "Failed to write TX data to audio device (rc = %d)\n", rc);
break;
}
#endif
@ -309,7 +309,7 @@ int main(int argc, char *argv[])
/* init sound */
audio = sound_open(dsp_audiodev, NULL, NULL, NULL, 1, 0.0, dsp_samplerate, dsp_buffer, 1.0, 1.0, 4000.0, 2.0);
if (!audio) {
PDEBUG(DBNETZ, DEBUG_ERROR, "No sound device!\n");
LOGP(DBNETZ, LOGL_ERROR, "No sound device!\n");
goto exit;
}
#endif
@ -318,13 +318,13 @@ int main(int argc, char *argv[])
if (write_tx_wave) {
rc = wave_create_record(&wave_tx_rec, write_tx_wave, dsp_samplerate, 1, 1.0);
if (rc < 0) {
PDEBUG(DBNETZ, DEBUG_ERROR, "Failed to create WAVE recoding instance!\n");
LOGP(DBNETZ, LOGL_ERROR, "Failed to create WAVE recoding instance!\n");
goto exit;
}
}
#ifndef HAVE_ALSA
else {
PDEBUG(DBNETZ, DEBUG_ERROR, "No sound support compiled in, so you need to write to a wave file. See help!\n");
LOGP(DBNETZ, LOGL_ERROR, "No sound support compiled in, so you need to write to a wave file. See help!\n");
goto exit;
}
#endif
@ -334,7 +334,7 @@ int main(int argc, char *argv[])
sound_start(audio);
#endif
PDEBUG(DBNETZ, DEBUG_ERROR, "Start audio after pause...\n");
LOGP(DBNETZ, LOGL_ERROR, "Start audio after pause...\n");
process_signal(buffer_size);

View File

@ -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 "imts.h"
#include "dsp.h"
@ -111,7 +111,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;
@ -123,7 +123,7 @@ int dsp_init_transceiver(imts_t *imts, double squelch_db, int ptt)
{
int rc = -1;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for Transceiver.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Init DSP for Transceiver.\n");
imts->sample_duration = 1.0 / (double)imts->sender.samplerate;
@ -164,11 +164,11 @@ int dsp_init_transceiver(imts_t *imts, double squelch_db, int ptt)
/* delay buffer */
if (ptt) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Push to talk: Adding delay buffer to remove noise when signal gets lost.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Push to talk: Adding delay buffer to remove noise when signal gets lost.\n");
imts->delay_max = (int)((double)imts->sender.samplerate * DELAY_TIME);
imts->delay_spl = calloc(imts->delay_max, sizeof(*imts->delay_spl));
if (!imts->delay_spl) {
PDEBUG(DDSP, DEBUG_ERROR, "No mem for delay buffer!\n");
LOGP(DDSP, LOGL_ERROR, "No mem for delay buffer!\n");
goto error;
}
}
@ -186,7 +186,7 @@ error:
/* Cleanup transceiver instance. */
void dsp_cleanup_transceiver(imts_t *imts)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for Transceiver.\n");
LOGP_CHAN(DDSP, LOGL_DEBUG, "Cleanup DSP for Transceiver.\n");
fm_demod_exit(&imts->demod);
if (imts->delay_spl) {
@ -221,7 +221,7 @@ static int generate_tone(imts_t *imts, sample_t *samples, int length)
case TONE_SILENCE:
break;
default:
PDEBUG_CHAN(DDSP, DEBUG_ERROR, "Software error, unsupported tone, please fix!\n");
LOGP_CHAN(DDSP, LOGL_ERROR, "Software error, unsupported tone, please fix!\n");
return length;
}
@ -386,7 +386,7 @@ static void tone_demod(imts_t *imts, sample_t *samples, int length)
printf("decoder debug: %s detected, waiting to sustain\n", tone_names[tone]);
#endif
if (imts->demod_sig_tone) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Lost %s (duration %.0f ms)\n", tone_names[imts->demod_current_tone], imts->demod_duration * 1000.0);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Lost %s (duration %.0f ms)\n", tone_names[imts->demod_current_tone], imts->demod_duration * 1000.0);
imts_lost_tone(imts, imts->demod_current_tone, imts->demod_duration);
imts->demod_sig_tone = 0;
}
@ -406,7 +406,7 @@ static void tone_demod(imts_t *imts, sample_t *samples, int length)
amp = amplitude[i];
imts->demod_sig_tone = 0;
}
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Detected %s (level %.0f%%)\n", tone_names[imts->demod_current_tone], amp * 100);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Detected %s (level %.0f%%)\n", tone_names[imts->demod_current_tone], amp * 100);
imts_receive_tone(imts, imts->demod_current_tone, imts->demod_duration, amp);
imts->demod_last_tone = imts->demod_current_tone;
imts->demod_duration = imts->demod_sustain;
@ -419,7 +419,7 @@ static void tone_demod(imts_t *imts, sample_t *samples, int length)
double quality = 1.0 - imts->demod_quality_value / (double)imts->demod_quality_count * 2.0;
if (quality < 0)
quality = 0;
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Quality: %.0f%%\n", quality * 100.0);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Quality: %.0f%%\n", quality * 100.0);
display_measurements_update(imts->dmp_tone_quality, quality * 100.0, 0.0);
}
}
@ -465,7 +465,7 @@ void sender_receive(sender_t *sender, sample_t *samples, int length, double rf_l
/* FALLTHRU */
case SQUELCH_MUTE:
if (imts->mode == MODE_MTS && !imts->is_mute) {
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Low RF level, muting.\n");
LOGP_CHAN(DDSP, LOGL_INFO, "Low RF level, muting.\n");
memset(imts->delay_spl, 0, sizeof(*samples) * imts->delay_max);
imts->is_mute = 1;
}
@ -475,7 +475,7 @@ void sender_receive(sender_t *sender, sample_t *samples, int length, double rf_l
break;
default:
if (imts->is_mute) {
PDEBUG_CHAN(DDSP, DEBUG_INFO, "High RF level, unmuting.\n");
LOGP_CHAN(DDSP, LOGL_INFO, "High RF level, unmuting.\n");
imts->is_mute = 0;
}
/* detect signal, if it is steady for a while */
@ -550,15 +550,15 @@ void imts_set_dsp_mode(imts_t *imts, enum dsp_mode mode, int tone, double durati
}
if (imts->dsp_mode != mode) {
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "DSP mode %s -> %s\n", imts_dsp_mode_name(imts->dsp_mode), imts_dsp_mode_name(mode));
LOGP_CHAN(DDSP, LOGL_DEBUG, "DSP mode %s -> %s\n", imts_dsp_mode_name(imts->dsp_mode), imts_dsp_mode_name(mode));
imts->dsp_mode = mode;
}
if (mode == DSP_MODE_TONE) {
if (duration)
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Start sending %s for %.3f seconds.\n", tone_names[tone], duration);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Start sending %s for %.3f seconds.\n", tone_names[tone], duration);
else
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Start sending %s continuously.\n", tone_names[tone]);
LOGP_CHAN(DDSP, LOGL_DEBUG, "Start sending %s continuously.\n", tone_names[tone]);
imts->tone = tone;
imts->tone_duration = duration * (double)imts->sender.samplerate;
}

View File

@ -39,11 +39,12 @@
#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 "../libmobile/get_time.h"
#include <osmocom/cc/message.h>
#include "imts.h"
#include "dsp.h"
@ -127,37 +128,37 @@ void imts_list_channels(void)
}
/* Timers */
#define PAGING_TO 4.0 /* Time to wait for the phone to respond */
#define RINGING_TO 45.0 /* Time to wait for the mobile user to answer */
#define SEIZE_TO 1.0 /* Time to wait for the phone to seize (Connect tone) */
#define ANI_TO 1.000 /* Time to wait for first / next digit */
#define DIALTONE_TO 10.0 /* Time to wait until dialing must be performed */
#define DIALING_TO 3.0 /* Time to wait until number is recognized as complete */
#define RELEASE_TO 0.350 /* Time to turn off transmitter before going idle ".. for about 300 ms .." */
#define ANI_PULSE_TO 0.100 /* Time to detect end of digit */
#define DIAL_PULSE_TO 0.200 /* Time to detect end of digit */
#define DISC_PULSE_TO 0.100 /* Time until aborting disconnect detection */
#define PAGE_PULSE_TO 0.200 /* Time to detect end of digit */
#define PAGING_TO 4,0 /* Time to wait for the phone to respond */
#define RINGING_TO 45,0 /* Time to wait for the mobile user to answer */
#define SEIZE_TO 1,0 /* Time to wait for the phone to seize (Connect tone) */
#define ANI_TO 1,0 /* Time to wait for first / next digit */
#define DIALTONE_TO 10,0 /* Time to wait until dialing must be performed */
#define DIALING_TO 3,0 /* Time to wait until number is recognized as complete */
#define RELEASE_TO 0,350000 /* Time to turn off transmitter before going idle ".. for about 300 ms .." */
#define ANI_PULSE_TO 0,100000 /* Time to detect end of digit */
#define DIAL_PULSE_TO 0,200000 /* Time to detect end of digit */
#define DISC_PULSE_TO 0.1 /* Time until aborting disconnect detection */
#define PAGE_PULSE_TO 0.2 /* Time to detect end of digit */
/* Counters */
#define DISC_COUNT 2 /* Number of pulses to detect disconnect (100 ms) */
#define RING_PULSES 40 /* 2 seconds ringer on */
#define DISC_COUNT 2 /* Number of pulses to detect disconnect (100 ms) */
#define RING_PULSES 40 /* 2 seconds ringer on */
/* Durations */
#define IDLE_DETECT 0.500 /* Time to detect Idle signal (loopback) */
#define PAGE_SEIZE 0.400 /* Time to seize channel until start paging pulses FIXME */
#define PAGE_PAUSE 0.225 /* Time to pause after each digit */
#define PAGE_MARK 0.050 /* Mark duration of page pulse */
#define PAGE_SPACE 0.050 /* Space duration of page pulse */
#define PAGE_PULSE 0.100 /* Duration of a complete pulse (MTS) */
#define RING_MARK 0.025 /* Mark duration of ring pulse */
#define RING_SPACE 0.025 /* Space duration of ring pulse */
#define RING_OFF 4.0 /* 4 seconds ringer off */
#define GUARD_TIME 0.200 /* Time until detecting Guard tone from mobile */
#define SEIZE_TIME 0.300 /* Time until sending Seize tone >= 250 */
#define SEIZE_LENGTH 0.250 /* Length of Seize */
#define RECEIVE_TIME 0.200 /* Time until detecting receive signal (Guard tone) from mobile */
#define ANSWER_TIME 0.200 /* Time until detecting answer signal (Connect tone) from mobile */
#define IDLE_DETECT 0,500000 /* Time to detect Idle signal (loopback) */
#define PAGE_SEIZE 0.400 /* Time to seize channel until start paging pulses FIXME */
#define PAGE_PAUSE 0.225 /* Time to pause after each digit */
#define PAGE_MARK 0.050 /* Mark duration of page pulse */
#define PAGE_SPACE 0.050 /* Space duration of page pulse */
#define PAGE_PULSE 0.100 /* Duration of a complete pulse (MTS) */
#define RING_MARK 0.025 /* Mark duration of ring pulse */
#define RING_SPACE 0.025 /* Space duration of ring pulse */
#define RING_OFF 4.0 /* 4 seconds ringer off */
#define GUARD_TIME 0.200 /* Time until detecting Guard tone from mobile */
#define SEIZE_TIME 0,300000 /* Time until sending Seize tone >= 250 */
#define SEIZE_LENGTH 0.250 /* Length of Seize */
#define RECEIVE_TIME 0.200 /* Time until detecting receive signal (Guard tone) from mobile */
#define ANSWER_TIME 0.200 /* Time until detecting answer signal (Connect tone) from mobile */
const char *imts_state_name(enum imts_state state)
{
@ -213,7 +214,7 @@ static void imts_new_state(imts_t *imts, enum imts_state new_state)
{
if (imts->state == new_state)
return;
PDEBUG_CHAN(DIMTS, DEBUG_DEBUG, "State change: %s -> %s\n", imts_state_name(imts->state), imts_state_name(new_state));
LOGP_CHAN(DIMTS, LOGL_DEBUG, "State change: %s -> %s\n", imts_state_name(imts->state), imts_state_name(new_state));
imts->state = new_state;
imts_display_status();
}
@ -295,34 +296,34 @@ int imts_create(const char *kanal, const char *device, int use_sdr, int samplera
int rc;
if (imts_channel2freq(kanal, 0) == 0.0) {
PDEBUG(DIMTS, DEBUG_ERROR, "Channel number %s invalid.\n", kanal);
LOGP(DIMTS, LOGL_ERROR, "Channel number %s invalid.\n", kanal);
return -EINVAL;
}
if (imts_is_canada_only(kanal)) {
PDEBUG(DIMTS, DEBUG_NOTICE, "*******************************************************************************\n");
PDEBUG(DIMTS, DEBUG_NOTICE, "Given channel '%s' was only available in Canada with Canadian phones.\n", kanal);
PDEBUG(DIMTS, DEBUG_NOTICE, "*******************************************************************************\n");
LOGP(DIMTS, LOGL_NOTICE, "*******************************************************************************\n");
LOGP(DIMTS, LOGL_NOTICE, "Given channel '%s' was only available in Canada with Canadian phones.\n", kanal);
LOGP(DIMTS, LOGL_NOTICE, "*******************************************************************************\n");
}
if (mode == MODE_IMTS && imts_channel2band(kanal) == VHF_LOW) {
PDEBUG(DIMTS, DEBUG_NOTICE, "*******************************************************************************\n");
PDEBUG(DIMTS, DEBUG_NOTICE, "Given channel '%s' was only available at MTS network.\n", kanal);
PDEBUG(DIMTS, DEBUG_NOTICE, "*******************************************************************************\n");
LOGP(DIMTS, LOGL_NOTICE, "*******************************************************************************\n");
LOGP(DIMTS, LOGL_NOTICE, "Given channel '%s' was only available at MTS network.\n", kanal);
LOGP(DIMTS, LOGL_NOTICE, "*******************************************************************************\n");
return -EINVAL;
}
if (mode == MODE_MTS && imts_channel2band(kanal) == UHF) {
PDEBUG(DIMTS, DEBUG_NOTICE, "*******************************************************************************\n");
PDEBUG(DIMTS, DEBUG_NOTICE, "Given channel '%s' was only available at IMTS network.\n", kanal);
PDEBUG(DIMTS, DEBUG_NOTICE, "*******************************************************************************\n");
LOGP(DIMTS, LOGL_NOTICE, "*******************************************************************************\n");
LOGP(DIMTS, LOGL_NOTICE, "Given channel '%s' was only available at IMTS network.\n", kanal);
LOGP(DIMTS, LOGL_NOTICE, "*******************************************************************************\n");
return -EINVAL;
}
imts = calloc(1, sizeof(imts_t));
if (!imts) {
PDEBUG(DIMTS, DEBUG_ERROR, "No memory!\n");
LOGP(DIMTS, LOGL_ERROR, "No memory!\n");
return -EIO;
}
PDEBUG(DIMTS, DEBUG_DEBUG, "Creating 'IMTS' instance for channel = %s (sample rate %d).\n", kanal, samplerate);
LOGP(DIMTS, LOGL_DEBUG, "Creating 'IMTS' instance for channel = %s (sample rate %d).\n", kanal, samplerate);
imts->fast_seize = fast_seize;
imts->mode = mode;
@ -333,18 +334,18 @@ int imts_create(const char *kanal, const char *device, int use_sdr, int samplera
/* do not enable emphasis, since it is done by imts code, not by common sender code */
rc = sender_create(&imts->sender, kanal, imts_channel2freq(kanal, 0), imts_channel2freq(kanal, 1), device, use_sdr, samplerate, rx_gain, tx_gain, 0, 0, write_rx_wave, write_tx_wave, read_rx_wave, read_tx_wave, loopback, PAGING_SIGNAL_NONE);
if (rc < 0) {
PDEBUG(DIMTS, DEBUG_ERROR, "Failed to init 'Sender' processing!\n");
LOGP(DIMTS, LOGL_ERROR, "Failed to init 'Sender' processing!\n");
goto error;
}
/* init audio processing */
rc = dsp_init_transceiver(imts, squelch_db, ptt);
if (rc < 0) {
PDEBUG(DIMTS, DEBUG_ERROR, "Failed to init signal processing!\n");
LOGP(DIMTS, LOGL_ERROR, "Failed to init signal processing!\n");
goto error;
}
timer_init(&imts->timer, imts_timeout, imts);
osmo_timer_setup(&imts->timer, imts_timeout, imts);
imts->pre_emphasis = pre_emphasis;
imts->de_emphasis = de_emphasis;
@ -363,7 +364,7 @@ int imts_create(const char *kanal, const char *device, int use_sdr, int samplera
imts_go_idle(imts);
}
PDEBUG(DIMTS, DEBUG_NOTICE, "Created channel #%s\n", kanal);
LOGP(DIMTS, LOGL_NOTICE, "Created channel #%s\n", kanal);
return 0;
@ -378,9 +379,9 @@ void imts_destroy(sender_t *sender)
{
imts_t *imts = (imts_t *) sender;
PDEBUG(DIMTS, DEBUG_DEBUG, "Destroying 'IMTS' instance for channel = %s.\n", sender->kanal);
LOGP(DIMTS, LOGL_DEBUG, "Destroying 'IMTS' instance for channel = %s.\n", sender->kanal);
timer_exit(&imts->timer);
osmo_timer_del(&imts->timer);
dsp_cleanup_transceiver(imts);
sender_destroy(&imts->sender);
free(sender);
@ -392,7 +393,7 @@ static void imts_go_idle(imts_t *imts)
sender_t *sender;
imts_t *idle;
timer_stop(&imts->timer);
osmo_timer_del(&imts->timer);
imts->station_id[0] = '\0'; /* remove station ID before state change, so status is shown correctly */
for (sender = sender_head; sender; sender = sender->next) {
@ -403,17 +404,17 @@ static void imts_go_idle(imts_t *imts)
break;
}
if (sender) {
PDEBUG(DIMTS, DEBUG_INFO, "Entering IDLE state on channel %s, turning transmitter off.\n", imts->sender.kanal);
LOGP(DIMTS, LOGL_INFO, "Entering IDLE state on channel %s, turning transmitter off.\n", imts->sender.kanal);
imts_new_state(imts, IMTS_OFF);
imts_set_dsp_mode(imts, DSP_MODE_OFF, 0, 0.0, 0);
} else {
if (imts->mode == MODE_IMTS) {
PDEBUG(DIMTS, DEBUG_INFO, "Entering IDLE state on channel %s, sending 2000 Hz tone.\n", imts->sender.kanal);
LOGP(DIMTS, LOGL_INFO, "Entering IDLE state on channel %s, sending 2000 Hz tone.\n", imts->sender.kanal);
imts_new_state(imts, IMTS_IDLE);
/* also reset detector, so if there is a new call it is answered */
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_IDLE, 0.0, 1);
} else {
PDEBUG(DIMTS, DEBUG_INFO, "Entering IDLE state on channel %s, sending 600 Hz tone.\n", imts->sender.kanal);
LOGP(DIMTS, LOGL_INFO, "Entering IDLE state on channel %s, sending 600 Hz tone.\n", imts->sender.kanal);
imts_new_state(imts, IMTS_IDLE);
/* also reset detector, so if there is a new call it is answered */
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_600, 0.0, 1);
@ -435,13 +436,13 @@ static void imts_activate_idle(void)
if (sender)
imts_go_idle(idle);
else
PDEBUG(DIMTS, DEBUG_INFO, "All channels are busy now, cannot activate any other channel.\n");
LOGP(DIMTS, LOGL_INFO, "All channels are busy now, cannot activate any other channel.\n");
}
/* Release connection towards mobile station by sending pause for a while. */
static void imts_release(imts_t *imts)
{
timer_stop(&imts->timer);
osmo_timer_del(&imts->timer);
/* remove station ID before state change, so status is shown correctly */
imts->station_id[0] = '\0';
@ -455,22 +456,22 @@ static void imts_release(imts_t *imts)
tone = TONE_600;
else
tone = TONE_1500;
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Sending pulse to stop ringing of the phone.\n");
LOGP_CHAN(DIMTS, LOGL_INFO, "Sending pulse to stop ringing of the phone.\n");
imts_new_state(imts, IMTS_RELEASE);
imts_set_dsp_mode(imts, DSP_MODE_TONE, tone, PAGE_PAUSE, 0);
} else {
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Turing transmitter off.\n");
LOGP_CHAN(DIMTS, LOGL_INFO, "Turing transmitter off.\n");
if (imts->state != IMTS_RELEASE)
imts_new_state(imts, IMTS_RELEASE);
imts_set_dsp_mode(imts, DSP_MODE_OFF, 0, 0.0, 0);
timer_start(&imts->timer, RELEASE_TO);
osmo_timer_schedule(&imts->timer, RELEASE_TO);
}
}
/* Enter detector test state */
static void imts_detector_test(imts_t *imts, double length_1, double length_2, double length_3)
{
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Entering detector test state, sending test sequence.\n");
LOGP_CHAN(DIMTS, LOGL_INFO, "Entering detector test state, sending test sequence.\n");
imts->detector_test_length_1 = length_1;
imts->detector_test_length_2 = length_2;
imts->detector_test_length_3 = length_3;
@ -483,12 +484,12 @@ static void imts_detector_test(imts_t *imts, double length_1, double length_2, d
static void imts_paging(imts_t *imts, const char *dial_string, int loopback)
{
/* stop timer, since it may be running while measuring Guard tone at IDLE state */
timer_stop(&imts->timer);
osmo_timer_del(&imts->timer);
if (loopback)
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Entering paging test state, sending digits %s.\n", dial_string);
LOGP_CHAN(DIMTS, LOGL_INFO, "Entering paging test state, sending digits %s.\n", dial_string);
else
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Entering paging state, sending phone's ID '%s'.\n", dial_string);
LOGP_CHAN(DIMTS, LOGL_INFO, "Entering paging state, sending phone's ID '%s'.\n", dial_string);
/* set station ID before state change, so status is shown correctly */
strncpy(imts->station_id, dial_string, sizeof(imts->station_id) - 1);
imts->tx_page_index = 0;
@ -509,18 +510,18 @@ static void imts_paging(imts_t *imts, const char *dial_string, int loopback)
/* Enter ringing state */
static void imts_ringing(imts_t *imts)
{
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Received response from mobile phone, ringing.\n");
LOGP_CHAN(DIMTS, LOGL_INFO, "Received response from mobile phone, ringing.\n");
imts->tx_ring_pulse = 0;
imts_new_state(imts, IMTS_RINGING);
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_IDLE, RING_MARK, 0);
timer_start(&imts->timer, RINGING_TO);
osmo_timer_schedule(&imts->timer, RINGING_TO);
}
/* Enter conversation state */
static void imts_answer(imts_t *imts)
{
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Received answer from mobile phone, conversation started.\n");
timer_stop(&imts->timer);
LOGP_CHAN(DIMTS, LOGL_INFO, "Received answer from mobile phone, conversation started.\n");
osmo_timer_del(&imts->timer);
imts_new_state(imts, IMTS_CONVERSATION);
imts_set_dsp_mode(imts, DSP_MODE_AUDIO, 0, 0.0, 0);
imts->rx_disc_pulse = 0;
@ -531,10 +532,10 @@ void imts_loss_indication(imts_t *imts, double loss_time)
{
/* stop timer */
if (imts->mode == MODE_MTS && (imts->state == IMTS_IDLE || imts->state == IMTS_RINGING))
timer_stop(&imts->timer);
osmo_timer_del(&imts->timer);
if (!imts->ptt && imts->state == IMTS_CONVERSATION) {
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Detected loss of signal after %.1f seconds, releasing.\n", loss_time);
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Detected loss of signal after %.1f seconds, releasing.\n", loss_time);
imts_release(imts);
call_up_release(imts->callref, CAUSE_TEMPFAIL);
imts->callref = 0;
@ -546,7 +547,7 @@ void imts_signal_indication(imts_t *imts)
{
/* setup a call from mobile to base station */
if (imts->mode == MODE_MTS && imts->state == IMTS_IDLE) {
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Detects RF signal in IDLE mode, calling the opterator at '%s'.\n", imts->operator);
LOGP_CHAN(DIMTS, LOGL_INFO, "Detects RF signal in IDLE mode, calling the opterator at '%s'.\n", imts->operator);
imts->callref = call_up_setup(NULL, imts->operator, OSMO_CC_NETWORK_MTS_NONE, "");
imts_new_state(imts, IMTS_CONVERSATION);
imts_set_dsp_mode(imts, DSP_MODE_AUDIO, 0, 0.0, 0);
@ -554,7 +555,7 @@ void imts_signal_indication(imts_t *imts)
/* answer a call from base station to mobile */
if (imts->mode == MODE_MTS && imts->state == IMTS_RINGING) {
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Detected RF signal, mobile is now transmitting.\n");
LOGP_CHAN(DIMTS, LOGL_INFO, "Detected RF signal, mobile is now transmitting.\n");
call_up_answer(imts->callref, imts->station_id);
imts_answer(imts);
}
@ -564,26 +565,26 @@ void imts_signal_indication(imts_t *imts)
static void imts_receive_seize(imts_t *imts, int tone)
{
/* other tone stops IDLE / GUARD timer */
timer_stop(&imts->timer);
osmo_timer_del(&imts->timer);
switch (tone) {
case TONE_IDLE:
case TONE_600:
timer_start(&imts->timer, IDLE_DETECT);
osmo_timer_schedule(&imts->timer, IDLE_DETECT);
break;
case TONE_GUARD:
imts->rx_guard_timestamp = get_time();
if (imts->fast_seize)
timer_start(&imts->timer, imts->fast_seize);
osmo_timer_schedule(&imts->timer, 0,imts->fast_seize * 1000000);
break;
case TONE_CONNECT:
if (imts->last_tone == TONE_GUARD && imts->rx_guard_duration >= GUARD_TIME) {
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Received seize (Guard + Connect tone) from mobile phone.\n");
PDEBUG_CHAN(DIMTS, DEBUG_INFO, " -> Guard tone duration: %.0f ms (level %.0f%%)\n", (get_time() - imts->rx_guard_timestamp) * 1000.0, imts->last_sigtone_amplitude * 100.0);
LOGP_CHAN(DIMTS, LOGL_INFO, "Received seize (Guard + Connect tone) from mobile phone.\n");
LOGP_CHAN(DIMTS, LOGL_INFO, " -> Guard tone duration: %.0f ms (level %.0f%%)\n", (get_time() - imts->rx_guard_timestamp) * 1000.0, imts->last_sigtone_amplitude * 100.0);
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_SILENCE, 0.0, 0);
imts_new_state(imts, IMTS_SEIZE);
imts_activate_idle(); /* must activate another channel right after station is not idle anymore */
timer_start(&imts->timer, SEIZE_TIME);
osmo_timer_schedule(&imts->timer, SEIZE_TIME);
}
break;
default:
@ -604,34 +605,34 @@ static void imts_receive_ani(imts_t *imts, int tone)
imts->rx_ani_pulse++;
imts->rx_ani_totpulses++;
if (imts->rx_ani_pulse > 10) {
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Received too many pulses, releasing!\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Received too many pulses, releasing!\n");
imts_release(imts);
break;
}
PDEBUG_CHAN(DIMTS, DEBUG_DEBUG, "Detected ANI pulse #%d.\n", imts->rx_ani_pulse);
timer_start(&imts->timer, ANI_PULSE_TO);
LOGP_CHAN(DIMTS, LOGL_DEBUG, "Detected ANI pulse #%d.\n", imts->rx_ani_pulse);
osmo_timer_schedule(&imts->timer, ANI_PULSE_TO);
break;
case TONE_GUARD:
/* even pulse completed */
if ((imts->rx_ani_totpulses & 1)) {
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Parity error: Received Guard tone after %d (odd) pulses, releasing!\n", imts->rx_ani_totpulses);
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Parity error: Received Guard tone after %d (odd) pulses, releasing!\n", imts->rx_ani_totpulses);
imts_release(imts);
break;
}
timer_start(&imts->timer, ANI_PULSE_TO);
osmo_timer_schedule(&imts->timer, ANI_PULSE_TO);
break;
case TONE_SILENCE:
/* odd pulse completed */
if (!(imts->rx_ani_totpulses & 1)) {
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Parity error: Received silence after %d (even) pulses, releasing!\n", imts->rx_ani_totpulses);
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Parity error: Received silence after %d (even) pulses, releasing!\n", imts->rx_ani_totpulses);
imts_release(imts);
break;
}
timer_start(&imts->timer, ANI_PULSE_TO);
osmo_timer_schedule(&imts->timer, ANI_PULSE_TO);
break;
default:
/* received noise */
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Received noise while dialing, releasing!\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Received noise while dialing, releasing!\n");
imts_release(imts);
}
}
@ -647,23 +648,23 @@ static void imts_receive_dialing(imts_t *imts, int tone)
/* pulse detected */
imts->rx_dial_pulse++;
if (imts->rx_dial_pulse > 10) {
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Received too many pulses, releasing!\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Received too many pulses, releasing!\n");
imts_release(imts);
break;
}
PDEBUG_CHAN(DIMTS, DEBUG_DEBUG, "Detected dialing pulse #%d.\n", imts->rx_dial_pulse);
timer_start(&imts->timer, DIAL_PULSE_TO);
LOGP_CHAN(DIMTS, LOGL_DEBUG, "Detected dialing pulse #%d.\n", imts->rx_dial_pulse);
osmo_timer_schedule(&imts->timer, DIAL_PULSE_TO);
break;
case TONE_GUARD:
/* pulse completed */
if (imts->rx_dial_pulse)
timer_start(&imts->timer, DIAL_PULSE_TO);
osmo_timer_schedule(&imts->timer, DIAL_PULSE_TO);
break;
default:
;
#if 0
/* received noise */
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Received noise while dialing, releasing!\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Received noise while dialing, releasing!\n");
imts_release(imts);
#endif
}
@ -675,7 +676,7 @@ static void imts_receive_disconnect(imts_t *imts, int tone, double elapsed, doub
/* reset disc counter on timeout */
if (elapsed > DISC_PULSE_TO) {
if (imts->rx_disc_pulse) {
PDEBUG_CHAN(DIMTS, DEBUG_DEBUG, "Timeout Disconnect sequence\n");
LOGP_CHAN(DIMTS, LOGL_DEBUG, "Timeout Disconnect sequence\n");
imts->rx_disc_pulse = 0;
}
return;
@ -684,11 +685,11 @@ static void imts_receive_disconnect(imts_t *imts, int tone, double elapsed, doub
switch (tone) {
case TONE_DISCONNECT:
imts->rx_disc_pulse++;
PDEBUG_CHAN(DIMTS, DEBUG_DEBUG, "Detected Disconnect pulse #%d.\n", imts->rx_disc_pulse);
LOGP_CHAN(DIMTS, LOGL_DEBUG, "Detected Disconnect pulse #%d.\n", imts->rx_disc_pulse);
break;
case TONE_GUARD:
if (imts->rx_disc_pulse == DISC_COUNT) {
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Received disconnect sequence from mobile phone (level %.0f%%).\n", amplitude * 100.0);
LOGP_CHAN(DIMTS, LOGL_INFO, "Received disconnect sequence from mobile phone (level %.0f%%).\n", amplitude * 100.0);
if (imts->state == IMTS_SEIZE
|| imts->state == IMTS_ANI
|| imts->state == IMTS_DIALING
@ -704,7 +705,7 @@ static void imts_receive_disconnect(imts_t *imts, int tone, double elapsed, doub
break;
default:
if (imts->rx_disc_pulse) {
PDEBUG_CHAN(DIMTS, DEBUG_DEBUG, "Disconnect sequence not detected anymore\n");
LOGP_CHAN(DIMTS, LOGL_DEBUG, "Disconnect sequence not detected anymore\n");
imts->rx_disc_pulse = 0;
}
}
@ -717,15 +718,15 @@ static void receive_page_imts(imts_t *imts, int tone)
case TONE_IDLE:
/* pulse detected */
imts->rx_page_pulse++;
PDEBUG_CHAN(DIMTS, DEBUG_DEBUG, "Detected page test pulse #%d.\n", imts->rx_page_pulse);
LOGP_CHAN(DIMTS, LOGL_DEBUG, "Detected page test pulse #%d.\n", imts->rx_page_pulse);
if (imts->rx_page_pulse > 10) {
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Received too many pulses!\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Received too many pulses!\n");
}
timer_start(&imts->timer, PAGE_PULSE_TO); // use for page test timeout
osmo_timer_schedule(&imts->timer, 0,PAGE_PULSE_TO * 1000000); // use for page test timeout
break;
case TONE_SEIZE:
/* pulse completed */
timer_start(&imts->timer, PAGE_PULSE_TO); // use for page test timeout
osmo_timer_schedule(&imts->timer, 0,PAGE_PULSE_TO * 1000000); // use for page test timeout
break;
default:
;
@ -738,11 +739,11 @@ static void receive_page_mts(imts_t *imts, int tone)
if (tone == TONE_600 || tone == TONE_1500) {
/* pulse detected */
imts->rx_page_pulse++;
PDEBUG_CHAN(DIMTS, DEBUG_DEBUG, "Detected page test pulse #%d.\n", imts->rx_page_pulse);
LOGP_CHAN(DIMTS, LOGL_DEBUG, "Detected page test pulse #%d.\n", imts->rx_page_pulse);
if (imts->rx_page_pulse > 10) {
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Received too many pulses!\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Received too many pulses!\n");
}
timer_start(&imts->timer, PAGE_PULSE_TO); // use for page test timeout
osmo_timer_schedule(&imts->timer, 0,PAGE_PULSE_TO * 1000000); // use for page test timeout
}
}
@ -784,12 +785,12 @@ void imts_lost_tone(imts_t *imts, int tone, double elapsed)
{
switch (imts->state) {
case IMTS_IDLE:
timer_stop(&imts->timer);
osmo_timer_del(&imts->timer);
imts->rx_guard_duration = elapsed;
break;
case IMTS_PAGING:
if (elapsed >= 0.300 && tone == TONE_GUARD && timer_running(&imts->timer)) {
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Received acknowledge (Guard tone) from mobile phone (level %.0f%%).\n", imts->last_sigtone_amplitude * 100.0);
if (elapsed >= 0.300 && tone == TONE_GUARD && osmo_timer_pending(&imts->timer)) {
LOGP_CHAN(DIMTS, LOGL_INFO, "Received acknowledge (Guard tone) from mobile phone (level %.0f%%).\n", imts->last_sigtone_amplitude * 100.0);
call_up_alerting(imts->callref);
imts_ringing(imts);
break;
@ -797,7 +798,7 @@ void imts_lost_tone(imts_t *imts, int tone, double elapsed)
break;
case IMTS_RINGING:
if (elapsed >= 0.190 && tone == TONE_CONNECT) {
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Received answer (Connect tone) from mobile phone (level %.0f%%).\n", imts->last_sigtone_amplitude * 100.0);
LOGP_CHAN(DIMTS, LOGL_INFO, "Received answer (Connect tone) from mobile phone (level %.0f%%).\n", imts->last_sigtone_amplitude * 100.0);
call_up_answer(imts->callref, imts->station_id);
imts_answer(imts);
break;
@ -818,30 +819,30 @@ static void ani_after_digit(imts_t *imts)
imts->rx_ani_pulse = 0;
imts->station_id[imts->rx_ani_index] = imts->rx_ani_pulse + '0';
imts->rx_ani_pulse = 0;
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Received ANI digit '%c' from mobile phone (level %.0f%%).\n", imts->station_id[imts->rx_ani_index], imts->last_sigtone_amplitude * 100.0);
LOGP_CHAN(DIMTS, LOGL_INFO, "Received ANI digit '%c' from mobile phone (level %.0f%%).\n", imts->station_id[imts->rx_ani_index], imts->last_sigtone_amplitude * 100.0);
imts->station_id[++imts->rx_ani_index] = '\0';
/* update status while receiving station ID */
imts_display_status();
/* if all digits have been received */
if (imts->rx_ani_index == 7) {
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "ANI '%s' complete, sending dial tone.\n", imts->station_id);
LOGP_CHAN(DIMTS, LOGL_INFO, "ANI '%s' complete, sending dial tone.\n", imts->station_id);
dt:
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_DIALTONE, 0.0, 0);
timer_start(&imts->timer, DIALTONE_TO);
osmo_timer_schedule(&imts->timer, DIALTONE_TO);
imts->dial_number[0] = '\0';
imts->rx_dial_index = 0;
imts->rx_dial_pulse = 0;
imts_new_state(imts, IMTS_DIALING);
return;
}
timer_start(&imts->timer, ANI_TO);
osmo_timer_schedule(&imts->timer, ANI_TO);
} else {
/* if only 5 digits have been received */
if (imts->rx_ani_index == 5) {
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "ANI '%s' (5 digits) complete, sending dial tone.\n", imts->station_id);
LOGP_CHAN(DIMTS, LOGL_INFO, "ANI '%s' (5 digits) complete, sending dial tone.\n", imts->station_id);
goto dt;
}
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Timeout receiving ANI from mobile phone, releasing!\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Timeout receiving ANI from mobile phone, releasing!\n");
imts_release(imts);
}
}
@ -850,7 +851,7 @@ static void dial_after_digit(imts_t *imts)
{
/* special case where nothing happens after dial tone */
if (!imts->rx_dial_pulse && !imts->rx_dial_index) {
PDEBUG_CHAN(DANETZ, DEBUG_NOTICE, "Mobile phone does not start dialing, releasing!\n");
LOGP_CHAN(DANETZ, LOGL_NOTICE, "Mobile phone does not start dialing, releasing!\n");
imts_release(imts);
return;
}
@ -860,7 +861,7 @@ static void dial_after_digit(imts_t *imts)
*/
if (imts->rx_dial_pulse) {
if (imts->rx_dial_index == sizeof(imts->dial_number) - 1) {
PDEBUG_CHAN(DANETZ, DEBUG_NOTICE, "Mobile phone dials too many digits, releasing!\n");
LOGP_CHAN(DANETZ, LOGL_NOTICE, "Mobile phone dials too many digits, releasing!\n");
imts_release(imts);
return;
}
@ -868,11 +869,11 @@ static void dial_after_digit(imts_t *imts)
imts->rx_dial_pulse = 0;
imts->dial_number[imts->rx_dial_index] = imts->rx_dial_pulse + '0';
imts->rx_dial_pulse = 0;
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Received dial digit '%c' from mobile phone. (level %.0f%%)\n", imts->dial_number[imts->rx_dial_index], imts->last_sigtone_amplitude * 100.0);
LOGP_CHAN(DIMTS, LOGL_INFO, "Received dial digit '%c' from mobile phone. (level %.0f%%)\n", imts->dial_number[imts->rx_dial_index], imts->last_sigtone_amplitude * 100.0);
imts->dial_number[++imts->rx_dial_index] = '\0';
timer_start(&imts->timer, DIALING_TO);
osmo_timer_schedule(&imts->timer, DIALING_TO);
} else {
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Timeout receiving dialing from mobile phone, number complete.\n");
LOGP_CHAN(DIMTS, LOGL_INFO, "Timeout receiving dialing from mobile phone, number complete.\n");
imts->callref = call_up_setup(imts->station_id, imts->dial_number, OSMO_CC_NETWORK_IMTS_NONE, "");
imts_new_state(imts, IMTS_CONVERSATION);
imts_set_dsp_mode(imts, DSP_MODE_AUDIO, 0, 0.0, 0);
@ -892,7 +893,7 @@ static void page_after_digit(imts_t *imts)
imts->rx_page_pulse = 0;
digit = imts->rx_page_pulse + '0';
delay = get_time() - imts->tx_page_timestamp - PAGE_PULSE_TO;
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Received paging test digit '%c' (level %.0f%% delay %.0f ms).\n", digit, imts->last_sigtone_amplitude * 100.0, delay * 1000.0);
LOGP_CHAN(DIMTS, LOGL_INFO, "Received paging test digit '%c' (level %.0f%% delay %.0f ms).\n", digit, imts->last_sigtone_amplitude * 100.0, delay * 1000.0);
}
imts->rx_page_pulse = 0;
}
@ -907,29 +908,29 @@ static void imts_timeout(void *data)
case IMTS_IDLE:
switch (imts->last_tone) {
case TONE_IDLE:
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Received idle tone (level of %.0f%%), loopback?\n", imts->last_sigtone_amplitude * 100.0);
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Received idle tone (level of %.0f%%), loopback?\n", imts->last_sigtone_amplitude * 100.0);
/* trigger reset of decoder to force detection again and again */
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_IDLE, 0.0, 1);
break;
case TONE_600:
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Received 600 Hz tone with level of %.0f%%, loopback?\n", imts->last_sigtone_amplitude * 100.0);
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Received 600 Hz tone with level of %.0f%%, loopback?\n", imts->last_sigtone_amplitude * 100.0);
/* trigger reset of decoder to force detection again and again */
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_600, 0.0, 1);
break;
case TONE_GUARD:
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Received Guard tone, turning off IDLE tone\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Received Guard tone, turning off IDLE tone\n");
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_SILENCE, 0.5, 0);
break;
}
break;
case IMTS_PAGING:
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "No response from mobile phone.\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "No response from mobile phone.\n");
imts_go_idle(imts);
call_up_release(imts->callref, CAUSE_OUTOFORDER);
imts->callref = 0;
break;
case IMTS_RINGING:
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "No answer from mobile phone's user, releasing.\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "No answer from mobile phone's user, releasing.\n");
imts_release(imts);
call_up_release(imts->callref, CAUSE_NOANSWER);
imts->callref = 0;
@ -938,9 +939,9 @@ static void imts_timeout(void *data)
imts_go_idle(imts);
break;
case IMTS_SEIZE:
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Sending Seize to mobile phone.\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Sending Seize to mobile phone.\n");
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_SEIZE, SEIZE_LENGTH, 0);
timer_start(&imts->timer, SEIZE_LENGTH + ANI_TO);
osmo_timer_schedule(&imts->timer, SEIZE_LENGTH + ANI_TO);
imts->station_id[0] = '\0';
imts->rx_ani_index = 0;
imts->rx_ani_pulse = 0;
@ -973,7 +974,7 @@ static void paging_pulses_imts(imts_t *imts, int tone)
if (tone == TONE_SEIZE) {
if (imts->tx_page_pulse == 0)
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Sending paging digit '%c' as pulses.\n", imts->station_id[imts->tx_page_index]);
LOGP_CHAN(DIMTS, LOGL_INFO, "Sending paging digit '%c' as pulses.\n", imts->station_id[imts->tx_page_index]);
/* send mark (pulse start) */
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_IDLE, PAGE_MARK, 0);
imts->tx_page_pulse++;
@ -993,7 +994,7 @@ static void paging_pulses_imts(imts_t *imts, int tone)
duration = PAGE_PAUSE;
else {
duration = 0;
timer_start(&imts->timer, PAGING_TO);
osmo_timer_schedule(&imts->timer, PAGING_TO);
}
}
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_SEIZE, duration, 0);
@ -1015,7 +1016,7 @@ static void paging_pulses_mts(imts_t *imts, int tone)
tone = TONE_1500;
if (imts->tx_page_pulse == 0) {
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Sending paging digit '%c' as pulses.\n", imts->station_id[imts->tx_page_index]);
LOGP_CHAN(DIMTS, LOGL_INFO, "Sending paging digit '%c' as pulses.\n", imts->station_id[imts->tx_page_index]);
}
imts->tx_page_pulse++;
if (imts->tx_page_pulse < pulses)
@ -1030,7 +1031,7 @@ static void paging_pulses_mts(imts_t *imts, int tone)
if (imts->station_id[imts->tx_page_index])
duration = PAGE_PAUSE;
else {
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Digits complete, assuming the phone is ringing.\n");
LOGP_CHAN(DIMTS, LOGL_INFO, "Digits complete, assuming the phone is ringing.\n");
duration = 0;
imts_new_state(imts, IMTS_RINGING);
call_up_alerting(imts->callref);
@ -1044,7 +1045,7 @@ static void ringing_pulses(imts_t *imts, int tone)
{
if (tone == TONE_IDLE) {
if (imts->tx_ring_pulse == 0)
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Sending ringing signal as pulses.\n");
LOGP_CHAN(DIMTS, LOGL_INFO, "Sending ringing signal as pulses.\n");
/* send space (pulse end) */
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_SEIZE, RING_SPACE, 0);
imts->tx_ring_pulse++;
@ -1053,7 +1054,7 @@ static void ringing_pulses(imts_t *imts, int tone)
/* send mark (pulse start) */
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_IDLE, RING_MARK, 0);
} else {
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Sending pause after ringing.\n");
LOGP_CHAN(DIMTS, LOGL_INFO, "Sending pause after ringing.\n");
/* send long space after last pulse */
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_SEIZE, RING_OFF, 0);
imts->tx_ring_pulse = 0;
@ -1077,21 +1078,21 @@ static void detector_test_imts(imts_t *imts, int tone)
tone_idle:
if (imts->detector_test_length_1 <= 0)
goto tone_seize;
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Sending %.3fs IDLE tone.\n", imts->detector_test_length_1);
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Sending %.3fs IDLE tone.\n", imts->detector_test_length_1);
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_IDLE, imts->detector_test_length_1, 0);
break;
case TONE_IDLE:
tone_seize:
if (imts->detector_test_length_2 <= 0)
goto tone_silence;
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Sending %.3fs SEIZE tone.\n", imts->detector_test_length_2);
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Sending %.3fs SEIZE tone.\n", imts->detector_test_length_2);
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_SEIZE, imts->detector_test_length_2, 0);
break;
case TONE_SEIZE:
tone_silence:
if (imts->detector_test_length_3 <= 0)
goto tone_idle;
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Sending %.3fs SILENCE.\n", imts->detector_test_length_3);
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Sending %.3fs SILENCE.\n", imts->detector_test_length_3);
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_SILENCE, imts->detector_test_length_3, 0);
break;
}
@ -1103,21 +1104,21 @@ static void detector_test_mts(imts_t *imts, int tone)
tone_idle:
if (imts->detector_test_length_1 <= 0)
goto tone_seize;
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Sending %.3fs 600 Hz tone.\n", imts->detector_test_length_1);
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Sending %.3fs 600 Hz tone.\n", imts->detector_test_length_1);
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_600, imts->detector_test_length_1, 0);
break;
case TONE_600:
tone_seize:
if (imts->detector_test_length_2 <= 0)
goto tone_silence;
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Sending %.3fs 1500 Hz tone.\n", imts->detector_test_length_2);
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Sending %.3fs 1500 Hz tone.\n", imts->detector_test_length_2);
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_1500, imts->detector_test_length_2, 0);
break;
case TONE_1500:
tone_silence:
if (imts->detector_test_length_3 <= 0)
goto tone_idle;
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Sending %.3fs SILENCE.\n", imts->detector_test_length_3);
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Sending %.3fs SILENCE.\n", imts->detector_test_length_3);
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_SILENCE, imts->detector_test_length_3, 0);
break;
}
@ -1128,7 +1129,7 @@ void imts_tone_sent(imts_t *imts, int tone)
{
switch (imts->state) {
case IMTS_IDLE:
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "No Seize tone after Guard tone, turning on IDLE tone\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "No Seize tone after Guard tone, turning on IDLE tone\n");
imts_set_dsp_mode(imts, DSP_MODE_TONE, TONE_IDLE, 0.0, 0);
break;
case IMTS_ANI:
@ -1172,7 +1173,7 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
break;
}
if (sender) {
PDEBUG(DIMTS, DEBUG_NOTICE, "Outgoing call to busy number, rejecting!\n");
LOGP(DIMTS, LOGL_NOTICE, "Outgoing call to busy number, rejecting!\n");
return -CAUSE_BUSY;
}
@ -1183,7 +1184,7 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
break;
}
if (!sender) {
PDEBUG(DIMTS, DEBUG_NOTICE, "Outgoing call, but no free channel, rejecting!\n");
LOGP(DIMTS, LOGL_NOTICE, "Outgoing call, but no free channel, rejecting!\n");
return -CAUSE_NOCHANNEL;
}
@ -1195,7 +1196,7 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
}
/* 4. trying to page mobile station */
PDEBUG_CHAN(DIMTS, DEBUG_INFO, "Call to mobile station, paging number: %s\n", dialing);
LOGP_CHAN(DIMTS, LOGL_INFO, "Call to mobile station, paging number: %s\n", dialing);
imts->callref = callref;
imts_paging(imts, dialing, 0);
@ -1215,7 +1216,7 @@ void call_down_disconnect(int callref, int cause)
sender_t *sender;
imts_t *imts;
PDEBUG(DIMTS, DEBUG_INFO, "Call has been disconnected by network.\n");
LOGP(DIMTS, LOGL_INFO, "Call has been disconnected by network.\n");
for (sender = sender_head; sender; sender = sender->next) {
imts = (imts_t *) sender;
@ -1223,7 +1224,7 @@ void call_down_disconnect(int callref, int cause)
break;
}
if (!sender) {
PDEBUG(DIMTS, DEBUG_NOTICE, "Outgoing disconnect, but no callref!\n");
LOGP(DIMTS, LOGL_NOTICE, "Outgoing disconnect, but no callref!\n");
call_up_release(callref, CAUSE_INVALCALLREF);
return;
}
@ -1234,7 +1235,7 @@ void call_down_disconnect(int callref, int cause)
switch (imts->state) {
case IMTS_PAGING:
case IMTS_RINGING:
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Outgoing disconnect, during paging/alerting, releasing!\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Outgoing disconnect, during paging/alerting, releasing!\n");
imts_release(imts);
break;
default:
@ -1253,7 +1254,7 @@ void call_down_release(int callref, __attribute__((unused)) int cause)
sender_t *sender;
imts_t *imts;
PDEBUG(DIMTS, DEBUG_INFO, "Call has been released by network, releasing call.\n");
LOGP(DIMTS, LOGL_INFO, "Call has been released by network, releasing call.\n");
for (sender = sender_head; sender; sender = sender->next) {
imts = (imts_t *) sender;
@ -1261,7 +1262,7 @@ void call_down_release(int callref, __attribute__((unused)) int cause)
break;
}
if (!sender) {
PDEBUG(DIMTS, DEBUG_NOTICE, "Outgoing release, but no callref!\n");
LOGP(DIMTS, LOGL_NOTICE, "Outgoing release, but no callref!\n");
/* don't send release, because caller already released */
return;
}
@ -1270,12 +1271,12 @@ void call_down_release(int callref, __attribute__((unused)) int cause)
switch (imts->state) {
case IMTS_CONVERSATION:
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Outgoing release, during call, releasing!\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Outgoing release, during call, releasing!\n");
imts_release(imts);
break;
case IMTS_PAGING:
case IMTS_RINGING:
PDEBUG_CHAN(DIMTS, DEBUG_NOTICE, "Outgoing release, during paging/alerting, releasing!\n");
LOGP_CHAN(DIMTS, LOGL_NOTICE, "Outgoing release, during paging/alerting, releasing!\n");
imts_release(imts);
break;
default:

View File

@ -61,7 +61,7 @@ typedef struct imts {
int callref; /* call reference */
char station_id[11]; /* current station ID (also used for test pattern) */
char dial_number[33]; /* number dialing */
struct timer timer;
struct osmo_timer_list timer;
int last_tone; /* last tone received */
double last_sigtone_amplitude; /* amplitude of last signaling tone received */
double fast_seize; /* fast seize: guard-length - roundtrip-delay */

View File

@ -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 "../amps/tones.h"
@ -279,6 +279,7 @@ fail:
imts_destroy(sender_head);
/* exits */
main_mobile_exit();
fm_exit();
options_free();

View File

@ -12,23 +12,21 @@ jollycom_LDADD = \
$(COMMON_LA) \
../anetz/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/libjitter/libjitter.a \
$(top_builddir)/src/libsquelch/libsquelch.a \
$(top_builddir)/src/libdtmf/libdtmf.a \
$(top_builddir)/src/libtimer/libtimer.a \
$(top_builddir)/src/libselect/libselect.a \
$(top_builddir)/src/libsamplerate/libsamplerate.a \
$(top_builddir)/src/libemphasis/libemphasis.a \
$(top_builddir)/src/libfilter/libfilter.a \
$(top_builddir)/src/libwave/libwave.a \
$(top_builddir)/src/libsample/libsample.a \
$(top_builddir)/src/libfm/libfm.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

View File

@ -27,8 +27,8 @@
#include <math.h>
#include "../libsample/sample.h"
#include "../libtimer/timer.h"
#include "../libdebug/debug.h"
#include <osmocom/core/timer.h>
#include "../liblogging/logging.h"
#include "../libmobile/call.h"
#include "jolly.h"
#include "dsp.h"
@ -63,7 +63,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 * M_PI);
dsp_info_tone[i] = s * TX_INFO_TONE;
@ -92,7 +92,7 @@ int dsp_init_sender(jolly_t *jolly, int nbfm, double squelch_db, int repeater)
* also we allow a minimum of -30 dB for each tone. */
rc = dtmf_decode_init(&jolly->dtmf, jolly, jolly_receive_dtmf, 8000, db2level(6.0), db2level(-30.0));
if (rc < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to init DTMF decoder!\n");
LOGP(DDSP, LOGL_ERROR, "Failed to init DTMF decoder!\n");
goto error;
}
@ -106,7 +106,7 @@ int dsp_init_sender(jolly_t *jolly, int nbfm, double squelch_db, int repeater)
jolly->delay_max = (int)((double)jolly->sender.samplerate * DELAY_TIME);
jolly->delay_spl = calloc(jolly->delay_max, sizeof(*jolly->delay_spl));
if (!jolly->delay_spl) {
PDEBUG(DDSP, DEBUG_ERROR, "No mem for delay buffer!\n");
LOGP(DDSP, LOGL_ERROR, "No mem for delay buffer!\n");
goto error;
}
@ -115,7 +115,7 @@ int dsp_init_sender(jolly_t *jolly, int nbfm, double squelch_db, int repeater)
jolly->repeater_max = (int)((double)jolly->sender.samplerate * REPEATER_TIME);
rc = jitter_create(&jolly->repeater_dejitter, "repeater", jolly->sender.samplerate, sizeof(sample_t), 0.050, 0.500, JITTER_FLAG_NONE);
if (rc < 0) {
PDEBUG(DDSP, DEBUG_ERROR, "Failed to create and init repeater buffer!\n");
LOGP(DDSP, LOGL_ERROR, "Failed to create and init repeater buffer!\n");
goto error;
}
@ -174,25 +174,25 @@ again:
spl = jolly_voice.spl[10];
size = jolly_voice.size[10];
if (!jolly->speech_pos)
PDEBUG(DDSP, DEBUG_DEBUG, "speaking 'incoming'.\n");
LOGP(DDSP, LOGL_DEBUG, "speaking 'incoming'.\n");
break;
case 'o':
spl = jolly_voice.spl[11];
size = jolly_voice.size[11];
if (!jolly->speech_pos)
PDEBUG(DDSP, DEBUG_DEBUG, "speaking 'outgoing'.\n");
LOGP(DDSP, LOGL_DEBUG, "speaking 'outgoing'.\n");
break;
case 'r':
spl = jolly_voice.spl[12];
size = jolly_voice.size[12];
if (!jolly->speech_pos)
PDEBUG(DDSP, DEBUG_DEBUG, "speaking 'released'.\n");
LOGP(DDSP, LOGL_DEBUG, "speaking 'released'.\n");
break;
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
spl = jolly_voice.spl[jolly->speech_string[jolly->speech_digit] - '0'];
size = jolly_voice.size[jolly->speech_string[jolly->speech_digit] - '0'];
if (!jolly->speech_pos)
PDEBUG(DDSP, DEBUG_DEBUG, "speaking digit '%c'.\n", jolly->speech_string[jolly->speech_digit]);
LOGP(DDSP, LOGL_DEBUG, "speaking digit '%c'.\n", jolly->speech_string[jolly->speech_digit]);
break;
default:
jolly->speech_digit++;
@ -292,7 +292,7 @@ void sender_receive(sender_t *sender, sample_t *samples, int length, double rf_l
case SQUELCH_LOSS:
case SQUELCH_MUTE:
if (!jolly->is_mute) {
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Low RF level, muting.\n");
LOGP_CHAN(DDSP, LOGL_INFO, "Low RF level, muting.\n");
jolly->ack_count = jolly->ack_max;
jolly->repeater_count = jolly->repeater_max;
}
@ -301,7 +301,7 @@ void sender_receive(sender_t *sender, sample_t *samples, int length, double rf_l
break;
default:
if (jolly->is_mute)
PDEBUG_CHAN(DDSP, DEBUG_INFO, "High RF level, unmuting; turning transmitter on.\n");
LOGP_CHAN(DDSP, LOGL_INFO, "High RF level, unmuting; turning transmitter on.\n");
jolly->is_mute = 0;
break;
}
@ -355,7 +355,7 @@ void sender_send(sender_t *sender, sample_t *samples, uint8_t *power, int length
if (jolly->repeater_count) {
jolly->repeater_count -= length;
if (jolly->repeater_count < 0) {
PDEBUG_CHAN(DDSP, DEBUG_INFO, "turning transmitter off.\n");
LOGP_CHAN(DDSP, LOGL_INFO, "turning transmitter off.\n");
jolly->repeater_count = 0;
}
}

View File

@ -134,11 +134,11 @@
#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 "../libmobile/cause.h"
#include "../libosmocc/message.h"
#include <osmocom/cc/message.h>
#include "jolly.h"
#include "dsp.h"
#include "voice.h"
@ -146,12 +146,12 @@
#define db2level(db) pow(10, (double)db / 20.0)
/* Timers */
#define T_DIAL 6 /* Time between digits */
#define T_DIAL2 1.5 /* Time between digits during call*/
#define T_PAGING 30 /* How long do we page the mobile party */
#define SPEECH_DELAY_PAGING 1.0 /* time before speaking paging sequence */
#define SPEECH_DELAY_VERIFY 2.0 /* time before speaking verifying sequence */
#define SPEECH_DELAY_RELEASE 2.0/* time before speaking release sequence */
#define T_DIAL 6,0 /* Time between digits */
#define T_DIAL2 1,500000 /* Time between digits during call*/
#define T_PAGING 30,0 /* How long do we page the mobile party */
#define SPEECH_DELAY_PAGING 1,0 /* time before speaking paging sequence */
#define SPEECH_DELAY_VERIFY 2,0 /* time before speaking verifying sequence */
#define SPEECH_DELAY_RELEASE 2,0 /* time before speaking release sequence */
const char *jolly_state_name(enum jolly_state state)
{
@ -199,7 +199,7 @@ static void jolly_new_state(jolly_t *jolly, enum jolly_state new_state)
{
if (jolly->state == new_state)
return;
PDEBUG_CHAN(DJOLLY, DEBUG_DEBUG, "State change: %s -> %s\n", jolly_state_name(jolly->state), jolly_state_name(new_state));
LOGP_CHAN(DJOLLY, LOGL_DEBUG, "State change: %s -> %s\n", jolly_state_name(jolly->state), jolly_state_name(new_state));
jolly->state = new_state;
jolly_display_status();
}
@ -216,11 +216,11 @@ int jolly_create(const char *kanal, double dl_freq, double ul_freq, double step,
jolly = calloc(1, sizeof(jolly_t));
if (!jolly) {
PDEBUG(DJOLLY, DEBUG_ERROR, "No memory!\n");
LOGP(DJOLLY, LOGL_ERROR, "No memory!\n");
return -EIO;
}
PDEBUG(DJOLLY, DEBUG_DEBUG, "Creating 'JollyCom' instance for 'Kanal' = %s (sample rate %d).\n", kanal, samplerate);
LOGP(DJOLLY, LOGL_DEBUG, "Creating 'JollyCom' instance for 'Kanal' = %s (sample rate %d).\n", kanal, samplerate);
dl_freq = dl_freq * 1e6 + step * 1e3 * (double)atoi(kanal);
ul_freq = ul_freq * 1e6 + step * 1e3 * (double)atoi(kanal);
@ -228,25 +228,25 @@ int jolly_create(const char *kanal, double dl_freq, double ul_freq, double step,
/* init general part of transceiver */
rc = sender_create(&jolly->sender, kanal, dl_freq, ul_freq, 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(DJOLLY, DEBUG_ERROR, "Failed to init 'Sender' processing!\n");
LOGP(DJOLLY, LOGL_ERROR, "Failed to init 'Sender' processing!\n");
goto error;
}
/* init audio processing */
rc = dsp_init_sender(jolly, nbfm, squelch_db, repeater);
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;
}
/* timers */
timer_init(&jolly->timer, jolly_timeout, jolly);
timer_init(&jolly->speech_timer, jolly_speech_timeout, jolly);
osmo_timer_setup(&jolly->timer, jolly_timeout, jolly);
osmo_timer_setup(&jolly->speech_timer, jolly_speech_timeout, jolly);
/* go into idle state */
jolly_go_idle(jolly);
PDEBUG(DJOLLY, DEBUG_NOTICE, "Created 'Kanal' #%s\n", kanal);
LOGP(DJOLLY, LOGL_NOTICE, "Created 'Kanal' #%s\n", kanal);
return 0;
@ -261,11 +261,11 @@ void jolly_destroy(sender_t *sender)
{
jolly_t *jolly = (jolly_t *) sender;
PDEBUG(DJOLLY, DEBUG_DEBUG, "Destroying 'JollyCom' instance for 'Kanal' = %s.\n", sender->kanal);
LOGP(DJOLLY, LOGL_DEBUG, "Destroying 'JollyCom' instance for 'Kanal' = %s.\n", sender->kanal);
dsp_cleanup_sender(jolly);
timer_exit(&jolly->timer);
timer_exit(&jolly->speech_timer);
osmo_timer_del(&jolly->timer);
osmo_timer_del(&jolly->speech_timer);
sender_destroy(&jolly->sender);
free(sender);
}
@ -273,11 +273,11 @@ void jolly_destroy(sender_t *sender)
/* Abort connection towards mobile station changing to IDLE state */
static void jolly_go_idle(jolly_t *jolly)
{
timer_stop(&jolly->timer);
timer_stop(&jolly->speech_timer);
osmo_timer_del(&jolly->timer);
osmo_timer_del(&jolly->speech_timer);
reset_speech_string(jolly);
PDEBUG(DJOLLY, DEBUG_INFO, "Entering IDLE state on channel %s.\n", jolly->sender.kanal);
LOGP(DJOLLY, LOGL_INFO, "Entering IDLE state on channel %s.\n", jolly->sender.kanal);
jolly->dialing[0] = '\0';
jolly->station_id[0] = '\0'; /* remove station ID before state change, so status is shown correctly */
jolly_new_state(jolly, STATE_IDLE);
@ -286,35 +286,35 @@ static void jolly_go_idle(jolly_t *jolly)
/* Release connection towards mobile station by sending idle tone for a while. */
static void jolly_release(jolly_t *jolly)
{
timer_stop(&jolly->timer);
timer_stop(&jolly->speech_timer);
osmo_timer_del(&jolly->timer);
osmo_timer_del(&jolly->speech_timer);
reset_speech_string(jolly);
PDEBUG(DJOLLY, DEBUG_INFO, "Sending Release sequence on channel %s.\n", jolly->sender.kanal);
timer_start(&jolly->speech_timer, SPEECH_DELAY_RELEASE);
LOGP(DJOLLY, LOGL_INFO, "Sending Release sequence on channel %s.\n", jolly->sender.kanal);
osmo_timer_schedule(&jolly->speech_timer, SPEECH_DELAY_RELEASE);
jolly_new_state(jolly, STATE_RELEASED);
}
/* Enter paging state and transmit 4 paging tones. */
static void jolly_page(jolly_t *jolly, const char *dial_string)
{
PDEBUG_CHAN(DJOLLY, DEBUG_INFO, "Entering paging state, sending paging sequence to '%s'.\n", dial_string);
LOGP_CHAN(DJOLLY, LOGL_INFO, "Entering paging state, sending paging sequence to '%s'.\n", dial_string);
/* set station ID before state change, so status is shown correctly */
strncpy(jolly->station_id, dial_string, sizeof(jolly->station_id) - 1);
timer_start(&jolly->timer, T_PAGING);
timer_start(&jolly->speech_timer, SPEECH_DELAY_PAGING);
osmo_timer_schedule(&jolly->timer, T_PAGING);
osmo_timer_schedule(&jolly->speech_timer, SPEECH_DELAY_PAGING);
jolly_new_state(jolly, STATE_IN_PAGING);
}
void speech_finished(jolly_t *jolly)
{
PDEBUG(DJOLLY, DEBUG_DEBUG, "speaking finished.\n");
LOGP(DJOLLY, LOGL_DEBUG, "speaking finished.\n");
switch (jolly->state) {
case STATE_OUT_VERIFY:
timer_start(&jolly->timer, T_DIAL);
osmo_timer_schedule(&jolly->timer, T_DIAL);
break;
case STATE_IN_PAGING:
timer_start(&jolly->speech_timer, SPEECH_DELAY_PAGING);
osmo_timer_schedule(&jolly->speech_timer, SPEECH_DELAY_PAGING);
break;
case STATE_RELEASED:
jolly_go_idle(jolly);
@ -331,7 +331,7 @@ void jolly_receive_dtmf(void *priv, char digit, dtmf_meas_t *meas)
{
jolly_t *jolly = (jolly_t *) priv;
PDEBUG_CHAN(DJOLLY, DEBUG_INFO, "Received dtmf digit '%c' frequency %.1f %.1f amplitude %.1f %.1f dB.\n",
LOGP_CHAN(DJOLLY, LOGL_INFO, "Received dtmf digit '%c' frequency %.1f %.1f amplitude %.1f %.1f dB.\n",
digit,
meas->frequency_low, meas->frequency_high,
level2db(meas->amplitude_low), level2db(meas->amplitude_high));
@ -343,68 +343,68 @@ void jolly_receive_dtmf(void *priv, char digit, dtmf_meas_t *meas)
switch (jolly->state) {
case STATE_IDLE:
if (digit == '*') {
PDEBUG_CHAN(DJOLLY, DEBUG_INFO, "Received start digit, entering dialing state.\n");
LOGP_CHAN(DJOLLY, LOGL_INFO, "Received start digit, entering dialing state.\n");
jolly->dialing[0] = '\0';
timer_start(&jolly->timer, T_DIAL);
osmo_timer_schedule(&jolly->timer, T_DIAL);
jolly_new_state(jolly, STATE_OUT_DIALING);
break;
}
break;
case STATE_OUT_DIALING:
if (digit == '*') {
PDEBUG_CHAN(DJOLLY, DEBUG_INFO, "Received start digit again, resetting dialing state.\n");
LOGP_CHAN(DJOLLY, LOGL_INFO, "Received start digit again, resetting dialing state.\n");
jolly->dialing[0] = '\0';
timer_start(&jolly->timer, T_DIAL);
osmo_timer_schedule(&jolly->timer, T_DIAL);
break;
}
if (digit >= '0' && digit <= '9' && strlen(jolly->dialing) < sizeof(jolly->dialing) - 1) {
PDEBUG_CHAN(DJOLLY, DEBUG_INFO, "Received dialed digit '%c'\n", digit);
LOGP_CHAN(DJOLLY, LOGL_INFO, "Received dialed digit '%c'\n", digit);
jolly->dialing[strlen(jolly->dialing) + 1] = '\0';
jolly->dialing[strlen(jolly->dialing)] = digit;
timer_start(&jolly->timer, T_DIAL);
osmo_timer_schedule(&jolly->timer, T_DIAL);
break;
}
if (digit == '#') {
timer_stop(&jolly->timer);
osmo_timer_del(&jolly->timer);
if (!jolly->dialing[0]) {
PDEBUG_CHAN(DJOLLY, DEBUG_INFO, "Received stop digit but no dial string, entering idle state.\n");
LOGP_CHAN(DJOLLY, LOGL_INFO, "Received stop digit but no dial string, entering idle state.\n");
jolly_go_idle(jolly);
break;
}
PDEBUG_CHAN(DJOLLY, DEBUG_INFO, "Received stop digit, entering verify state.\n");
timer_start(&jolly->speech_timer, SPEECH_DELAY_VERIFY);
LOGP_CHAN(DJOLLY, LOGL_INFO, "Received stop digit, entering verify state.\n");
osmo_timer_schedule(&jolly->speech_timer, SPEECH_DELAY_VERIFY);
jolly_new_state(jolly, STATE_OUT_VERIFY);
break;
}
break;
case STATE_OUT_VERIFY:
if (digit == '*') {
PDEBUG_CHAN(DJOLLY, DEBUG_INFO, "Received start digit, entering dialing state.\n");
LOGP_CHAN(DJOLLY, LOGL_INFO, "Received start digit, entering dialing state.\n");
reset_speech_string(jolly);
jolly->dialing[0] = '\0';
timer_start(&jolly->timer, T_DIAL);
osmo_timer_schedule(&jolly->timer, T_DIAL);
jolly_new_state(jolly, STATE_OUT_DIALING);
break;
}
if (digit == '#') {
PDEBUG_CHAN(DJOLLY, DEBUG_INFO, "Received ack digit, entering call state.\n");
timer_stop(&jolly->timer);
LOGP_CHAN(DJOLLY, LOGL_INFO, "Received ack digit, entering call state.\n");
osmo_timer_del(&jolly->timer);
jolly->callref = call_up_setup(NULL, jolly->dialing, OSMO_CC_NETWORK_JOLLYCOM_NONE, "");
jolly_new_state(jolly, STATE_CALL);
}
break;
case STATE_CALL:
if (digit == '*') {
PDEBUG_CHAN(DJOLLY, DEBUG_INFO, "Received start digit, entering call dialing state.\n");
LOGP_CHAN(DJOLLY, LOGL_INFO, "Received start digit, entering call dialing state.\n");
jolly->dialing[0] = '\0';
timer_start(&jolly->timer, T_DIAL2);
osmo_timer_schedule(&jolly->timer, T_DIAL2);
jolly_new_state(jolly, STATE_CALL_DIALING);
break;
}
break;
case STATE_CALL_DIALING:
if (digit == '#') {
PDEBUG_CHAN(DJOLLY, DEBUG_INFO, "Received stop digit, going idle.\n");
LOGP_CHAN(DJOLLY, LOGL_INFO, "Received stop digit, going idle.\n");
call_up_release(jolly->callref, CAUSE_NORMAL);
jolly->callref = 0;
jolly_release(jolly);
@ -413,7 +413,7 @@ void jolly_receive_dtmf(void *priv, char digit, dtmf_meas_t *meas)
break;
case STATE_IN_PAGING:
if (digit == '#') {
PDEBUG_CHAN(DJOLLY, DEBUG_INFO, "Received answer digit, entering call state.\n");
LOGP_CHAN(DJOLLY, LOGL_INFO, "Received answer digit, entering call state.\n");
call_up_answer(jolly->callref, jolly->station_id);
jolly_new_state(jolly, STATE_CALL);
break;
@ -431,19 +431,19 @@ static void jolly_timeout(void *data)
switch (jolly->state) {
case STATE_OUT_DIALING:
PDEBUG_CHAN(DJOLLY, DEBUG_NOTICE, "Timeout while dialing, going idle.\n");
LOGP_CHAN(DJOLLY, LOGL_NOTICE, "Timeout while dialing, going idle.\n");
jolly_go_idle(jolly);
break;
case STATE_OUT_VERIFY:
PDEBUG_CHAN(DJOLLY, DEBUG_NOTICE, "Timeout while verifying, going idle.\n");
LOGP_CHAN(DJOLLY, LOGL_NOTICE, "Timeout while verifying, going idle.\n");
jolly_go_idle(jolly);
break;
case STATE_CALL_DIALING:
PDEBUG_CHAN(DJOLLY, DEBUG_NOTICE, "Timeout while dialing during call.\n");
LOGP_CHAN(DJOLLY, LOGL_NOTICE, "Timeout while dialing during call.\n");
jolly_new_state(jolly, STATE_CALL);
break;
case STATE_IN_PAGING:
PDEBUG_CHAN(DJOLLY, DEBUG_NOTICE, "Timeout while paging, going idle.\n");
LOGP_CHAN(DJOLLY, LOGL_NOTICE, "Timeout while paging, going idle.\n");
call_up_release(jolly->callref, CAUSE_NOANSWER);
jolly->callref = 0;
jolly_go_idle(jolly);
@ -459,15 +459,15 @@ static void jolly_speech_timeout(void *data)
switch (jolly->state) {
case STATE_OUT_VERIFY:
PDEBUG_CHAN(DJOLLY, DEBUG_DEBUG, "Start verifying speech.\n");
LOGP_CHAN(DJOLLY, LOGL_DEBUG, "Start verifying speech.\n");
set_speech_string(jolly, 'o', jolly->dialing);
break;
case STATE_IN_PAGING:
PDEBUG_CHAN(DJOLLY, DEBUG_DEBUG, "Start paging speech.\n");
LOGP_CHAN(DJOLLY, LOGL_DEBUG, "Start paging speech.\n");
set_speech_string(jolly, 'i', jolly->station_id);
break;
case STATE_RELEASED:
PDEBUG_CHAN(DJOLLY, DEBUG_DEBUG, "Start release speech.\n");
LOGP_CHAN(DJOLLY, LOGL_DEBUG, "Start release speech.\n");
set_speech_string(jolly, 'r', "");
default:
break;
@ -487,7 +487,7 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
break;
}
if (sender) {
PDEBUG(DJOLLY, DEBUG_NOTICE, "Outgoing call to busy number, rejecting!\n");
LOGP(DJOLLY, LOGL_NOTICE, "Outgoing call to busy number, rejecting!\n");
return -CAUSE_BUSY;
}
@ -498,11 +498,11 @@ int call_down_setup(int callref, const char __attribute__((unused)) *caller_id,
break;
}
if (!sender) {
PDEBUG(DJOLLY, DEBUG_NOTICE, "Outgoing call, but no free channel, rejecting!\n");
LOGP(DJOLLY, LOGL_NOTICE, "Outgoing call, but no free channel, rejecting!\n");
return -CAUSE_NOCHANNEL;
}
PDEBUG_CHAN(DJOLLY, DEBUG_INFO, "Call to mobile station.\n");
LOGP_CHAN(DJOLLY, LOGL_INFO, "Call to mobile station.\n");
/* 3. trying to page mobile station */
jolly->callref = callref;
@ -526,7 +526,7 @@ void call_down_disconnect(int callref, int cause)
sender_t *sender;
jolly_t *jolly;
PDEBUG(DJOLLY, DEBUG_INFO, "Call has been disconnected by network.\n");
LOGP(DJOLLY, LOGL_INFO, "Call has been disconnected by network.\n");
for (sender = sender_head; sender; sender = sender->next) {
jolly = (jolly_t *) sender;
@ -534,7 +534,7 @@ void call_down_disconnect(int callref, int cause)
break;
}
if (!sender) {
PDEBUG(DJOLLY, DEBUG_NOTICE, "Outgoing disconnect, but no callref!\n");
LOGP(DJOLLY, LOGL_NOTICE, "Outgoing disconnect, but no callref!\n");
call_up_release(callref, CAUSE_INVALCALLREF);
return;
}
@ -544,7 +544,7 @@ void call_down_disconnect(int callref, int cause)
return;
switch (jolly->state) {
case STATE_IN_PAGING:
PDEBUG_CHAN(DJOLLY, DEBUG_NOTICE, "Outgoing disconnect, during paging, releaseing.\n");
LOGP_CHAN(DJOLLY, LOGL_NOTICE, "Outgoing disconnect, during paging, releaseing.\n");
jolly_go_idle(jolly);
break;
default:
@ -563,7 +563,7 @@ void call_down_release(int callref, __attribute__((unused)) int cause)
sender_t *sender;
jolly_t *jolly;
PDEBUG(DJOLLY, DEBUG_INFO, "Call has been released by network, releasing call.\n");
LOGP(DJOLLY, LOGL_INFO, "Call has been released by network, releasing call.\n");
for (sender = sender_head; sender; sender = sender->next) {
jolly = (jolly_t *) sender;
@ -571,7 +571,7 @@ void call_down_release(int callref, __attribute__((unused)) int cause)
break;
}
if (!sender) {
PDEBUG(DJOLLY, DEBUG_NOTICE, "Outgoing release, but no callref!\n");
LOGP(DJOLLY, LOGL_NOTICE, "Outgoing release, but no callref!\n");
/* don't send release, because caller already released */
return;
}
@ -581,11 +581,11 @@ void call_down_release(int callref, __attribute__((unused)) int cause)
switch (jolly->state) {
case STATE_CALL:
case STATE_CALL_DIALING:
PDEBUG_CHAN(DJOLLY, DEBUG_NOTICE, "Outgoing release, during call, releasing\n");
LOGP_CHAN(DJOLLY, LOGL_NOTICE, "Outgoing release, during call, releasing\n");
jolly_release(jolly);
break;
case STATE_IN_PAGING:
PDEBUG_CHAN(DJOLLY, DEBUG_NOTICE, "Outgoing release, during paging, releaseing.\n");
LOGP_CHAN(DJOLLY, LOGL_NOTICE, "Outgoing release, during paging, releaseing.\n");
jolly_go_idle(jolly);
break;
default:

View File

@ -21,7 +21,7 @@ typedef struct jolly {
int callref; /* call reference */
char station_id[32]; /* current station ID */
char dialing[32]; /* dial string */
struct timer timer;
struct osmo_timer_list timer;
/* display measurements */
dispmeasparam_t *dmp_dtmf_low;
@ -41,7 +41,7 @@ typedef struct jolly {
double ack_phase65536; /* current phase */
int ack_count; /* counter to count down while playing ack tone */
int ack_max; /* duration in samples */
struct timer speech_timer;
struct osmo_timer_list speech_timer;
char speech_string[40]; /* speech string */
int speech_digit; /* counts digits */
int speech_pos; /* counts samples */

View File

@ -29,8 +29,8 @@
#include <sys/stat.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 "../anetz/freiton.h"
#include "../anetz/besetztton.h"
#include "../liboptions/options.h"
@ -210,6 +210,7 @@ fail:
jolly_destroy(sender_head);
/* exits */
main_mobile_exit();
fm_exit();
options_free();

View File

@ -1,7 +0,0 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
noinst_LIBRARIES = libdebug.a
libdebug_a_SOURCES = \
debug.c

View File

@ -1,331 +0,0 @@
/* Simple debug functions for level and category filtering
*
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
#include <math.h>
#include <time.h>
#include <pthread.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include "debug.h"
const char *debug_level[] = {
"debug ",
"info ",
"notice ",
"error ",
NULL,
};
struct debug_cat {
const char *name;
const char *color;
} debug_cat[] = {
{ "options", "\033[0;33m" },
{ "sender", "\033[1;33m" },
{ "sound", "\033[0;35m" },
{ "dsp", "\033[0;31m" },
{ "anetz", "\033[1;34m" },
{ "bnetz", "\033[1;34m" },
{ "cnetz", "\033[1;34m" },
{ "nmt", "\033[1;34m" },
{ "amps", "\033[1;34m" },
{ "r2000", "\033[1;34m" },
{ "imts", "\033[1;34m" },
{ "mpt1327", "\033[1;34m" },
{ "jollycom", "\033[1;34m" },
{ "eurosignal", "\033[1;34m" },
{ "pocsag", "\033[1;34m" },
{ "golay", "\033[1;34m" },
{ "5-ton-folge", "\033[1;34m" },
{ "frame", "\033[0;36m" },
{ "call", "\033[0;37m" },
{ "cc", "\033[1;32m" },
{ "database", "\033[0;33m" },
{ "transaction", "\033[0;32m" },
{ "dms", "\033[0;33m" },
{ "sms", "\033[1;37m" },
{ "sdr", "\033[1;31m" },
{ "uhd", "\033[1;35m" },
{ "soapy", "\033[1;35m" },
{ "wave", "\033[1;33m" },
{ "radio", "\033[1;34m" },
{ "am791x", "\033[0;31m" },
{ "uart", "\033[0;32m" },
{ "device", "\033[0;33m" },
{ "datenklo", "\033[1;34m" },
{ "zeit", "\033[1;34m" },
{ "sim layer 1", "\033[0;31m" },
{ "sim layer 2", "\033[0;33m" },
{ "sim ICL layer", "\033[0;36m" },
{ "sim layer 7", "\033[0;37m" },
{ "mtp layer 2", "\033[1;33m" },
{ "mtp layer 3", "\033[1;36m" },
{ "MuP", "\033[1;37m" },
{ "router", "\033[1;35m" },
{ "stderr", "\033[1;37m" },
{ "ss5", "\033[1;34m" },
{ "r1", "\033[1;34m" },
{ "isdn", "\033[1;35m" },
{ "misdn", "\033[0;34m" },
{ "dss1", "\033[1;34m" },
{ "sip", "\033[1;35m" },
{ "telephone", "\033[1;34m" },
{ "uk0", "\033[1;34m" },
{ "ph", "\033[0;33m" },
{ "dcf77", "\033[1;34m" },
{ "jitter", "\033[0;36m" },
{ NULL, NULL }
};
int debuglevel = DEBUG_INFO;
int debug_date = 0;
uint64_t debug_mask[2] = { ~0, ~0 };
extern int num_kanal;
void (*clear_console_text)(void) = NULL;
void (*print_console_text)(void) = NULL;
int debug_limit_scroll = 0;
static int lock_initialized = 0;
static pthread_mutex_t debug_mutex;
void lock_debug(void)
{
int rc;
if (!lock_initialized) {
rc = pthread_mutex_init(&debug_mutex, NULL);
if (rc == 0)
lock_initialized = 1;
}
if (lock_initialized)
pthread_mutex_lock(&debug_mutex);
}
void unlock_debug(void)
{
if (lock_initialized)
pthread_mutex_unlock(&debug_mutex);
}
void get_win_size(int *w, int *h)
{
struct winsize win;
int rc;
rc = ioctl(0, TIOCGWINSZ, &win);
if (rc) {
*w = 80;
*h = 25;
return;
}
*h = win.ws_row;
*w = win.ws_col;
}
void _printdebug(const char *file, const char __attribute__((unused)) *function, int line, int cat, int level, const char *kanal, const char *fmt, ...)
{
char buffer[4096], *b = buffer;
int s = sizeof(buffer) - 1;
const char *p;
va_list args;
int w, h = 0; // make GCC happy
if (debuglevel > level)
return;
if (!(debug_mask[cat >> 6] & ((uint64_t)1 << (cat & 63))))
return;
lock_debug();
buffer[sizeof(buffer) - 1] = '\0';
/* if kanal is used, prefix the channel number */
if (num_kanal > 1 && kanal) {
sprintf(buffer, "(chan %s) ", kanal);
b = strchr(buffer, '\0');
s -= strlen(buffer);
}
va_start(args, fmt);
vsnprintf(b, s, fmt, args);
va_end(args);
while ((p = strchr(file, '/')))
file = p + 1;
if (clear_console_text)
clear_console_text();
if (debug_limit_scroll) {
get_win_size(&w, &h);
printf("\0337\033[%d;%dr\0338", debug_limit_scroll + 1, h);
}
if (debug_date) {
struct timeval tv;
struct tm *tm;
gettimeofday(&tv, NULL);
tm = localtime(&tv.tv_sec);
printf("%04d-%02d-%02d %02d:%02d:%02d.%03d ", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 10000.0));
}
printf("%s%s %4d %s-%s: %s\033[0;39m", debug_cat[cat].color, file, line, debug_cat[cat].name, debug_level[level], buffer);
if (debug_limit_scroll)
printf("\0337\033[%d;%dr\0338", 1, h);
if (print_console_text)
print_console_text();
fflush(stdout);
unlock_debug();
}
const char *debug_amplitude(double level)
{
static char text[42];
strcpy(text, " : ");
if (level > 1.0)
level = 1.0;
if (level < -1.0)
level = -1.0;
text[20 + (int)(level * 20)] = '*';
return text;
}
#define level2db(level) (20 * log10(level))
const char *debug_db(double level_db)
{
static char text[128];
int l;
strcpy(text, ": . : . : . : . : . : . : . : . | . : . : . : . : . : . : . : . :");
if (level_db <= 0.0)
return text;
l = (int)round(level2db(level_db));
if (l > 48)
return text;
if (l < -48)
return text;
text[l + 48] = '*';
return text;
}
void debug_print_help(void)
{
printf(" -v --verbose <level> | <level>,<category>[,<category>[,...]] | list\n");
printf(" Use 'list' to get a list of all levels and 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(" -v --verbose date\n");
printf(" Show date with debug output\n");
}
void debug_list_cat(void)
{
int i;
printf("Give number of debug level:\n");
for (i = 0; debug_level[i]; i++)
printf(" %d = %s\n", i, debug_level[i]);
printf("\n");
printf("Give name(s) of debug category:\n");
for (i = 0; debug_cat[i].name; i++)
printf(" %s%s\033[0;39m\n", debug_cat[i].color, debug_cat[i].name);
printf("\n");
}
int parse_debug_opt(const char *optarg)
{
int i, max_level = 0;
char *dup, *dstring, *p;
if (!strcasecmp(optarg, "date")) {
debug_date = 1;
return 0;
}
for (i = 0; debug_level[i]; i++)
max_level = i;
dup = dstring = strdup(optarg);
p = strsep(&dstring, ",");
for (i = 0; i < p[i]; i++) {
if (p[i] < '0' || p[i] > '9') {
fprintf(stderr, "Only digits are allowed for debug level!\n");
free(dup);
return -EINVAL;
}
}
debuglevel = atoi(p);
if (debuglevel > max_level) {
fprintf(stderr, "Debug level too high, use 'list' to show available levels!\n");
free(dup);
return -EINVAL;
}
if (dstring)
memset(debug_mask, 0, sizeof(debug_mask));
while((p = strsep(&dstring, ","))) {
for (i = 0; debug_cat[i].name; i++) {
if (!strcasecmp(p, debug_cat[i].name))
break;
}
if (!debug_cat[i].name) {
fprintf(stderr, "Given debug category '%s' unknown, use 'list' to show available categories!\n", p);
free(dup);
return -EINVAL;
}
debug_mask[i >> 6] |= ((uint64_t)1 << (i & 63));
}
free(dup);
return 0;
}
const char *debug_hex(const uint8_t *data, int len)
{
static char *text = NULL;
char *p;
int i;
if (text)
free(text);
p = text = calloc(1, len * 3 + 1);
for (i = 0; i < len; i++) {
sprintf(p, "%02x ", *data++);
p += 3;
}
if (text[0])
p[-1] = '\0';
return text;
}

View File

@ -1,94 +0,0 @@
#define DEBUG_DEBUG 0 /* debug info, not for normal use */
#define DEBUG_INFO 1 /* all info about process */
#define DEBUG_NOTICE 2 /* something unexpected happens */
#define DEBUG_ERROR 3 /* there is an error with this software */
#define DOPTIONS 0
#define DSENDER 1
#define DSOUND 2
#define DDSP 3
#define DANETZ 4
#define DBNETZ 5
#define DCNETZ 6
#define DNMT 7
#define DAMPS 8
#define DR2000 9
#define DIMTS 10
#define DMPT1327 11
#define DJOLLY 12
#define DEURO 13
#define DPOCSAG 14
#define DGOLAY 15
#define DFUENF 16
#define DFRAME 17
#define DCALL 18
#define DCC 19
#define DDB 20
#define DTRANS 21
#define DDMS 22
#define DSMS 23
#define DSDR 24
#define DUHD 25
#define DSOAPY 26
#define DWAVE 27
#define DRADIO 28
#define DAM791X 29
#define DUART 30
#define DDEVICE 31
#define DDATENKLO 32
#define DZEIT 33
#define DSIM1 34
#define DSIM2 35
#define DSIMI 36
#define DSIM7 37
#define DMTP2 38
#define DMTP3 39
#define DMUP 40
#define DROUTER 41
#define DSTDERR 42
#define DSS5 43
#define DR1 44
#define DISDN 45
#define DMISDN 46
#define DDSS1 47
#define DSIP 48
#define DTEL 49
#define DUK0 50
#define DPH 51
#define DDCF77 52
#define DJITTER 53
//NOTE: increment mask array, if 127 is exceeded
void lock_debug(void);
void unlock_debug(void);
void get_win_size(int *w, int *h);
#define PDEBUG(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, NULL, fmt, ## arg)
#define PDEBUG_CHAN(cat, level, fmt, arg...) _printdebug(__FILE__, __FUNCTION__, __LINE__, cat, level, CHAN, fmt, ## arg)
void _printdebug(const char *file, const char *function, int line, int cat, int level, const char *chan_str, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 7, 8)));
const char *debug_amplitude(double level);
const char *debug_db(double level_db);
void debug_print_help(void);
void debug_list_cat(void);
int parse_debug_opt(const char *opt);
extern int debuglevel;
extern void (*clear_console_text)(void);
extern void (*print_console_text)(void);
extern int debug_limit_scroll;
const char *debug_hex(const uint8_t *data, int len);
#define LOGP PDEBUG
#define LOGL_DEBUG DEBUG_DEBUG
#define LOGL_INFO DEBUG_INFO
#define LOGL_NOTICE DEBUG_NOTICE
#define LOGL_ERROR DEBUG_ERROR
#define osmo_hexdump debug_hex

View File

@ -24,7 +24,7 @@
#include <pthread.h>
#include <stdlib.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libdisplay/display.h"
/* must be odd value! */
@ -60,14 +60,16 @@ void display_iq_on(int on)
if (iq_on) {
memset(&screen, ' ', sizeof(screen));
memset(&screen_history, 0, sizeof(screen_history));
lock_debug();
lock_logging();
enable_limit_scroll(false);
printf("\0337\033[H");
for (j = 0; j < SIZE; j++) {
screen[j][w] = '\0';
puts(screen[j]);
}
printf("\0338"); fflush(stdout);
unlock_debug();
enable_limit_scroll(true);
unlock_logging();
}
if (on < 0) {
@ -77,9 +79,9 @@ void display_iq_on(int on)
iq_on = on;
if (iq_on)
debug_limit_scroll = SIZE;
logging_limit_scroll_top(SIZE);
else
debug_limit_scroll = 0;
logging_limit_scroll_top(0);
}
/*
@ -116,8 +118,6 @@ void display_iq(float *samples, int length)
if (!iq_on)
return;
lock_debug();
get_win_size(&width, &h);
if (width > MAX_DISPLAY_WIDTH - 1)
width = MAX_DISPLAY_WIDTH - 1;
@ -235,6 +235,8 @@ cont:
else
sprintf(screen[0], "(IQ log %.0f dB", db);
*strchr(screen[0], '\0') = ')';
lock_logging();
enable_limit_scroll(false);
printf("\0337\033[H");
for (j = 0; j < SIZE; j++) {
for (k = 0; k < width; k++) {
@ -271,12 +273,12 @@ cont:
}
/* reset color and position */
printf("\033[0;39m\0338"); fflush(stdout);
enable_limit_scroll(true);
unlock_logging();
}
}
disp.interval_pos = pos;
unlock_debug();
}

View File

@ -26,7 +26,7 @@
#include <math.h>
#include <sys/param.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libdisplay/display.h"
#define MAX_NAME_LEN 16
@ -111,10 +111,10 @@ static void print_measurements(int on)
if (bar_width < 1)
return;
lock_debug();
lines_total = 0;
color = -1;
lock_logging();
enable_limit_scroll(false);
printf("\0337\033[H");
for (disp = meas_head; disp; disp = disp->next) {
memset(line, ' ', width);
@ -253,10 +253,10 @@ static void print_measurements(int on)
}
/* reset color and position */
printf("\033[0;39m\0338"); fflush(stdout);
debug_limit_scroll = lines_total;
unlock_debug();
enable_limit_scroll(true);
unlock_logging();
/* Set new limit. */
logging_limit_scroll_top(lines_total);
}
void display_measurements_on(int on)
@ -269,7 +269,7 @@ void display_measurements_on(int on)
else
measurements_on = on;
debug_limit_scroll = 0;
logging_limit_scroll_top(0);
}
/* add new parameter on startup to the list of measurements */

View File

@ -24,7 +24,7 @@
#include <math.h>
#include "../libsample/sample.h"
#include "../libfft/fft.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libdisplay/display.h"
#define HEIGHT 20
@ -101,14 +101,16 @@ void display_spectrum_on(int on)
if (spectrum_on) {
memset(&screen, ' ', sizeof(screen));
memset(&buffer_hold, 0, sizeof(buffer_hold));
lock_debug();
lock_logging();
enable_limit_scroll(false);
printf("\0337\033[H");
for (j = 0; j < HEIGHT; j++) {
screen[j][w] = '\0';
puts(screen[j]);
}
printf("\0338"); fflush(stdout);
unlock_debug();
enable_limit_scroll(true);
unlock_logging();
}
if (on < 0) {
@ -118,9 +120,9 @@ void display_spectrum_on(int on)
spectrum_on = on;
if (spectrum_on)
debug_limit_scroll = HEIGHT;
logging_limit_scroll_top(HEIGHT);
else
debug_limit_scroll = 0;
logging_limit_scroll_top(0);
}
/*
@ -142,8 +144,6 @@ void display_spectrum(float *samples, int length)
if (!spectrum_on)
return;
lock_debug();
get_win_size(&width, &h);
if (width > MAX_DISPLAY_WIDTH - 1)
width = MAX_DISPLAY_WIDTH - 1;
@ -390,6 +390,8 @@ void display_spectrum(float *samples, int length)
screen_color[0][j-1] = 7;
screen_color[0][j+1] = 7;
/* display buffer */
lock_logging();
enable_limit_scroll(false);
printf("\0337\033[H");
for (j = 0; j < HEIGHT; j++) {
for (k = 0; k < width; k++) {
@ -403,12 +405,11 @@ void display_spectrum(float *samples, int length)
}
/* reset color and position */
printf("\033[0;39m\0338"); fflush(stdout);
enable_limit_scroll(true);
unlock_logging();
}
}
disp.interval_pos = pos;
unlock_debug();
}

View File

@ -23,7 +23,7 @@
#include <pthread.h>
#include <sys/ioctl.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libdisplay/display.h"
static int status_on = 0;
@ -46,7 +46,8 @@ static void print_status(int on)
if (h > lines_total)
h = lines_total;
lock_debug();
lock_logging();
enable_limit_scroll(false);
printf("\0337\033[H\033[1;37m");
for (i = 0; i < h; i++) {
j = 0;
@ -60,7 +61,8 @@ static void print_status(int on)
putchar('\n');
}
printf("\0338"); fflush(stdout);
unlock_debug();
enable_limit_scroll(true);
unlock_logging();
}
void display_status_on(int on)
@ -77,9 +79,9 @@ void display_status_on(int on)
print_status(1);
if (status_on)
debug_limit_scroll = lines_total;
logging_limit_scroll_top(lines_total);
else
debug_limit_scroll = 0;
logging_limit_scroll_top(0);
}
/* start status display */
@ -139,7 +141,7 @@ void display_status_end(void)
/* set new total lines */
lines_total = line_count;
if (status_on)
debug_limit_scroll = lines_total;
logging_limit_scroll_top(lines_total);
}

View File

@ -24,7 +24,7 @@
#include <math.h>
#include <sys/ioctl.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "../libdisplay/display.h"
#define HEIGHT 11
@ -52,7 +52,8 @@ void display_wave_on(int on)
if (wave_on) {
memset(&screen, ' ', sizeof(screen));
lock_debug();
lock_logging();
enable_limit_scroll(false);
printf("\0337\033[H");
for (i = 0; i < num_sender; i++) {
for (j = 0; j < HEIGHT; j++) {
@ -61,7 +62,8 @@ void display_wave_on(int on)
}
}
printf("\0338"); fflush(stdout);
unlock_debug();
enable_limit_scroll(true);
unlock_logging();
}
if (on < 0)
@ -70,9 +72,9 @@ void display_wave_on(int on)
wave_on = on;
if (wave_on)
debug_limit_scroll = HEIGHT * num_sender;
logging_limit_scroll_top(HEIGHT * num_sender);
else
debug_limit_scroll = 0;
logging_limit_scroll_top(0);
}
/*
@ -104,8 +106,6 @@ void display_wave(dispwav_t *disp, sample_t *samples, int length, double range)
if (!wave_on)
return;
lock_debug();
get_win_size(&width, &h);
if (width > MAX_DISPLAY_WIDTH - 1)
width = MAX_DISPLAY_WIDTH - 1;
@ -208,6 +208,8 @@ void display_wave(dispwav_t *disp, sample_t *samples, int length, double range)
}
sprintf(screen[0], "(chan %s", disp->kanal);
*strchr(screen[0], '\0') = ')';
lock_logging();
enable_limit_scroll(false);
printf("\0337\033[H");
for (j = 0; j < disp->offset; j++)
puts("");
@ -241,12 +243,12 @@ void display_wave(dispwav_t *disp, sample_t *samples, int length, double range)
}
/* reset color and position */
printf("\033[0;39m\0338"); fflush(stdout);
enable_limit_scroll(true);
unlock_logging();
}
}
disp->interval_pos = pos;
unlock_debug();
}

View File

@ -22,10 +22,10 @@
#include <string.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "dtmf_decode.h"
//#define DEBUG
//#define DEBUG_DTMF
#define level2db(level) (20 * log10(level))
#define db2level(db) pow(10, (double)db / 20.0)
@ -133,7 +133,7 @@ void dtmf_decode(dtmf_dec_t *dtmf, sample_t *samples, int length)
dtmf_decode_filter(dtmf, samples, length, frequency_low, frequency_high, amplitude_low, amplitude_high);
for (i = 0; i < length; i++) {
#ifdef DEBUG
#ifdef DEBUG_DTMF
// printf("%s %.5f\n", debug_amplitude(samples[i]/2.0), samples[i]/2.0);
#endif
/* get frequency of low frequencies, correct amplitude drop at cutoff point */
@ -194,7 +194,7 @@ void dtmf_decode(dtmf_dec_t *dtmf, sample_t *samples, int length)
/* check for limits */
if (amplitude_low[i] <= max_amplitude && amplitude_low[i] >= min_amplitude && amplitude_high[i] <= max_amplitude && amplitude_high[i] >= min_amplitude) {
amplitude_ok = 1;
#ifdef DEBUG
#ifdef DEBUG_DTMF
printf("%.1f %.1f (limits %.1f .. %.1f) %.1f\n", level2db(amplitude_low[i]), level2db(amplitude_high[i]), level2db(min_amplitude), level2db(max_amplitude), level2db(amplitude_high[i] / amplitude_low[i]));
#endif
if (amplitude_high[i] / amplitude_low[i] <= forward_twist && amplitude_low[i] / amplitude_high[i] <= reverse_twist)
@ -231,14 +231,14 @@ void dtmf_decode(dtmf_dec_t *dtmf, sample_t *samples, int length)
count++;
if (count >= time_pause) {
detected = 0;
#ifdef DEBUG
#ifdef DEBUG_DTMF
printf("lost!\n");
#endif
}
} else
count = 0;
}
#ifdef DEBUG
#ifdef DEBUG_DTMF
if (digit)
printf("DTMF tone='%c' diff frequency=%.1f %.1f amplitude=%.1f %.1f dB (%s) twist=%.1f dB (%s)\n", digit, f1, f2, level2db(amplitude_low[i]), level2db(amplitude_high[i]), (amplitude_ok) ? "OK" : "nok", level2db(amplitude_high[i] / amplitude_low[i]), (twist_ok) ? "OK" : "nok");
#endif

View File

@ -24,7 +24,7 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "fsk.h"
#define PI M_PI
@ -51,7 +51,7 @@ int fsk_mod_init(fsk_mod_t *fsk, void *inst, int (*send_bit)(void *inst), int sa
int i;
int rc;
PDEBUG(DDSP, DEBUG_DEBUG, "Setup FSK for Transmitter. (F0 = %.1f, F1 = %.1f, peak = %.1f)\n", f0, f1, level);
LOGP(DDSP, LOGL_DEBUG, "Setup FSK for Transmitter. (F0 = %.1f, F1 = %.1f, peak = %.1f)\n", f0, f1, level);
memset(fsk, 0, sizeof(*fsk));
@ -79,12 +79,12 @@ int fsk_mod_init(fsk_mod_t *fsk, void *inst, int (*send_bit)(void *inst), int sa
}
fsk->bits65536_per_sample = (double)bitrate / (double)samplerate * 65536.0;
PDEBUG(DDSP, DEBUG_DEBUG, "Bitduration of %.4f bits per sample @ %d.\n", fsk->bits65536_per_sample / 65536.0, samplerate);
LOGP(DDSP, LOGL_DEBUG, "Bitduration of %.4f bits per sample @ %d.\n", fsk->bits65536_per_sample / 65536.0, samplerate);
fsk->phaseshift65536[0] = f0 / (double)samplerate * 65536.0;
fsk->phaseshift65536[1] = f1 / (double)samplerate * 65536.0;
PDEBUG(DDSP, DEBUG_DEBUG, "F0 = %.0f Hz (phaseshift65536[0] = %.4f)\n", f0, fsk->phaseshift65536[0]);
PDEBUG(DDSP, DEBUG_DEBUG, "F1 = %.0f Hz (phaseshift65536[1] = %.4f)\n", f1, fsk->phaseshift65536[1]);
LOGP(DDSP, LOGL_DEBUG, "F0 = %.0f Hz (phaseshift65536[0] = %.4f)\n", f0, fsk->phaseshift65536[0]);
LOGP(DDSP, LOGL_DEBUG, "F1 = %.0f Hz (phaseshift65536[1] = %.4f)\n", f1, fsk->phaseshift65536[1]);
/* use ffsk modulation, i.e. each bit has an integer number of
* half waves and starts/ends at zero crossing
@ -93,12 +93,12 @@ int fsk_mod_init(fsk_mod_t *fsk, void *inst, int (*send_bit)(void *inst), int sa
double waves;
if (filter) {
PDEBUG(DDSP, DEBUG_ERROR, "Cannot use FFSK with filter.\n");
LOGP(DDSP, LOGL_ERROR, "Cannot use FFSK with filter.\n");
rc = -EINVAL;
goto error;
}
PDEBUG(DDSP, DEBUG_DEBUG, "enable FFSK modulation mode\n");
LOGP(DDSP, LOGL_DEBUG, "enable FFSK modulation mode\n");
fsk->ffsk = 1;
waves = (f0 / bitrate);
if (fabs(round(waves * 2) - (waves * 2)) > 0.001) {
@ -116,8 +116,8 @@ int fsk_mod_init(fsk_mod_t *fsk, void *inst, int (*send_bit)(void *inst), int sa
fsk->cycles_per_bit65536[0] = f0 / bitrate * 65536.0;
fsk->cycles_per_bit65536[1] = f1 / bitrate * 65536.0;
}
PDEBUG(DDSP, DEBUG_DEBUG, "F0 = %.0f Hz (cycles_per_bit65536[0] = %.4f)\n", f0, fsk->cycles_per_bit65536[0]);
PDEBUG(DDSP, DEBUG_DEBUG, "F1 = %.0f Hz (cycles_per_bit65536[1] = %.4f)\n", f1, fsk->cycles_per_bit65536[1]);
LOGP(DDSP, LOGL_DEBUG, "F0 = %.0f Hz (cycles_per_bit65536[0] = %.4f)\n", f0, fsk->cycles_per_bit65536[0]);
LOGP(DDSP, LOGL_DEBUG, "F1 = %.0f Hz (cycles_per_bit65536[1] = %.4f)\n", f1, fsk->cycles_per_bit65536[1]);
/* if filter is enabled, use a cosine shaped curve to change the phase each sample */
if (filter) {
@ -138,7 +138,7 @@ int fsk_mod_init(fsk_mod_t *fsk, void *inst, int (*send_bit)(void *inst), int sa
#endif
}
PDEBUG(DDSP, DEBUG_DEBUG, "Enable filter to smooth FSK transmission.\n");
LOGP(DDSP, LOGL_DEBUG, "Enable filter to smooth FSK transmission.\n");
fsk->filter = 1;
}
@ -155,7 +155,7 @@ error:
/* Cleanup transceiver instance. */
void fsk_mod_cleanup(fsk_mod_t *fsk)
{
PDEBUG(DDSP, DEBUG_DEBUG, "Cleanup FSK for Transmitter.\n");
LOGP(DDSP, LOGL_DEBUG, "Cleanup FSK for Transmitter.\n");
if (fsk->sin_tab) {
free(fsk->sin_tab);
@ -314,7 +314,7 @@ int fsk_demod_init(fsk_demod_t *fsk, void *inst, void (*receive_bit)(void *inst,
double bandwidth;
int rc;
PDEBUG(DDSP, DEBUG_DEBUG, "Setup FSK for Receiver. (F0 = %.1f, F1 = %.1f)\n", f0, f1);
LOGP(DDSP, LOGL_DEBUG, "Setup FSK for Receiver. (F0 = %.1f, F1 = %.1f)\n", f0, f1);
memset(fsk, 0, sizeof(*fsk));
@ -341,7 +341,7 @@ int fsk_demod_init(fsk_demod_t *fsk, void *inst, void (*receive_bit)(void *inst,
goto error;
fsk->bits_per_sample = (double)bitrate / (double)samplerate;
PDEBUG(DDSP, DEBUG_DEBUG, "Bitduration of %.4f bits per sample @ %d.\n", fsk->bits_per_sample, samplerate);
LOGP(DDSP, LOGL_DEBUG, "Bitduration of %.4f bits per sample @ %d.\n", fsk->bits_per_sample, samplerate);
return 0;
@ -353,7 +353,7 @@ error:
/* Cleanup transceiver instance. */
void fsk_demod_cleanup(fsk_demod_t *fsk)
{
PDEBUG(DDSP, DEBUG_DEBUG, "Cleanup FSK for Receiver.\n");
LOGP(DDSP, LOGL_DEBUG, "Cleanup FSK for Receiver.\n");
fm_demod_exit(&fsk->demod);
}

View File

@ -1,7 +0,0 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
noinst_LIBRARIES = libg711.a
libg711_a_SOURCES = \
g711.c

View File

@ -1,537 +0,0 @@
/*****************************************************************************\
** **
** PBX4Linux **
** **
**---------------------------------------------------------------------------**
** Copyright: Andreas Eversberg (GPL) **
** **
** audio conversions for alaw and ulaw **
** **
\*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
/* ulaw -> signed 16-bit */
static int16_t g711_ulaw_to_linear[256] =
{
0x8284, 0x8684, 0x8a84, 0x8e84, 0x9284, 0x9684, 0x9a84, 0x9e84,
0xa284, 0xa684, 0xaa84, 0xae84, 0xb284, 0xb684, 0xba84, 0xbe84,
0xc184, 0xc384, 0xc584, 0xc784, 0xc984, 0xcb84, 0xcd84, 0xcf84,
0xd184, 0xd384, 0xd584, 0xd784, 0xd984, 0xdb84, 0xdd84, 0xdf84,
0xe104, 0xe204, 0xe304, 0xe404, 0xe504, 0xe604, 0xe704, 0xe804,
0xe904, 0xea04, 0xeb04, 0xec04, 0xed04, 0xee04, 0xef04, 0xf004,
0xf0c4, 0xf144, 0xf1c4, 0xf244, 0xf2c4, 0xf344, 0xf3c4, 0xf444,
0xf4c4, 0xf544, 0xf5c4, 0xf644, 0xf6c4, 0xf744, 0xf7c4, 0xf844,
0xf8a4, 0xf8e4, 0xf924, 0xf964, 0xf9a4, 0xf9e4, 0xfa24, 0xfa64,
0xfaa4, 0xfae4, 0xfb24, 0xfb64, 0xfba4, 0xfbe4, 0xfc24, 0xfc64,
0xfc94, 0xfcb4, 0xfcd4, 0xfcf4, 0xfd14, 0xfd34, 0xfd54, 0xfd74,
0xfd94, 0xfdb4, 0xfdd4, 0xfdf4, 0xfe14, 0xfe34, 0xfe54, 0xfe74,
0xfe8c, 0xfe9c, 0xfeac, 0xfebc, 0xfecc, 0xfedc, 0xfeec, 0xfefc,
0xff0c, 0xff1c, 0xff2c, 0xff3c, 0xff4c, 0xff5c, 0xff6c, 0xff7c,
0xff88, 0xff90, 0xff98, 0xffa0, 0xffa8, 0xffb0, 0xffb8, 0xffc0,
0xffc8, 0xffd0, 0xffd8, 0xffe0, 0xffe8, 0xfff0, 0xfff8, 0xffff,
0x7d7c, 0x797c, 0x757c, 0x717c, 0x6d7c, 0x697c, 0x657c, 0x617c,
0x5d7c, 0x597c, 0x557c, 0x517c, 0x4d7c, 0x497c, 0x457c, 0x417c,
0x3e7c, 0x3c7c, 0x3a7c, 0x387c, 0x367c, 0x347c, 0x327c, 0x307c,
0x2e7c, 0x2c7c, 0x2a7c, 0x287c, 0x267c, 0x247c, 0x227c, 0x207c,
0x1efc, 0x1dfc, 0x1cfc, 0x1bfc, 0x1afc, 0x19fc, 0x18fc, 0x17fc,
0x16fc, 0x15fc, 0x14fc, 0x13fc, 0x12fc, 0x11fc, 0x10fc, 0x0ffc,
0x0f3c, 0x0ebc, 0x0e3c, 0x0dbc, 0x0d3c, 0x0cbc, 0x0c3c, 0x0bbc,
0x0b3c, 0x0abc, 0x0a3c, 0x09bc, 0x093c, 0x08bc, 0x083c, 0x07bc,
0x075c, 0x071c, 0x06dc, 0x069c, 0x065c, 0x061c, 0x05dc, 0x059c,
0x055c, 0x051c, 0x04dc, 0x049c, 0x045c, 0x041c, 0x03dc, 0x039c,
0x036c, 0x034c, 0x032c, 0x030c, 0x02ec, 0x02cc, 0x02ac, 0x028c,
0x026c, 0x024c, 0x022c, 0x020c, 0x01ec, 0x01cc, 0x01ac, 0x018c,
0x0174, 0x0164, 0x0154, 0x0144, 0x0134, 0x0124, 0x0114, 0x0104,
0x00f4, 0x00e4, 0x00d4, 0x00c4, 0x00b4, 0x00a4, 0x0094, 0x0084,
0x0078, 0x0070, 0x0068, 0x0060, 0x0058, 0x0050, 0x0048, 0x0040,
0x0038, 0x0030, 0x0028, 0x0020, 0x0018, 0x0010, 0x0008, 0x0000
};
/* alaw -> signed 16-bit */
static int16_t g711_alaw_flipped_to_linear[256] =
{
0x13fc, 0xec04, 0x0144, 0xfebc, 0x517c, 0xae84, 0x051c, 0xfae4,
0x0a3c, 0xf5c4, 0x0048, 0xffb8, 0x287c, 0xd784, 0x028c, 0xfd74,
0x1bfc, 0xe404, 0x01cc, 0xfe34, 0x717c, 0x8e84, 0x071c, 0xf8e4,
0x0e3c, 0xf1c4, 0x00c4, 0xff3c, 0x387c, 0xc784, 0x039c, 0xfc64,
0x0ffc, 0xf004, 0x0104, 0xfefc, 0x417c, 0xbe84, 0x041c, 0xfbe4,
0x083c, 0xf7c4, 0x0008, 0xfff8, 0x207c, 0xdf84, 0x020c, 0xfdf4,
0x17fc, 0xe804, 0x018c, 0xfe74, 0x617c, 0x9e84, 0x061c, 0xf9e4,
0x0c3c, 0xf3c4, 0x0084, 0xff7c, 0x307c, 0xcf84, 0x030c, 0xfcf4,
0x15fc, 0xea04, 0x0164, 0xfe9c, 0x597c, 0xa684, 0x059c, 0xfa64,
0x0b3c, 0xf4c4, 0x0068, 0xff98, 0x2c7c, 0xd384, 0x02cc, 0xfd34,
0x1dfc, 0xe204, 0x01ec, 0xfe14, 0x797c, 0x8684, 0x07bc, 0xf844,
0x0f3c, 0xf0c4, 0x00e4, 0xff1c, 0x3c7c, 0xc384, 0x03dc, 0xfc24,
0x11fc, 0xee04, 0x0124, 0xfedc, 0x497c, 0xb684, 0x049c, 0xfb64,
0x093c, 0xf6c4, 0x0028, 0xffd8, 0x247c, 0xdb84, 0x024c, 0xfdb4,
0x19fc, 0xe604, 0x01ac, 0xfe54, 0x697c, 0x9684, 0x069c, 0xf964,
0x0d3c, 0xf2c4, 0x00a4, 0xff5c, 0x347c, 0xcb84, 0x034c, 0xfcb4,
0x12fc, 0xed04, 0x0134, 0xfecc, 0x4d7c, 0xb284, 0x04dc, 0xfb24,
0x09bc, 0xf644, 0x0038, 0xffc8, 0x267c, 0xd984, 0x026c, 0xfd94,
0x1afc, 0xe504, 0x01ac, 0xfe54, 0x6d7c, 0x9284, 0x06dc, 0xf924,
0x0dbc, 0xf244, 0x00b4, 0xff4c, 0x367c, 0xc984, 0x036c, 0xfc94,
0x0f3c, 0xf0c4, 0x00f4, 0xff0c, 0x3e7c, 0xc184, 0x03dc, 0xfc24,
0x07bc, 0xf844, 0x0008, 0xfff8, 0x1efc, 0xe104, 0x01ec, 0xfe14,
0x16fc, 0xe904, 0x0174, 0xfe8c, 0x5d7c, 0xa284, 0x05dc, 0xfa24,
0x0bbc, 0xf444, 0x0078, 0xff88, 0x2e7c, 0xd184, 0x02ec, 0xfd14,
0x14fc, 0xeb04, 0x0154, 0xfeac, 0x557c, 0xaa84, 0x055c, 0xfaa4,
0x0abc, 0xf544, 0x0058, 0xffa8, 0x2a7c, 0xd584, 0x02ac, 0xfd54,
0x1cfc, 0xe304, 0x01cc, 0xfe34, 0x757c, 0x8a84, 0x075c, 0xf8a4,
0x0ebc, 0xf144, 0x00d4, 0xff2c, 0x3a7c, 0xc584, 0x039c, 0xfc64,
0x10fc, 0xef04, 0x0114, 0xfeec, 0x457c, 0xba84, 0x045c, 0xfba4,
0x08bc, 0xf744, 0x0018, 0xffe8, 0x227c, 0xdd84, 0x022c, 0xfdd4,
0x18fc, 0xe704, 0x018c, 0xfe74, 0x657c, 0x9a84, 0x065c, 0xf9a4,
0x0cbc, 0xf344, 0x0094, 0xff6c, 0x327c, 0xcd84, 0x032c, 0xfcd4
};
/* Xlaw -> signed 16-bit */
static int16_t g711_alaw_to_linear[256];
static int16_t g711_ulaw_flipped_to_linear[256];
/* signed 16-bit -> Xlaw */
static uint8_t g711_linear_to_alaw_flipped[65536];
static uint8_t g711_linear_to_ulaw_flipped[65536];
static uint8_t g711_linear_to_alaw[65536];
static uint8_t g711_linear_to_ulaw[65536];
/* transcode */
static uint8_t g711_alaw_to_ulaw[256];
static uint8_t g711_ulaw_to_alaw[256];
static uint8_t g711_alaw_flipped_to_ulaw[256];
static uint8_t g711_ulaw_flipped_to_alaw[256];
static uint8_t g711_alaw_to_ulaw_flipped[256];
static uint8_t g711_ulaw_to_alaw_flipped[256];
/* table is used to generate linear_to_alaw */
static int16_t g711_alaw_relations[] =
{
0x8684, 0x55, 0x8a84, 0xd5, 0x8e84, 0x15, 0x9284, 0x95,
0x9684, 0x75, 0x9a84, 0xf5, 0x9e84, 0x35, 0xa284, 0xb5,
0xa684, 0x45, 0xaa84, 0xc5, 0xae84, 0x05, 0xb284, 0x85,
0xb684, 0x65, 0xba84, 0xe5, 0xbe84, 0x25, 0xc184, 0xa5,
0xc384, 0x5d, 0xc584, 0xdd, 0xc784, 0x1d, 0xc984, 0x9d,
0xcb84, 0x7d, 0xcd84, 0xfd, 0xcf84, 0x3d, 0xd184, 0xbd,
0xd384, 0x4d, 0xd584, 0xcd, 0xd784, 0x0d, 0xd984, 0x8d,
0xdb84, 0x6d, 0xdd84, 0xed, 0xdf84, 0x2d, 0xe104, 0xad,
0xe204, 0x51, 0xe304, 0xd1, 0xe404, 0x11, 0xe504, 0x91,
0xe604, 0x71, 0xe704, 0xf1, 0xe804, 0x31, 0xe904, 0xb1,
0xea04, 0x41, 0xeb04, 0xc1, 0xec04, 0x01, 0xed04, 0x81,
0xee04, 0x61, 0xef04, 0xe1, 0xf004, 0x21, 0xf0c4, 0x59,
0xf0c4, 0xa1, 0xf144, 0xd9, 0xf1c4, 0x19, 0xf244, 0x99,
0xf2c4, 0x79, 0xf344, 0xf9, 0xf3c4, 0x39, 0xf444, 0xb9,
0xf4c4, 0x49, 0xf544, 0xc9, 0xf5c4, 0x09, 0xf644, 0x89,
0xf6c4, 0x69, 0xf744, 0xe9, 0xf7c4, 0x29, 0xf844, 0x57,
0xf844, 0xa9, 0xf8a4, 0xd7, 0xf8e4, 0x17, 0xf924, 0x97,
0xf964, 0x77, 0xf9a4, 0xf7, 0xf9e4, 0x37, 0xfa24, 0xb7,
0xfa64, 0x47, 0xfaa4, 0xc7, 0xfae4, 0x07, 0xfb24, 0x87,
0xfb64, 0x67, 0xfba4, 0xe7, 0xfbe4, 0x27, 0xfc24, 0x5f,
0xfc24, 0xa7, 0xfc64, 0x1f, 0xfc64, 0xdf, 0xfc94, 0x9f,
0xfcb4, 0x7f, 0xfcd4, 0xff, 0xfcf4, 0x3f, 0xfd14, 0xbf,
0xfd34, 0x4f, 0xfd54, 0xcf, 0xfd74, 0x0f, 0xfd94, 0x8f,
0xfdb4, 0x6f, 0xfdd4, 0xef, 0xfdf4, 0x2f, 0xfe14, 0x53,
0xfe14, 0xaf, 0xfe34, 0x13, 0xfe34, 0xd3, 0xfe54, 0x73,
0xfe54, 0x93, 0xfe74, 0x33, 0xfe74, 0xf3, 0xfe8c, 0xb3,
0xfe9c, 0x43, 0xfeac, 0xc3, 0xfebc, 0x03, 0xfecc, 0x83,
0xfedc, 0x63, 0xfeec, 0xe3, 0xfefc, 0x23, 0xff0c, 0xa3,
0xff1c, 0x5b, 0xff2c, 0xdb, 0xff3c, 0x1b, 0xff4c, 0x9b,
0xff5c, 0x7b, 0xff6c, 0xfb, 0xff7c, 0x3b, 0xff88, 0xbb,
0xff98, 0x4b, 0xffa8, 0xcb, 0xffb8, 0x0b, 0xffc8, 0x8b,
0xffd8, 0x6b, 0xffe8, 0xeb, 0xfff8, 0x2b, 0xfff8, 0xab,
0x0008, 0x2a, 0x0008, 0xaa, 0x0018, 0xea, 0x0028, 0x6a,
0x0038, 0x8a, 0x0048, 0x0a, 0x0058, 0xca, 0x0068, 0x4a,
0x0078, 0xba, 0x0084, 0x3a, 0x0094, 0xfa, 0x00a4, 0x7a,
0x00b4, 0x9a, 0x00c4, 0x1a, 0x00d4, 0xda, 0x00e4, 0x5a,
0x00f4, 0xa2, 0x0104, 0x22, 0x0114, 0xe2, 0x0124, 0x62,
0x0134, 0x82, 0x0144, 0x02, 0x0154, 0xc2, 0x0164, 0x42,
0x0174, 0xb2, 0x018c, 0x32, 0x018c, 0xf2, 0x01ac, 0x72,
0x01ac, 0x92, 0x01cc, 0x12, 0x01cc, 0xd2, 0x01ec, 0x52,
0x01ec, 0xae, 0x020c, 0x2e, 0x022c, 0xee, 0x024c, 0x6e,
0x026c, 0x8e, 0x028c, 0x0e, 0x02ac, 0xce, 0x02cc, 0x4e,
0x02ec, 0xbe, 0x030c, 0x3e, 0x032c, 0xfe, 0x034c, 0x7e,
0x036c, 0x9e, 0x039c, 0x1e, 0x039c, 0xde, 0x03dc, 0x5e,
0x03dc, 0xa6, 0x041c, 0x26, 0x045c, 0xe6, 0x049c, 0x66,
0x04dc, 0x86, 0x051c, 0x06, 0x055c, 0xc6, 0x059c, 0x46,
0x05dc, 0xb6, 0x061c, 0x36, 0x065c, 0xf6, 0x069c, 0x76,
0x06dc, 0x96, 0x071c, 0x16, 0x075c, 0xd6, 0x07bc, 0x56,
0x07bc, 0xa8, 0x083c, 0x28, 0x08bc, 0xe8, 0x093c, 0x68,
0x09bc, 0x88, 0x0a3c, 0x08, 0x0abc, 0xc8, 0x0b3c, 0x48,
0x0bbc, 0xb8, 0x0c3c, 0x38, 0x0cbc, 0xf8, 0x0d3c, 0x78,
0x0dbc, 0x98, 0x0e3c, 0x18, 0x0ebc, 0xd8, 0x0f3c, 0x58,
0x0f3c, 0xa0, 0x0ffc, 0x20, 0x10fc, 0xe0, 0x11fc, 0x60,
0x12fc, 0x80, 0x13fc, 0x00, 0x14fc, 0xc0, 0x15fc, 0x40,
0x16fc, 0xb0, 0x17fc, 0x30, 0x18fc, 0xf0, 0x19fc, 0x70,
0x1afc, 0x90, 0x1bfc, 0x10, 0x1cfc, 0xd0, 0x1dfc, 0x50,
0x1efc, 0xac, 0x207c, 0x2c, 0x227c, 0xec, 0x247c, 0x6c,
0x267c, 0x8c, 0x287c, 0x0c, 0x2a7c, 0xcc, 0x2c7c, 0x4c,
0x2e7c, 0xbc, 0x307c, 0x3c, 0x327c, 0xfc, 0x347c, 0x7c,
0x367c, 0x9c, 0x387c, 0x1c, 0x3a7c, 0xdc, 0x3c7c, 0x5c,
0x3e7c, 0xa4, 0x417c, 0x24, 0x457c, 0xe4, 0x497c, 0x64,
0x4d7c, 0x84, 0x517c, 0x04, 0x557c, 0xc4, 0x597c, 0x44,
0x5d7c, 0xb4, 0x617c, 0x34, 0x657c, 0xf4, 0x697c, 0x74,
0x6d7c, 0x94, 0x717c, 0x14, 0x757c, 0xd4, 0x797c, 0x54
};
uint8_t g711_flip[256];
static int g711_initialized = 0;
/* generate tables
*/
void g711_init(void)
{
int i, j;
/* flip tables */
for (i = 0; i < 256; i++) {
g711_flip[i]
= ((i & 1) << 7)
+ ((i & 2) << 5)
+ ((i & 4) << 3)
+ ((i & 8) << 1)
+ ((i & 16) >> 1)
+ ((i & 32) >> 3)
+ ((i & 64) >> 5)
+ ((i & 128) >> 7);
g711_alaw_to_linear[i] = g711_alaw_flipped_to_linear[g711_flip[i]];
g711_ulaw_flipped_to_linear[i] = g711_ulaw_to_linear[g711_flip[i]];
}
/* linear to alaw tables */
i = j = 0;
while(i < 65536) {
if (i - 32768 > g711_alaw_relations[j << 1])
j++;
if (j > 255)
j = 255;
g711_linear_to_alaw_flipped[(i - 32768) & 0xffff] = g711_alaw_relations[(j << 1) | 1];
g711_linear_to_alaw[(i - 32768) & 0xffff] = g711_flip[g711_alaw_relations[(j << 1) | 1]];
i++;
}
/* linear to ulaw tables */
i = j = 0;
while(i < 32768) {
if (i - 32768 > g711_ulaw_to_linear[j])
j++;
g711_linear_to_ulaw[(i - 32768) & 0xffff] = j;
g711_linear_to_ulaw_flipped[(i - 32768) & 0xffff] = g711_flip[j];
i++;
}
j = 255;
while(i < 65536) {
if (i - 32768 > g711_ulaw_to_linear[j])
j--;
g711_linear_to_ulaw[(i - 32768) & 0xffff] = j;
g711_linear_to_ulaw_flipped[(i - 32768) & 0xffff] = g711_flip[j];
i++;
}
/* transcode */
for (i = 0; i < 256; i++) {
g711_alaw_to_ulaw[i] = g711_linear_to_ulaw[(uint16_t)g711_alaw_to_linear[i]];
g711_ulaw_to_alaw[i] = g711_linear_to_alaw[(uint16_t)g711_ulaw_to_linear[i]];
g711_alaw_flipped_to_ulaw[i] = g711_linear_to_ulaw[(uint16_t)g711_alaw_to_linear[g711_flip[i]]];
g711_ulaw_flipped_to_alaw[i] = g711_linear_to_alaw[(uint16_t)g711_ulaw_to_linear[g711_flip[i]]];
g711_alaw_to_ulaw_flipped[i] = g711_flip[g711_linear_to_ulaw[(uint16_t)g711_alaw_to_linear[i]]];
g711_ulaw_to_alaw_flipped[i] = g711_flip[g711_linear_to_alaw[(uint16_t)g711_ulaw_to_linear[i]]];
}
g711_initialized = 1;
}
void g711_encode_alaw_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
int16_t *src = (int16_t *)src_data;
uint8_t *dst;
int len = src_len / 2, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_linear_to_alaw_flipped[(uint16_t)src[i]];
*dst_data = dst;
*dst_len = len;
}
void g711_encode_ulaw_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
int16_t *src = (int16_t *)src_data;
uint8_t *dst;
int len = src_len / 2, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_linear_to_ulaw_flipped[(uint16_t)src[i]];
*dst_data = dst;
*dst_len = len;
}
void g711_decode_alaw_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
uint8_t *src = src_data;
int16_t *dst;
int len = src_len, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len * 2);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_alaw_flipped_to_linear[src[i]];
*dst_data = (uint8_t *)dst;
*dst_len = len * 2;
}
void g711_decode_ulaw_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
uint8_t *src = src_data;
int16_t *dst;
int len = src_len, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len * 2);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_ulaw_flipped_to_linear[src[i]];
*dst_data = (uint8_t *)dst;
*dst_len = len * 2;
}
void g711_encode_alaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
int16_t *src = (int16_t *)src_data;
uint8_t *dst;
int len = src_len / 2, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_linear_to_alaw[(uint16_t)src[i]];
*dst_data = dst;
*dst_len = len;
}
void g711_encode_ulaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
int16_t *src = (int16_t *)src_data;
uint8_t *dst;
int len = src_len / 2, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_linear_to_ulaw[(uint16_t)src[i]];
*dst_data = dst;
*dst_len = len;
}
void g711_decode_alaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
uint8_t *src = src_data;
int16_t *dst;
int len = src_len, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len * 2);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_alaw_to_linear[src[i]];
*dst_data = (uint8_t *)dst;
*dst_len = len * 2;
}
void g711_decode_ulaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
uint8_t *src = src_data;
int16_t *dst;
int len = src_len, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len * 2);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_ulaw_to_linear[src[i]];
*dst_data = (uint8_t *)dst;
*dst_len = len * 2;
}
void g711_transcode_alaw_to_ulaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
uint8_t *src = src_data, *dst;
int len = src_len, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_alaw_to_ulaw[src[i]];
*dst_data = dst;
*dst_len = len;
}
void g711_transcode_alaw_flipped_to_ulaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
uint8_t *src = src_data, *dst;
int len = src_len, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_alaw_flipped_to_ulaw[src[i]];
*dst_data = dst;
*dst_len = len;
}
void g711_transcode_alaw_to_ulaw_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
uint8_t *src = src_data, *dst;
int len = src_len, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_alaw_to_ulaw_flipped[src[i]];
*dst_data = dst;
*dst_len = len;
}
void g711_transcode_ulaw_to_alaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
uint8_t *src = src_data, *dst;
int len = src_len, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_ulaw_to_alaw[src[i]];
*dst_data = dst;
*dst_len = len;
}
void g711_transcode_ulaw_flipped_to_alaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
uint8_t *src = src_data, *dst;
int len = src_len, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_ulaw_flipped_to_alaw[src[i]];
*dst_data = dst;
*dst_len = len;
}
void g711_transcode_ulaw_to_alaw_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
uint8_t *src = src_data, *dst;
int len = src_len, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_ulaw_to_alaw_flipped[src[i]];
*dst_data = dst;
*dst_len = len;
}
void g711_transcode_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void __attribute__((unused)) *priv)
{
uint8_t *src = src_data, *dst;
int len = src_len, i;
if (!g711_initialized) {
fprintf(stderr, "G711 codec not initialized! Please fix!\n");
abort();
}
dst = malloc(len);
if (!dst)
return;
for (i = 0; i < len; i++)
dst[i] = g711_flip[src[i]];
*dst_data = dst;
*dst_len = len;
}

View File

@ -1,17 +0,0 @@
void g711_init(void);
void g711_encode_alaw_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_encode_ulaw_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_decode_alaw_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_decode_ulaw_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_encode_alaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_encode_ulaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_decode_alaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_decode_ulaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_transcode_alaw_to_ulaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_transcode_alaw_flipped_to_ulaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_transcode_alaw_to_ulaw_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_transcode_ulaw_to_alaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_transcode_ulaw_flipped_to_alaw(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_transcode_ulaw_to_alaw_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);
void g711_transcode_flipped(uint8_t *src_data, int src_len, uint8_t **dst_data, int *dst_len, void *priv);

View File

@ -23,7 +23,7 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "goertzel.h"
/*

View File

@ -77,7 +77,7 @@
#include <errno.h>
#include <math.h>
#include "../libsample/sample.h"
#include "../libdebug/debug.h"
#include "../liblogging/logging.h"
#include "jitter.h"
#define INITIAL_DELAY_INTERVAL 0.5
@ -104,7 +104,7 @@ int jitter_create(jitter_t *jb, const char *name, double samplerate, int sample_
jb->extra_size = (int)(EXTRA_BUFFER * samplerate);
jb->extra_samples = calloc(sample_size, jb->extra_size);
if (!jb->extra_samples) {
PDEBUG(DJITTER, DEBUG_ERROR, "No memory for frame.\n");
LOGP(DJITTER, LOGL_ERROR, "No memory for frame.\n");
rc = -ENOMEM;
goto error;
}
@ -118,7 +118,7 @@ int jitter_create(jitter_t *jb, const char *name, double samplerate, int sample_
jitter_reset(jb);
PDEBUG(DJITTER, DEBUG_INFO, "%sCreated jitter buffer. (samplerate=%.0f, target_window=%.0fms, max_window=%.0fms, flag:latency=%s flag:repeat=%s)\n", jb->name, samplerate, target_window_duration * 1000.0, max_window_duration * 1000.0, (window_flags & JITTER_FLAG_LATENCY) ? "true" : "false", (window_flags & JITTER_FLAG_REPEAT) ? "true" : "false");
LOGP(DJITTER, LOGL_INFO, "%sCreated jitter buffer. (samplerate=%.0f, target_window=%.0fms, max_window=%.0fms, flag:latency=%s flag:repeat=%s)\n", jb->name, samplerate, target_window_duration * 1000.0, max_window_duration * 1000.0, (window_flags & JITTER_FLAG_LATENCY) ? "true" : "false", (window_flags & JITTER_FLAG_REPEAT) ? "true" : "false");
error:
if (rc)
@ -139,7 +139,7 @@ void jitter_reset(jitter_t *jb)
{
jitter_frame_t *jf, *temp;
PDEBUG(DJITTER, DEBUG_INFO, "%sReset jitter buffer.\n", jb->name);
LOGP(DJITTER, LOGL_INFO, "%sReset jitter buffer.\n", jb->name);
/* jitter buffer locked */
jb->unlocked = 0;
@ -172,7 +172,7 @@ void jitter_destroy(jitter_t *jb)
{
jitter_reset(jb);
PDEBUG(DJITTER, DEBUG_INFO, "%sDestroying jitter buffer.\n", jb->name);
LOGP(DJITTER, LOGL_INFO, "%sDestroying jitter buffer.\n", jb->name);
if (jb->extra_samples) {
free(jb->extra_samples);
@ -201,7 +201,7 @@ void jitter_save(jitter_t *jb, void *samples, int length, int has_sequence, uint
/* generate sequence and timestamp automatically, if enabled */
if (!has_sequence) {
#ifdef DEBUG_JITTER
PDEBUG(DJITTER, DEBUG_DEBUG, "%sSave frame of %d samples (no seqence).\n", jb->name, length);
LOGP(DJITTER, LOGL_DEBUG, "%sSave frame of %d samples (no seqence).\n", jb->name, length);
#endif
sequence = jb->next_sequence;
jb->next_sequence++;
@ -210,7 +210,7 @@ void jitter_save(jitter_t *jb, void *samples, int length, int has_sequence, uint
ssrc = jb->window_ssrc;
} else {
#ifdef HEAVY_DEBUG
PDEBUG(DJITTER, DEBUG_DEBUG, "%sSave frame of %d samples (seqence=%u timestamp=%u ssrc=0x%02x).\n", jb->name, length, sequence, timestamp, ssrc);
LOGP(DJITTER, LOGL_DEBUG, "%sSave frame of %d samples (seqence=%u timestamp=%u ssrc=0x%02x).\n", jb->name, length, sequence, timestamp, ssrc);
#endif
jb->next_sequence = sequence + 1;
jb->next_timestamp = timestamp + length;
@ -219,9 +219,9 @@ void jitter_save(jitter_t *jb, void *samples, int length, int has_sequence, uint
/* first packet (with this ssrc) sets window size to target_window_size */
if (!jb->window_valid || jb->window_ssrc != ssrc) {
if (!jb->window_valid)
PDEBUG(DJITTER, DEBUG_DEBUG, "%s Initial frame after init or reset.\n", jb->name);
LOGP(DJITTER, LOGL_DEBUG, "%s Initial frame after init or reset.\n", jb->name);
else
PDEBUG(DJITTER, DEBUG_DEBUG, "%s SSRC changed.\n", jb->name);
LOGP(DJITTER, LOGL_DEBUG, "%s SSRC changed.\n", jb->name);
// NOTE: Reset must be called before finding the frame location below, because there will be no frame in list anymore!
jitter_reset(jb);
jb->unlocked = 1;
@ -241,7 +241,7 @@ void jitter_save(jitter_t *jb, void *samples, int length, int has_sequence, uint
offset_sequence = (int16_t)(sequence - (*jfp)->sequence);
/* found double entry */
if (offset_sequence == 0) {
PDEBUG(DJITTER, DEBUG_DEBUG, "%s Dropping double packet (sequence = %d)\n", jb->name, sequence);
LOGP(DJITTER, LOGL_DEBUG, "%s Dropping double packet (sequence = %d)\n", jb->name, sequence);
return;
}
/* offset is negative, so we found the position to insert frame */
@ -252,7 +252,7 @@ void jitter_save(jitter_t *jb, void *samples, int length, int has_sequence, uint
offset_timestamp = timestamp - jb->window_timestamp;
#ifdef HEAVY_DEBUG
PDEBUG(DJITTER, DEBUG_DEBUG, "%sFrame has offset of %.0fms in jitter buffer.\n", jb->name, (double)offset_timestamp * jb->sample_duration * 1000.0);
LOGP(DJITTER, LOGL_DEBUG, "%sFrame has offset of %.0fms in jitter buffer.\n", jb->name, (double)offset_timestamp * jb->sample_duration * 1000.0);
#endif
/* measure delay */
@ -262,11 +262,11 @@ void jitter_save(jitter_t *jb, void *samples, int length, int has_sequence, uint
/* if frame is too early (delay ceases), shift window to the future */
if (offset_timestamp > jb->max_window_size) {
if ((jb->window_flags & JITTER_FLAG_LATENCY)) {
PDEBUG(DJITTER, DEBUG_DEBUG, "%s Frame too early: Shift jitter buffer to the future, to make the frame fit to the end. (offset_timestamp(%d) > max_window_size(%d))\n", jb->name, offset_timestamp, jb->max_window_size);
LOGP(DJITTER, LOGL_DEBUG, "%s Frame too early: Shift jitter buffer to the future, to make the frame fit to the end. (offset_timestamp(%d) > max_window_size(%d))\n", jb->name, offset_timestamp, jb->max_window_size);
/* shift window so it fits to the end of window */
jb->window_timestamp = timestamp - jb->max_window_size;
} else {
PDEBUG(DJITTER, DEBUG_DEBUG, "%s Frame too early: Shift jitter buffer to the future, to make the frame fit to the target delay. (offset_timestamp(%d) > max_window_size(%d))\n", jb->name, offset_timestamp, jb->max_window_size);
LOGP(DJITTER, LOGL_DEBUG, "%s Frame too early: Shift jitter buffer to the future, to make the frame fit to the target delay. (offset_timestamp(%d) > max_window_size(%d))\n", jb->name, offset_timestamp, jb->max_window_size);
/* shift window so frame fits to the start of window + target delay */
jb->window_timestamp = timestamp - (uint32_t)(jb->target_window_size);
}
@ -275,11 +275,11 @@ void jitter_save(jitter_t *jb, void *samples, int length, int has_sequence, uint
/* is frame is too late, shift window to the past. */
if (offset_timestamp < 0) {
if ((jb->window_flags & JITTER_FLAG_LATENCY)) {
PDEBUG(DJITTER, DEBUG_DEBUG, "%s Frame too late: Shift jitter buffer to the past, and add target window size. (offset_timestamp(%d) < 0)\n", jb->name, offset_timestamp);
LOGP(DJITTER, LOGL_DEBUG, "%s Frame too late: Shift jitter buffer to the past, and add target window size. (offset_timestamp(%d) < 0)\n", jb->name, offset_timestamp);
/* shift window so frame fits to the start of window + half of target delay */
jb->window_timestamp = timestamp - (uint32_t)(jb->target_window_size) / 2;
} else {
PDEBUG(DJITTER, DEBUG_DEBUG, "%s Frame too late: Shift jitter buffer to the past, and add half target window size. (offset_timestamp(%d) < 0)\n", jb->name, offset_timestamp);
LOGP(DJITTER, LOGL_DEBUG, "%s Frame too late: Shift jitter buffer to the past, and add half target window size. (offset_timestamp(%d) < 0)\n", jb->name, offset_timestamp);
/* shift window so frame fits to the start of window + target delay */
jb->window_timestamp = timestamp - (uint32_t)(jb->target_window_size);
}
@ -287,11 +287,11 @@ void jitter_save(jitter_t *jb, void *samples, int length, int has_sequence, uint
/* insert or append frame */
#ifdef HEAVY_DEBUG
PDEBUG(DJITTER, DEBUG_DEBUG, "%s Store frame\n", jb->name);
LOGP(DJITTER, LOGL_DEBUG, "%s Store frame\n", jb->name);
#endif
jf = malloc(sizeof(*jf) + length * jb->sample_size);
if (!jf) {
PDEBUG(DJITTER, DEBUG_ERROR, "No memory for frame.\n");
LOGP(DJITTER, LOGL_ERROR, "No memory for frame.\n");
return;
}
memset(jf, 0, sizeof(*jf)); // note: clear header only
@ -311,7 +311,7 @@ void jitter_load(jitter_t *jb, void *samples, int length)
int32_t count, count2, index;
#ifdef HEAVY_DEBUG
PDEBUG(DJITTER, DEBUG_DEBUG, "%sLoad chunk of %d samples.\n", jb->name, length);
LOGP(DJITTER, LOGL_DEBUG, "%sLoad chunk of %d samples.\n", jb->name, length);
#endif
/* now unlock jitter buffer */
@ -321,10 +321,10 @@ void jitter_load(jitter_t *jb, void *samples, int length)
jb->delay_counter += jb->sample_duration * (double)length;
if (jb->delay_counter >= jb->delay_interval) {
if (jb->min_delay_value >= 0)
PDEBUG(DJITTER, DEBUG_DEBUG, "%s Statistics: target_window_delay=%.0fms max_window_delay=%.0fms current min_delay=%.0fms\n", jb->name, (double)jb->target_window_size * jb->sample_duration * 1000.0, (double)jb->max_window_size * jb->sample_duration * 1000.0, (double)jb->min_delay_value * jb->sample_duration * 1000.0);
LOGP(DJITTER, LOGL_DEBUG, "%s Statistics: target_window_delay=%.0fms max_window_delay=%.0fms current min_delay=%.0fms\n", jb->name, (double)jb->target_window_size * jb->sample_duration * 1000.0, (double)jb->max_window_size * jb->sample_duration * 1000.0, (double)jb->min_delay_value * jb->sample_duration * 1000.0);
/* delay reduction, if maximum delay is greater than target jitter window size */
if ((jb->window_flags & JITTER_FLAG_LATENCY) && jb->min_delay_value > jb->target_window_size) {
PDEBUG(DJITTER, DEBUG_DEBUG, "%s Reducing current minimum delay of %.0fms, because maximum delay is greater than target window size of %.0fms.\n", jb->name, (double)jb->min_delay_value * jb->sample_duration * 1000.0, (double)jb->target_window_size * jb->sample_duration * 1000.0);
LOGP(DJITTER, LOGL_DEBUG, "%s Reducing current minimum delay of %.0fms, because maximum delay is greater than target window size of %.0fms.\n", jb->name, (double)jb->min_delay_value * jb->sample_duration * 1000.0, (double)jb->target_window_size * jb->sample_duration * 1000.0);
/* only reduce delay to half of the target window size */
jb->window_timestamp += jb->min_delay_value - jb->target_window_size / 2;
@ -349,9 +349,9 @@ void jitter_load(jitter_t *jb, void *samples, int length)
if (count > 0) {
#ifdef HEAVY_DEBUG
if (jf)
PDEBUG(DJITTER, DEBUG_DEBUG, "%s There is a frame ahead in buffer after %d samples. Interpolating gap.\n", jb->name, jf->timestamp - jb->window_timestamp);
LOGP(DJITTER, LOGL_DEBUG, "%s There is a frame ahead in buffer after %d samples. Interpolating gap.\n", jb->name, jf->timestamp - jb->window_timestamp);
else
PDEBUG(DJITTER, DEBUG_DEBUG, "%s There is no frame ahead in buffer. Interpolating gap.\n", jb->name);
LOGP(DJITTER, LOGL_DEBUG, "%s There is no frame ahead in buffer. Interpolating gap.\n", jb->name);
#endif
/* extrapolate by playing the extrapolation buffer */
while (count) {
@ -366,7 +366,7 @@ void jitter_load(jitter_t *jb, void *samples, int length)
jb->extra_timeout_count++;
if (jb->extra_timeout_count == jb->extra_timeout_max) {
#ifdef HEAVY_DEBUG
PDEBUG(DJITTER, DEBUG_DEBUG, "%s Repeated jitter buffer enough, clearing to silence.\n", jb->name);
LOGP(DJITTER, LOGL_DEBUG, "%s Repeated jitter buffer enough, clearing to silence.\n", jb->name);
#endif
clear_extra_buffer(jb);
}
@ -393,7 +393,7 @@ void jitter_load(jitter_t *jb, void *samples, int length)
count = jb->extra_size - jb->extra_index;
/* copy samples from packet to play out, increment sample pointer and decrement length */
#ifdef HEAVY_DEBUG
PDEBUG(DJITTER, DEBUG_DEBUG, "%s Copy data (offset=%u count=%u) from frame (sequence=%u timestamp=%u length=%u).\n", jb->name, index, count, jf->sequence, jf->timestamp, jf->length);
LOGP(DJITTER, LOGL_DEBUG, "%s Copy data (offset=%u count=%u) from frame (sequence=%u timestamp=%u length=%u).\n", jb->name, index, count, jf->sequence, jf->timestamp, jf->length);
#endif
memcpy(samples, (uint8_t *)jf->samples + index * jb->sample_size, count * jb->sample_size);
samples = (uint8_t *)samples + count * jb->sample_size;

View File

@ -0,0 +1,8 @@
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
noinst_LIBRARIES = liblogging.a
liblogging_a_SOURCES = \
logging.c \
categories.c

227
src/liblogging/categories.c Normal file
View File

@ -0,0 +1,227 @@
#include <osmocom/core/utils.h>
#include <osmocom/core/logging.h>
#include "categories.h"
/* All logging categories used by this project. */
struct log_info_cat log_categories[] = {
[DLCC] = {
.name = "DLCC",
.description = "libosmo-cc CC Layer",
.color = "\033[0;37m",
},
[DOPTIONS] = {
.name = "DOPTIONS",
.description = "config options",
.color = "\033[0;33m",
},
[DSENDER] = {
.name = "DSENDER",
.description = "transceiver instance",
.color = "\033[1;33m",
},
[DSOUND] = {
.name = "DSOUND",
.description = "sound io",
.color = "\033[0;35m",
},
[DDSP] = {
.name = "DDSP",
.description = "digital signal processing",
.color = "\033[0;31m",
},
[DANETZ] = {
.name = "DANETZ",
.description = "A-Netz",
.color = "\033[1;34m",
},
[DBNETZ] = {
.name = "DBNETZ",
.description = "B-Netz",
.color = "\033[1;34m",
},
[DCNETZ] = {
.name = "DCNETZ",
.description = "C-Netz",
.color = "\033[1;34m",
},
[DNMT] = {
.name = "DNMT",
.description = "Norisk Mobil Telefoni",
.color = "\033[1;34m",
},
[DAMPS] = {
.name = "DAMPS",
.description = "Advanced Mobile Phone Service",
.color = "\033[1;34m",
},
[DR2000] = {
.name = "DR2000",
.description = "Radiocom 2000",
.color = "\033[1;34m",
},
[DIMTS] = {
.name = "DIMTS",
.description = "Improved Mobile Telephone Service",
.color = "\033[1;34m",
},
[DMPT1327] = {
.name = "DMPT1327",
.description = "MPT-1327",
.color = "\033[1;34m",
},
[DJOLLY] = {
.name = "DJOLLY",
.description = "Jolly-Com",
.color = "\033[1;34m",
},
[DEURO] = {
.name = "DEUROSIGNAL",
.description = "Eurosignal",
.color = "\033[1;34m",
},
[DPOCSAG] = {
.name = "DPOCSAG",
.description = "POCSAG",
.color = "\033[1;34m",
},
[DGOLAY] = {
.name = "DGOLAY",
.description = "Golay",
.color = "\033[1;34m",
},
[DFUENF] = {
.name = "DFUENF",
.description = "5-Ton-Folge",
.color = "\033[1;34m",
},
[DFRAME] = {
.name = "DFRAME",
.description = "message frame",
.color = "\033[0;36m",
},
[DCALL] = {
.name = "DCALL",
.description = "call processing",
.color = "\033[0;37m",
},
[DDB] = {
.name = "DDB",
.description = "database access",
.color = "\033[0;33m",
},
[DTRANS] = {
.name = "DTRANS",
.description = "transaction handing",
.color = "\033[0;32m",
},
[DDMS] = {
.name = "DDMS",
.description = "DMS layer of NMT",
.color = "\033[0;33m",
},
[DSMS] = {
.name = "DSMS",
.description = "SMS layer of NMT",
.color = "\033[1;37m",
},
[DSDR] = {
.name = "DSDR",
.description = "Software Defined Radio",
.color = "\033[1;31m",
},
[DUHD] = {
.name = "DUHD",
.description = "UHD interface",
.color = "\033[1;35m",
},
[DSOAPY] = {
.name = "DSOAPY",
.description = "Soapy interface",
.color = "\033[1;35m",
},
[DWAVE] = {
.name = "DWAVE",
.description = "WAVE file handling",
.color = "\033[1;33m",
},
[DRADIO] = {
.name = "DRADIO",
.description = "Radio application",
.color = "\033[1;34m",
},
[DAM791X] = {
.name = "DAM791X",
.description = "AM791x modem chip emulation",
.color = "\033[0;31m",
},
[DUART] = {
.name = "DUART",
.description = "UART emulation",
.color = "\033[0;32m",
},
[DDEVICE] = {
.name = "DDEVICE",
.description = "CUSE device emulation",
.color = "\033[0;33m",
},
[DDATENKLO] = {
.name = "DDATENKLO",
.description = "Das Datenklo",
.color = "\033[1;34m",
},
[DZEIT] = {
.name = "DZEIT",
.description = "Zeitansage",
.color = "\033[1;34m",
},
[DSIM1] = {
.name = "DSIM1",
.description = "C-Netz SIM layer 1",
.color = "\033[0;31m",
},
[DSIM2] = {
.name = "DSIM2",
.description = "C-Netz SIM layer 2",
.color = "\033[0;33m",
},
[DSIMI] = {
.name = "DSIMI",
.description = "C-Netz SIM ICL layer",
.color = "\033[0;36m",
},
[DSIM7] = {
.name = "DSIM7",
.description = "C-Netz SIM layer 7",
.color = "\033[0;37m",
},
[DMTP2] = {
.name = "DMTP LAYER 2",
.description = "MTP layer 2",
.color = "\033[1;33m",
},
[DMTP3] = {
.name = "DMTP LAYER 3",
.description = "MTP layer 3",
.color = "\033[1;36m",
},
[DMUP] = {
.name = "DMUP",
.description = "C-Netz Mobile User Part",
.color = "\033[1;37m",
},
[DDCF77] = {
.name = "DDCF77",
.description = "DCF77 Radio Clock",
.color = "\033[1;34m",
},
[DJITTER] = {
.name = "DJITTER",
.description = "jitter buffer handling",
.color = "\033[0;36m",
},
};
size_t log_categories_size = ARRAY_SIZE(log_categories);

View File

@ -0,0 +1,50 @@
enum {
DLCC,
DOPTIONS,
DSENDER,
DSOUND,
DDSP,
DANETZ,
DBNETZ,
DCNETZ,
DNMT,
DAMPS,
DR2000,
DIMTS,
DMPT1327,
DJOLLY,
DEURO,
DPOCSAG,
DGOLAY,
DFUENF,
DFRAME,
DCALL,
DDB,
DTRANS,
DDMS,
DSMS,
DSDR,
DUHD,
DSOAPY,
DWAVE,
DRADIO,
DAM791X,
DUART,
DDEVICE,
DDATENKLO,
DZEIT,
DSIM1,
DSIM2,
DSIMI,
DSIM7,
DMTP2,
DMTP3,
DMUP,
DDCF77,
DJITTER,
};
extern struct log_info_cat log_categories[];
extern size_t log_categories_size;

264
src/liblogging/logging.c Normal file
View File

@ -0,0 +1,264 @@
/* Logging (on segmented part of the window)
*
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sys/ioctl.h>
#include <math.h>
#include <errno.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/application.h>
#include <osmocom/cc/misc.h>
#include "logging.h"
int loglevel = LOGL_INFO;
static int scroll_window_start = 0;
static int scroll_window_end = 0;
static int scroll_window_height = 0;
void lock_logging(void)
{
log_tgt_mutex_lock();
}
void unlock_logging(void)
{
log_tgt_mutex_unlock();
}
void get_win_size(int *w, int *h)
{
struct winsize win;
int rc;
rc = ioctl(0, TIOCGWINSZ, &win);
if (rc) {
*w = 80;
*h = 25;
return;
}
if (h)
*h = win.ws_row;
if (w)
*w = win.ws_col;
}
void enable_limit_scroll(bool enable)
{
/* Before the window is set, keep scrolling everything. */
if (scroll_window_height == 0)
return;
/* If window is too small. */
if (scroll_window_end - scroll_window_start <= 0)
return;
if (enable) {
printf("\0337\033[%d;%dr\0338", scroll_window_start, scroll_window_end);
} else
printf("\0337\033[%d;%dr\0338", 1, scroll_window_height);
fflush(stdout);
}
void logging_limit_scroll_top(int lines)
{
lock_logging();
get_win_size(NULL, &scroll_window_height);
scroll_window_start = lines + 1;
if (scroll_window_end == 0)
scroll_window_end = scroll_window_height;
enable_limit_scroll(true);
unlock_logging();
}
void logging_limit_scroll_bottom(int lines)
{
int i;
lock_logging();
get_win_size(NULL, &scroll_window_height);
scroll_window_end = scroll_window_height - lines;
if (scroll_window_start == 0)
scroll_window_start = 1;
/* Make space by adding empty lines. */
for (i = scroll_window_end; i < scroll_window_height; i++)
printf("\n");
/* Go up by number of lines to be in window. */
printf("\033[%dA", scroll_window_height - scroll_window_end);
/* Enable window. */
enable_limit_scroll(true);
unlock_logging();
}
const char *debug_amplitude(double level)
{
static char text[42];
strcpy(text, " : ");
if (level > 1.0)
level = 1.0;
if (level < -1.0)
level = -1.0;
text[20 + (int)(level * 20)] = '*';
return text;
}
#define level2db(level) (20 * log10(level))
const char *debug_db(double level_db)
{
static char text[128];
int l;
strcpy(text, ": . : . : . : . : . : . : . : . | . : . : . : . : . : . : . : . :");
if (level_db <= 0.0)
return text;
l = (int)round(level2db(level_db));
if (l > 48)
return text;
if (l < -48)
return text;
text[l + 48] = '*';
return text;
}
void logging_print_help(void)
{
printf(" -v --verbose <level> | <level>,<category>[,<category>[,...]] | list\n");
printf(" Use 'list' to get a list of all levels and categories.\n");
printf(" Verbose level: digit of debug level (default = '%d')\n", loglevel);
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(" -v --verbose date\n");
printf(" Show date with debug output\n");
}
static unsigned char log_levels[] = { LOGL_DEBUG, LOGL_INFO, LOGL_NOTICE, LOGL_ERROR };
static char *log_level_names[] = { "debug", "info", "notice", "error" };
static void list_cat(void)
{
int i;
printf("Give number of debug level:\n");
for (i = 0; i < (int)sizeof(log_levels); i++)
printf(" %d = %s\n", log_levels[i], log_level_names[i]);
printf("\n");
printf("Give name(s) of debug category:\n");
for (i = 0; i < (int)log_categories_size; i++) {
if (!log_categories[i].name)
continue;
printf(" ");
if (log_categories[i].color)
printf("%s", log_categories[i].color);
if (log_categories[i].name)
printf("%s\033[0;39m = %s\n", log_categories[i].name, log_categories[i].description);
}
printf("\n");
}
int parse_logging_opt(const char *optarg)
{
int i;
char *dup, *dstring, *p;
if (!strcasecmp(optarg, "list")) {
list_cat();
return 1;
}
if (!strcasecmp(optarg, "date")) {
log_set_print_timestamp(osmo_stderr_target, 1);
return 0;
}
dup = dstring = strdup(optarg);
p = strsep(&dstring, ",");
for (i = 0; i < p[i]; i++) {
if (p[i] < '0' || p[i] > '9') {
fprintf(stderr, "Only digits are allowed for debug level!\n");
free(dup);
return -EINVAL;
}
}
loglevel = atoi(p);
for (i = 0; i < (int)sizeof(log_levels); i++) {
if (log_levels[i] == loglevel)
break;
}
if (i == (int)sizeof(log_levels)) {
fprintf(stderr, "Logging level does not exist, use '-v list' to show available levels!\n");
free(dup);
return -EINVAL;
}
/* Set loglevel and enable all categories, if dstring is not set. Else set loglevel and disable all categories. */
for (i = 0; i < (int)log_categories_size; i++)
log_set_category_filter(osmo_stderr_target, i, (!dstring), loglevel);
/* Enable each given category. */
while((p = strsep(&dstring, ","))) {
for (i = 0; i < (int)log_categories_size; i++) {
if (!log_category_name(i))
continue;
if (!strcasecmp(p, log_category_name(i)))
break;
}
if (i == (int)log_categories_size) {
fprintf(stderr, "Given logging category '%s' unknown, use '-v list' to show available categories!\n", p);
free(dup);
return -EINVAL;
}
log_set_category_filter(osmo_stderr_target, i, 1, loglevel);
}
free(dup);
return 0;
}
/* Call after configuation above. */
void logging_init(void)
{
int i;
struct log_info log_info = {
.cat = log_categories,
.num_cat = log_categories_size,
};
osmo_cc_set_log_cat(DLCC);
osmo_init_logging2(NULL, &log_info);
log_set_print_timestamp(osmo_stderr_target, 0);
log_set_print_level(osmo_stderr_target, 1);
log_set_print_category_hex(osmo_stderr_target, 0);
log_set_print_category(osmo_stderr_target, 1);
/* Set loglevel and enable all categories. */
for (i = 0; i < (int)log_categories_size; i++)
log_set_category_filter(osmo_stderr_target, i, 1, loglevel);
}

21
src/liblogging/logging.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#include <osmocom/core/logging.h>
#include "categories.h"
extern int loglevel;
#define LOGP_CHAN(cat, level, fmt, arg...) LOGP(cat, level, "(chan %s) " fmt, CHAN, ## arg)
void get_win_size(int *w, int *h);
void lock_logging(void);
void unlock_logging(void);
void enable_limit_scroll(bool enable);
void logging_limit_scroll_top(int lines);
void logging_limit_scroll_bottom(int lines);
const char *debug_amplitude(double level);
const char *debug_db(double level_db);
void logging_print_help(void);
int parse_logging_opt(const char *optarg);
void logging_init(void);

View File

@ -8,6 +8,7 @@ libmobile_a_SOURCES = \
console.c \
testton.c \
cause.c \
get_time.c \
main_mobile.c
if HAVE_ALSA

Some files were not shown because too many files have changed in this diff Show More