## Phone firmware
## Firmware must be on 4.1.4.0.5 and higher to work properly.
## Older firmwares do not accept a full URL in the APPNAME field so it will use HTTPSRVR and HTTPDIR to look for the firmware file.
## You will need to move the firmware files to /app/provision the first time to get them to update.
SET APPNAME "{if isset($avaya_j179_firmware_url)}{$avaya_j179_firmware_url}{else}FW_S_J179_R4_1_4_0_5.bin{/if}"
## JEM24 Expansion Module firmware
SET "{if isset($avaya_jem24_firmware_url)}{$avaya_jem24_firmware_url}{else}JEM24_APPNAME FW_JEM24_R1_0_1_0_26.bin{/if}"

## Enable Out-Of-Dialog REFER messages to provision or reboot the device
SET ENABLE_OOD_RESET_NOTIFY 1
## Do not require TLS to accept Out-Of-Dialog REFER messages
SET ENABLE_OOD_MSG_TLS_ONLY 0

# Set the default SUBSCRIBE expiry time
# This needs to be set to a value equal to or lower than the 'nonce-ttl' that is in your SIP Profile
# The defaule for 'nonce-ttl' is 60
SET OUTBOUND_SUBSCRIPTION_REQUEST_DURATION {if isset($avaya_blf_subscription_expiry)}{$avaya_blf_subscription_expiry}{else}60{/if}

## Trust public certs rather than the phone downloading a trusted cert from the server
SET ENABLE_PUBLIC_CA_CERTS 1

## Set Admin Access
## 27238 is the Avaya default
## Valid values are 8 to 31 alphanumeric characters.
SET ENABLE_WEBSERVER 1
SET FORCE_WEB_ADMIN_PASSWORD "{if isset($admin_password)}{$admin_password}{else}27238{/if}"

SET SHA2CAPABLE 1
SET ENABLE_PRESENCE 0

## Codec Settings
SET ENABLE_G729 0
SET ENABLE_G722 0
SET ENABLE_G726 0
SET ENABLE_OPUS 0
SET CODEC_PRIORITY G711U

## Call forwarding allowed
## 1 = permits unconditional call forwarding
## 2 = permits call forwarding on busy
## 4 = permits call forwarding on no answer
## add the numbers above to get your desired combination
## 7 means 1+2+4 
SET CALLFWDSTAT 7

## Sets the BLF incoming call mode
##     0 - None (no alerting for BLF incoming call).
##     1 - Audible (only audible alerting for BLF incoming call).
##     2 - Visual (only visual alerting for BLF incoming call).
##     3(default) - Both (both audible and visual alerting for BLF incoming call)
##     4 - Force None (forced only audible alerting for BLF incoming call).
##     5 - Force Audible (forced only audible alerting for BLF incoming call).
##     6 - Force Visual (forced only visual alerting for BLF incoming call).
##     7 - Force Both (forced both audible and visual alerting for BLF incoming call).
SET BLF_INCOMING_CALL_INDICATION_MODE 0

## Specifies whether Prioritize own incoming calls over BLF calls feature is enabled or not. Valid values are:
##     0 - Feature is disabled. The phone displays all calls in the order they are received.
##     1 - Feature is enabled. The phone displays user’s own incoming calls and own parked calls before BLF calls and BLF parked calls.
SET PRIORITIZE_OWN_INCOMING_CALL 1

## Allows the call decline button to be visible
SET CALL_DECLINE_POLICY 1

## Allow the phone to be locked
SET ENABLE_PHONE_LOCK 1

## DISABLE Avaya Spaces
SET SPACES_ACCESS_MODE 0

SET CALL_PICKUP_BARGEIN_FAC *33

SET ENCRYPT_VERSION_IN_USE 1
SET MAX__DISPLAYED_SESSION_APPEARANCES 3
SET ENHDIALSTAT 0

