Asterisk phone snom

Tweaks to make the SNOMs happier with Asterisk


Snom phones in general are easy to configure for Asterisk, if both are on the same network.
If the phone is behind a NAT, then some care is needed to get best results. Make sure your snom phones have the latest firmware, 3.60x (snom190, end-of-life), 6.5.8 or newer (snom 300/320/360) since STUN support was broken in earlier versions.

Broken Registrar

If your Snom phone's firmware has a Support broken Registrar option on the 'SIP line settings' page/tab, this should be set to 'on' for proper phone operation with Asterisk (necessary for Asterisk versions before 1.2).

Page Contents


The setting variable for 'Support broken Registrar' is called 'user_sipusername_as_line': Normally the SNOM requires ";line=xyz" to accept an incoming call and be able to map it to the correct line, with the 'broken register' option turned on this may be omitted and the SNOM will still take the call. See also bug 732.
It looks like the issue was finally fixed for Asterisk 1.6, which would make this option unnecessary from there on.

According to SNOM Asterisk doesn't follow the rules: Technically this means that incoming INVITE's from your provider do not contain the Contact URI which was previously registered by your phone as its Contact. Thus the phone can not safely identify the target line of the incoming call. If you compare the URI in the first line of the incoming INVITE and the URI in the Contact of the REGISTER, which the phone sends to the registrar of your provider, they will presumably differ. If that happens, the registrar is called to be broken.
See also: SNOM White Paper: Asterisk and SNOM Phones

Note: In firmware 7.x there is now an option available to select "Asterisk" as "Server type". This is not a new setting by itself, but a shortcut to configure multiple settings at once like "broken registrar ON" and "user=phone OFF".

Custom ring tone

