Community discussions

MUM Europe 2020
 
Tedionius
just joined
Topic Author
Posts: 15
Joined: Sat Feb 16, 2019 8:29 pm

Decode USSD response

Thu Apr 25, 2019 3:00 pm

How to decode the USSD response from 3G carrier on wAP LTE kit with r11e antenna?

All answers suggest using the Winbox sms utility but that is not what I want to do. I want to do it via the command window. Can anyone offer a solution?

I have looked at these articles but cannot find the answer:
viewtopic.php?t=129693
https://wiki.mikrotik.com/wiki/Manual:Interface/LTE
https://wiki.mikrotik.com/wiki/Manual:Tools/Sms
viewtopic.php?t=48725

I am able to send a ussd code to Vodacom in South Africa using
/interface lte at-chat lte1 input="AT+CUSD=1,\"*135#\",15" wait=yes
and correctly receive an encoded response.
How can I decode that response in the command window or receive it back already decoded?
 
Tedionius
just joined
Topic Author
Posts: 15
Joined: Sat Feb 16, 2019 8:29 pm

Re: Decode USSD response

Fri Apr 26, 2019 9:27 am

So 37 views at this point and no suggestions. Does this mean that it cannot be done? Should I be looking at a different solution?
 
ctil004
just joined
Posts: 5
Joined: Sun Mar 08, 2015 8:51 am

Re: Decode USSD response

Wed Jul 24, 2019 1:10 pm

I get the same problem with Vodacom South Africa - unreadable output!
However, with MTN it works fine.
This may be an issue specific to the service provider.
My hardware is RB912 with R11e_LTE miniPCI-e card.
 
ctil004
just joined
Posts: 5
Joined: Sun Mar 08, 2015 8:51 am

Re: Decode USSD response

Wed Jul 24, 2019 2:56 pm

Sorry, in my previous post I forgot to mention that the MTN response was obtained using a different router.
That was done with a RB411u routerboard and Sierra 7710 mini PCIe LTE interface (both set to 3G only for this purpose).
When using the MTN SIM on the RB912 routerboard with R11e_LTE interface, I get the same unreadable response as with the Vodacom SIM.
Clearly this is not dependent on the Service Provider.
Both routers are running under RouterOS 6.45.1 (stable) with diitto firmware.
I have not swapped the LTE interfaces, so it could be either the routerboard or the interface...
 
Tedionius
just joined
Topic Author
Posts: 15
Joined: Sat Feb 16, 2019 8:29 pm

Re: Decode USSD response

Fri Aug 02, 2019 11:23 am

Thanks for the reply. I cannot unfortunately confirm whether this is a carrier based issue as I have a Vodacom and a Rain sim card in the Mikrotik and Rain does not provide sms capabilities, only data connectivity.

I suspect that it is carrier based though as I am using a different rig to your setup and experience the same problem.

My setup is RBSXTR routerboard with 6.45.2 firmware, and R11e-LTE modem.

When I send the command, the response from Vodacom is:
output: OK +CUSD: 1,"31292042616c616e6365730a3229204275790a332920416c6c2034205
96f750a3429204a757374203420596f750a3529204d6f7265506f7765720a362920507
26f6d6f730a372920416476616e6365265472616e73666572730a38292053657276696
365730a39292046756e26526577617264730a3130292047657420313025206d6f72650
a31312920496e737572616e63650a2020", 0
 
ctil004
just joined
Posts: 5
Joined: Sun Mar 08, 2015 8:51 am

Re: Decode USSD response  [SOLVED]

Fri Aug 02, 2019 5:53 pm

Yes, thanks for the follow-up. My best guess is the R11e_LTE modem is at fault. Using the Sierra modem the response from Vodacom is:

Aug/02/2019 16:19:18 lte,async,event +COPS: 0,0,"VodaCom-SA",2
Aug/02/2019 16:19:29 lte,async,event +CUSD: 0,"Subscription Airtime is R0.00; data is 4.14 GB; Night Owl 5.23 GB; ; 0 SMS's; ",15

The R11e has the latest firmware installed: MikroTik_CP_2.160.000_v012

Let's hope the next firmware update will include a fix!
 
oceanmaster
newbie
Posts: 25
Joined: Sat Nov 03, 2007 2:29 pm

Re: Decode USSD response

Sat Nov 23, 2019 4:39 pm

New firmware version out 13
 
sindy
Forum Guru
Forum Guru
Posts: 4193
Joined: Mon Dec 04, 2017 9:19 pm

Re: Decode USSD response

Sat Nov 23, 2019 4:58 pm

the response from Vodacom is:
output: OK +CUSD: 1,"31292042616c616e6365730a3229204275790a332920416c6c2034205
96f750a3429204a757374203420596f750a3529204d6f7265506f7765720a362920507
26f6d6f730a372920416476616e6365265472616e73666572730a38292053657276696
365730a39292046756e26526577617264730a3130292047657420313025206d6f72650
a31312920496e737572616e63650a2020", 0
I do realize I'm late to the party, but do you need the Mikrotik itself to understand the USSD response (and maybe take some action based on the contents) or is it sufficient to make it human-readable?