## Specifies the screen mode used on the phone
## 0 = Non-forced Half Screen mode
## 1 = Non-forced Full Screen mode
## 2 = Forced Half Screen mode is used
## 3 = Forced Full Screen mode
SET PHONE_SCREEN_MODE 2

## Specifies the scrolling mode used on the phone
## 0 = Line scrolling mode
## 1 = Page scrolling mode
SET SCROLLING_MODE 1

SET OVERRIDE_USER_SELECTION ""

SET USER_LOGGED_IN 1

SET LANGUAGE_FILE_IN_USE Mlf_English.xml
SET LANGUAGES_RESOURCE_LIST English=res://Mlf_English.xml,Canadian French=lang/Mlf_J169_J179_CanadianFrench.xml,Latin American Spanish=lang/Mlf_J169_J179_LatinAmericanSpanish.xml,Brazilian Portuguese=lang/Mlf_J169_J179_BrazilianPortuguese.xml,Italian=lang/Mlf_J169_J179_Italian.xml
SET SYSTEM_LANGUAGE Mlf_J169_J179_English.xml
SET LANGUAGE_IN_USE English
SET LANGUAGES Mlf_J169_J179_CanadianFrench.xml,Mlf_J169_J179_LatinAmericanSpanish.xml,Mlf_J169_J179_BrazilianPortuguese.xml,Mlf_J169_J179_Italian.xml

## DIALING_MODE_DEFAULT
## 0 - Automatic
## 1 - Manual
SET DIALING_MODE_DEFAULT 0
## Dialplan
## |: This character is used to separate each different number pattern.
## X: This character is a wildcard for any single digit match.
## [ ]- Square brackets can be used to contain possible specific single digit matches. For example:
##     [1237] matches 1, 2, 3 or 7. A - character can be used to match a range of digits.
##     [1-4] matches any digit from 1 to 4.
SET DIALPLAN "{if isset($avaya_dialplan)}{$avaya_dialplan}{else}XXX|XXXX,*XX,1XXXXXXXXXX,XXXXXXXXXX{/if}"
## INTER_DIGIT_TIMEOUT - Set the number of seconds from the last digit dialed after which the phone assumes dialing is complete and send the digits dialed to the system
SET INTER_DIGIT_TIMEOUT 2

## 	GMTOFFSET
SET GMTOFFSET "{if isset($avaya_time_zone)}{$avaya_time_zone}{else}-5:00{/if}"
## Time format
##  0 - 12hr, 1 - 24h, 2 - 12hr forced, 3 - 24h forced
SET ADMINTIMEFORMAT 0
## DST start date. Default: 2SunMar2L
SET DSTSTART "{if isset($avaya_dst_start)}{$avaya_dst_start}{else}2SunMar2L{/if}"
## DST stop date. Default: 1SunNov2L
SET DSTSTOP "{if isset($avaya_dst_stop)}{$avaya_dst_stop}{else}1SunNov2L{/if}"

SET ENABLE_SHOW_EMERG_SK 0
SET ENABLE_SHOW_EMERG_SK_UNREG 0
SET DISCOVER_AVAYA_ENVIRONMENT 0
SET TCP_KEEP_ALIVE_TIME 30
SET DTMF_PAYLOAD_TYPE 101
SET RTP_PORT_LOW 40750
SET RTP_PORT_RANGE 10000

## User Key customization
## 0 - Blocked, 1 - Limited (User customization is allowed for Applications and Contacts), 2 - Full
SET CUSTOMIZATION_MODE {if isset($avaya_key_customization)}{$avaya_key_customization}{else}0{/if}

## Specifies whether the Auto Answer feature is available to users.
SET ENABLE_AUTO_ANSWER_SUPPORT 1

## Voicemail access code
SET PSTN_VM_NUM *97