The custom ring tone preference had problems in the past. With the latest firmware releases it has been working well (last tested with v3.60i on the snom360), configure a HTTP URI (http://webserver.com/myringtone.wav) into the URL box and turn on CUSTOM Melody as ring tone.

NEW in FW v.6.5.2
As of firmware version 6.5.2 it is possible to use dialplan function Asterisk func SipAddHeader to insert a header which triggers a ringer you set in the firmware. Assuming you have firmware version 6.5.2, under the "Preferences" section of fimware's settings page you should now see a section resembling:

Alert-Info Ringer:
  • Alert Internal Text: -------- alert-internal
  • Alert Internal Ringer: ------ Ringer1 *
  • Alert External Text: -------- alert-external
  • Alert External Ringer: ------ Ringer1 *
  • Alert Group Text: ----------- alert-group
  • Alert Group Ringer: --------- Ringer1 *

  • indicates a drop down-menu

For instance, assuming you leave the "Alert Internal Text:" field at the default value of "alert-internal" you can choose a ringer for internal callers in the drop-down menu below it, and access it in the dialplan like this:

exten => s,1,sipaddheader("Alert-Info:<http://www.notused.com>\;info=alert-internal\;x-line-id=0")
exten => s,n,dial(sip/101,60)

Similarly, it is possible to use alert-external and alert-group "contextually" to set distinctuve rings for other calls.


The Alert-Info method is also available, example:

exten => 666,1,SetVar(_ALERT_INFO=http://ip-address/sounds/stng_chime.wav)
exten => 666,2,Dial(SIP/voipphone,20)

For 1.2 use the following Syntax:

exten => 666,1,SIPAddHeader("Alert-Info: <http://ip-address/sound.wav>")
exten => 666,2,Dial(SIP/voipphone,60)


In either case, the http URL should point to a standard 8 kHz mono 16-bit sample WAV file.

To create this format from mp3:
/usr/bin/mpg123 -m -r 8000 -w foo.wav -n 190 -q foo.mp3

  • -m sets the ouput to mono
  • -r sets the sampling rate, then specify 8000 (samples/second)
  • -w set the output to wav, then specify a file name
  • -n specifies the number of frames to grab (similarly, use -k n to skip ahead n frames)
  • -q sets the mode to "quiet"

To convert an existing WAV file:
sox GENERIC.wav -c 1 -r 8000 -w SNOM.wav

  • The "-c 1" flag makes the output mono.
  • The "-r 8000" flag makes the output a 8kHz sample.
  • The "-w" flag uses 16 bits ("word") per sample.

Q: How to trigger the built-in ringer melodies via Alert-Info?
A: 'Alert-Info: <http://127.0.0.1/Bellcore-dr2>' should work as expected. Even 'Alert-Info: Bellcore-dr2' should also be ok. Bellcore-dr2 to Bellcore-dr5 should work. The melodies may differ from the usual build in ones.

(These rings are often too similar to the original. For a more flexible solution, see the method above made available in the 6.5.2 firmware)

See also: MySQL custom ringtones


Making the MWI and voicemail work with ASTERISK

Visual voicemail

Unfortunately no-one has yet come up with a nice visual voicemail XML Interface for SNOM 360/370 like it exists for the Aastra phones.

MWI

Asterisk sends notifications on voicemail messages (if you configured the mailbox option in sip.conf. The messages are sent by default from "asterisk@yourlocalserver.com", which can be modified using vmexten= in sip.conf. When pressing the MWI or Vmail soft button on the SNOM phones the phone calls this extension to connect to the voicemail application. If you haven't configured an extension named "asterisk" in the context of the phone, the MWI/VMail button will not work.

MWI and Asterisk v1.2 (Aug. 2005)

The patch 4801 found it's way into cvs. The new sip.conf option vmexten= sets the "Message-Account" in the MWI notify. This also needs a correct fromdomain= setting in the general section of sip.conf in order to work correctly. See also this posting about Asterisk 1.2 and SNOM MWI (in German).

Trixbox/Asterisk@home

These notes are applicable to Asterisk@home 2.8 and Trixbox 1.x and should apply to most Snom phones, but have been specifically tested with the Snom 190 and 320.

1. Edit the file /etc/asterisk/extensions_custom.conf
Add a line to this file under the section [from-internal-custom] as shown. Note that the lines at the top of your [from-internal-custom] may differ from those shown below.

[from-internal-custom]
include => custom-speed-dial
;The line below enables MWI for Snom
exten => asterisk,1,VoiceMailMain(${CALLERIDNUM})
...rest of file...

2. Once you have made and saved your changes, restart your Asterisk system (eg: amportal restart) and reboot your phone.
3. If your MWI still does not work, make sure that your sip.conf file has the following entry in the [general] section:

vmexten = *97

If you need to add the above line, remember to restart your asterisk system afterwards.

NB: Some Asterisk@Home/Trixbox users have reported that some phones still do not react to the MWI notification until you select the applicable extension in FreePBX, make a change to one of the voicemail settings for the extension (eg: change 'Play CID' from 'no' to 'yes'), click submit and then click the red banner at the top of the web page to apply the change. Once this has been done you can undo the change you just made, click submit and the red banner again.


DTMF Mode

If you are having difficulties with your SNOM hardware phone detecting tones that are entered from the keypad, try setting the DTMF Mode to rfc2833 in your sip.conf:

dtmfmode=rfc2833

New in firmware 5.x: Support for dtmfmode=info (SIP Info)

The SNOM software phone (firmware 3.60j) however only appears to support dtmfmode=inband, which means that you can only apply g711 (A-law or ulaw) if you'd like to have working DTMF detection.

If you find you cannot login to voicemail (always getting 'login incorrect' even though you know you are using the right code), make sure that the following settings are correct on your phone (checked on a Snom 190). These settings are from the Snom Wiki on Asterisk Interoperability:

  • Call Completion OFF
  • Use user=phone: OFF
  • Filter packets from Registrar: OFF
  • Challenge Response on Phone: OFF

NAT Traversal

Snom phones used to have good features for NAT traversal, but since the advent of the SNOM 190, this has been deteriorating. THe snom2xx phones still have those features, since the firmware revisions are lagging behind current development. In the snom190 and the new 360/320 UPnP has been removed.
STUN support has finally been fixed for both 190 (version 3.60s) and 320/360 (version 4.1) phones. For these versions STUN can now be configured separately for each registration account (line). Previously, the STUN setting was a phone global setting only, and if the phone used a remote provider and a local PBX, the phone would try to hairpin SIP and RTP through the external NAT address, usually resulting in failed connections with most routers, or very inefficient routing in others.
All phones also claim ICE support, but this is not available for Asterisk.

For a tutorial on the problems with SIP and NAT, have a look here

SNOM SUBSCRIBE/NOTIFY support for monitoring extension states

You can bind the function keys on SNOM 190, 200, 220, 300, 320 or 360 phone to the extension state of any extension in your dial plan to monitor its status. This turns on the LEDs in case of an active call on those monitored extensions.
In your dial plan insert extra extension lines for the monitored extensions with the priority set to "hint":

exten = 2000,hint,Phone/phone0
exten = 2200,hint,SIP/2200
exten = 2300,hint,MGCP/aaln/1@mygw

NOTE: You must use the above syntax, id est, constant strings for the device and extension definitions. Dialplan variable constructs, such as SIP/${EXTEN}, make no sense here.
Update: Asterisk 1.2.x might now also permit variables here; see Asterisk standard extensions

In addition to this you probably (Asterisk 1.0.x or Asterisk 1.1 and later?) also need to define the subscription context in sip.conf for the subscriber (not for the channel that is to be monitored):

subscribecontext=from-sip

where "from-sip" needs to be replaced with the context that contains the target channel that you (the subscriber) are interested in. This is a security measure to disallow any SIP user to be able to subscribe to any other SIP peer. By the way, specifying an empty subscribecontext is also fine if the phone should not at all subscribe to _any_ context.

Then set the function key definitions in the SNOM phone web page to the DESTINATION (renamed in firmware 6.x to EXTENSION) setting and enter the extension you want to monitor in the field provided and save your settings. After saving, the field will change to a full SIP URI, something like <sip:2000@server.com>
If, however, you don't want the phone to subscribe while having a DESTINATION button defined, you can either set the subscribecontext to an empty context, or - which is better - simply use the new button type "SPEED DIAL" of firmware 6.x (5.x?).

Tip: If you don't want the LED to light up when a dynamic peer is totally off-line (not just busy), then insert a "defaultip=xx.xx.xx.xx" after your "host=dynamic" statement for the peer/friend in sip.conf.

Note: Usually you will have to reboot the phone to refresh the subscriptions (or wait for automatic refresh) after changing the function key definitions or restarting Asterisk, since the SUBSCRIBE support in Asterisk is not complete. Apparently also hyphens "-" in the SIP username break hint/SUBSCRIPTION.

Note: Asterisk 1.0.9 (and some earlier versions) contains a bug the effectively disables subscriptions for phones with multiple regististrations in place. When processing a "nonce response" as a result to an 407 authentication request Asterisk reports "Found peer YYY" even though it should look at peer XXX to compare user credentials. Consequently a NOTICE is displayed with "Failed to authenticate user ... for SUBSCRIBE" (YYY and XXX share the same IP and port, only the user name differs). See bug 5103

Note: Apparently, the Call completion feature of the SNOM 360 interferes with subscriptions to Asterisk. Call completion also uses subscriptions to monitor the called peers state, which Asterisk misunderstands. As soon as a subscribed extension is dialed from the SNOM 360, Asterisk ends the subscription (stating timeout). I experienced this with a SNOM 360 w/ firmware 6.3 and Asterisk 1.2.9.1-BRIstuffed-0.3.0-PRE-1r (davidded).

New in Asterisk v1.2:
  • set "notifyringing=yes" in sip.conf if you'd also like to see the RINGING state to be notified
  • "incominglimit" was renamed to "call-limit"

Call-pickup for blinking buttons


New in Asterisk 1.6.2: Added support for SUBSCRIBE/NOTIFY with dialog-info based call pickups. Snom phones use this for call pickup of extensions that the phone is subscribed to.

Call Pickup & TakeOver (Steal)

New in firmware 6.5: Add these phone settings for a tighter control on SIP subscriptions:

subscription_delay&: 5
subscription_expiry&: 300

New in firmware 6.5.12: "Added call pickup via access code on programmable function keys e.g. ext@dmn.org|*68"
This means the SNOM will dial *68ext@dmn.org upon pressing on a blinking button; the *68 can then easily be recognised and dealt with in the Asterisk dialplan, for example together with the Pickup command.

New in firmware 7.1.33: The button type "BLF" has been added, and this needs to be selected in order for pick-up to work with an upatched Asterisk (1.2 and/or 1.4?), i.e. if you don't work with the bristuff patches. The SNOM wiki has more details and recipies for Asterisk 1.2 and 1.4.

More recent patches & discussion here (German web forum).

For those who are interested in picking up the call by hitting the blinking button: Please use the most recent patch supplied with bug 5014 or look at the bristuff patches (see above).

app_bridge: See bug/patch 5841 - this is quite similar to the bristuff app_steal and could be used to "steal" a certain channel upon pressing a SNOM destination button that has its LED fully lit. Don't confuse this with a pickup of a ringing channel, though. See also ChannelRedirect in Asterisk 1.4.
New in Asterisk 1.4: app_ManagerRedirect: Break a bridged call and send called party to some context|exten|priority; see example here



Transfer and adjusting Caller ID display

With the help of SIP INFO message the Caller ID can be changed in order for the final recipient (C) of the call to see the original Caller ID of (A). See also this post (in German) about a patch for bristuff.

Asterisk 1.8

Asterisk 1.8 comes with P-Asserted-Identity support (see 'pai' argument to the sendrpid setting).
See also Asterisk func CONNECTEDLINE.

Parking Lot Status / Access from the Programmable Buttons / LEDs - Asterisk 1.2.x


You can patch 1.2.x versions of Asterisk (see below for later versions) with the "metermaid patch" so that the programmable buttons / LEDs show the status of parking slots (LED on = parked call, off = no parked call). Pressing the button next to a lit LED connects to that parked call. This is handy for juggling calls in a small office (as an alternative to key systems), or for people who move around between different phones frequently.

Here are the steps to implement this function:

  • For Asterisk 1.2.7.1 - 1.2.15 download the metermaid-1.2.7.1.txt patch from bug/patch 5779 (see http://www.asterisk.org/node/97 for later versions).
  • In the asterisk source directory, run "patch -p0 < metermaid-1.2.7.1.txt"
  • Run "make clean; make install"
  • In your extensions.conf, add something like:

exten => 701,1,ParkedCall(701)
exten => 701,hint,Local/701@parkedcalls

exten => 702,1,ParkedCall(702)
exten => 702,hint,Local/702@parkedcalls

.. etc ..

  • Do not use "include => parkedcalls". You need to add the extensions manually, so that they exist when the phone subscribes to them. Don't use the "parkhints" feature in features.conf either; add the hints manually as above. Remember that macros don't work for hints, for some reason or other.
  • Set up one programmable phone button as "Park Orbit", with sip address 700.
  • Set up other programmable phone buttons as "destinations", with sip addresses 701, 702, 703 ... (as many as desired).
  • Answer a call.
  • Park the call by pressing the park orbit button that you assigned. Hangup.
  • The "701" button light will light up (continuously, not flashing).
  • Retrieve the parked call by pressing the 701 button, and resume talking. The light stays on until you finish talking.

(NOTE: either the newest kernel version from snom, 'Linux 3.25', or the latest firmware version, 6.5.2, seems to break metermaid parking to some extent. On the phone that uses the "Park Orbit" button, the lamp corresponding to the spot you just used may stay lit after the channel hangs up. The only solution seems to be to reboot the phone. Setting the park extension (700), as a regular extension (as opposed to 'park orbit') takes a few extra button-strokes, but the parker will know what extension the parkee is going to. Conversely, if two people hit the "park orbit" button at the same time, there will be no way of knowing which call went where.)

This has been tested with Snom 360 phones, and to a lesser extent, Snom 200 phones.

Parking Lot Status / Access from the Programmable Buttons / LEDs - Asterisk 1.4.x


Asterisk 1.4.x has the metermaid functionality built-in, allowing programmable buttons / LEDs to show the status of parking slots (LED on = parked call, off = no parked call). Pressing the button next to a lit LED connects to that parked call. This is handy for juggling calls in a small office (as an alternative to key systems), or for people who move around between different phones frequently.

Here are the steps to implement this function:

  • In your extensions.conf, add something like:

include => parkedcalls

exten => 701,1,ParkedCall(701)
exten => 701,hint,park:701@parkedcalls

exten => 702,1,ParkedCall(702)
exten => 702,hint,park:702@parkedcalls

.. etc ..

Note that the syntax is subtly different than for 1.2.x - the "Local/701" is replaced with "park:701". Also, note that "include => parkedcalls" must be added to the dial plan, as shown above. This is also different from 1.2.x.

  • Set up one programmable phone button as "Park Orbit", with sip address 700.
  • Set up other programmable phone buttons as "destinations", with sip addresses 701, 702, 703 ... (as many as desired).
  • Answer a call.
  • Park the call by pressing the park orbit button that you assigned. Hangup.
  • The "701" button light will light up (continuously, not flashing).
  • Retrieve the parked call by pressing the 701 button, and resume talking. The light stays on until you finish talking.

I (mjc@avtechpulse.com) have this working on 1.4.11, with Snom 360 phones (firmware 6.5.6).


New SNOM-related features in Bristuff:

  • 0.3.0-PRE-1c
    • fixed callerid support for extension states (for snom firmware version 4). The handling of the callerid in 1.2.0 has changed when using app_dial. To retain the old 1.0.10 behaviour (needed for the extension states to work) you have to use the "o" option for app_dial (see "show application dial"):
  • 0.3.0-PRE-1b
    • "One Touch Record" support for the "Record" key on the SNOM 3XX. You have to enable the "automon" feature in features.conf and use the app_dial options "W" or "w" (see "show application dial"). See also this related patch 4845 (not part of Asterisk)
    • SIPNotify manager command, e.g.:
Action: SIPNotify
Peer: my_snom_peer
Type: reboot-snom
  • Bristuff 0.2.0-RC8q
    • callerid support for extension states (useful for snoms version 4 firmware)
    • chan_sip fix for attended xfers (thanks to friendly help provided by snom)
  • The Bristuff patches 0.2.0-RC8k for Asterisk 1.0.9 come with the following enhancement (that is already implemented in a similar fashion in Asterisk 1.2.x and newer):
    • chan_sip fix to make SNOM leds blink when ringing

This is also discussed in this web forum thread (German), including the feature "call pickup of blinking buttons with bristuff". You will need

exten => _*8.,1,PickUpChan(SIP/${EXTEN:2})

and features.conf with *8 configured for call-pickup in order for this to work; and of couse this Wiki has more info on PickUpChan.


Manipulating the button LEDs (BLF)

You should read this article from snom, to ensure that your BLF subscriptions are set correctly http://wiki.snom.com/Features/Extension_Monitoring#Configuration

app_devstate

If you'd like to implement more advanced features where specific features/states of Asterisk determine the LED status then you will want to take a look at app_devstate (which is part of the bristuff patches).
However, there is also a stand-alone patch of app_devstate that does not require the comprehensive bristuff patches (related instructions in German).
Patch for Asterisk 1.2 and here | Patch for Asterisk 1.4
Update: For Asterisk 1.4 there is now a backported patch available for func_devstate (note the change from application to function). Asterisk 1.6 has the function DEVSTATE now on-board by default.

Example 1 taken from IP-Phone-Forum:

This snippet is designed for two phones, home and work: The home phone can be set to DND using a BLF button that is made available on both phones, i.e. work and home. Therefore the work phone can "see" wether the home phone is on DND or not and toggle this setting. Desired side effect: The home phone shall include all calls in the "missed calls" list even when set to DND.

exten => MSN,1,Dial,SIP/10&SIP/11&SIP/12
...
exten => 920,hint,DS/920
exten => 920,1,Set(HOME=${DB(home/status)})
exten => 920,2,GotoIf($[ ${HOME} = 1 ]?10:20)

exten => 920,10(donotdisturb),Set(DB(home/status)=2)
exten => 920,11,DevState(920,0)
exten => 920,12,TrySystem(wget -qb -O /dev/null -o /dev/null http://[login]:[passwd]@[Telefon-IP]/dummy.htm?settings=save&dnd_mode=on")
exten => 920,13,playback,home-inaktiv
exten => 920,14,HangUp()

exten => 920,20(available),Set(DB(home/status)=1)
exten => 920,21,DevState(920,2)
exten => 920,22,TrySystem(wget -qb -O /dev/null -o /dev/null "http://[login]:[passwd]@[Telefon-IP]/dummy.htm?settings=save&dnd_mode=off")
exten => 920,23,playback,home-aktiv
exten => 920,24,HangUp()

Example 2: Use LED to show queue login status of an agent

Look at this post (in German), requires bristuff'ed Asterisk 1.2 or 1.4, or this: http://maug.com.my/wordpress/?p=59 which makes a lot more sense in English (works fine with Asterisk 1.6).

Example 3: Use LED and button as a "Night Service" button, in Asterisk 1.6 and AEL http://www.voip-info.org/wiki/view/Asterisk+day+night+mode+example


func_devstate

New: While Asterisk 1.6 will include func_devstate natively there is now also a backport available for 1.4 (direct link). This is quite similar to app_devstate as part of the bristuff patches (see above).

See also: Asterisk Standard Extensions

Direct BLF manipulation (without 'hint')

Q: Is there a way to control the LED buttons without using Asterisk hints?
A: Yes, starting with SNOM firmware 7 this can be done as described here. See here for a full featured example - in german language.

Example using SIPSAK:

MESSAGE sip0016@192.168.XXX.XXX;transport=udp SIP/2.0
Via: SIP/2.0/UDP 192.168.XXX.XXX:1036;branch=z9hG4bK-6fa3b6d82ceb544b5912c20f0dba8efc;rport
From: sip:sipsak@192.168.XXX.XXX:1036;tag=38473
To: sip0016@192.168.XXX.XXX
Call-ID: 6algjorv@test
CSeq: 59620 MESSAGE
Max-Forwards: 70
Contact: <sip0016@192.168.XXX.XXX;transport=udp>
Subject: buttons
Content-Type: application/x-buttons
Content-Length: XXX

k=5
c=on

Make sure that the content length is set correctly (SIPSAK should take care of that by itself); The key type needs to be set to "Button, and the "Number" field of that button needs to correspond to the value of the k= paramter (in this case 5).


Example with SNOM 360

Firmware: snom360-SIP 3.60d

1. Set "Filter Packets from Registrar" to OFF (only newer firmware has this option) otherwise the SNOM phone will respond to subscription status information sent by Asterisk with "FORBIDDEN". This by the way also helps if you use the SNOM behind a SIP-aware firewall.
2. It appears that the subscription request is authenticated with the user credentials that have been entered in LINE 1 (or maybe the first LINE that isn't empty) - for some reason it doesn't matter which of the LINE entries is set as default identity. Update: Firmware 5.0 appears to address and solve this issue.
3. Use the phone's "SIP Trace" feature in the web interface for debugging the SUBSCRIBE messages
4. Issue a "SIP SHOW SUBSCRIPTIONS" on the asterisk CLI to check if asterisk has accepted one or more subscription requests. Use a "SIP SHOW PEER <NAME>" in order to find out which phone-generated "Full contact" header matches the "User" column of the asterisk output.
5. Note that subscriptions are kept in-memory only which means that after a restart asterisk will forget this information and has to wait for the phone to again request subscription.

References: bug 652, bug 3644 and bug 3882






Phone-based redirection/diversion

Related tip: You need to set "pedantic=yes" in sip.conf, otherwise Asterisk won't interpret the %xx escapes that newer snom firmware (7.xx) send for the "#" and "*" keys when they are dialed as part of a number.

Objective: Set one of the SNOM buttons to "F_REDIRECT:12345@domain.com" in order to transfer all calls via the same Asterisk server to a different number, typically a mobile phone. The button's LED informs about redirection on/off.
Problem: Asterisk however reacts too strictly and replies with "482" Loop Detected and stops the call.

Solutions/workarounds

  • Allow SIP spiral calls via patch 7403
  • Check that the destination number can be dialed via your dialplan, if not then you might need promiscredir=yes in sip.conf
  • Workaround: Install SER/OpenSER (a SIP proxy) on the same box and give it its own IP address, then set the SNOM to forward to SER, and then let SER in turn forward to Asterisk (concept untested)
  • Use Local channel with /n option for outgoing transfered calls

Call forwarding with AstDB and call deflection chan_mISDN

IN WORK...

http://{SNOM}/action.htm

http://{SNOM}/dummy.htm?settings=save&action_redirection_on_url=http://{WEBSERVER}/calldeflect.php?user=$active_user&amp;cd={DESTINATION}
http://{SNOM}/dummy.htm?settings=save&action_redirection_off_url=http://{WEBSERVER}/calldeflect.php?user=$active_user&amp;cd=off


calldeflect.php

<?php
if (isset($_GET["user"]) AND isset($_GET["cd"])) {
    if(preg_match("/^[1-9][0-9][0-9]$/", $_GET["user"])) {
        if(preg_match("/^0\d+$/", $_GET["cd"]) OR $_GET["cd"] == "off") {
            if ($_GET["cd"] == "off") {
                exec("sudo asterisk -rx \"database del calldeflect " . $_GET["user"] . "\"");
                exit(0);
            } else {
                exec("sudo asterisk -rx \"database put calldeflect " . $_GET["user"] . " " . $_GET["cd"] . "\"");
                exit(0);
            }
        }
    }
}
?>


extensions.conf

[isdn-extern]
exten => _******XXX,1,Set(cd=${DB(calldeflect/${EXTEN:6})})
exten => _******XXX,n,sipaddheader("Alert-Info:<http://******>\;info=alert-external\;x-line-id=0")
exten => _******XXX,n,GotoIf(${cd}?moh)
exten => _******XXX,n,Dial(SIP/${EXTEN:6},20,tro)
exten => _******XXX,n,Goto(VoiceMailExtern-${DIALSTATUS},1)
exten => _******XXX,n,Hangup()
exten => _******XXX,n(moh),misdn_facility(calldeflect|${cd})



Syncing DND status with Asterisk/Db (possibly also call forwarding status)

On 9/3/07, Russell Brown wrote some stuff on asterisk-users and then edited this section:

I wanted to keep the DND status and display on my snom phones in line with my DND records in my Asterisk database. I wanted this for two reasons a) it makes sense to the user to keep the DND indication on the phone in line with the behavior of the dialplan and b) when routing an incoming PSTN call to a number of Sip Phones having the actual phone in DND makes life easier for my dialplan logic (I can just do Dial(SIP/112&SIP/113&SIP/114 without having to worry about handling such a group call in stdexten).

Here's how I did it.

Firstly, for 360's & 370's (the ones with DND buttons) set the dnd_on_code and dnd_off_code in the Preferences section to send the appropriate DND on/off sequences to match your dialplan (I use *08 for DND on and *09 for DND off to match the key sequences from a pre-existing phone system).

In your dialplan the DND-on code looks something like the following (Note: SNOM_PASSWD is the http password for your snom not the admin one):


exten => *08,1,Answer
exten => *08,n,Set(SipIP=${CUT(SIPURI,@,2)})
exten => *08,n,Set(SipIP=${CUT(SipIP,:,1)})
exten => *08,n,Set(DB(DND/SIP/${SipIP}=1)
; Set DND on the Phone itself
exten => *08,n,TrySystem(wget -qb -O /dev/null -o /dev/null "http://admin:${SNOM_PASSWD}@${SipIP}/dummy.htm?settings=save&dnd_mode=on")
exten => *08,n,playback(do-not-disturb)
exten => *08,n,playback(activated)
exten => *08,n,hangup


This means that a user can dial *08 and the Asterisk Database record for that phone gets set and the phone also goes into, and displays, DND. Likewise pressing DND on the phone sets DND on the phone and updates the Asterisk DB.

I also wanted to be able to control both the Asterisk Database and phone DND settings from a GUI which it talking to the Asterisk Manager interface (and in my case didn't have a network route to the action Snom phone so everything had to be done through the Manager
Interface). Here's how I did that.

In my Dialplan I have:


[setdndon]
exten => _.,1,NoOp(SetDND Routine Called for ${EXTEN})
exten => _.,n,TrySystem(wget -qb -O /dev/null -o /dev/null "http://admin:${SNOM_PASSWD}@${EXTEN}/dummy.htm?settings=save&dnd_mode=on")
exten => _.,n,Set(DB(DND/SIP/${EXTEN}=1)
exten => _.,n,Hangup


...and then my GUI can call this via the Manager Originate action as follows:


Action: Originate
Channel: Local/192.168.1.21@setdndon
Application: NoOp
Data: Hello World


I leave the dnd off functions as an exercise for the reader :-)

Record button

See https://issues.asterisk.org/view.php?id=4845 from 2005 or the bristuff patches/fork of Asterisk.
It appears that in Asterisk 1.6 (which version exactly) this support was added, see also this discussion (in German).

Audio codecs

g726

With firmware 7.3.7 (actually slightly earlier in a firmware that was not released) SNOM changed the payload of the g726 codec so that it should (!?) now be compatible with the standard g726 implementation of Asterisk 1.4. See also "g726nonstandard=yes" and "allow=g726aal2" settings in sip.conf.
Firmwares 7.3.22 and 8.2.5 introduced a packing order option for the RTP settings for either "RFC3551" or "AAL2".

Wideband g722 audio codec

Asterisk 1.4 comes with limited g722 support for 16 kHz audio, it still lacks the ability to transcode. With this backported patch or this possibly more up-to-date patch, however, the SNOM can make full use of this superior voice quality (aka "HD Voice") already in Asterisk 1.4.





Click-to-dial (click2dial)

You would like to be able to click on a phone number in your web browser and have the SNOM dial it, without a PBX in between?


Bookmarklet for Firefox

Create a bookmarklet for Firefox 3.6, then select the phone number on any web page, then click on the bookmarklet (as suggested here in German).

Dials with a pop-up window to adjust the selected number:

javascript:num=window.getSelection();void(num=prompt('Phone number',num));if(num){remSnom=window.open('http://user:pass@snomip/command.htm?number='+escape(num),'snom');remSnom.close();}else{void(0);}

Hang up:

javascript:check=confirm('Hangup call?');if(check==true){remSnom=window.open('http://user:pass@snomip/command.htm?key=cancel','snom');remSnom.close();}else{void(0);}

Intercom and Auto Answer support

The intercom feature is now working again in firmware version 3.56q and higher and there is now a setting to enable or disable this feature on the receiving phone. The phone will always challenge the INVITE request to the intercom. For requests to pass authentication, the phone needs to be configured such that it uses the realm="snom" parameter in the digest challenge.

There are several "hacks" on the net that have attempted to make this work with Asterisk.
  • Nov 05: For Asterisk v1.2.x use SIPAddHeader(Call-Info:<sip:domain>\;answer-after=0). See also app_page or the SNOM Wiki.
  • Post Aug. 04 on Asterisk Mailing List
Except use:
exten => 10,1,SetVar(_VXML_URL=intercom=true)

this alone doesn't work
For those who want a patch that doesn't affect VXML_URL, get it here.
The syntax is (before the dial):

exten => 10,1,SetVar(_INTERCOM=true)

The "intercom=true" should persist across authentication requests, but the phone will always reject the authentication regardless. Perhaps the digest or password are incorrect?
yes, see above

Please note, there seems to be a bug with the Call Waiting Indication feature on the Snom360 and Intercom support. Even with Call Waiting deactivated within Asterisk, if you page an
extension that is currently off the hook, it will light up another line on speaker and will present a dial tone. The only way I have been able to prevent this from occuring is by completely disabling
the Call Waiting Indication. This problem exists in all firmware versions up through 6.2.3. Update: This is fixed for me in the beta v8 firmware.

Note that later versions of the Snom firmware implement a setting 'answer_after_policy' and that this is defaulted to 'off'. In order to enable auto answering for paging, this must be configured to 'idle' or 'always'. This setting is also available through the 'advanced'-->'behaviour'-->'Intercom policy' option on the web GUI.

Related: Multicast app_rtppage (Asterisk 1.6 or later, backport for Asterisk 1.4)

Patch 11797 contains the application RTPPage() that can page multicast capable receivers (e.g. Snom, Linksys, Cisco, Barix devices); app_rtpstream reads the input channel's voice frames and does rtp stream them to either unicast or multicast addresses defined as groups in the config file.

In Asterisk 1.8 look out for the new channel type MulticastRTP (that is the "technology" to be used with Dial).

Attention: Make sure you have your IP routing set up correctly! Check with "route -n" so that you do not try to stream out to the Internet instead of to the LAN. Something like "route add 239.255.1.1 dev eth1" might help - but that of course depends on your system setup.

Using VLC 0.9.9 to stream directly to a SNOM:


vlc.exe "ulaw_audiofile.wav" --sout "#transcode{acodec=ulaw,ab=64,scale=1,channels=1,ar=8000}:rtp{dst=239.255.1.1,port-audio=1234}"

Make sure you have enabled the multicast setting in the SNOM phone accordingly for ip 239.255.1.1 port 1234. You will see "PA" in the status line of the phone's display (at least on a snom 370) when a stream is detected. Incoming or outgoing calls interrupt the streaming. Note that you cannot control the volume of the stream from the phone (fw 7.3.14), so be careful with what you send, or else you will cause distortions. The SNOM will play the sound via the speaker even if headset operation is set to ON. Both ulaw and alaw work; In VLC 1.0 or later G.726 is "g726", and it supports 16, 24, 32 and 64 kbps variants through libavcodec, so that might also work for the SNOM phone.
Note: There is a console-only version of VLC called cvlc (Gentoo: Compile VLC with USE="-svg" to avoid all X related dependencies); on Windows you can call this with "vlc.exe -I dummy"
Instead of VLC you might also be able to use MAST (use something like "mast_filecast -p PCMU -z 300 ..." for 20ms u-law packets) or rtpsend or rtpspy or rtpsend-pcmu.pl.

See also





Voice encryption

OpenVPN

Those phones with a larger memory (snom 370, 820, 870) can be loaded with an OpenVPN-enabled firmware that smoothly solves NAT and traffic encryption issues at the same time: No need to configure an unkown SoHo router for SIP/RTP passthru! Also secure XML access to a web server is provided by employing OpenVPN. If desired the LAN switch on those phones can be used to provide a VPN tunnel to a connected PC. See also: Asterisk encryption

RTP Encryption on Snom 360 / v5.3.6

I found that after upgrading from v4.3 to 5.3.6 on the SNOM 360 (and using Asterisk 1.2.4), that I had to set Line 1 > RTP > RTP Encryption to "off". Otherwise, I could make one successful outgoing call after a reboot, but subsequent calls would just hang. Other than that, the default settings appear to work fine with Asterisk.

See also: Asterisk encryption


Rebooting a SNOM 360/320

You could send a sip notify via asterisk and set that up via cron to happen once per day.
Make sure that the reboot-snom clause is setup in sip_notify.conf (ref. bug 3231 and 3243) before attempting this. The reboot action must be allowed in Snom's configuration (challenge_reboot).

asterisk -rx "sip notify reboot-snom <sip peername the snom is at>

Background details: You can send a NOTIFY with 'Event: reboot' to the phone.

Here is a simple perl script, suitable for crontab use, that will reboot all of your Snom phones (assuming that your Snom phones are listed in sip.conf, with "type=friend"):

#!/usr/bin/perl
$sip_conf_file = "/etc/asterisk/sip.conf";
open (CONF,$sip_conf_file);
while (<CONF>)
        {
        $line_in = $_;
        if ($line_in =~ /\[(.*)\]/)
                {
                $current_name = $1;
                }
        if ($line_in =~ /type\s*\=\s*friend/)
                {
                print "rebooting $current_name\n\r";
                `/usr/sbin/asterisk -rx "sip notify reboot-snom $current_name"`;
                }
        }
close CONF;

Lock-up issue

Not sure if this will help you identify the lock-ups (regardless of v6.2.2 or v6.2.3 same results) I have found that issuing a, sip notify reboot-snom <extension number> causes the phone to go into a weird state - which could almost be defined as a lock-up state, and the only way to reset it is to remove power.
After modifying the sip_notify.conf file, from originally

[reboot-snom]
Event=>reboot
Content-Length=>0

to the following (don't forget to do a sip reload),

[reboot-snom]
Event=>check-sync;reboot=false
Content-Length=>0

then re-issued a sip notify reboot-snom <extension number> the phone reboots fine.

SNOM Dialplan

SNOM has a whitepaper that covers this topic.
To setup the SNOM phone's dialplan, you need at least some familiarity with Regular Expressions. The examples below will almost certainly need to be tweaked for your own installation, but they should give you an idea of how it is done. The critical part here, that I have not seen elsewhere, is that the replacement strings must contain at least "sip:" or the speed dials and address book entries will not work. You can have multiple (supposedly 7) space-separated expressions.

On newer (>=3.60) firmwares, the dialplan strings are set up for each registration line under Setup:Line X:SIP(tab):Dial-Plan String, and in the config file as: user_dp_strX, where X is the registration line number.

Each expression is made up of three parts, delimited by the first character of the expression. For instance, if you have the expression "|a|b|c", the "|" is the delimiter. However, you could just as easily specify the expression "!a!b!c", which would use the "!" character as the delimiter. In the examples below, I use the "|" delimiter.

The first part of the expression is the pattern to match. This is a straight extended Regular Expression. Items within parentheses will be matched to an integer in order, starting with 1, so that you can place them in the replacement section. Common components here are items enclosed in brackets, which match any single character within those brackets, and numbers in braces, which match a multiple, equal to the number in braces, of the previous term. Also useful to note: "^" matches the beginning of a string and "$" matches the end of a string.

The second part of the expression is the replacement string. This contains the characters which will be sent on. You may use letters and numbers here, as well as backslash-identified number labels of the previous section's parenthetically-selected terms. That is, \1 may be used to insert the pattern matched in the first set of parentheses, \2 for the second, etc. They may be inserted in any order. Another substitution to note is \d, which inserts the registrar.

The third part of the expression is for flags. There are only two, from what I saw in the SNOM FAQ:
  • d - The nunber is complete and should be dialed
  • i - Make the pattern matching case insensitive

Now, for the examples:

1) Match 21XX or 22XX (local extensions), and dial them immediately
|^2([12][0-9]{2})$|sip:2\1@\d;user=phone|d

2) Match 1XX
|^1([0-9]{2})$|sip:1\1@\d;user=phone|d

3) Match 4XXXXXXXXX, 6XXXXXXXXX, or 7XXXXXXXXX (a sloppy 10-digit local calling area for Atlanta, GA)
|^([467][0-9]{9})$|sip:\1@\d;user=phone|d

4) Match 411, 611, or 911 and send them to extension "notallowed"
|^([469]11$|sip:notallowed@\d;user=phone|d

5) Match an eleven-digit long distance call, starting with 1
|^1([0-9]{10})$|sip:1\1@\d;user=phone|d

6) A complete example of a dial plan on the Snom 360 for use in the US
user_dp_str1&: |^9*([469]11)$|sip:9\1@\d;phone=yes|d |^9011([0-9]+)$|sip:9011\1@\d;phone=yes|d |^91([0-9]{10})$|sip:91\1@\d;phone=yes|d |^9([2-9]{1}[0-9]{6})$|sip:9\1@\d;phone=yes|d |^1([0-9]{2})$|sip:1\1@\d;user=phone|d
  • Components:
    • this is the identifier for the identity 1 dialplan (user_dp_str1&:)
    • dial 911,611,411
    • dial internationally
    • dial long distance
    • dial local number
    • dial internal extensions (100-199)

Remember, there is only one field in which to put your dial plan, so just pile the ones you need into it, separating each one with a space.


XML Browser

The 6.0 firmware (in unsupported beta state as of April 2006) adds an XML browser to the SNOM 360. With firmware 7 also SNOM 320 and 300 have a XML browser (but without graphics due to their display limitations). The wiki on http://wiki.snom.com/Minibrowser has more details

XML MiniBrowser Emulator

Ciphron released a simple XML MiniBrowser Emulator written in PHP. Screenshot and short infos are located at their blog: http://blog.ciphron.de/2008/06/snom-xml-browser-emulator.html and here: http://www.ciphron.de/de/support/index/downloads.html. Helps a lot while developing XML apps. Of course GPLed. Warning, information currently only in german!

SNOM Idle Image

See SNOM's Wiki for more information
On the snom360 (all firmware versions) you can control the appearance of the idle screen for each line with an XML document. When you select a line to be the active registration, its idle screen XML document, configured in the line's setup page, will be fetch by the phone. This includes such things as a clock face, date, account/line information, and a background image.

The image is expected to be a base64-encoded Windows bitmap (.BMP) file with 1-bit depth. Once set, any other XML object will be placed on top of the image, depending on the coordinates.
Note: Status line and digital clock objects have been added in firmware version 5.

Caller photo on SNOM 370

The SNOM 370 with it's grey scale display supports a customized user picture in 60x78 with 256 colors (5-bits) and encoded as base64. The Asterisk PBX needs to send an additional SIP header using "Call-Info" using SIPAddHeader.
Hint: Make sure to properly escape the required semicolon in front of "purpose=icon" with a backslash when using SIPAddHeader, example:

SIPAddHeader(Call-Info: <http://hostname.com/pics/face-b64.bmp>\;purpose=icon)

Phone book tool (in Python)

Bevuta offers a GPL'd backend for snom 360 phones to query various data sources by using the minibrowser-feature. Expandable with own handler plugins.

Home automation: Sensor and relais integration with ALLNET ALL400x

Sep 2007: ALL4000 and ALL4001 are now compatible with the SNOM XML browser, meaning that the SNOM can be used to display e.g. temperature information or e.g. switch radio controller power outlets on or off.

Video on SNOM 370

Video per XML with reload, resulting in 15 fps (greyscale)


Miscellaneous

Automatic Configuration / Mass Deployment

Snom phones come with very decent support for Mass Deployment/Auto Provisioning meaning they can be configured from a central server. This means you can set up some scripts to generate the phone configuration and the related Asterisk configuration (extensions.conf and sip.conf). An example how do implement this including phonebooks and printed labels for the buttons on the Snom phones can be found at the teenage mutant ninja hero coders blog.

Provisioning tools


Backup tool

There is also a nice shell script made available on net-performer.de that can be used to collectively store the settings of all your snoms, possibly on a regular basis using a CRON job. Find the related discussion here (in German).

Client code

useclientcode=yes in sip.conf: A SNOM specific setting that reads a client code (CMC) sent by the phone (trust X-ClientCode info message). See bug/patch 2521; support for this feature was in Asterisk 1.2 by writing into the CDR userfield.
Description by SNOM: When this setting is turned on, the user is offered a soft key “CMC” during a call; its use sends a code to the server using the INFO message in SIP. This code can later be used for billing or bookkeeping along with the call ID of that call.

Advice of Charge (AOC)

Asterisk 1.8 added the 'snom_aoc_enabled' option to turn on support for sending Advice of Charge messages to snom phones.
This goes along with new Advice-Of-Charge events (AOC-S, AOC-D, and AOC-E) in the new aoc event class.

URL dialing on a Mac (Apple)

See Jon's Dialectic Tool

Outlook Addin for SNOM

http://www.snom.com/download/share/snom-Outlook-Addin.zip

FAQ

Sipsak and SIP MESSAGE

Q: SNOM phones support text messages sent by using the MESSAGE method. How can I get this to work (sometimes referred to as SMS even though GSM-based SMS messaging is not meant here)?
A: Have a look at this FAQ entry, and try the following on a Linux machine to download and install SIPSAK:

cvs -d :pserver:anonymous@cvs.sipsak.berlios.de:/cvsroot/sipsak co sipsak
cd sipsak ./configure make

For sending an SMS:
./sipsak -M -B "test test" -s sip:448@intern.snom.de:5060

For a desktop message (doesn't work on SNOM 360 with firmware 3.60r - what does "desktop" do?):
./sipsak -M -O desktop -B "test test" -s sip:444@intern.snom.de
/usr/local/bin/sipsak -M -O desktop -B "MESSAGE HERE" -r 5060 -s sip:phone@192.168.1.10

To remove the desktop message simply send an empty message:
./sipsak -M -O desktop -B "" -s sip:444@intern.snom.de

If you have a firmware with XML NOTIFY support and this feature has been enabled:
./sipsak -O ID -l 1036 -i -vvv -f notify.txt -s sip:ABC@192.168.X.Y

How to get this working:
  • Important: The message can only be seen if a) the identity the text was sent is the currently active one of the phone; with firmware 7.x a SNOM 360/370 will show a SIP MESSAGE directly in the status bar = no blinking "Message LED" and no need to press the associated button.
  • Starting with firmware 6.0.5 it is also possible to show special messages for a particular call as long as the Call-Id matches the current call
  • Issue a "SIP show peer <name>" at the Asterisk CLI to find out at which port the phone is listening
  • If necessary (e.g. due to a NAT firewall between sipsak and the phone) use option -H with SIPSAK to specify the originating IP address (e.g. if the SNOM phone tries to reply to 127.0.0.1) and make sure sipsak can receive a reply on the random port it chooses (or on the port that you specify).
  • Make sure that the SNOM has "filter packets from registrar" set to 'off', but be aware: This is a security hole! Only needed if you intend to send message from a different IP than that of Asterisk.
  • You might need to turn off "GRUU" support in the SNOM
  • Look at the setting "Clear Desktop Message On Cancel" if you would like the user to be able to remove the message from the status line manually (introduced with firmware 6.2.2)
Use -vvv for more verbose output of SIPSAK to permit debugging and look into the SIP logging of the SNOM as well.

Question: Does "desktop" refer to a push-type message that is immediately displayed on the screen?

Notes:
  • SIPSAK doesn't scale well, meaning that you might get into trouble adressing 30+ phones at the same time. You could, for example, use PERL and IO::Socket instead, or this PHP SIP class.
  • Asterisk doesn't support receiving the MESSAGE method (but it does support sending!) so you'll need to point sipsak directly to your phone.
  • A simple method using Asterisk and not SIPSAK: Asterisk cmd sendtext
  • For a Windows Messenger guide see also: http://www.snom.com/whitepapers/FAQ-02-08-29-cs.pdf

Alternative approach using http:
Set an alias on the phone for the first identity rather than simply sending a message to the phone. This means that whenever the phone would have displayed it's extension number or name, it would display the string we'd set instead. We use this for roaming extensions rather than agents. How you obtain the IP address of the phone very much depends on your own install - be it via sip.conf, AstDB or RealTime.

exten => s,n,TrySystem(wget -qb -O /dev/null -o /dev/null "http://${new_ipaddr}/dummy.htm?settings=save&user_idle_text1=${ARG1}+(Roam)")

Encryption: TLS and SRTP

Q: Where can I find more information on TLS and SRTP _encryption_ in the snom 190? How do I configure a key for the phone itself, CA certificates for SIP peers etc.?
A: On the snom190, the SRTP keys are generated randomly for each call. We use 128-bit AES for SRTP which is the de facto standard for this protocol. These are the links for the RFCs: http://www.faqs.org/rfcs/rfc3711.html (SRTP) http://www.faqs.org/rfcs/rfc3686.html (AES-CM)

We use Advanced Encryption Standard (AES) in counter mode with 128-bit keys for encrypting the RTP payload. On the snom190, every SIP line has a setting for "RTP Encryption". If this setting is "on", a base64-encrypted "master key" and "salt" are passed on in an extension header "k:" in the SDP of the INVITE. The key and salt are used to generate the actual session keys for SRTP and SRTCP. You can find references in the RFCs as to how these keys are calculated. The counter mode generates a key stream for each outgoing RTP packet, XORs the RTP data with the key stream, thus creating the cipher payload. The receiving side also generates the same key stream for the received packet, XORs it with the cipher payload to get the original RTP data. For TLS or SIPS, the phone acts as a client. The server/proxy sends the certificate, not the phone. This certificate contains the public key of the proxy server which the phone uses for encryption. The certificate loading option that you see on the web interface is only for the web server of the phone. Technically speaking SRTP doesn't make sense without having a TLS based signalling connection. However, the media is still secure even if SRTP is used without TLS. The master key sent in the INVITE is not used as such but is instead used to generate the actual SRTP encryption keys via AES. These keys are then used to encrypt the RTP. For a completely secure call, SRTP can be used in conjunction with a TLS signalling connection. At present, the display of the snom190 does not show whether or not the call is secure. As far as TLS or SIPS is concerned, the phone sets up a TLS connection to the proxy server, and keeps it up for the duration of the registration. This connection is used persistently for incoming as well as outgoing calls. Right now we don't have CA list for trusted authorities but we will be adding it in the future.


STEP BY STEP setup for asterisk and the Snom 100 version B with firmware SIP2.04e

Replace 10.0.0.7 with the ip your phone displays when booting

Upgrade your firmware:
http://10.0.0.7/set_operator_en.htm
Bootloader: http://www.snom.com/download/snom100-boot1.9.bin
Firmware: http://www.snom.com/download/snom100-2.04e-SIP.bin
Click the load button, unit will reboot asking if you want to upgrade.

Erase old settings and verify firmware:
http://10.0.0.7/set_base_en.htm
Phone type: snom100-SIP
Version: snom100-SIP 2.04e
Bootloader URL: http://www.snom.com/download/snom100-boot1.9.bin
Firmware URL: http://www.snom.com/download/snom100-2.04e-SIP.bin
Click reset then reboot or use links
http://10.0.0.7/set_base_en.htm?reset=Reset
http://10.0.0.7/set_base_en.htm?reboot=Reboot
As phone boots, select Language and Time Zone using keys on phone

Program new settings:
http://10.0.0.7/set_sip_auth_en.htm
Line: 1
Realm: your-asterisk-hostname-here
Username: your-username-here
Password: your-password-here
SAVE
http://10.0.0.7/set_sip_lines_en.htm
Name: 9876543210
Account: your-username-here
Registrar: your-asterisk-hostname-here
Expiry: 1 min
SAVE
http://10.0.0.7/set_base_en.htm?reboot=Reboot

edit asterisk sip.conf
[your-username-here]
callerid="Your Name" <9876543210>
type=friend
nat=yes
secret=your-password-here
context=default
host=dynamic
qualify=yes







PHP script for xml directory under AMP/freepbx


This works on an AMP box, looking up the extensions from mysql. It should work with freepbx as well
and be easily customised for your database and schema if you are using something else.

  • Save this file onto a php/apache accessible directory somewhere that can log into mysql.
  • customise it for you databse details etc.
  • check you can view it with a web browser.
  • use the Snom 360 web interface to assign one of the programmable buttons with this URL




<?php header('Content-type: text/xml');
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
print "<SnomIPPhoneDirectory>\n";
print "<Title>Phone directory</Title>\n";
print "<Prompt>Prompt</Prompt>\n";


require_once('DB.php'); //PEAR must be installed

$db_user = 'asteriskuser'; 
$db_pass = 'amp109';
$db_host = 'localhost';
$db_name = 'asterisk';
$db_engine = 'mysql';

$datasource = $db_engine.'://'.$db_user.':'.$db_pass.'@'.$db_host.'/'.$db_name;

/* datasource in in this style:

dbengine://username:password@host/database */

$db = DB::connect($datasource); // attempt connection

// if connection failed show error
// don't worry about this for now, we get to it in the errors section
if(DB::isError($db)) {
        die($db->getDebugInfo());
}

$sql='Select extension,name from users  where name not like \'%test%\'  order by name';

$results = $db->getAll($sql);
foreach($results as $result){
                print "<DirectoryEntry>\n\t\t\t<Name>" . $result[1]. "</Name>\n";
                print "\t\t\t<Telephone>".$result[0]."</Telephone>\n\t\t\t</DirectoryEntry>";
}
print "</SnomIPPhoneDirectory>";

?>



Another example of how to do a Directory, but using the extensions in the voicemail.conf




#! /usr/bin/perl

open DIR,"</etc/asterisk/voicemail.conf";
while (<DIR>) {
        chomp;
        $_ =~ m/^[0-9]{3}/ && do {
                ($ext,$data) = split(/[ ]+\=\>[ ]+/,$_);
                ($pw,$name,$email,$other) = split(/,/,$data);
                ($first,$last)=split(/[ ]+/,$name);
                $dir{"$last$first"}=[$first,$last,$ext];
        };
}


print "Content-type: text/xml\n\n";
print '<?xml version="1.0" encoding="UTF-8" ?>
 <SnomIPPhoneDirectory>
  <Title>Directory</Title>
  <Prompt>Dial</Prompt>
';

for $key (sort keys %dir) {
        ($first,$last,$ext)=@{$dir{$key}};
print "<DirectoryEntry>
  <Name>$first $last</Name>
  <Telephone>$ext</Telephone>
  </DirectoryEntry>
";
}


print '
  </SnomIPPhoneDirectory>';




See also



Asterisk | Asterisk Configuration | Channel Configuration | Configuration for Specific Phones

Created by: oej, Last modification: Thu 10 of May, 2012 (19:26 UTC) by admin


Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+

Page Changes | Comments