2017-11-15 18:08:37 +00:00
|
|
|
#include "../libsquelch/squelch.h"
|
2017-11-16 20:04:23 +00:00
|
|
|
#include "../libfsk/fsk.h"
|
2017-11-18 07:33:07 +00:00
|
|
|
#include "../libmobile/sender.h"
|
2017-11-13 19:00:52 +00:00
|
|
|
#include "../libtimer/timer.h"
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
/* fsk modes of transmission */
|
|
|
|
enum dsp_mode {
|
|
|
|
DSP_MODE_SILENCE, /* sending silence */
|
2016-12-09 15:34:33 +00:00
|
|
|
DSP_MODE_AUDIO, /* stream audio */
|
2017-08-12 14:38:40 +00:00
|
|
|
DSP_MODE_AUDIO_METER, /* stream audio */
|
2016-03-01 17:40:38 +00:00
|
|
|
DSP_MODE_0, /* send tone 0 */
|
|
|
|
DSP_MODE_1, /* send tone 1 */
|
|
|
|
DSP_MODE_TELEGRAMM, /* send "Telegramm" */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* current state of b-netz sender */
|
|
|
|
enum bnetz_state {
|
2016-12-06 16:47:58 +00:00
|
|
|
BNETZ_NULL = 0,
|
2016-03-01 17:40:38 +00:00
|
|
|
BNETZ_FREI, /* sending 'Gruppenfreisignal' */
|
|
|
|
BNETZ_WAHLABRUF, /* sending 'Wahlabruf', receiving call setup */
|
2016-05-22 12:52:57 +00:00
|
|
|
BNETZ_SELEKTIVRUF_EIN, /* paging phone (switch to calling channel) */
|
|
|
|
BNETZ_SELEKTIVRUF_AUS, /* paging phone (wait before switching back) */
|
2016-03-01 17:40:38 +00:00
|
|
|
BNETZ_RUFBESTAETIGUNG, /* waitig for acknowledge from phone */
|
|
|
|
BNETZ_RUFHALTUNG, /* phone is ringing */
|
|
|
|
BNETZ_GESPRAECH, /* during conversation */
|
|
|
|
BNETZ_TRENNEN, /* release of call */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* current state of received dialing */
|
|
|
|
enum dial_mode {
|
|
|
|
DIAL_MODE_START,
|
|
|
|
DIAL_MODE_STATIONID,
|
|
|
|
DIAL_MODE_NUMBER,
|
|
|
|
DIAL_MODE_START2,
|
|
|
|
DIAL_MODE_STATIONID2,
|
|
|
|
DIAL_MODE_NUMBER2,
|
|
|
|
};
|
|
|
|
|
2016-07-19 18:33:48 +00:00
|
|
|
/* current dialing type (metering support) */
|
|
|
|
enum dial_type {
|
|
|
|
DIAL_TYPE_NOMETER,
|
|
|
|
DIAL_TYPE_METER,
|
2016-11-13 05:39:14 +00:00
|
|
|
DIAL_TYPE_METER_MUENZ,
|
2016-07-19 18:33:48 +00:00
|
|
|
};
|
|
|
|
|
2016-03-01 17:40:38 +00:00
|
|
|
/* current state of paging mobile station */
|
|
|
|
enum page_mode {
|
|
|
|
PAGE_MODE_NUMBER,
|
|
|
|
PAGE_MODE_KANALBEFEHL,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* instance of bnetz sender */
|
|
|
|
typedef struct bnetz {
|
|
|
|
sender_t sender;
|
|
|
|
|
|
|
|
/* system info */
|
|
|
|
int gfs; /* 'Gruppenfreisignal' */
|
2017-08-12 14:38:40 +00:00
|
|
|
int metering; /* use metering pulses in seconds 0 = off, < 0 = force */
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
/* switch sender to channel 19 */
|
2017-01-07 09:33:13 +00:00
|
|
|
char paging_file[256]; /* if set, write to given file to switch to channel 19 or back */
|
|
|
|
char paging_on[256]; /* what to write to switch to channel 19 */
|
|
|
|
char paging_off[256]; /* what to write to switch back */
|
|
|
|
int paging_is_on; /* set, if we are on channel 19. also used to switch back on exit */
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
/* all bnetz states */
|
|
|
|
enum bnetz_state state; /* main state of sender */
|
2016-08-21 07:00:55 +00:00
|
|
|
int callref; /* call reference */
|
2016-03-01 17:40:38 +00:00
|
|
|
enum dial_mode dial_mode; /* sub state while dialing is received */
|
2016-07-19 18:33:48 +00:00
|
|
|
enum dial_type dial_type; /* defines if mobile supports metering pulses */
|
2018-02-15 06:33:43 +00:00
|
|
|
char dial_number[14]; /* dial string received (13 digits + termination, first 0-digit not included) */
|
2016-03-01 17:40:38 +00:00
|
|
|
int dial_pos; /* current position while receiving digits */
|
|
|
|
char station_id[6]; /* current station ID */
|
|
|
|
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;
|
|
|
|
int trenn_count; /* count number of release messages */
|
|
|
|
|
2017-09-25 16:46:50 +00:00
|
|
|
/* display measurements */
|
|
|
|
dispmeasparam_t *dmp_tone_level;
|
2018-06-05 05:08:35 +00:00
|
|
|
dispmeasparam_t *dmp_tone_stddev;
|
2017-09-25 16:46:50 +00:00
|
|
|
dispmeasparam_t *dmp_tone_quality;
|
|
|
|
dispmeasparam_t *dmp_frame_level;
|
|
|
|
dispmeasparam_t *dmp_frame_stddev;
|
|
|
|
dispmeasparam_t *dmp_frame_quality;
|
|
|
|
|
2016-03-01 17:40:38 +00:00
|
|
|
/* dsp states */
|
|
|
|
enum dsp_mode dsp_mode; /* current mode: audio, durable tone 0 or 1, "Telegramm" */
|
2019-09-01 13:38:16 +00:00
|
|
|
fsk_mod_t fsk_mod; /* fsk modem instance */
|
|
|
|
fsk_demod_t fsk_demod;
|
2021-01-01 21:11:48 +00:00
|
|
|
uint16_t rx_telegramm; /* rx shift register for receiving telegramm */
|
2017-08-05 08:41:23 +00:00
|
|
|
double rx_telegramm_quality[16];/* quality of each bit in telegramm */
|
|
|
|
double rx_telegramm_level[16]; /* level of each bit in telegramm */
|
|
|
|
int rx_telegramm_qualidx; /* index of quality array above */
|
2021-01-01 21:11:48 +00:00
|
|
|
uint16_t rx_tone; /* rx shift register for receiving continuous tone */
|
2018-06-05 05:08:35 +00:00
|
|
|
double rx_tone_quality[16]; /* quality of tone fragment (100th of second) */
|
|
|
|
double rx_tone_level[16]; /* level of tone fragment (100th of second) */
|
|
|
|
int rx_tone_qualidx; /* index of quality array above */
|
2016-03-01 17:40:38 +00:00
|
|
|
int tone_detected; /* what tone has been detected */
|
|
|
|
int tone_count; /* how long has that tone been detected */
|
2018-06-05 05:08:35 +00:00
|
|
|
int tone_duration; /* how long has that tone been detected */
|
2017-08-05 08:41:23 +00:00
|
|
|
const char *tx_telegramm; /* carries bits of one frame to transmit */
|
|
|
|
int tx_telegramm_pos;
|
2017-08-12 14:38:40 +00:00
|
|
|
double meter_phaseshift65536; /* how much the phase of sine wave changes per sample */
|
|
|
|
double meter_phase65536; /* current phase */
|
2017-10-09 18:49:14 +00:00
|
|
|
squelch_t squelch; /* squelch detection process */
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
/* loopback test for latency */
|
|
|
|
int loopback_count; /* count digits from 0 to 9 */
|
|
|
|
double loopback_time[10]; /* time stamp when sending digits 0..9 */
|
|
|
|
} bnetz_t;
|
|
|
|
|
|
|
|
double bnetz_kanal2freq(int kanal, int unterband);
|
|
|
|
int bnetz_init(void);
|
2020-06-14 18:59:41 +00:00
|
|
|
int bnetz_create(const char *kanal, const char *audiodev, int use_sdr, int samplerate, double rx_gain, double tx_gain, int gfs, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, const char *read_tx_wave, int loopback, double squelch_db, const char *paging, int metering);
|
2016-03-01 17:40:38 +00:00
|
|
|
void bnetz_destroy(sender_t *sender);
|
2017-10-09 18:49:14 +00:00
|
|
|
void bnetz_loss_indication(bnetz_t *bnetz, double loss_time);
|
2016-03-01 17:40:38 +00:00
|
|
|
void bnetz_receive_tone(bnetz_t *bnetz, int bit);
|
2018-06-05 05:08:35 +00:00
|
|
|
void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm);
|
2016-03-01 17:40:38 +00:00
|
|
|
const char *bnetz_get_telegramm(bnetz_t *bnetz);
|
|
|
|
|