[asterisk-users] Completing my Configuration

Anselm Martin Hoffmeister anselm at hoffmeister-online.de
Tue Sep 25 02:34:14 CDT 2007


Am Dienstag, den 25.09.2007, 07:37 +0200 schrieb Guenther Sohler:
> Hallo Group,
> 
> I have basically set up a small asterisk system,
> which ahs 4 peers:
> 
> * registers at 2 Sipgates
> * 2 hardware phones connected to it
> 
> Both Hardware phones can phone outwards(cheaper sipgate is selected with dialplan)
> Calls from both sipgates make my hardware phones ring
> 
> But here comes the challenges:
> 
> Is it possible to configure asterisk in such a way that in the phone:
> 
> * there are names instead of numbers in my hardware phone displayed

Depends on the hardware phones. In theory, with each SIP call connecting
to the phone, both a name and a number can be transferred. AFAIK sipgate
defaults to setting both to the usual callerID. That is exactly the
reason why you can set the variables ${CALLERID(num)} and
${CALLERID(name)}.

Some hardware phones (I assume, the better ones ;-) display both; my
Allnet for example seems to only display the name, but store the number
for the "call back" list. My Fritz!Boxen seem to forward both name and
number to ISDN devices on the internal S0-bus, just not many ISDN phones
can actually display text "numbers".

Let your asterisk have an ast database, looking like
callerid/420123456789 => "Doe, John Q."
callerid/492240224922 => "Mustermann, Dr. Peter"

Then you could expand your dialplan logic a little. If you have a line

exten => 12345,4,Dial(SIP/phone1,60)

or whatever that looks like in your SIP-incoming context, insert those
lines before it [and change the "4", "5", "6", "7"s ;-) ]

exten => 12345,4,Set(CALLERID(name)=${DB(callerid/${CALLERID(num)})})
exten => 12345,5,GotoIf($["${CALLERID(name)}" = ""]?6:7)
exten => 12345,6,Set(CALLERID(name)="-- ${CALLERID(num)}")
exten => 12345,7,Dial(SIP/phone1,60)

Line 6 treats the case that the number is not in your database and sets
the callerid-name to "-- NUMBER_OF_CALLER"

You can manually add data to the astdb from the asterisk CLI with

database set callerid 420456789 "Silly, Roger M."

You should check that both your SIP providers provide incoming CLI in
the international formatting, without country prefix or "+". In my
experience some SIP providers send numbers like
492240224922, others send +49... or 0049..., some send national format
02240... for all national calls, some even omit the leading "0" there,
and some just change the behaviour depending from which network (T-Com
landline, Arcor landline, T-Mobile cell phone, O2 cellphone, foreign
callers...) the call originates. If you have more than two providers,
this can be a PITA - you will need some dialplan logic to sanitize the
callerid in those cases, and sometimes you are just left for guessing,
for example when the provider signals calls from T-Mobile as 16177554224
and calls from Boston, MA, USA the very same. Germany does not have
fixed-length numbers, even in the mobile phone networks the length
differs, and the number given might be valid for both circumstances.
</rant>

> * The Ringtone is different for special call numbers 

If your phone supports that, yes, you can do it. The common method for
this seems to be sending an additional header. There will be docs on
"SIPAddHeader(blah)" or similar on www.voip-info.org, and you might want
to also use a database here to find out wether special ringtones are to
be activated or not.

> * it is displayed, in which sipgate the call came from

You could use the CALLERID(name) field for that, by adding the provider
short name in front of the caller's name, like

exten => 12345,4,Set(CALLERID(name)=at-${DB(callerid/${CALLERID(num)})})

for calls via the "at" provider - or whatever seems stylish enough.

I personally have a logic that makes use of the dial-around prefix in
use here in Germany: From a regular T-Com landline you can select the
provider that will carry the next call by dialling 010[1-9]X or 0100XX.
Those prefixes of course do not work on SIP provider lines, and my
asterisk does not have landlines connected. So I use those for my own
purposes, e.g. selecting the SIP account that the call may go out
through. Dialplan logic detects "010XX" (100 possible accounts are
enough, I just ignore 0100XX as additional number field here) and
selects the outgoing provider accordingly.

If I wished to have the incoming line signalled to me, I would prefix
the incoming CALLERID(num) with the provider code. Callbacks would go
through the same line - nice bonus. Most of my phones do not handle text
and number simultaneous display in a reasonable way, so I do not rely on
the text.

> * using an extension in my call number redirects the call just to one
>   sip phone ?

AFAIK you could only do this by Answer()ing the line (at which point the
caller starts paying the connection) and asking the caller to input an
extension. (Hint: "Read()"). I personally do not like this solution at
all, because that is what DID and number block allocation were invented
for. You can get a number block with SIP from some providers. Or you
just get yourself another "private" phone number ;-)

BR,

Anselm




More information about the asterisk-users mailing list