B-Netz / NMT: minor changes at signal detection

pull/1/head
Andreas Eversberg 7 years ago
parent 47dbf094d9
commit b73894ac49
  1. 12
      src/bnetz/bnetz.c
  2. 16
      src/nmt/dsp.c
  3. 4
      src/nmt/nmt.c

@ -505,11 +505,11 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm, double quality,
{
int digit = 0;
int i;
int quality_percent = quality * 100;
int level_percent = level * 100;
PDEBUG(DFRAME, DEBUG_INFO, "RX Level: %.0f%% Quality=%.0f\n", level * 100.0 + 0.5, quality * 100.0 + 0.5);
/* drop any telegramm that is too bad */
if (quality_percent < 20)
if (quality < 0.2)
return;
for (i = 0; impulstelegramme[i].digit; i++) {
@ -519,9 +519,9 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm, double quality,
}
}
if (digit == 0)
PDEBUG(DBNETZ, DEBUG_DEBUG, "Received unknown telegramm '0x%04x'. (quality=%d%% level=%d%%)\n", telegramm, quality_percent, level_percent);
PDEBUG(DBNETZ, DEBUG_DEBUG, "Received unknown telegramm '0x%04x'.\n", telegramm);
else
PDEBUG(DBNETZ, (bnetz->sender.loopback) ? DEBUG_NOTICE : DEBUG_DEBUG, "Received telegramm '%s'. (quality=%d%% level=%d%%)\n", impulstelegramme[i].description, quality_percent, level_percent);
PDEBUG(DBNETZ, (bnetz->sender.loopback) ? DEBUG_NOTICE : DEBUG_DEBUG, "Received telegramm '%s'.\n", impulstelegramme[i].description);
if (bnetz->sender.loopback) {
if (digit >= '0' && digit <= '9') {
@ -661,7 +661,7 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm, double quality,
break;
case BNETZ_GESPRAECH:
/* only good telegramms shall pass */
if (quality_percent < 70)
if (quality < 0.7)
return;
if (digit == 't') {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Received 'Schlusssignal' from mobile station\n");

@ -303,41 +303,45 @@ static inline void fsk_decode_step(nmt_t *nmt, int pos)
nmt->rx_sample_count += nmt->fsk_filter_step;
level = audio_level(spl, max);
/* limit level to prevent division by zero */
if (level < 0.01)
level = 0.01;
// level = 0.63662 / 2.0;
audio_goertzel(spl, max, pos, nmt->fsk_coeff, result, 2);
/* calculate soft bit from both frequencies */
softbit = (result[1] / level - result[0] / level + 1.0) / 2.0;
//printf("%.3f: %.3f\n", level, softbit);
/* scale it, since both filters overlap by some percent */
#define MIN_QUALITY 0.33
softbit = (softbit - MIN_QUALITY) / (1.0 - MIN_QUALITY - MIN_QUALITY);
if (softbit > 1)
softbit = 1;
if (softbit < 0)
softbit = 0;
#ifdef DEBUG_FILTER
// printf("|%s", show_level(result[0]/level*100));
// printf("|%s| low=%.3f high=%.3f level=%d\n", show_level(result[1]/level*100), result[0]/level, result[1]/level, (int)level);
printf("|%s| softbit=%.3f\n", show_level(softbit * 100), softbit);
#endif
if (softbit > 1)
softbit = 1;
if (softbit < 0)
softbit = 0;
if (softbit > 0.5)
bit = 1;
else
bit = 0;
if (nmt->fsk_filter_bit != bit) {
/* if we have a bit change, reset sample counter to one half bit duration */
#ifdef DEBUG_FILTER
puts("bit change");
#endif
/* if we have a bit change, reset sample counter to one half bit duration */
nmt->fsk_filter_bit = bit;
nmt->fsk_filter_sample = 5;
} else if (--nmt->fsk_filter_sample == 0) {
/* if sample counter bit reaches 0, we reset sample counter to one bit duration */
#ifdef DEBUG_FILTER
puts("sample");
#endif
/* if sample counter bit reaches 0, we reset sample counter to one bit duration */
// quality = result[bit] / level;
if (softbit > 0.5)
quality = softbit * 2.0 - 1.0;

@ -1124,9 +1124,10 @@ void nmt_receive_frame(nmt_t *nmt, const char *bits, double quality, double leve
frame_t frame;
int rc;
PDEBUG(DFRAME, DEBUG_INFO, "RX Level: %.0f%% Quality=%.0f\n", level * 100.0 + 0.5, quality * 100.0 + 0.5);
rc = decode_frame(&frame, bits, (nmt->sender.loopback) ? MTX_TO_XX : XX_TO_MTX, (nmt->state == STATE_MT_PAGING));
if (rc < 0) {
PDEBUG(DFRAME, DEBUG_INFO, "RX Level: %.0f%% Quality=%.0f\n", level * 100.0, quality * 100.0);
PDEBUG(DNMT, (nmt->sender.loopback) ? DEBUG_NOTICE : DEBUG_DEBUG, "Received invalid frame.\n");
return;
}
@ -1134,7 +1135,6 @@ void nmt_receive_frame(nmt_t *nmt, const char *bits, double quality, double leve
/* frame counter */
nmt->rx_frame_count += (int)(frames_elapsed + 0.5);
PDEBUG(DFRAME, DEBUG_INFO, "RX Level: %.0f%% Quality=%.0f\n", level * 100.0, quality * 100.0);
PDEBUG(DNMT, (nmt->sender.loopback) ? DEBUG_NOTICE : DEBUG_DEBUG, "Received frame %s\n", nmt_frame_name(frame.index));
if (nmt->sender.loopback)

Loading…
Cancel
Save