Add function to change dsp state, more debug with channel info

This commit is contained in:
Andreas Eversberg 2016-12-09 16:34:33 +01:00
parent f111c50478
commit 7585f9c22d
12 changed files with 191 additions and 101 deletions

View File

@ -35,6 +35,8 @@
* are processed.
*/
#define CHAN amps->sender.kanal
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@ -250,7 +252,7 @@ static void amps_new_state(amps_t *amps, enum amps_state new_state)
{
if (amps->state == new_state)
return;
PDEBUG(DAMPS, DEBUG_DEBUG, "State change: %s -> %s\n", amps_state_name(amps->state), amps_state_name(new_state));
PDEBUG_CHAN(DAMPS, DEBUG_DEBUG, "State change: %s -> %s\n", amps_state_name(amps->state), amps_state_name(new_state));
amps->state = new_state;
}
@ -522,14 +524,14 @@ static void amps_go_idle(amps_t *amps)
amps_new_state(amps, STATE_IDLE);
if (amps->chan_type != CHAN_TYPE_VC) {
PDEBUG(DAMPS, DEBUG_INFO, "Entering IDLE state, sending Overhead/Filler frames on %s.\n", chan_type_long_name(amps->chan_type));
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Entering IDLE state, sending Overhead/Filler frames on %s.\n", chan_type_long_name(amps->chan_type));
if (amps->sender.loopback)
frame_length = 441; /* bits after sync (FOCC) */
else
frame_length = 247; /* bits after sync (RECC) */
amps_set_dsp_mode(amps, DSP_MODE_FRAME_RX_FRAME_TX, frame_length);
} else {
PDEBUG(DAMPS, DEBUG_INFO, "Entering IDLE state, sending test tone on %s.\n", chan_type_long_name(amps->chan_type));
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Entering IDLE state, sending test tone on %s.\n", chan_type_long_name(amps->chan_type));
amps_set_dsp_mode(amps, DSP_MODE_OFF, 0);
}
}
@ -564,14 +566,14 @@ void amps_rx_signaling_tone(amps_t *amps, int tone, double quality)
{
transaction_t *trans = amps->trans_list;
if (trans == NULL) {
PDEBUG(DAMPS, DEBUG_ERROR, "Signaling Tone without transaction, please fix!\n");
PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "Signaling Tone without transaction, please fix!\n");
return;
}
if (tone)
PDEBUG(DAMPS, DEBUG_INFO, "Detected Signaling Tone with quality=%.0f.\n", quality * 100.0);
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Detected Signaling Tone with quality=%.0f.\n", quality * 100.0);
else
PDEBUG(DAMPS, DEBUG_INFO, "Lost Signaling Tone signal\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Lost Signaling Tone signal\n");
switch (trans->state) {
case TRANS_CALL:
@ -606,7 +608,7 @@ void amps_rx_signaling_tone(amps_t *amps, int tone, double quality)
}
break;
default:
PDEBUG(DAMPS, DEBUG_ERROR, "Signaling Tone without active call, please fix!\n");
PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "Signaling Tone without active call, please fix!\n");
}
}
@ -614,7 +616,7 @@ void amps_rx_sat(amps_t *amps, int tone, double quality)
{
transaction_t *trans = amps->trans_list;
if (trans == NULL) {
PDEBUG(DAMPS, DEBUG_ERROR, "SAT signal without transaction, please fix!\n");
PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "SAT signal without transaction, please fix!\n");
return;
}
/* irgnoring SAT loss on release */
@ -624,7 +626,7 @@ void amps_rx_sat(amps_t *amps, int tone, double quality)
if (trans->state != TRANS_CALL
&& trans->state != TRANS_CALL_MT_ALERT
&& trans->state != TRANS_CALL_MT_ALERT_SEND) {
PDEBUG(DAMPS, DEBUG_ERROR, "SAT signal without active call, please fix!\n");
PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "SAT signal without active call, please fix!\n");
return;
}
@ -654,14 +656,14 @@ void amps_rx_sat(amps_t *amps, int tone, double quality)
static void timeout_sat(amps_t *amps, double duration)
{
if (!amps->trans_list) {
PDEBUG(DAMPS, DEBUG_ERROR, "SAT timeout, but no transaction, please fix!\n");
PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "SAT timeout, but no transaction, please fix!\n");
return;
}
if (duration == SAT_TO1)
PDEBUG(DAMPS, DEBUG_NOTICE, "Timeout after %.0f seconds not receiving SAT signal.\n", duration);
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Timeout after %.0f seconds not receiving SAT signal.\n", duration);
else
PDEBUG(DAMPS, DEBUG_NOTICE, "Timeout after %.0f seconds loosing SAT signal.\n", duration);
PDEBUG(DAMPS, DEBUG_INFO, "Release call towards network.\n");
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Timeout after %.0f seconds loosing SAT signal.\n", duration);
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Release call towards network.\n");
amps_release(amps->trans_list, CAUSE_TEMPFAIL);
}
@ -674,12 +676,12 @@ void amps_rx_recc(amps_t *amps, uint8_t scm, uint32_t esn, uint32_t min1, uint16
/* check if we are busy, so we ignore all signaling */
if (amps->state == STATE_BUSY) {
PDEBUG(DAMPS, DEBUG_NOTICE, "Ignoring RECC messages from phone while using this channel for voice.\n");
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Ignoring RECC messages from phone while using this channel for voice.\n");
return;
}
if (order == 13 && (ordq == 0 || ordq == 1 || ordq == 2 || ordq == 3) && msg_type == 0) {
PDEBUG(DAMPS, DEBUG_INFO, "Registration %s (ESN = %08x, %s)\n", callerid, esn, amps_scm(scm));
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Registration %s (ESN = %08x, %s)\n", callerid, esn, amps_scm(scm));
trans = create_transaction(amps, TRANS_REGISTER_ACK, min1, min2, msg_type, ordq, order, 0);
if (!trans) {
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to create transaction\n");
@ -687,7 +689,7 @@ void amps_rx_recc(amps_t *amps, uint8_t scm, uint32_t esn, uint32_t min1, uint16
}
} else
if (order == 13 && ordq == 3 && msg_type == 1) {
PDEBUG(DAMPS, DEBUG_INFO, "Registration - Power Down %s (ESN = %08x, %s)\n", callerid, esn, amps_scm(scm));
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Registration - Power Down %s (ESN = %08x, %s)\n", callerid, esn, amps_scm(scm));
trans = create_transaction(amps, TRANS_REGISTER_ACK, min1, min2, msg_type, ordq, order, 0);
if (!trans) {
PDEBUG(DAMPS, DEBUG_ERROR, "Failed to create transaction\n");
@ -696,9 +698,9 @@ void amps_rx_recc(amps_t *amps, uint8_t scm, uint32_t esn, uint32_t min1, uint16
} else
if (order == 0 && ordq == 0 && msg_type == 0) {
if (!dialing)
PDEBUG(DAMPS, DEBUG_INFO, "Paging reply %s (ESN = %08x, %s)\n", callerid, esn, amps_scm(scm));
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Paging reply %s (ESN = %08x, %s)\n", callerid, esn, amps_scm(scm));
else
PDEBUG(DAMPS, DEBUG_INFO, "Call %s -> %s (ESN = %08x, %s)\n", callerid, dialing, esn, amps_scm(scm));
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call %s -> %s (ESN = %08x, %s)\n", callerid, dialing, esn, amps_scm(scm));
trans = search_transaction_number(amps, min1, min2);
if (!trans && !dialing) {
PDEBUG(DAMPS, DEBUG_NOTICE, "Paging reply, but call is already gone, rejecting call\n");
@ -737,7 +739,7 @@ reject:
trans->chan = vc->sender.kanal;
}
} else
PDEBUG(DAMPS, DEBUG_NOTICE, "Unsupported RECC messages: ORDER: %d ORDQ: %d MSG TYPE: %d (See Table 4 of specs.)\n", order, ordq, msg_type);
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Unsupported RECC messages: ORDER: %d ORDQ: %d MSG TYPE: %d (See Table 4 of specs.)\n", order, ordq, msg_type);
}
/*
@ -803,7 +805,7 @@ inval:
return -CAUSE_NOCHANNEL;
}
PDEBUG(DAMPS, DEBUG_INFO, "Call to mobile station, paging station id '%s'\n", dialing);
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call to mobile station, paging station id '%s'\n", dialing);
/* 6. trying to page mobile station */
trans = create_transaction(amps, TRANS_PAGE, min1, min2, 0, 0, 0, 0);
@ -849,12 +851,12 @@ void call_out_disconnect(int callref, int cause)
case DSP_MODE_AUDIO_RX_FRAME_TX:
if (trans->state == TRANS_CALL_MT_ALERT
|| trans->state == TRANS_CALL_MT_ALERT_SEND) {
PDEBUG(DAMPS, DEBUG_INFO, "Call control disconnect on voice channel while alerting, releasing towards mobile station.\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call control disconnect on voice channel while alerting, releasing towards mobile station.\n");
amps_release(trans, cause);
}
return;
default:
PDEBUG(DAMPS, DEBUG_INFO, "Call control disconnects on control channel, removing transaction.\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call control disconnects on control channel, removing transaction.\n");
call_in_release(callref, cause);
trans->callref = 0;
destroy_transaction(trans);
@ -889,11 +891,11 @@ void call_out_release(int callref, int cause)
switch (amps->dsp_mode) {
case DSP_MODE_AUDIO_RX_AUDIO_TX:
case DSP_MODE_AUDIO_RX_FRAME_TX:
PDEBUG(DAMPS, DEBUG_INFO, "Call control releases on voice channel, releasing towards mobile station.\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call control releases on voice channel, releasing towards mobile station.\n");
amps_release(trans, cause);
break;
default:
PDEBUG(DAMPS, DEBUG_INFO, "Call control releases on control channel, removing transaction.\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Call control releases on control channel, removing transaction.\n");
destroy_transaction(trans);
amps_go_idle(amps);
}
@ -933,7 +935,7 @@ void transaction_timeout(struct timer *timer)
break;
case TRANS_CALL_RELEASE:
case TRANS_CALL_RELEASE_SEND:
PDEBUG(DAMPS, DEBUG_NOTICE, "Release timeout, destroying transaction\n");
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Release timeout, destroying transaction\n");
destroy_transaction(trans);
amps_go_idle(amps);
break;
@ -941,20 +943,20 @@ void transaction_timeout(struct timer *timer)
amps_release(trans, CAUSE_TEMPFAIL);
break;
case TRANS_CALL_MT_ALERT_SEND:
PDEBUG(DAMPS, DEBUG_NOTICE, "Alerting timeout, destroying transaction\n");
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Alerting timeout, destroying transaction\n");
amps_release(trans, CAUSE_NOANSWER);
break;
case TRANS_PAGE_REPLY:
if (trans->page_retry++ == PAGE_TRIES) {
PDEBUG(DAMPS, DEBUG_NOTICE, "Paging timeout, destroying transaction\n");
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Paging timeout, destroying transaction\n");
amps_release(trans, CAUSE_OUTOFORDER);
} else {
PDEBUG(DAMPS, DEBUG_NOTICE, "Paging timeout, retrying\n");
PDEBUG_CHAN(DAMPS, DEBUG_NOTICE, "Paging timeout, retrying\n");
trans_new_state(trans, TRANS_PAGE);
}
break;
default:
PDEBUG(DAMPS, DEBUG_ERROR, "Timeout unhandled in state %d\n", trans->state);
PDEBUG_CHAN(DAMPS, DEBUG_ERROR, "Timeout unhandled in state %d\n", trans->state);
}
}
@ -1012,39 +1014,39 @@ again:
switch (trans->state) {
case TRANS_REGISTER_ACK:
PDEBUG(DAMPS, DEBUG_INFO, "Sending Register acknowledge\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Sending Register acknowledge\n");
trans_new_state(trans, TRANS_REGISTER_ACK_SEND);
return trans;
case TRANS_REGISTER_ACK_SEND:
destroy_transaction(trans);
goto again;
case TRANS_CALL_REJECT:
PDEBUG(DAMPS, DEBUG_INFO, "Rejecting call from mobile station\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Rejecting call from mobile station\n");
trans_new_state(trans, TRANS_CALL_REJECT_SEND);
return trans;
case TRANS_CALL_REJECT_SEND:
destroy_transaction(trans);
goto again;
case TRANS_CALL_MO_ASSIGN:
PDEBUG(DAMPS, DEBUG_INFO, "Assigning channel to call from mobile station\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Assigning channel to call from mobile station\n");
trans_new_state(trans, TRANS_CALL_MO_ASSIGN_SEND);
return trans;
case TRANS_CALL_MO_ASSIGN_SEND:
vc = assign_voice_channel(trans);
if (vc) {
PDEBUG(DAMPS, DEBUG_INFO, "Assignment complete, voice connected\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Assignment complete, voice connected\n");
trans_new_state(trans, TRANS_CALL);
amps_set_dsp_mode(vc, DSP_MODE_AUDIO_RX_AUDIO_TX, 0);
}
return NULL;
case TRANS_CALL_MT_ASSIGN:
PDEBUG(DAMPS, DEBUG_INFO, "Assigning channel to call to mobile station\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Assigning channel to call to mobile station\n");
trans_new_state(trans, TRANS_CALL_MT_ASSIGN_SEND);
return trans;
case TRANS_CALL_MT_ASSIGN_SEND:
vc = assign_voice_channel(trans);
if (vc) {
PDEBUG(DAMPS, DEBUG_INFO, "Assignment complete, next: sending altering on VC\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Assignment complete, next: sending altering on VC\n");
trans->chan = 0;
trans->msg_type = 0;
trans->ordq = 0;
@ -1054,7 +1056,7 @@ again:
}
return NULL;
case TRANS_PAGE:
PDEBUG(DAMPS, DEBUG_INFO, "Paging the phone\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Paging the phone\n");
trans_new_state(trans, TRANS_PAGE_SEND);
return trans;
case TRANS_PAGE_SEND:
@ -1077,16 +1079,16 @@ again:
switch (trans->state) {
case TRANS_CALL_RELEASE:
PDEBUG(DAMPS, DEBUG_INFO, "Releasing call towards mobile station\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Releasing call towards mobile station\n");
trans_new_state(trans, TRANS_CALL_RELEASE_SEND);
return trans;
case TRANS_CALL_RELEASE_SEND:
PDEBUG(DAMPS, DEBUG_INFO, "Release call was sent, destroying call\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Release call was sent, destroying call\n");
destroy_transaction(trans);
amps_go_idle(amps);
goto again;
case TRANS_CALL_MT_ALERT:
PDEBUG(DAMPS, DEBUG_INFO, "Sending altering\n");
PDEBUG_CHAN(DAMPS, DEBUG_INFO, "Sending altering\n");
return trans;
default:
return NULL;

View File

@ -189,7 +189,7 @@ int dsp_init_sender(amps_t *amps, int high_pass, int tolerant)
/* attack (3ms) and recovery time (13.5ms) according to amps specs */
init_compandor(&amps->cstate, 8000, 3.0, 13.5, COMPANDOR_0DB);
PDEBUG(DDSP, DEBUG_DEBUG, "Init DSP for transceiver.\n");
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for transceiver.\n");
if (amps->sender.samplerate < 96000) {
PDEBUG(DDSP, DEBUG_ERROR, "Sample rate must be at least 96000 Hz to process FSK and SAT signals.\n");
@ -275,7 +275,7 @@ error:
/* Cleanup transceiver instance. */
void dsp_cleanup_sender(amps_t *amps)
{
PDEBUG(DDSP, DEBUG_DEBUG, "Cleanup DSP for treansceiver.\n");
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for treansceiver.\n");
if (amps->fsk_tx_buffer)
free(amps->fsk_tx_buffer);

View File

@ -17,6 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define CHAN amps->sender.kanal
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@ -3025,7 +3027,7 @@ static void amps_decode_word_focc(amps_t *amps, uint64_t word)
/* control message */
if (t1t2 != 3) {
PDEBUG(DFRAME, DEBUG_INFO, "Received Mobile Station Control Message (T1T2 = %d)\n", t1t2);
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Received Mobile Station Control Message (T1T2 = %d)\n", t1t2);
if (t1t2 == 1)
amps->rx_focc_word_count = 1;
if (t1t2 == 0 || t1t2 == 1) {
@ -3042,7 +3044,7 @@ static void amps_decode_word_focc(amps_t *amps, uint64_t word)
w = &word2_extended_address_word_b;
goto decode;
}
PDEBUG(DFRAME, DEBUG_INFO, "Decoding of more than 2 Control messages not supported\n");
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Decoding of more than 2 Control messages not supported\n");
}
return;
}
@ -3107,14 +3109,14 @@ static void amps_decode_word_focc(amps_t *amps, uint64_t word)
decode:
if (!w) {
PDEBUG(DFRAME, DEBUG_INFO, "Received Illegal Overhead Message\n");
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Received Illegal Overhead Message\n");
return;
}
frame = amps_decode_word(word, w);
/* show control filler delay */
if (amps->sender.loopback && ohd == 1)
PDEBUG(DDSP, DEBUG_NOTICE, "Round trip delay is %.3f seconds\n", amps->when_received - amps->when_transmitted[frame->ie[AMPS_IE_1111]]);
PDEBUG_CHAN(DDSP, DEBUG_NOTICE, "Round trip delay is %.3f seconds\n", amps->when_received - amps->when_transmitted[frame->ie[AMPS_IE_1111]]);
}
/* get word from data bits and call decoder function
@ -3132,12 +3134,12 @@ static int amps_decode_word_recc(amps_t *amps, uint64_t word, int first)
memset(amps->rx_recc_dialing, 0, sizeof(amps->rx_recc_dialing));
amps->rx_recc_word_count = 0;
if (f == 0) {
PDEBUG(DFRAME, DEBUG_NOTICE, "Received first word, but F bit is not set.\n");
PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received first word, but F bit is not set.\n");
return 0;
}
} else {
if (f == 1) {
PDEBUG(DFRAME, DEBUG_NOTICE, "Received additional word, but F bit is set.\n");
PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received additional word, but F bit is set.\n");
return 0;
}
}
@ -3145,7 +3147,7 @@ static int amps_decode_word_recc(amps_t *amps, uint64_t word, int first)
msg_count = amps->rx_recc_word_count;
if (msg_count == 8) {
PDEBUG(DFRAME, DEBUG_NOTICE, "Received too many words.\n");
PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Received too many words.\n");
return 0;
}
@ -3184,7 +3186,7 @@ static int amps_decode_word_recc(amps_t *amps, uint64_t word, int first)
if (!w) {
PDEBUG(DFRAME, DEBUG_INFO, "Received Illegal RECC Message\n");
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "Received Illegal RECC Message\n");
goto done;
}
@ -3529,19 +3531,19 @@ static void amps_decode_bits_focc(amps_t *amps, const char *bits)
else
idle = 0;
PDEBUG(DFRAME, DEBUG_INFO, "RX FOCC: B/I = %s\n", (idle) ? "idle" : "busy");
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "RX FOCC: B/I = %s\n", (idle) ? "idle" : "busy");
if (debuglevel == DEBUG_DEBUG) {
char text[64];
for (i = 0; i < 5; i++) {
strncpy(text, bits + i * 44, 44);
text[44] = '\0';
PDEBUG(DFRAME, DEBUG_DEBUG, " word a - %s%s\n", text, (crc_a_ok[i % 5]) ? " ok" : " BAD CRC!");
PDEBUG_CHAN(DFRAME, DEBUG_DEBUG, " word a - %s%s\n", text, (crc_a_ok[i % 5]) ? " ok" : " BAD CRC!");
}
for (i = 5; i < 10; i++) {
strncpy(text, bits + i * 44, 44);
text[44] = '\0';
PDEBUG(DFRAME, DEBUG_DEBUG, " word b - %s%s\n", text, (crc_b_ok[i % 5]) ? " ok" : " BAD CRC!");
PDEBUG_CHAN(DFRAME, DEBUG_DEBUG, " word b - %s%s\n", text, (crc_b_ok[i % 5]) ? " ok" : " BAD CRC!");
}
}
@ -3617,7 +3619,7 @@ static int amps_decode_bits_recc(amps_t *amps, const char *bits, int first)
crc_ok++;
}
if (crc_ok) {
PDEBUG(DFRAME, DEBUG_NOTICE, "Seems we RX FOCC frame due to loopback, ignoring!\n");
PDEBUG_CHAN(DFRAME, DEBUG_NOTICE, "Seems we RX FOCC frame due to loopback, ignoring!\n");
return 0;
}
bits_ -= 221;
@ -3630,7 +3632,7 @@ static int amps_decode_bits_recc(amps_t *amps, const char *bits, int first)
if (first) {
if (debuglevel == DEBUG_DEBUG || crc_ok_count > 0) {
PDEBUG(DFRAME, DEBUG_INFO, "RX RECC: DCC=%d (%d of 5 CRCs are ok)\n", dcc, crc_ok_count);
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "RX RECC: DCC=%d (%d of 5 CRCs are ok)\n", dcc, crc_ok_count);
if (dcc != amps->si.dcc) {
PDEBUG(DFRAME, DEBUG_INFO, "received DCC=%d missmatches the base station's DCC=%d\n", dcc, amps->si.dcc);
return 0;
@ -3638,7 +3640,7 @@ static int amps_decode_bits_recc(amps_t *amps, const char *bits, int first)
}
} else {
if (debuglevel == DEBUG_DEBUG || crc_ok_count > 0)
PDEBUG(DFRAME, DEBUG_INFO, "RX RECC: (%d of 5 CRCs are ok)\n", crc_ok_count);
PDEBUG_CHAN(DFRAME, DEBUG_INFO, "RX RECC: (%d of 5 CRCs are ok)\n", crc_ok_count);
}
if (debuglevel == DEBUG_DEBUG) {
char text[64];
@ -3646,7 +3648,7 @@ static int amps_decode_bits_recc(amps_t *amps, const char *bits, int first)
for (i = 0; i < 5; i++) {
strncpy(text, bits + i * 48, 48);
text[48] = '\0';
PDEBUG(DFRAME, DEBUG_DEBUG, " word - %s%s\n", text, (crc_a_ok[i % 5]) ? " ok" : " BAD CRC!");
PDEBUG_CHAN(DFRAME, DEBUG_DEBUG, " word - %s%s\n", text, (crc_a_ok[i % 5]) ? " ok" : " BAD CRC!");
}
}
@ -3661,7 +3663,7 @@ int amps_decode_frame(amps_t *amps, const char *bits, int count, double level, d
/* not if additional words are received without sync */
if (count != 240) {
PDEBUG(DDSP, DEBUG_INFO, "RX Level: %.0f%% Quality: %.0f%% Polarity: %s\n", level * 100.0, quality * 100.0, (negative) ? "NEGATIVE" : "POSITIVE");
PDEBUG_CHAN(DDSP, DEBUG_INFO, "RX Level: %.0f%% Quality: %.0f%% Polarity: %s\n", level * 100.0, quality * 100.0, (negative) ? "NEGATIVE" : "POSITIVE");
}
if (count == 441) {
amps_decode_bits_focc(amps, bits);
@ -3670,7 +3672,7 @@ int amps_decode_frame(amps_t *amps, const char *bits, int count, double level, d
} else if (count == 240) {
more = amps_decode_bits_recc(amps, bits, 0);
} else {
PDEBUG(DFRAME, DEBUG_ERROR, "Frame with unknown lenght = %d, please fix!\n", count);
PDEBUG_CHAN(DFRAME, DEBUG_ERROR, "Frame with unknown lenght = %d, please fix!\n", count);
}
return more;

View File

@ -402,7 +402,7 @@ inval:
return -CAUSE_NOCHANNEL;
}
PDEBUG(DANETZ, DEBUG_INFO, "Call to mobile station, paging with tones: %.1f %.1f %.1f %.1f\n", freq[0], freq[1], freq[2], freq[3]);
PDEBUG_CHAN(DANETZ, DEBUG_INFO, "Call to mobile station, paging with tones: %.1f %.1f %.1f %.1f\n", freq[0], freq[1], freq[2], freq[3]);
if (anetz->page_sequence)
PDEBUG(DANETZ, DEBUG_NOTICE, "Sending paging tones in sequence.\n");
@ -442,7 +442,7 @@ void call_out_disconnect(int callref, int cause)
return;
switch (anetz->state) {
case ANETZ_ANRUF:
PDEBUG(DANETZ, DEBUG_NOTICE, "Outgoing disconnect, during alerting, going idle!\n");
PDEBUG_CHAN(DANETZ, DEBUG_NOTICE, "Outgoing disconnect, during alerting, going idle!\n");
anetz_go_idle(anetz);
break;
default:
@ -478,11 +478,11 @@ void call_out_release(int callref, __attribute__((unused)) int cause)
switch (anetz->state) {
case ANETZ_GESPRAECH:
PDEBUG(DANETZ, DEBUG_NOTICE, "Outgoing release, during call, sending release tone!\n");
PDEBUG_CHAN(DANETZ, DEBUG_NOTICE, "Outgoing release, during call, sending release tone!\n");
anetz_release(anetz);
break;
case ANETZ_ANRUF:
PDEBUG(DANETZ, DEBUG_NOTICE, "Outgoing release, during alerting, going idle!\n");
PDEBUG_CHAN(DANETZ, DEBUG_NOTICE, "Outgoing release, during alerting, going idle!\n");
anetz_go_idle(anetz);
break;
default:

View File

@ -17,6 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define CHAN anetz->sender.kanal
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@ -90,7 +92,7 @@ int dsp_init_sender(anetz_t *anetz, int page_sequence)
int i;
double tone;
PDEBUG(DDSP, DEBUG_DEBUG, "Init DSP for 'Sender'.\n");
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for 'Sender'.\n");
anetz->page_sequence = page_sequence;
@ -122,7 +124,7 @@ int dsp_init_sender(anetz_t *anetz, int page_sequence)
/* Cleanup transceiver instance. */
void dsp_cleanup_sender(anetz_t *anetz)
{
PDEBUG(DDSP, DEBUG_DEBUG, "Cleanup DSP for 'Sender'.\n");
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for 'Sender'.\n");
if (anetz->fsk_filter_spl) {
free(anetz->fsk_filter_spl);
@ -136,7 +138,7 @@ static void fsk_receive_tone(anetz_t *anetz, int tone, int goodtone, double leve
/* lost tone because it is not good anymore or has changed */
if (!goodtone || tone != anetz->tone_detected) {
if (anetz->tone_count >= TONE_DETECT_TH) {
PDEBUG(DDSP, DEBUG_INFO, "Lost %.0f Hz tone after %.0f ms.\n", fsk_tones[anetz->tone_detected], 1000.0 * CHUNK_DURATION * anetz->tone_count);
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Lost %.0f Hz tone after %.0f ms.\n", fsk_tones[anetz->tone_detected], 1000.0 * CHUNK_DURATION * anetz->tone_count);
anetz_receive_tone(anetz, -1);
}
if (goodtone)
@ -153,7 +155,7 @@ static void fsk_receive_tone(anetz_t *anetz, int tone, int goodtone, double leve
if (anetz->tone_count >= TONE_DETECT_TH)
audio_reset_loss(&anetz->sender.loss);
if (anetz->tone_count == TONE_DETECT_TH) {
PDEBUG(DDSP, DEBUG_INFO, "Detecting continuous %.0f Hz tone. (level = %d%%)\n", fsk_tones[anetz->tone_detected], (int)(level * 100.0 + 0.5));
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Detecting continuous %.0f Hz tone. (level = %d%%)\n", fsk_tones[anetz->tone_detected], (int)(level * 100.0 + 0.5));
anetz_receive_tone(anetz, anetz->tone_detected);
}
}
@ -173,10 +175,10 @@ static void fsk_decode_chunk(anetz_t *anetz, int16_t *spl, int max)
/* show quality of tone */
if (anetz->sender.loopback) {
/* adjust level, so we get peak of sine curve */
PDEBUG(DDSP, DEBUG_NOTICE, "Tone %.0f: Level=%3.0f%% Quality=%3.0f%%\n", fsk_tones[1], level / 0.63662 * 100.0 * 32768.0 / TX_PEAK_TONE, result[1] / level * 100.0);
PDEBUG_CHAN(DDSP, DEBUG_NOTICE, "Tone %.0f: Level=%3.0f%% Quality=%3.0f%%\n", fsk_tones[1], level / 0.63662 * 100.0 * 32768.0 / TX_PEAK_TONE, result[1] / level * 100.0);
}
if (level / 0.63 > 0.05 && result[0] / level > 0.5)
PDEBUG(DDSP, DEBUG_INFO, "Tone %.0f: Level=%3.0f%% Quality=%3.0f%%\n", fsk_tones[0], level / 0.63662 * 100.0 * 32768.0 / TX_PEAK_TONE, result[0] / level * 100.0);
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Tone %.0f: Level=%3.0f%% Quality=%3.0f%%\n", fsk_tones[0], level / 0.63662 * 100.0 * 32768.0 / TX_PEAK_TONE, result[0] / level * 100.0);
/* adjust level, so we get peak of sine curve */
/* indicate detected tone */
@ -383,9 +385,28 @@ void sender_send(sender_t *sender, int16_t *samples, int length)
}
}
const char *anetz_dsp_mode_name(enum dsp_mode mode)
{
static char invalid[16];
switch (mode) {
case DSP_MODE_SILENCE:
return "SILENCE";
case DSP_MODE_AUDIO:
return "AUDIO";
case DSP_MODE_TONE:
return "TONE";
case DSP_MODE_PAGING:
return "PAGING";
}
sprintf(invalid, "invalid(%d)", mode);
return invalid;
}
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);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "DSP mode %s -> %s\n", anetz_dsp_mode_name(anetz->dsp_mode), anetz_dsp_mode_name(mode));
anetz->dsp_mode = mode;
/* reset sequence paging */
anetz->paging_tone = 0;

View File

@ -703,7 +703,7 @@ inval:
return -CAUSE_NOCHANNEL;
}
PDEBUG(DBNETZ, DEBUG_INFO, "Call to mobile station, paging station id '%s'\n", dialing);
PDEBUG_CHAN(DBNETZ, DEBUG_INFO, "Call to mobile station, paging station id '%s'\n", dialing);
/* 4. trying to page mobile station */
bnetz->callref = callref;
@ -741,11 +741,11 @@ void call_out_disconnect(int callref, int cause)
case BNETZ_SELEKTIVRUF_EIN:
case BNETZ_SELEKTIVRUF_AUS:
case BNETZ_RUFBESTAETIGUNG:
PDEBUG(DBNETZ, DEBUG_NOTICE, "Outgoing disconnect, during paging, releasing!\n");
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Outgoing disconnect, during paging, releasing!\n");
bnetz_release(bnetz, TRENN_COUNT);
break;
case BNETZ_RUFHALTUNG:
PDEBUG(DBNETZ, DEBUG_NOTICE, "Outgoing disconnect, during alerting, releasing!\n");
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Outgoing disconnect, during alerting, releasing!\n");
bnetz_release(bnetz, TRENN_COUNT);
break;
default:
@ -780,17 +780,17 @@ void call_out_release(int callref, int __attribute__((unused)) cause)
switch (bnetz->state) {
case BNETZ_GESPRAECH:
PDEBUG(DBNETZ, DEBUG_NOTICE, "Outgoing release, during call, releasing!\n");
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Outgoing release, during call, releasing!\n");
bnetz_release(bnetz, TRENN_COUNT);
break;
case BNETZ_SELEKTIVRUF_EIN:
case BNETZ_SELEKTIVRUF_AUS:
case BNETZ_RUFBESTAETIGUNG:
PDEBUG(DBNETZ, DEBUG_NOTICE, "Outgoing release, during paging, releasing!\n");
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Outgoing release, during paging, releasing!\n");
bnetz_release(bnetz, TRENN_COUNT);
break;
case BNETZ_RUFHALTUNG:
PDEBUG(DBNETZ, DEBUG_NOTICE, "Outgoing release, during alerting, releasing!\n");
PDEBUG_CHAN(DBNETZ, DEBUG_NOTICE, "Outgoing release, during alerting, releasing!\n");
bnetz_release(bnetz, TRENN_COUNT);
break;
default:

View File

@ -2,8 +2,8 @@
/* fsk modes of transmission */
enum dsp_mode {
DSP_MODE_AUDIO, /* stream audio */
DSP_MODE_SILENCE, /* sending silence */
DSP_MODE_AUDIO, /* stream audio */
DSP_MODE_0, /* send tone 0 */
DSP_MODE_1, /* send tone 1 */
DSP_MODE_TELEGRAMM, /* send "Telegramm" */

View File

@ -17,6 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define CHAN bnetz->sender.kanal
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@ -81,7 +83,7 @@ int dsp_init_sender(bnetz_t *bnetz)
return -EINVAL;
}
PDEBUG(DDSP, DEBUG_DEBUG, "Init DSP for 'Sender'.\n");
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init DSP for 'Sender'.\n");
audio_init_loss(&bnetz->sender.loss, LOSS_INTERVAL, bnetz->sender.loss_volume, LOSS_TIME);
@ -121,7 +123,7 @@ int dsp_init_sender(bnetz_t *bnetz)
/* Cleanup transceiver instance. */
void dsp_cleanup_sender(bnetz_t *bnetz)
{
PDEBUG(DDSP, DEBUG_DEBUG, "Cleanup DSP for 'Sender'.\n");
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for 'Sender'.\n");
if (bnetz->telegramm_spl) {
free(bnetz->telegramm_spl);
@ -139,7 +141,7 @@ static void fsk_receive_tone(bnetz_t *bnetz, int bit, int goodtone, double level
/* lost tone because it is not good anymore or has changed */
if (!goodtone || bit != bnetz->tone_detected) {
if (bnetz->tone_count >= TONE_DETECT_TH) {
PDEBUG(DDSP, DEBUG_DEBUG, "Lost %.0f Hz tone after %d ms.\n", fsk_bits[bnetz->tone_detected], bnetz->tone_count);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Lost %.0f Hz tone after %d ms.\n", fsk_bits[bnetz->tone_detected], bnetz->tone_count);
bnetz_receive_tone(bnetz, -1);
}
if (goodtone)
@ -156,7 +158,7 @@ static void fsk_receive_tone(bnetz_t *bnetz, int bit, int goodtone, double level
if (bnetz->tone_count >= TONE_DETECT_TH)
audio_reset_loss(&bnetz->sender.loss);
if (bnetz->tone_count == TONE_DETECT_TH) {
PDEBUG(DDSP, DEBUG_INFO, "Detecting continuous tone: %.0f:Level=%3.0f%% Quality=%3.0f%%\n", fsk_bits[bnetz->tone_detected], level * 100.0, quality * 100.0);
PDEBUG_CHAN(DDSP, DEBUG_INFO, "Detecting continuous tone: %.0f:Level=%3.0f%% Quality=%3.0f%%\n", fsk_bits[bnetz->tone_detected], level * 100.0, quality * 100.0);
bnetz_receive_tone(bnetz, bnetz->tone_detected);
}
}
@ -330,10 +332,10 @@ static int fsk_telegramm(bnetz_t *bnetz, int16_t *samples, int length)
next_telegramm:
if (!bnetz->telegramm) {
/* request telegramm */
// PDEBUG(DDSP, DEBUG_DEBUG, "Request new 'Telegramm'.\n");
// PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Request new 'Telegramm'.\n");
telegramm = bnetz_get_telegramm(bnetz);
if (!telegramm) {
PDEBUG(DDSP, DEBUG_DEBUG, "Stop sending 'Telegramm'.\n");
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Stop sending 'Telegramm'.\n");
return length;
}
bnetz->telegramm = 1;
@ -382,12 +384,12 @@ void sender_send(sender_t *sender, int16_t *samples, int length)
again:
switch (bnetz->dsp_mode) {
case DSP_MODE_AUDIO:
jitter_load(&bnetz->sender.audio, samples, length);
break;
case DSP_MODE_SILENCE:
memset(samples, 0, length * sizeof(*samples));
break;
case DSP_MODE_AUDIO:
jitter_load(&bnetz->sender.audio, samples, length);
break;
case DSP_MODE_0:
fsk_tone(bnetz, samples, length, 0);
break;
@ -407,13 +409,34 @@ again:
}
}
const char *bnetz_dsp_mode_name(enum dsp_mode mode)
{
static char invalid[16];
switch (mode) {
case DSP_MODE_SILENCE:
return "SILENCE";
case DSP_MODE_AUDIO:
return "AUDIO";
case DSP_MODE_0:
return "TONE 0";
case DSP_MODE_1:
return "TONE 1";
case DSP_MODE_TELEGRAMM:
return "TELEGRAMM";
}
sprintf(invalid, "invalid(%d)", mode);
return invalid;
}
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);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "DSP mode %s -> %s\n", bnetz_dsp_mode_name(bnetz->dsp_mode), bnetz_dsp_mode_name(mode));
bnetz->dsp_mode = mode;
}

View File

@ -557,7 +557,7 @@ inval:
return -CAUSE_NOCHANNEL;
}
PDEBUG(DCNETZ, DEBUG_INFO, "Call to mobile station, paging station id '%s'\n", dialing);
PDEBUG_CHAN(DCNETZ, DEBUG_INFO, "Call to mobile station, paging station id '%s'\n", dialing);
/* 6. trying to page mobile station */
trans = create_transaction(cnetz, TRANS_VAK, dialing[0] - '0', dialing[1] - '0', atoi(dialing + 2), -1);
@ -821,13 +821,13 @@ void cnetz_sync_frame(cnetz_t *cnetz, double sync, int block)
}
/* if more than +- one bit out of sync */
if (offset < -0.5 || offset > 0.5) {
PDEBUG(DCNETZ, DEBUG_NOTICE, "Frame sync offset = %.2f, correcting!\n", offset);
PDEBUG_CHAN(DCNETZ, DEBUG_NOTICE, "Frame sync offset = %.2f, correcting!\n", offset);
fsk_correct_sync(&cnetz->fsk_demod, offset);
return;
}
/* resync by some fraction of received sync error */
PDEBUG(DCNETZ, DEBUG_DEBUG, "Frame sync offset = %.2f, correcting.\n", offset);
PDEBUG_CHAN(DCNETZ, DEBUG_DEBUG, "Frame sync offset = %.2f, correcting.\n", offset);
fsk_correct_sync(&cnetz->fsk_demod, offset / 2.0);
}

View File

@ -86,7 +86,7 @@ int dsp_init_sender(cnetz_t *cnetz, int measure_speed, double clock_speed[2], do
double size;
double RC, dt;
PDEBUG(DDSP, DEBUG_DEBUG, "Init FSK for 'Sender'.\n");
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Init FSK for 'Sender'.\n");
if (measure_speed) {
cnetz->measure_speed = measure_speed;
@ -171,7 +171,7 @@ error:
void dsp_cleanup_sender(cnetz_t *cnetz)
{
PDEBUG(DDSP, DEBUG_DEBUG, "Cleanup FSK for 'Sender'.\n");
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup FSK for 'Sender'.\n");
if (cnetz->fsk_tx_buffer)
free(cnetz->fsk_tx_buffer);
@ -226,7 +226,7 @@ void calc_clock_speed(cnetz_t *cnetz, uint64_t samples, int tx, int result)
speed_ppm_tx[0] = ((double)cs->spl_count[1] / (double)cnetz->sender.samplerate) / (cs->last_ti[1] - cs->start_ti[1]) * 1000000.0 - 1000000.0;
speed_ppm_rx[1] = ((double)cs->spl_count[2] / (double)cnetz->sender.samplerate) / (cs->last_ti[2] - cs->start_ti[2]) * 1000000.0 - 1000000.0;
speed_ppm_tx[1] = ((double)cs->spl_count[3] / (double)cnetz->sender.samplerate) / (cs->last_ti[3] - cs->start_ti[3]) * 1000000.0 - 1000000.0;
PDEBUG(DDSP, DEBUG_NOTICE, "Clock: RX=%.2f TX=%.2f; Signal: RX=%.2f TX=%.2f ppm\n", speed_ppm_rx[0], speed_ppm_tx[0], speed_ppm_rx[1], speed_ppm_tx[1]);
PDEBUG_CHAN(DDSP, DEBUG_NOTICE, "Clock: RX=%.2f TX=%.2f; Signal: RX=%.2f TX=%.2f ppm\n", speed_ppm_rx[0], speed_ppm_tx[0], speed_ppm_rx[1], speed_ppm_tx[1]);
}
static int fsk_testtone_encode(cnetz_t *cnetz)
@ -649,10 +649,10 @@ again:
if (cnetz->sched_r_m == 0) {
/* set last time slot, so we can match received message from mobile station */
cnetz->sched_last_ts[cnetz->cell_nr] = cnetz->sched_ts;
PDEBUG(DDSP, DEBUG_DEBUG, "Transmitting 'Rufblock' at timeslot %d\n", cnetz->sched_ts);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Rufblock' at timeslot %d\n", cnetz->sched_ts);
bits = cnetz_encode_telegramm(cnetz);
} else {
PDEBUG(DDSP, DEBUG_DEBUG, "Transmitting 'Meldeblock' at timeslot %d\n", cnetz->sched_ts);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Meldeblock' at timeslot %d\n", cnetz->sched_ts);
bits = cnetz_encode_telegramm(cnetz);
}
fsk_block_encode(cnetz, bits);
@ -661,12 +661,12 @@ again:
}
break;
case DSP_MODE_SPK_K:
PDEBUG(DDSP, DEBUG_DEBUG, "Transmitting 'Konzentrierte Signalisierung'\n");
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Konzentrierte Signalisierung'\n");
bits = cnetz_encode_telegramm(cnetz);
fsk_block_encode(cnetz, bits);
break;
case DSP_MODE_SPK_V:
PDEBUG(DDSP, DEBUG_DEBUG, "Transmitting 'Verteilte Signalisierung'\n");
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Transmitting 'Verteilte Signalisierung'\n");
bits = cnetz_encode_telegramm(cnetz);
fsk_distributed_encode(cnetz, bits);
break;
@ -829,9 +829,30 @@ void unshrink_speech(cnetz_t *cnetz, int16_t *speech_buffer, int count)
cnetz->sender.rxbuf_pos = pos;
}
const char *cnetz_dsp_mode_name(enum dsp_mode mode)
{
static char invalid[16];
switch (mode) {
case DSP_SCHED_NONE:
return "SCHED_NONE";
case DSP_MODE_OFF:
return "OFF";
case DSP_MODE_OGK:
return "OGK";
case DSP_MODE_SPK_K:
return "SPK_K";
case DSP_MODE_SPK_V:
return "SPK_V";
}
sprintf(invalid, "invalid(%d)", mode);
return invalid;
}
void cnetz_set_dsp_mode(cnetz_t *cnetz, enum dsp_mode mode)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "DSP mode %d -> %d\n", cnetz->dsp_mode, mode);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "DSP mode %s -> %s\n", cnetz_dsp_mode_name(cnetz->dsp_mode), cnetz_dsp_mode_name(mode));
cnetz->dsp_mode = mode;
/* we must get rid of partly received frame */
fsk_demod_reset(&cnetz->fsk_demod);
@ -839,7 +860,7 @@ 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)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, " Schedule DSP mode %d -> %d in %d frames\n", cnetz->dsp_mode, mode, frames_ahead);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, " Schedule DSP mode %s -> %s in %d frames\n", cnetz_dsp_mode_name(cnetz->dsp_mode), cnetz_dsp_mode_name(mode), frames_ahead);
cnetz->sched_dsp_mode = mode;
cnetz->sched_switch_mode = frames_ahead;
}

