Add dsp mode change fuction to A and B Netz, fixed NMT

This commit is contained in:
Andreas Eversberg 2016-06-04 15:14:20 +02:00
parent 997f8eda43
commit c933250685
8 changed files with 44 additions and 24 deletions

View File

@ -202,7 +202,7 @@ static void anetz_go_idle(anetz_t *anetz)
PDEBUG(DANETZ, DEBUG_INFO, "Entering IDLE state, sending 2280 Hz tone.\n");
anetz->state = ANETZ_FREI;
anetz->dsp_mode = DSP_MODE_TONE;
anetz_set_dsp_mode(anetz, DSP_MODE_TONE);
anetz->station_id[0] = '\0';
}
@ -213,7 +213,7 @@ static void anetz_release(anetz_t *anetz)
PDEBUG(DANETZ, DEBUG_INFO, "Sending 2280 Hz release tone.\n");
anetz->state = ANETZ_AUSLOESEN;
anetz->dsp_mode = DSP_MODE_TONE;
anetz_set_dsp_mode(anetz, DSP_MODE_TONE);
anetz->station_id[0] = '\0';
timer_start(&anetz->timer, RELEASE_TO);
}
@ -223,7 +223,7 @@ static void anetz_page(anetz_t *anetz, const char *dial_string, double *freq)
{
PDEBUG(DANETZ, DEBUG_INFO, "Entering paging state, sending 'Selektivruf' to '%s'.\n", dial_string);
anetz->state = ANETZ_ANRUF;
anetz->dsp_mode = DSP_MODE_PAGING;
anetz_set_dsp_mode(anetz, DSP_MODE_PAGING);
dsp_set_paging(anetz, freq);
strcpy(anetz->station_id, dial_string);
timer_start(&anetz->timer, PAGING_TO);
@ -262,7 +262,7 @@ void anetz_receive_tone(anetz_t *anetz, int tone)
if (tone == 1) {
PDEBUG(DANETZ, DEBUG_INFO, "Received 1750 Hz calling signal from mobile station, removing idle signal.\n");
anetz->state = ANETZ_GESPRAECH;
anetz->dsp_mode = DSP_MODE_SILENCE;
anetz_set_dsp_mode(anetz, DSP_MODE_SILENCE);
break;
}
break;
@ -285,7 +285,7 @@ void anetz_receive_tone(anetz_t *anetz, int tone)
PDEBUG(DANETZ, DEBUG_INFO, "1750 Hz signal from mobile station is gone, answer call.\n");
call_in_answer(anetz->sender.callref, anetz->station_id);
}
anetz->dsp_mode = DSP_MODE_AUDIO;
anetz_set_dsp_mode(anetz, DSP_MODE_AUDIO);
}
/* release call */
if (tone == 1) {
@ -302,7 +302,7 @@ void anetz_receive_tone(anetz_t *anetz, int tone)
PDEBUG(DANETZ, DEBUG_INFO, "Received 1750 Hz answer signal from mobile station, removing paging tones.\n");
timer_stop(&anetz->timer);
anetz->state = ANETZ_GESPRAECH;
anetz->dsp_mode = DSP_MODE_SILENCE;
anetz_set_dsp_mode(anetz, DSP_MODE_SILENCE);
break;
}
default:

View File

@ -349,3 +349,9 @@ void sender_send(sender_t *sender, int16_t *samples, int length)
}
}
void anetz_set_dsp_mode(anetz_t *anetz, enum dsp_mode mode)
{
PDEBUG(DDSP, DEBUG_DEBUG, "DSP mode %d -> %d\n", anetz->dsp_mode, mode);
anetz->dsp_mode = mode;
}

View File

@ -3,4 +3,5 @@ void dsp_init(void);
int dsp_init_sender(anetz_t *anetz);
void dsp_cleanup_sender(anetz_t *anetz);
void dsp_set_paging(anetz_t *anetz, double *freq);
void anetz_set_dsp_mode(anetz_t *anetz, enum dsp_mode mode);

View File

@ -412,6 +412,8 @@ void bnetz_set_dsp_mode(bnetz_t *bnetz, enum dsp_mode mode)
/* reset telegramm */
if (mode == DSP_MODE_TELEGRAMM && bnetz->dsp_mode != mode)
bnetz->telegramm = 0;
PDEBUG(DDSP, DEBUG_DEBUG, "DSP mode %d -> %d\n", bnetz->dsp_mode, mode);
bnetz->dsp_mode = mode;
}

View File

