Compare commits

...

1 Commits

Author SHA1 Message Date
Yalu Zhang
291266f500 Re-fix Bug #705: Asterisk gives tone even if number is not configured
Set the parameter "context" in asterisk channel configuration file according to
voice_client.sipX.call_lines, i.e. "Incoming Phone Lines".

Also remove voice_client.sip0.call_lines in the default config. So no voice lines
are bound to "Incoming Phone Lines" of any SIP accounts by default.
2019-06-10 10:18:54 +02:00
2 changed files with 46 additions and 13 deletions

View File

@@ -174,5 +174,4 @@ config sip_service_provider 'sip0'
option redial '*66'
option is_fax '0'
option transport 'udp'
option call_lines '0'

View File

@@ -259,7 +259,7 @@ read_lines()
local loffset=$(ubus -t 1 call voice.asterisk platform | jsonfilter -e @.lineoffset)
loffset=${loffset:-0}
config_get call_lines $1 call_lines "0"
config_get call_lines $1 call_lines
for line in $call_lines ; do
@@ -1839,12 +1839,49 @@ configure_tel()
sed -i "s/|DTMFCOMPATIBILITY|/$dtmfcompatibility/" $WORKDIR/$LINENAME.tmp
}
# Return all SIP accounts to which a voice line is bound as per "voice_client.sipX.call_lines",
# i.e. Incoming Phone Lines
get_sip_accounts_for_incoming_call()
{
local tel_line="$1"
local sip_accounts=""
local line_name_len=${#LINENAME}
local lnum=${tel_line:${line_name_len}}
local section cfgtype call_lines
for section in ${CONFIG_SECTIONS}; do
config_get cfgtype "$section" TYPE
[ "$cfgtype" != "sip_service_provider" ] && continue
config_get call_lines "$section" call_lines
# Note: voice_client.sipX.call_lines contains voice line index which starts with 0
# for all platforms, e.g. "0", "1", or "0 1"
[ -n "$call_lines" ] && echo "$call_lines" | grep -wq "$lnum" && {
local user enabled
config_get user $section user
config_get enabled $section enabled
[ "$section" != "-" -a "$enabled" == "1" -a -n "$user" ] && {
# Append this sip_acount to the tel line
if [ -z "$sip_accounts" ]; then
sip_accounts="$section"
else
sip_accounts="$sip_accounts $section"
fi
}
}
done
echo "$sip_accounts"
}
#
# Configure settings for individual line in $LINENAME.conf
#
configure_tel_line()
{
echo "Configuring $CHANNELNAME line $1"
local extension
local sip_provider
local codecs
@@ -1852,13 +1889,10 @@ configure_tel_line()
local autodial
local autodial_timeout
local dialtone_timeout
local sip_provider_user
local sip_provider_enabled
local callwaiting
local clir
config_get extension $1 extension
config_get sip_provider $1 sip_account
config_get autodial $1 autodial
config_get autodial_timeout $1 autodial_timeout
config_get dialtone_timeout $1 dialtone_timeout
@@ -1866,9 +1900,8 @@ configure_tel_line()
config_get clir $1 clir
#If line is configured with no sip_provider, or sip_provider is disabled, use local_extensions context
config_get sip_provider_user $sip_provider user
config_get sip_provider_enabled $sip_provider enabled
if [ "$sip_provider" == "-" -o -z "$sip_provider_enabled" -o "$sip_provider_enabled" == "0" -o -z "$sip_provider_user" ] ; then
sip_provider=$(get_sip_accounts_for_incoming_call $1)
if [ -z "$sip_provider" ] ; then
sip_provider="local_extensions"
fi
@@ -2240,16 +2273,17 @@ stop_service() {
reload_service() {
start
#stop
# turn off voice led; asterisk will turn it on
# if there is a registered account
# turn off voice led; asterisk will turn it on if there is a registered account
ubus call led.voice1 set '{"state":"off"}'
# FXS channel module must be reloaded before sip module. Otherwise some attributes like
# line's registration state which is updated by SIP module through callback might be
# reset.
asterisk -rx "$(getChipVendor) reload"
asterisk -rx "config reload $ASTERISKDIR/sip.conf"
sleep 1
asterisk -rx "core reload"
asterisk -rx "dialplan reload"
asterisk -rx "$(getChipVendor) reload"
}
service_triggers() {