Because the above is merely a hex-encoded ASCII, each pair of symbols 0..9,a..f represents one resulting symbol, so the translation done by any hex->ascii converter is

ascii code

1) Balances
2) Buy
3) All 4 You
4) Just 4 You
5) MorePower
6) Promos
7) Advance&Transfers
8) Services
9) Fun&Rewards
10) Get 10% more
11) Insurance
Instead of writing novels, post /export hide-sensitive. Use find&replace in your favourite text editor to systematically replace all occurrences of each public IP address potentially identifying you by a distinctive pattern such as my.public.ip.1.
 
Tedionius
just joined
Topic Author
Posts: 15
Joined: Sat Feb 16, 2019 8:29 pm

Re: Decode USSD response

Wed Nov 27, 2019 9:15 am

... do you need the Mikrotik itself to understand the USSD response (and maybe take some action based on the contents) or is it sufficient to make it human-readable?
I actually need both functions:
1. The Mik needs to understand the code to be able to respond to USSD message keywords correctly
2. The message contents need to be written to a log in human-readable form

Thanks for the pointer on the encoded ASCII, SIndy. Will see where that leads me in terms of a solution. Will also test with upgrade as Oceanmaster suggested.
 
sindy
Forum Guru
Forum Guru
Posts: 4193
Joined: Mon Dec 04, 2017 9:19 pm

Re: Decode USSD response

Wed Nov 27, 2019 10:37 am

There is no embedded hex->char conversion in RouterOS scripting, so the following may inspire you:
local asciitable {"20"=" ";"21"="!";"22"="\""} ; put ($asciitable->"21")
You may save some CPU time through storing the translation table as a global variable just once at startup.
Instead of writing novels, post /export hide-sensitive. Use find&replace in your favourite text editor to systematically replace all occurrences of each public IP address potentially identifying you by a distinctive pattern such as my.public.ip.1.
 
ctil004
just joined
Posts: 5
Joined: Sun Mar 08, 2015 8:51 am

Re: Decode USSD response

Wed Nov 27, 2019 11:25 am

Thanks for the tip!

Using the R11e-LTE modem with firmware version 13, and for Vodacom South Africa,
the following request gives my data balance summary without any further input required:

> /interface lte at-chat input="AT+CUSD=1,\"*111*502#\",15" wait=yes lte1

The result I got today was:

nov/27/2019 10:14:20 lte,async,event +CUSD: 1, "537562736372697074696f6e2041697274696d652069732052302e30303b20206461746120697320322e37302047423b4e69676874204f776c20362e30302047423b203b203020534d5327733b200a31292044657461696c65640a32292050726f6d6f74696f6e616c0a2020"

Then copied and pasted the output into a command-line hex-to-decimal converter to read the result:

"Subscription Airtime is R0.00; data is 2.70 GB;Night Owl 6.00 GB; ; 0 SMS's;"
 
Tedionius
just joined
Topic Author
Posts: 15
Joined: Sat Feb 16, 2019 8:29 pm

Re: Decode USSD response

Thu Nov 28, 2019 7:43 am

Perfect, Sindy

Can confirm ctil004 findings. Firmware upgrade made no difference. Hex-to-decimal converter works and is useful for once off use.

Creating a local ascii table works like a charm. This is the correct solution for this particular use case. Thank you!
 
ctil004
just joined
Posts: 5
Joined: Sun Mar 08, 2015 8:51 am

Re: Decode USSD response

Thu Nov 28, 2019 4:26 pm

I have no experience with scripting - could you make a suitable script available?

A long-term solution would be to include automatic hex-ascii translation of CUSD call results in the next firmware upgrade for the R11e-LTE modem. Sierra can do it, so perhaps RB also?
 
sindy
Forum Guru
Forum Guru
Posts: 4193
Joined: Mon Dec 04, 2017 9:19 pm

Re: Decode USSD response

Thu Nov 28, 2019 5:27 pm

I'm not a Mikrotik developer, but think about international markets. I.e. ASCII is not enough and you need Unicode, which would have to be handled by the modem (RouterOS seems to handle it already, I've seen comments in Arabic script in Winbox yesterday). So the hex is a safe choice. You often don't need to actually convert the complete data from hex to ascii, you can search for a pattern in the string in hex and convert only few bytes carrying digits.
Instead of writing novels, post /export hide-sensitive. Use find&replace in your favourite text editor to systematically replace all occurrences of each public IP address potentially identifying you by a distinctive pattern such as my.public.ip.1.
 
Tedionius
just joined
Topic Author
Posts: 15
Joined: Sat Feb 16, 2019 8:29 pm

Re: Decode USSD response

Sat Nov 30, 2019 4:34 pm

For others looking at a solution around this, I found this: viewtopic.php?t=108127
and this: https://gist.github.com/jpluimers/f667a ... f1eeda2c2f
really useful.

Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 82 guests