B-Netz / NMT: minor changes at signal detection

This commit is contained in:
Andreas Eversberg 2016-05-01 10:23:45 +02:00
parent 47dbf094d9
commit b73894ac49
3 changed files with 18 additions and 14 deletions

View File

@ -505,11 +505,11 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm, double quality,
{ {
int digit = 0; int digit = 0;
int i; 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 */ /* drop any telegramm that is too bad */
if (quality_percent < 20) if (quality < 0.2)
return; return;
for (i = 0; impulstelegramme[i].digit; i++) { 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) 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 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 (bnetz->sender.loopback) {
if (digit >= '0' && digit <= '9') { if (digit >= '0' && digit <= '9') {
@ -661,7 +661,7 @@ void bnetz_receive_telegramm(bnetz_t *bnetz, uint16_t telegramm, double quality,
break; break;
case BNETZ_GESPRAECH: case BNETZ_GESPRAECH:
/* only good telegramms shall pass */ /* only good telegramms shall pass */
if (quality_percent < 70) if (quality < 0.7)
return; return;
if (digit == 't') { if (digit == 't') {
PDEBUG(DBNETZ, DEBUG_NOTICE, "Received 'Schlusssignal' from mobile station\n"); PDEBUG(DBNETZ, DEBUG_NOTICE, "Received 'Schlusssignal' from mobile station\n");

View File

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

View File

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