C-Netz: Swtitch speech scrambler only after receiving 3 consecutive frames with different scrambler mode

pull/1/head
Andreas Eversberg 5 years ago
parent 7c4cfd5567
commit 40aec4f14c
  1. 13
      src/cnetz/cnetz.c
  2. 1
      src/cnetz/cnetz.h

@ -1428,6 +1428,7 @@ void cnetz_receive_telegramm_spk_k(cnetz_t *cnetz, telegramm_t *telegramm)
if (trans->state != TRANS_DS)
break;
cnetz->scrambler = telegramm->betriebs_art;
cnetz->scrambler_switch = 0;
timer_stop(&trans->timer);
break;
case OPCODE_VH_K:
@ -1469,6 +1470,7 @@ void cnetz_receive_telegramm_spk_k(cnetz_t *cnetz, telegramm_t *telegramm)
if (trans->state == TRANS_AHQ || trans->state == TRANS_VHQ || trans->state == TRANS_AF)
break;
cnetz->scrambler = telegramm->betriebs_art;
cnetz->scrambler_switch = 0;
trans_new_state(trans, TRANS_AHQ);
trans->repeat = 0;
timer_stop(&trans->timer);
@ -1602,7 +1604,15 @@ void cnetz_receive_telegramm_spk_v(cnetz_t *cnetz, telegramm_t *telegramm)
break;
}
valid_frame = 1;
cnetz->scrambler = telegramm->betriebs_art;
if (cnetz->scrambler != telegramm->betriebs_art) {
/* if the scrambler mode changes, we wait 3 frames */
/* i guess that this was implemented to prevent switching by one corrupt frame. */
if (++cnetz->scrambler_switch >= 3) {
cnetz->scrambler = telegramm->betriebs_art;
cnetz->scrambler_switch = 0;
}
} else
cnetz->scrambler_switch = 0;
break;
case OPCODE_AT_V:
if (!match_fuz(cnetz, telegramm, cnetz->cell_nr)) {
@ -1616,7 +1626,6 @@ void cnetz_receive_telegramm_spk_v(cnetz_t *cnetz, telegramm_t *telegramm)
/* if already received this frame, if we are releasing */
if (trans->state == TRANS_AT || trans->state == TRANS_AF)
break;
cnetz->scrambler = telegramm->betriebs_art;
trans_new_state(trans, TRANS_AT);
trans->repeat = 0;
timer_stop(&trans->timer);

@ -107,6 +107,7 @@ typedef struct cnetz {
double fsk_tx_phase; /* current bit position */
uint64_t fsk_tx_scount; /* sample counter (used to sync multiple channels) */
int scrambler; /* 0 = normal speech, 1 = scrambled speech */
int scrambler_switch; /* counter to switch after 3 frames with new scrabler state */
sample_t *dsp_speech_buffer; /* samples in one chunk */
int dsp_speech_length; /* number of samples */
int dsp_speech_pos; /* current position in buffer */

Loading…
Cancel
Save