4

I am trying to send at commands to get balance on huawei e3131a modem but i always receive "Ok" as answer no matter the configuration i use (GSM, IRA, UCS2). I also tried to change the operator code (#123#) to many formats like Hex PDU Simple String but no way to get the balance. Here is the command i sent : AT+CUSD=1,"#123#",15. Thanks in advance for the help.

NB: I am using Putty to send commands.

vasek
  • 2,759
  • 1
  • 26
  • 30

3 Answers3

7

I finally found the method to send USSD At commands.

Some 3G Modem doesn't support plain text or even hexadecimal form. So to send commands I have to set the modem to IRA form by doing:

AT+CSCS="IRA"

After I convert the command that permits me to get balance (for me : #123#) to gsm7bit form.

Finally sending the command by doing:

AT+CUSD=1,"A3986C3602",15

It will return OK the first time and 5 seconds after, it returns the response in gsm7bit form. It exactly returns:

+CUSD: 1,"4379999CA683CEECB738CCD68162351CCDC81ABFDB707AB92E07C9CB6374587E2E8362351CCD080A83C66FF7FCDD6E97E5A0B03DECA683D86510CCF682E55E3258ECE6A286E1653D080682BFEB7210BB0C2297E9E1345B470ED3CB207219640FB3D3E434BD0C2AD341EDB79B1E76D341E432688C0EC7EB65D0F8DD86D3CB75B92B5A4FD3E965B92E06",15

And to get it in plain text just copy and convert to string.

Thanks to all !!

danday74
  • 52,471
  • 49
  • 232
  • 283
  • 1
    JAVA gsm7bitEncoder : https://github.com/bsimic0001/AegisWallet/blob/master/mobile/src/main/java/com/aegiswallet/utils/MessagingUtils.java – Papa Daouda NIANG Mar 13 '17 at 15:43
  • 1
    Tried yout way...Itsent with OK but response never came back...Any idea what I should do ? – Jason Krs Jan 22 '18 at 21:54
  • Jason Krs... were you ever able to resolve it? I am facing the same issue. –  Feb 12 '19 at 15:40
  • On-line encoder/decoder: http://smstools3.kekekasvi.com/topic.php?id=288 – Mladen B. Mar 02 '20 at 09:05
  • @JasonKrs you need to setup a ussd listener to get the response. this library will help -> https://www.npmjs.com/package/serialport-gsm POC: ``` modem.on('onNewIncomingUSSD', (data) => { console.log('onNewIncomingUSSD ', { data }); }) ``` – Spidy Jun 05 '22 at 10:12
1

As per the documentation the AT+CUSD command will return OK immediately if all the parameters are correct. If the first parameter is set to 1, an unsolicited response (+CUSD:...) will be returned when the network responds to the USSD request.

So you must wait for +CUSD response after you have received an OK.

manishg
  • 9,520
  • 1
  • 16
  • 19
1

first run this : AT+CSCS="IRA"

goto http://www.rednaxela.net/pdu.php

alphabet size: 7

enter USSD code (eg. *124#) , click convert

in the 2nd box, copy the last line

add it to your ussd section: AT+CUSD=1,"AA988C3602", 15

after getting the output in 7bit (CUSD=1,"xxxxxxxxxx..7bit"), copy it

goto http://smstools3.kekekasvi.com/topic.php?id=288

in the "USSD Entry/Display" section, select GSM 7bit packed

paste the result you had from the modem

click convert

if you want to do this programatically, use https://www.npmjs.com/package/ussd-pdu-text-converter

Spidy
  • 556
  • 5
  • 11