## BACKGROUND_IMAGE - The selected image
## BACKGROUND_IMAGE_AVAILABLE - The list of available images
## JPG is the only supported format
## Wallpaper dimensions: 320 x 240 pixels
## The Avaya JEM24 will display the default wallpaper if you use a custom image.
{if isset($avaya_j179_wallpaper)}
SET BACKGROUND_IMAGE "{$avaya_j179_wallpaper_url}"
SET BACKGROUND_IMAGE_AVAILABLE "{$avaya_j179_wallpaper_url}"
SET BACKGROUND_IMAGE_DISPLAY "{$avaya_j179_wallpaper_filename}"
{/if}

## Disable Avaya Mode
SET ENABLE_IPOFFICE 0
SET ENABLE_AVAYA_ENVIRONMENT 0
SET ENABLE_3PCC_ENVIRONMENT 1
SET 3PCC_SERVER_MODE 0

SET DES_BLOCK 1
SET DES_SUPPORT 0
SET DES_STAT 0
SET BLF_LIST_URI_CURRENT BLFfakegroup
SET DOWNLOADABLE_DIRECTORY {if isset($avaya_directory_url)}{$avaya_directory_url}{else}https://{$http_auth_username}:{$http_auth_password}@{$domain_name}{$project_path}/app/provision/index.php?mac={$mac}&file=directory.xml{/if}

SET ENABLE_RCV_CONFERENCE 0

{foreach $lines as $row}
SET FORCE_SIP_EXTENSION {$row.user_id}
SET FORCE_SIP_USERNAME {$row.user_id}
SET FORCE_SIP_PASSWORD {$row.password}

SET SIP_USER_ACCOUNT {$row.user_id}@{$row.server_address}
SET SIP_USER_ID {$row.user_id}

SET SNTPSRVR "{if isset($avaya_ntp_server)}{$avaya_ntp_server}{else}ca.pool.ntp.org{/if}"

SET SIP_CONTROLLER_LIST {$row.server_address}:{$row.sip_port};transport={$row.sip_transport}
SET SIPPROXYSRVR_IN_USE {$row.server_address}
SET SIP_PROXY_SELECTION_POLICY 1
SET SIPDOMAIN {$row.server_address}
SET MWISRVR {$row.server_address}
SET RTCPMON {$row.server_address}
SET SIMULTANEOUS_REGISTRATIONS 1

{if $row@index eq 2}{break}{/if}
{/foreach}

## Button config
## Type can be feature,application,line,autodial
## Name is the name of the button type. All options can be found here: https://documentation.avaya.com/bundle/InstallandAdminJ100seriesIPPhonein3PCCsetup_r4.0.11/page/PHONEKEY_parameter_values__3PCC_.html
## attr1 is usually the specific data for the button. For example extension number
{foreach $keys["line"] as $row}

{if in_array($row.device_key_type, array("callfwd", "callfwdna", "callfwdbusy", "dnd" , "autoanswer"))}
SET PHONEKEY "Key={$row.device_key_id+3};Type=feature;Name={$row.device_key_type};Label={$row.device_key_label};Forced"

{elseif in_array($row.device_key_type, array("blf"))}
SET PHONEKEY "Key={$row.device_key_id+3};Type=feature;Name={$row.device_key_type};Label={$row.device_key_label};attr1={$row.device_key_value};attr2={$row.device_key_value};Forced"

{elseif in_array($row.device_key_type, array("lock", "logout", "screensaver"))}
SET PHONEKEY "Key={$row.device_key_id+3};Type=application;Name={$row.device_key_type};Label={$row.device_key_label};Forced"

{elseif in_array($row.device_key_type, array("primary"))}
SET PHONEKEY "Key={$row.device_key_id+3};Type=line;Name={$row.device_key_type};attr1={$row.device_key_line};Forced"

{elseif in_array($row.device_key_type, array("autodial"))}
SET PHONEKEY "Key={$row.device_key_id+3};Type=autodial;Name={$row.device_key_type};attr1={$row.device_key_value};Label={$row.device_key_label};Forced"

{/if}
{/foreach}