@ -221,23 +221,21 @@ int cnetz_create(int kanal, enum cnetz_chan_type chan_type, const char *sounddev
goto error;
/* go into idle state */
cnetz->dsp_mode = DSP_MODE_OGK;
cnetz->sched_dsp_mode = DSP_MODE_OGK;
cnetz->sched_switch_mode = 0;
cnetz_set_dsp_mode(cnetz, DSP_MODE_OGK);
cnetz_set_sched_dsp_mode(cnetz, DSP_MODE_OGK, 0);
cnetz_go_idle(cnetz);
#ifdef DEBUG_SPK
transaction_t *trans = create_transaction(cnetz, TRANS_DS, 2, 2, 22002);
trans->mo_call = 1;
cnetz->sched_switch_mode = 2;
cnetz->sched_dsp_mode = DSP_MODE_SPK_K;
cnetz_set_sched_dsp_mode(cnetz, DSP_MODE_SPK_K, 2);
#else
/* create transaction for speech channel loopback */
if (loopback && chan_type == CHAN_TYPE_SPK) {
transaction_t *trans = create_transaction(cnetz, TRANS_VHQ, 2, 2, 22002);
trans->mo_call = 1;
cnetz->dsp_mode = DSP_MODE_SPK_K;
cnetz->sched_dsp_mode = DSP_MODE_SPK_K;
cnetz_set_dsp_mode(cnetz, DSP_MODE_SPK_K);
cnetz_set_sched_dsp_mode(cnetz, DSP_MODE_SPK_K, 0);
}
#endif
@ -282,11 +280,10 @@ static void cnetz_go_idle(cnetz_t *cnetz)
cnetz_new_state(cnetz, CNETZ_IDLE);
if (cnetz->dsp_mode == DSP_MODE_SPK_K || cnetz->dsp_mode == DSP_MODE_SPK_V) {
/* go idle after next frame/slot */
cnetz->sched_switch_mode = 1;
cnetz->sched_dsp_mode = (cnetz->sender.kanal == CNETZ_OGK_KANAL) ? DSP_MODE_OGK : DSP_MODE_OFF;
cnetz_set_sched_dsp_mode(cnetz, (cnetz->sender.kanal == CNETZ_OGK_KANAL) ? DSP_MODE_OGK : DSP_MODE_OFF, 1);
} else {
cnetz->sched_switch_mode = 0;
cnetz->dsp_mode = (cnetz->sender.kanal == CNETZ_OGK_KANAL) ? DSP_MODE_OGK : DSP_MODE_OFF;
cnetz_set_sched_dsp_mode(cnetz, (cnetz->sender.kanal == CNETZ_OGK_KANAL) ? DSP_MODE_OGK : DSP_MODE_OFF, 0);
cnetz_set_dsp_mode(cnetz, (cnetz->sender.kanal == CNETZ_OGK_KANAL) ? DSP_MODE_OGK : DSP_MODE_OFF);
}
}
@ -1014,8 +1011,7 @@ wbn:
telegramm.frequenz_nr = spk->sender.kanal;
cnetz_new_state(spk, CNETZ_BUSY);
/* schedule switching two slots ahead */
spk->sched_switch_mode = 2;
spk->sched_dsp_mode = DSP_MODE_SPK_K;
cnetz_set_sched_dsp_mode(cnetz, DSP_MODE_SPK_K, 2);
unlink_transaction(trans);
link_transaction(trans, spk);
/* flush all other transactions, if any (in case of OgK/SpK) */
@ -1251,8 +1247,7 @@ const telegramm_t *cnetz_transmit_telegramm_spk_k(cnetz_t *cnetz)
/* next sub frame */
trans_new_state(trans, TRANS_VHQ);
trans->count = 0;
cnetz->sched_switch_mode = 1;
cnetz->sched_dsp_mode = DSP_MODE_SPK_V;
cnetz_set_sched_dsp_mode(cnetz, DSP_MODE_SPK_V, 1);
#ifndef DEBUG_SPK
timer_start(&trans->timer, 0.075 + 0.6 * F_VHQ); /* one slot + F_VHQ frames */
#endif
@ -1269,8 +1264,7 @@ const telegramm_t *cnetz_transmit_telegramm_spk_k(cnetz_t *cnetz)
/* next sub frame */
trans_new_state(trans, TRANS_VHQ);
trans->count = 0;
cnetz->sched_switch_mode = 1;
cnetz->sched_dsp_mode = DSP_MODE_SPK_V;
cnetz_set_sched_dsp_mode(cnetz, DSP_MODE_SPK_V, 1);
timer_start(&trans->timer, 0.075 + 0.6 * F_VHQ); /* one slot + F_VHQ frames */
}
break;

View File

@ -639,7 +639,7 @@ again:
if (--cnetz->sched_switch_mode == 0) {
/* OgK / SpK(K) / SpK(V) */
PDEBUG(DDSP, DEBUG_INFO, "Switching channel (mode)\n");
cnetz->dsp_mode = cnetz->sched_dsp_mode;
cnetz_set_dsp_mode(cnetz, cnetz->sched_dsp_mode);
}
}
@ -827,3 +827,16 @@ void unshrink_speech(cnetz_t *cnetz, int16_t *speech_buffer, int count)
cnetz->sender.rxbuf_pos = pos;
}
void cnetz_set_dsp_mode(cnetz_t *cnetz, enum dsp_mode mode)
{
PDEBUG(DDSP, DEBUG_DEBUG, "DSP mode %d -> %d\n", cnetz->dsp_mode, mode);
cnetz->dsp_mode = mode;
}
void cnetz_set_sched_dsp_mode(cnetz_t *cnetz, enum dsp_mode mode, int frames_ahead)
{
PDEBUG(DDSP, DEBUG_DEBUG, "Schedule DSP mode %d -> %d in %d frames\n", cnetz->dsp_mode, mode, frames_ahead);
cnetz->sched_dsp_mode = mode;
cnetz->sched_switch_mode = frames_ahead;
}

View File

@ -4,4 +4,6 @@ int dsp_init_sender(cnetz_t *cnetz, int measure_speed, double clock_speed[2], do
void dsp_cleanup_sender(cnetz_t *cnetz);
void calc_clock_speed(cnetz_t *cnetz, uint64_t samples, int tx, int result);
void unshrink_speech(cnetz_t *cnetz, int16_t *speech_buffer, int count);
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 frames_ahead);

View File

@ -607,6 +607,8 @@ void nmt_set_dsp_mode(nmt_t *nmt, enum dsp_mode mode)
/* reset telegramm */
if (mode == DSP_MODE_FRAME && nmt->dsp_mode != mode)
nmt->frame = 0;
PDEBUG(DDSP, DEBUG_DEBUG, "DSP mode %d -> %d\n", nmt->dsp_mode, mode);
nmt->dsp_mode = mode;
}