How to browse throught USSD menu on softphone side (Dongle, GSM)

1,089 views
Skip to first unread message

Pol Isidor

unread,
Apr 5, 2018, 10:33:26 AM4/5/18
to dongle

The problem is that if I execute the command over CLI (Asterisk 13.19):

dongle ussd dongle0 *100#

I got the menu without problem, and if I do again:

dongle ussd dongle0 5

Then I can nicely browse over USSD menu.

The main problem is that if I execute this over my SIP phone (CSIPSimple, Zoiper), the USSD code are sent with command:

exten => _*.,1,DongleSendUSSD(dongle0,${EXTEN})

and I can see in the CLI window, but nothing comming back to my client (Softphone).
What I need to add, change in dialplan to be able to browse USSD menu drom client side?
If some log is need it I will show!
Thx

Alejandro Donato

unread,
Apr 5, 2018, 11:06:18 AM4/5/18
to chan_...@googlegroups.com

Maybe message is truncated, try base64 decode

exten => ussd,n,Set(ussd_multiline=${BASE64_DECODE(${USSD_BASE64})})
        ; USSD text, may be multiline

grab full debug from extension and client to see where USSD dies.

IDK if your SIP client support USSD, but i found a JAVA client that claims it can. Maybe you can give it a try for test purposes only

https://github.com/RestComm/ussdgateway/blob/master/examples/sip/src/main/java/org/mobicents/applications/ussd/examples/sip/SipClientTest.java

good luck

El 05/04/18 a las 11:33, Pol Isidor escribió:
--
You received this message because you are subscribed to the Google Groups "dongle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chan_dongle...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pol Isidor

unread,
Apr 5, 2018, 8:29:24 PM4/5/18
to dongle
Thx for replay:
The full log is:
 > 0xb5e04af8 -- Strict RTP learning after remote address set to: 192.168.xx.xx:4062
   
