added configuration of gains in openzap.conf and display through CLI
This commit is contained in:
parent
6ddcb9044c
commit
ae13883b2a
|
@ -2767,6 +2767,8 @@ void dump_chan(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stre
|
|||
"type: %s\n"
|
||||
"state: %s\n"
|
||||
"last_state: %s\n"
|
||||
"txgain: %3.2f\n"
|
||||
"rxgain: %3.2f\n"
|
||||
"cid_date: %s\n"
|
||||
"cid_name: %s\n"
|
||||
"cid_num: %s\n"
|
||||
|
@ -2782,6 +2784,8 @@ void dump_chan(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *stre
|
|||
ftdm_chan_type2str(span->channels[chan_id]->type),
|
||||
ftdm_channel_state2str(span->channels[chan_id]->state),
|
||||
ftdm_channel_state2str(span->channels[chan_id]->last_state),
|
||||
span->channels[chan_id]->txgain,
|
||||
span->channels[chan_id]->rxgain,
|
||||
span->channels[chan_id]->caller_data.cid_date,
|
||||
span->channels[chan_id]->caller_data.cid_name,
|
||||
span->channels[chan_id]->caller_data.cid_num.digits,
|
||||
|
@ -2808,6 +2812,8 @@ void dump_chan_xml(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *
|
|||
" <type>%s</type>\n"
|
||||
" <state>%s</state>\n"
|
||||
" <last-state>%s</last-state>\n"
|
||||
" <txgain>%3.2f</txgain>\n"
|
||||
" <rxgain>%3.2f</rxgain>\n"
|
||||
" <cid-date>%s</cid-date>\n"
|
||||
" <cid-name>%s</cid-name>\n"
|
||||
" <cid-num>%s</cid-num>\n"
|
||||
|
@ -2824,6 +2830,8 @@ void dump_chan_xml(ftdm_span_t *span, uint32_t chan_id, switch_stream_handle_t *
|
|||
ftdm_chan_type2str(span->channels[chan_id]->type),
|
||||
ftdm_channel_state2str(span->channels[chan_id]->state),
|
||||
ftdm_channel_state2str(span->channels[chan_id]->last_state),
|
||||
span->channels[chan_id]->txgain,
|
||||
span->channels[chan_id]->rxgain,
|
||||
span->channels[chan_id]->caller_data.cid_date,
|
||||
span->channels[chan_id]->caller_data.cid_name,
|
||||
span->channels[chan_id]->caller_data.cid_num.digits,
|
||||
|
|
|
@ -2034,7 +2034,6 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_command(ftdm_channel_t *ftdmchan, ftdm_co
|
|||
}
|
||||
break;
|
||||
|
||||
/* FIXME: validate user gain values */
|
||||
case FTDM_COMMAND_SET_RX_GAIN:
|
||||
{
|
||||
ftdmchan->rxgain = FTDM_COMMAND_OBJ_FLOAT;
|
||||
|
@ -2826,6 +2825,24 @@ FT_DECLARE(char *) ftdm_api_execute(const char *type, const char *cmd)
|
|||
return rval;
|
||||
}
|
||||
|
||||
static void ftdm_set_channels_gains(ftdm_span_t *span, int currindex, float rxgain, float txgain)
|
||||
{
|
||||
unsigned chan_index = 0;
|
||||
|
||||
if (!span->chan_count) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (chan_index = currindex+1; chan_index <= span->chan_count; chan_index++) {
|
||||
if (!FTDM_IS_VOICE_CHANNEL(span->channels[chan_index])) {
|
||||
continue;
|
||||
}
|
||||
ftdm_channel_command(span->channels[chan_index], FTDM_COMMAND_SET_RX_GAIN, &rxgain);
|
||||
ftdm_channel_command(span->channels[chan_index], FTDM_COMMAND_SET_TX_GAIN, &txgain);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static ftdm_status_t ftdm_group_add_channels(const char* name, ftdm_span_t* span, int currindex);
|
||||
static ftdm_status_t load_config(void)
|
||||
|
@ -2842,6 +2859,8 @@ static ftdm_status_t load_config(void)
|
|||
char group_name[80] = "default";
|
||||
ftdm_io_interface_t *fio = NULL;
|
||||
ftdm_analog_start_type_t tmp;
|
||||
float rxgain = 0.0;
|
||||
float txgain = 0.0;
|
||||
ftdm_size_t len = 0;
|
||||
|
||||
if (!ftdm_config_open_file(&cfg, cfg_name)) {
|
||||
|
@ -2949,6 +2968,7 @@ static ftdm_status_t load_config(void)
|
|||
if (span->trunk_type == FTDM_TRUNK_FXO) {
|
||||
currindex = span->chan_count;
|
||||
configured += fio->configure_span(span, val, FTDM_CHAN_TYPE_FXO, name, number);
|
||||
ftdm_set_channels_gains(span, currindex, rxgain, txgain);
|
||||
ftdm_group_add_channels(group_name, span, currindex);
|
||||
} else {
|
||||
ftdm_log(FTDM_LOG_WARNING, "Cannot add FXO channels to an FXS trunk!\n");
|
||||
|
@ -2962,6 +2982,7 @@ static ftdm_status_t load_config(void)
|
|||
if (span->trunk_type == FTDM_TRUNK_FXS) {
|
||||
currindex = span->chan_count;
|
||||
configured += fio->configure_span(span, val, FTDM_CHAN_TYPE_FXS, name, number);
|
||||
ftdm_set_channels_gains(span, currindex, rxgain, txgain);
|
||||
ftdm_group_add_channels(group_name, span, currindex);
|
||||
} else {
|
||||
ftdm_log(FTDM_LOG_WARNING, "Cannot add FXS channels to an FXO trunk!\n");
|
||||
|
@ -2975,6 +2996,7 @@ static ftdm_status_t load_config(void)
|
|||
if (span->trunk_type == FTDM_TRUNK_EM) {
|
||||
currindex = span->chan_count;
|
||||
configured += fio->configure_span(span, val, FTDM_CHAN_TYPE_EM, name, number);
|
||||
ftdm_set_channels_gains(span, currindex, rxgain, txgain);
|
||||
ftdm_group_add_channels(group_name, span, currindex);
|
||||
} else {
|
||||
ftdm_log(FTDM_LOG_WARNING, "Cannot add EM channels to a non-EM trunk!\n");
|
||||
|
@ -2982,6 +3004,7 @@ static ftdm_status_t load_config(void)
|
|||
} else if (!strcasecmp(var, "b-channel")) {
|
||||
currindex = span->chan_count;
|
||||
configured += fio->configure_span(span, val, FTDM_CHAN_TYPE_B, name, number);
|
||||
ftdm_set_channels_gains(span, currindex, rxgain, txgain);
|
||||
ftdm_group_add_channels(group_name, span, currindex);
|
||||
} else if (!strcasecmp(var, "d-channel")) {
|
||||
if (d) {
|
||||
|
@ -3000,10 +3023,19 @@ static ftdm_status_t load_config(void)
|
|||
} else if (!strcasecmp(var, "cas-channel")) {
|
||||
currindex = span->chan_count;
|
||||
configured += fio->configure_span(span, val, FTDM_CHAN_TYPE_CAS, name, number);
|
||||
ftdm_set_channels_gains(span, currindex, rxgain, txgain);
|
||||
ftdm_group_add_channels(group_name, span, currindex);
|
||||
} else if (!strcasecmp(var, "dtmf_hangup")) {
|
||||
span->dtmf_hangup = ftdm_strdup(val);
|
||||
span->dtmf_hangup_len = strlen(val);
|
||||
} else if (!strcasecmp(var, "txgain")) {
|
||||
if (sscanf(val, "%f", &txgain) != 1) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "invalid txgain: '%s'\n", val);
|
||||
}
|
||||
} else if (!strcasecmp(var, "rxgain")) {
|
||||
if (sscanf(val, "%f", &rxgain) != 1) {
|
||||
ftdm_log(FTDM_LOG_ERROR, "invalid rxgain: '%s'\n", val);
|
||||
}
|
||||
} else if (!strcasecmp(var, "group")) {
|
||||
len = strlen(val);
|
||||
if (len >= sizeof(group_name)) {
|
||||
|
|
Loading…
Reference in New Issue