Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Add always_use_exten configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
RoEdAl committed Jun 25, 2024
1 parent 5552c36 commit 5c98ab1
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions etc/quectel.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ initstate=start ; specified initial state of device, must be one of 'stop' 's
; 'remove' same as 'disable=yes'

;exten=70 ; exten for start incoming calls, only in case of Subscriber Number not available!, also set to CALLERID(ndid)
;always_use_exten=no ; always use exten from config regardless of Subscriber Number is available or not

;dtmf=no
;dtmf_duration=120
Expand Down
1 change: 1 addition & 0 deletions quectel.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ initstate=start ; specified initial state of device, must be one of 'stop' 's
; 'remove' same as 'disable=yes'

;exten=70 ; exten for start incoming calls, only in case of Subscriber Number not available!, also set to CALLERID(ndid)
;always_use_exten=no ; always use exten from config regardless of Subscriber Number is available or not

;dtmf=no
;dtmf_duration=120
Expand Down
11 changes: 9 additions & 2 deletions src/at_response.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,11 +902,18 @@ static int at_response_error(struct pvt* const pvt, const at_res_t at_res, const
return -1;
}

static const char* get_exten(const struct pvt* const pvt)
{
if (CONF_SHARED(pvt, always_use_exten)) {
return CONF_SHARED(pvt, exten);
}
return pvt->has_subscriber_number ? pvt->subscriber_number : CONF_SHARED(pvt, exten);
}

static int start_pbx(struct pvt* const pvt, const char* const number, const int call_idx, const call_state_t state)
{
/* TODO: pass also Subscriber number or other DID info for exten */
struct ast_channel* channel = channel_new(pvt, AST_STATE_RING, number, call_idx, CALL_DIR_INCOMING, state,
pvt->has_subscriber_number ? pvt->subscriber_number : CONF_SHARED(pvt, exten), NULL, NULL, 0);
struct ast_channel* channel = channel_new(pvt, AST_STATE_RING, number, call_idx, CALL_DIR_INCOMING, state, get_exten(pvt), NULL, NULL, 0);

if (!channel) {
ast_log(LOG_ERROR, "[%s] Unable to allocate channel for incoming call\n", PVT_ID(pvt));
Expand Down
1 change: 1 addition & 0 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ static char* cli_show_device_settings(struct ast_cli_entry* e, int cmd, struct a
ast_cli(a->fd, " Channel Language : %s\n", CONF_SHARED(pvt, language));
ast_cli(a->fd, " Context : %s\n", CONF_SHARED(pvt, context));
ast_cli(a->fd, " Exten : %s\n", CONF_SHARED(pvt, exten));
ast_cli(a->fd, " Always use exten : %s\n", AST_CLI_YESNO(CONF_SHARED(pvt, always_use_exten)));
ast_cli(a->fd, " Group : %d\n", CONF_SHARED(pvt, group));
ast_cli(a->fd, " Used Notifications : %s\n", S_COR(CONF_SHARED(pvt, dsci), "DSCI", "CCINFO"));
ast_cli(a->fd, " 16kHz audio : %s\n", AST_CLI_YESNO(CONF_UNIQ(pvt, slin16)));
Expand Down
8 changes: 5 additions & 3 deletions src/dc_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ void dc_sconfig_fill(struct ast_config* cfg, const char* cat, struct dc_sconfig*
ast_copy_string(config->context, v->value, sizeof(config->context));
} else if (!strcasecmp(v->name, "exten")) {
ast_copy_string(config->exten, v->value, sizeof(config->exten));
} else if (!strcasecmp(v->name, "always_use_exten")) {
config->always_use_exten = parse_on_off(v->name, v->value, 0u);
} else if (!strcasecmp(v->name, "language")) {
ast_copy_string(config->language, v->value, sizeof(config->language)); /* set channel language */
} else if (!strcasecmp(v->name, "group")) {
Expand Down Expand Up @@ -344,9 +346,9 @@ static int dc_sconfig_compare(const struct dc_sconfig* const cfg1, const struct
cfg1->rxgain != cfg2->rxgain || cfg1->txgain != cfg2->txgain || cfg1->calling_pres != cfg2->calling_pres ||
cfg1->use_calling_pres != cfg2->use_calling_pres || cfg1->sms_autodelete != cfg2->sms_autodelete || cfg1->reset_modem != cfg2->reset_modem ||
cfg1->multiparty != cfg2->multiparty || cfg1->dtmf != cfg2->dtmf || cfg1->moh != cfg2->moh || cfg1->query_time != cfg2->query_time ||
cfg1->dsci != cfg2->dsci || cfg1->qhup != cfg2->qhup || cfg1->dtmf_duration != cfg2->dtmf_duration || cfg1->init_state != cfg2->init_state ||
cfg1->call_waiting != cfg2->call_waiting || cfg1->msg_service != cfg2->msg_service || cfg1->msg_direct != cfg2->msg_direct ||
cfg1->msg_storage != cfg2->msg_storage;
cfg1->dsci != cfg2->dsci || cfg1->qhup != cfg2->qhup || cfg1->always_use_exten != cfg2->always_use_exten ||
cfg1->dtmf_duration != cfg2->dtmf_duration || cfg1->init_state != cfg2->init_state || cfg1->call_waiting != cfg2->call_waiting ||
cfg1->msg_service != cfg2->msg_service || cfg1->msg_direct != cfg2->msg_direct || cfg1->msg_storage != cfg2->msg_storage;
}

static int dc_uconfig_compare(const struct dc_uconfig* const cfg1, const struct dc_uconfig* const cfg2)
Expand Down
1 change: 1 addition & 0 deletions src/dc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ typedef struct dc_sconfig {
unsigned int query_time :1; /*! 0 */
unsigned int dsci :1; /*!< use ^DSCI call state notifications */
unsigned int qhup :1; /*!< use QHUP command */
unsigned int always_use_exten:1; /*!< always use exten field from config */

long dtmf_duration; /*! duration of DTMF in miliseconds */
dev_state_t init_state; /*! DEV_STATE_STARTED */
Expand Down
1 change: 1 addition & 0 deletions uac/quectel.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ initstate=start ; specified initial state of device, must be one of 'stop' 's
; 'remove' same as 'disable=yes'

;exten=70 ; exten for start incoming calls, only in case of Subscriber Number not available!, also set to CALLERID(ndid)
;always_use_exten=no ; always use exten from config regardless of Subscriber Number is available or not

;dtmf=no
;dtmf_duration=120
Expand Down

0 comments on commit 5c98ab1

Please sign in to comment.