-- Executing [*797#@dongle-incoming:1] DongleSendUSSD("SIP/usename-0000000f", "dongle0,*797#") in new stack
   
-- Auto fallthrough, channel 'SIP/usename-0000000f' status is 'UNKNOWN'
   
-- [dongle0] Successfully sent USSD 0x7e9fa8
[Apr  6 02:17:42] NOTICE[13504]: at_response.c:266 at_response_ok: [dongle0] Successfully sent USSD 0x7e9fa8
 
[dongle0] Got USSD type 1 'USSD Request': 'mts vodic
 Stanje: 13.6 din. (bez PDV-a)
 Izaberite:
 
 1. Stanje racuna
 2. Roming
 3. Roming DATA dodaci
 4. Nacionalni DATA dodaci
 5. Pripejd dopuna
 6. Usluge
 '

[Apr  6 02:17:44] WARNING[25740][C-00000022]: pbx.c:4416 __ast_pbx_run: Channel 'Local/ussd@dongle-incoming-0000000c;1' sent to invalid extension but no invalid handler: context,exten,priority=dongle-incoming,ussd,1
orangepipc
*CLI>
 and in extension.conf I have:
[dongle-incoming]
; example of ussd receive
exten
=> _*.,1,DongleSendUSSD(dongle0,${EXTEN})
exten
=> _*.,n,Hangup()

In dongle.conf I have:
[defaults]
; now you can set here any not required device settings as template
;   sure you can overwrite in any [device] section this default values

context
=dongle-incoming
...
...


Now, your suggestion to put:

exten => ussd,n,Set(ussd_multiline=${BASE64_DECODE(${USSD_BASE64})})
giving me error:
> 0xb5e04af8 -- Strict RTP learning after remote address set to: 192.168.xx.xx:4064
[Apr  6 02:22:47] WARNING[28028][C-00000023]: func_base64.c:81 base64_helper: Syntax: BASE64_DECODE(<data>) - missing argument!
   
-- Executing [*797#@dongle-incoming:1] Set("SIP/username-00000010", "ussd_multiline=") in new stack
   
-- Auto fallthrough, channel 'SIP/username-00000010' status is 'UNKNOWN'
 I even tried part of code from internet what I found:
exten => ussd,1,Verbose(Incoming USSD: ${BASE64_DECODE(${USSD_BASE64})})
exten
=> ussd,n,System(echo '${STRFTIME(${EPOCH},,%d.%m.%Y %H:%M:%S)} - ${DONGLENAME}: ${BASE64_DECODE(${USSD_BASE64})}' >> /var/log/asterisk/ussd.txt)

exten
=> ussd,n,Set(ussd_multiline=${BASE64_DECODE(${USSD_BASE64})})

exten
=> ussd,n,DongleSendUSSD(dongle0,${EXTEN}
exten
=> ussd,n,Hangup()


but I got:
> 0xb5e04af8 -- Strict RTP learning after remote address set to: 192.168.xx.xx:4066
[Apr  6 02:25:27] NOTICE[13479][C-00000024]: chan_sip.c:26414 handle_request_invite: Call from 'username' (192.168.xx.yy:35350) to extension '*797#' rejected because extension not found in context 'dongle-incoming'.
orangepipc
*CLI>

what is logical couse it isn't definated what is the ussd code what I'm sending.
Do you need mroe log?

I would appreciate any kind of help!

Marco Gaiarin

unread,
Apr 6, 2018, 8:10:12 AM4/6/18
to chan_...@googlegroups.com
Mandi! Pol Isidor
In chel di` si favelave...

> and I can see in the CLI window, but nothing comming back to my client
> (Softphone).

It is normal. There's nothing in dialplan that instruct Asterisk to
send the output of USSD to some extension, in some way...


> What I need to add, change in dialplan to be able to browse USSD menu drom
> client side?

..and worster, there's no a single ''some way''.

Some SIP client (most notably, Gigaset cordless) support ETSI SMS (not
USSD); some other support the standard SIP 'MESSAGE' messaging
protocol:

https://www.voip-info.org/wiki/view/Asterisk+SIP+Messaging

, other support propietary protocols/extensions, some other support
XMPP.


So, to achive what you need you have to:

a) choose a 'messaging' protocol that work in your environemnt

b) build a ''gateway'' between that and your dongle

--
Marco ``Gaio'' Gaiarin | LUG Pordenone (http://pordenone.linux.it)
P.zza S. Tommaso, 20 | Lilliput BBS (http://bbs.lilliput.linux.it)
Cimpello di Fiume Veneto | Azione Cattolica - Concordia-Pordenone
33080 Pordenone (Italia) | (http://www.accanto.org)
Tel. +39-0434-56-1305 | http://www.gaiarin.it/ ga...@linux.it

Pol Isidor

unread,
Apr 8, 2018, 10:04:13 AM4/8/18
to dongle
Thx for helping me but I found the solution:
I did it and it work.
So the main asking of USSD code going through dialpad, and the answer comes as “message” on softphone. All the browsing through the USSD menu continuing through “message” of softphone. I personally using CSIPSimple apk.
Here is mine extension:

extensions.conf

[globals]

[general]
autofallthrough
=yes


[dongle-incoming-sms]
exten
=> sms,1,Set(MESSAGE(body)=${BASE64_DECODE(${SMS_BASE64})})
exten
=> sms,n,Noop(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
exten
=> sms,n,System(echo '${STRFTIME(${EPOCH},,%d.%m.%Y %H:%M:%S)} From: ${CALLERID(num)}: ${BASE64_DECODE(${SMS_BASE64})}' >> /var/log/asterisk/incoming-sms.txt)
exten
=> sms,n,MessageSend(sip:username,"${CALLERID(num)}"<${CALLERID(num)}>)
exten
=> sms,n,NoOp(Send status: ${MESSAGE_SEND_STATUS})
exten
=> sms,n,Hangup()

[dongle-outgoing-sms]
exten
=> _X.,1,NoCDR
exten
=> _X.,n,NoOp(SMS receiving dialplan invoked)
exten
=> _X.,n,NoOp(To ${MESSAGE(to)})
exten
=> _X.,n,NoOp(From ${MESSAGE(from)})
exten
=> _X.,n,NoOp(Body ${MESSAGE(body)})
exten
=> _X.,n,Set(IS_IT_ZERO=${EXTEN:0:1})
exten
=> _X.,n,GotoIf($[${IS_IT_ZERO} = 0]?8:13)
exten
=> _X.,n,Set(CHANGED_NO=$[381${EXTEN:1}])
exten
=> _X.,n,NoOp(Number is:${CHANGED_NO})
exten
=> _X.,n,DongleSendSMS(dongle0,${CHANGED_NO},${MESSAGE(body)},1440,yes)
exten
=> _X.,n,System(echo '${STRFTIME(${EPOCH},,%d.%m.%Y %H:%M:%S)} - To: ${EXTEN} - Message: ${MESSAGE(body)} ' >> /var/log/asterisk/outgoing-sms.txt)
exten
=> _X.,n,Hangup()
exten
=> _X.,n,DongleSendSMS(dongle0,${EXTEN},${MESSAGE(body)},1440,yes)
exten
=> _X.,n,System(echo '${STRFTIME(${EPOCH},,%d.%m.%Y %H:%M:%S)} - To: ${EXTEN} - Message: ${MESSAGE(body)} ' >> /var/log/asterisk/outgoing-sms.txt)
exten
=> _X.,n,Hangup()

[dongle-outgoing-sms-plus-prefix]
exten
=> _+X.,1,NoCDR
exten
=> _+X.,n,NoOp(SMS receiving dialplan invoked)
exten
=> _+X.,n,NoOp(To ${MESSAGE(to)})
exten
=> _+X.,n,NoOp(From ${MESSAGE(from)})
exten
=> _+X.,n,NoOp(Body ${MESSAGE(body)})
;dongle sms dongle0 +XXXXXXXXXX From:+XXXXXXXXXX Msg:testing 123
exten
=> _+X.,n,Set(IS_IT_ZERO=${EXTEN:0:1})
exten
=> _+X.,n,GotoIf("$[${IS_IT_ZERO}" = "+"]?8:12)
exten
=> _+X.,n,Set(CHANGED_NO=$[${EXTEN:1}])
exten
=> _+X.,n,NoOp(Number is:${CHANGED_NO})
exten
=> _+X.,n,DongleSendSMS(dongle0,${CHANGED_NO},${MESSAGE(body)},1440,yes)
exten
=> _+X.,n,System(echo '${STRFTIME(${EPOCH},,%d.%m.%Y %H:%M:%S)} - To: ${EXTEN} - Message: ${MESSAGE(body)} ' >> /var/log/asterisk/outgoing-sms.txt)
exten
=> _+X.,n,Hangup()

[from-gsm]
exten
=> s,1,System(echo '${STRFTIME(${EPOCH},,%d.%m.%Y %H:%M:%S)} - Incoming call from: ${CALLERID(num}' >> /var/log/asterisk/incoming-calls.txt)
exten
=> s,n,Dial(SIP/username)
exten
=> s,n,Hangup()

; This part commuicate over message at softphone side
exten
=> asterisk,1,Answer()
exten
=> asterisk,n,DongleSendUSSD(dongle0,${MESSAGE(body)})
exten
=> asterisk,n,NoOp(Number is:${MESSAGE(body)})
exten
=> asterisk,n,MessageSend(sip:username)
exten
=> asterisk,n,Hangup

include
=> dongle-incoming-sms
include
=> dongle-outgoing-sms
include
=> dongle-incoming-ussd
include
=> dongle-outgoing-sms-plus-prefix


[from-sip-phone]
exten
=> _0[1,2,3,6,800].,1,System(echo '${STRFTIME(${EPOCH},,%d.%m.%Y %H:%M:%S)} - Called Number: ${EXTEN}' >> /var/log/asterisk/outgoing-calls.txt)
exten
=> _0[1,2,3,6,800].,n,Dial(Dongle/dongle0/${EXTEN})
exten
=> _0[1,2,3,6,800].,n,Hangup()

exten
=> _+381[1,2,3,6,800].,1,System(echo '${STRFTIME(${EPOCH},,%d.%m.%Y %H:%M:%S)} - Called Number: ${EXTEN}' >> /var/log/asterisk/outgoing-calls.txt)
exten
=> _+381[1,2,3,6,800].,n,Dial(Dongle/dongle0/${EXTEN}); Svi brojevi koji pocinju sa +381 a sledeci je 1 ili 2 ili 3 ili 6 ili 800 gde tacka oznacava svi ostali brojevi
exten
=> _+381[1,2,3,6,800].,n,Hangup()

; -------------------------------   This part is responsable for sending USSD code from dialpad, and replay creating message on softphone.   ------------------------------------
; Browsing through USSD menu will continue in message part of softphone app
exten
=> _*.,1,DongleSendUSSD(dongle0,${EXTEN})

[dongle-incoming-ussd]
exten
=> ussd,1,Noop(Incoming USSD: ${BASE64_DECODE(${USSD_BASE64})})

exten
=> ussd,n,Set(ussd_multiline=${BASE64_DECODE(${USSD_BASE64})})

exten
=> ussd,n,Set(MESSAGE(body)=${ussd_multiline})
exten
=> ussd,n,MessageSend(sip:username,[username]); Message form is: MessageSend(to,[from])
exten
=> ussd,n,Hangup()
;--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



dongle.conf

[general]

interval
=5            ; Number of seconds between trying to connect to devices

;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
jbenable
= yes
jbforce
= no
jbmaxsize
= 200
jbresyncthreshold
= 1000
jbimpl
= fixed
;jbtargetextra = 40    
;jblog = no
;-----------------------------------------------------------------------------------
[defaults]

group=0                ; calling group
rxgain
=0            ; increase the incoming volume; may be negative
txgain
=0            ; increase the outgoint volume; may be negative
autodeletesms
=yes        ; auto delete incoming sms
resetdongle
=yes            ; reset dongle during initialization with ATZ command
u2diag
=-1            ; set ^U2DIAG parameter on device (0 = disable everything except modem function) ; -1 not use ^U2DIAG command
usecallingpres
=yes        ; use the caller ID presentation or not
callingpres
=allowed_passed_screen ; set caller ID presentation        by default use default network settings
disablesms
=no

language
=en            ; set channel default language
smsaspdu
=yes            ; if 'yes' send SMS in PDU mode, feature implementation incomplete and we strongly recommend say 'yes'
mindtmfgap
=45            ; minimal interval from end of previews DTMF from begining of next in ms
mindtmfduration
=8000        ; minimal DTMF tone duration in ms
mindtmfinterval
=200        ; minimal interval between ends of DTMF of same digits in ms

callwaiting
=auto
disable
=no

initstate
=start

;exten=+xxxxxxxxxxxxx        ; exten for start incoming calls, only in case of Subscriber Number not available!, also set to CALLERID(ndid)

dtmf
=off

; dongle required settings
[dongle0]
audio
=/dev/DONGLE-3G-MODEM-1        ; tty port for audio connection
data
=/dev/DONGLE-3G-MODEM-2            ; tty port for AT commands
context
=from-gsm             ; context for incoming calls

sip.conf:
[general]

dtmfmode
=info
relaxdtmf
=no
alwaysauthreject
=yes

externhost
=my_dns:my_udp_port
localnet
= 192.168.xx.0/255.255.255.0
bindaddrr
=0.0.0.0
bindport
= my_udp_port
tcpbindaddr
=0.0.0.0:my_tcp_port
tcpenable
= yes
externtcpport
= my_tcp_port
transport
=udp,tcp
keepalive
=yes
directmedia
=no
defaultexpiry
= 3600

canreinvite
= no
subscribe_network_change_event
= yes

disallow
= all
allow
= g729
;allow = gsm
;allow = ulaw
;allow = alaw
nat
=force_rport,comedia

textsupport
=yes
accept_outofcall_message
= yes                                                                                                                                  

[username]
context
=from-gsm
outofcall_message_context
=from-gsm
context
=from-sip-phone

host
= dynamic
type
= friend
mailbox
=xxx@default
username
=username
secret
=password
qualifyfreq
=30
busylevel
=1

Marco Gaiarin

unread,
Apr 8, 2018, 3:30:07 PM4/8/18
to chan_...@googlegroups.com
Mandi! Pol Isidor
In chel di` si favelave...

> Thx for helping me but I found the solution:

(From https://www.voip-info.org/wiki/view/Asterisk+cmd+MessageSend)

Asterisk 10 now has protocol independent support for processing text messages outside of a call. Messages are routed through the Asterisk dialplan. SIP MESSAGE and XMPP are currently supported. There are options in jabber.conf and sip.conf to allow enabling these features.

i was not aware of that! Cool!

Thanks!
Reply all
Reply to author
Forward
0 new messages