View File

@ -201,7 +201,7 @@ int dsp_init_sender(nmt_t *nmt)
/* Cleanup transceiver instance. */
void dsp_cleanup_sender(nmt_t *nmt)
{
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for 'Sender'.\n");
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "Cleanup DSP for Transceiver.\n");
if (nmt->frame_spl) {
free(nmt->frame_spl);
@ -641,13 +641,34 @@ again:
}
}
const char *nmt_dsp_mode_name(enum dsp_mode mode)
{
static char invalid[16];
switch (mode) {
case DSP_MODE_SILENCE:
return "SILENCE";
case DSP_MODE_DIALTONE:
return "DIALTONE";
case DSP_MODE_AUDIO:
return "AUDIO";
case DSP_MODE_FRAME:
return "FRAME";
case DSP_MODE_DTMF:
return "DTMF";
}
sprintf(invalid, "invalid(%d)", mode);
return invalid;
}
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_CHAN(DDSP, DEBUG_DEBUG, "DSP mode %d -> %d\n", nmt->dsp_mode, mode);
PDEBUG_CHAN(DDSP, DEBUG_DEBUG, "DSP mode %s -> %s\n", nmt_dsp_mode_name(nmt->dsp_mode), nmt_dsp_mode_name(mode));
nmt->dsp_mode = mode;
}

View File

@ -7,9 +7,9 @@
enum dsp_mode {
DSP_MODE_SILENCE, /* stream nothing */
DSP_MODE_DIALTONE, /* stream dial tone to mobile phone */
DSP_MODE_AUDIO, /* stream audio */
DSP_MODE_SILENCE, /* stream nothing */
DSP_MODE_FRAME, /* send frames */
DSP_MODE_DTMF, /* send DTMF tones */
};