Click here to Skip to main content
15,063,287 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I have written a C# application which is supposed to interact with a gsm modem using AT commands.
All other commands are working well for me except for USSD commands which are appearing to be returning a hexadecimal or encrypted string in the response.

The USSD command which i am executing is: AT+CUSD=1,"*125#",15 and its returning the same result in my code and on hyperterminal.

Have a look at the query and the result of the query which i took from the hyperterminal screen

AT+CUSD=1,"*125#",15
OK

+CUSD: 0,"004100630063002000420061006C00200030002E003000300030003000200055005300
440020004500780070003A00300036002F00300033002F00310034002E0030005400580054007300
20004500780070003A002D002E00300042006F006E0075007300200053004D005300200045007800
70003A002D002E0030004600720065006500200053004D005300730020004500780070003A002D00
2E0030002E0030003000550053004400200042006F006E0075007300200061006900720074006900
6D00650020006500780070003A002D002E004E00650077002000530049004D00200030002E003000
30005500530044002C00300053004D0053002C00200030002E00300030004D0042002C0020003000
4D004D00530020004500780070003A002D002E002000300054004D00200053004D005300730020",
72

can you please assist me in the best way possible, i am stuck.
Posted
Updated 29-Dec-17 1:22am
Comments
Richard MacCutchan 30-Oct-13 5:50am
   
What results are you expecting? If you get the same values from hyperterm then your code is probably correct.
Member 10364520 30-Oct-13 5:52am
   
I am expecting retrieve my balance and i must receive an answer like this: "your balance is 100$..."
Richard MacCutchan 30-Oct-13 5:56am
   
You need to check with your service provider what the response format is.
aminvincent 27-Apr-15 6:00am
   
may i get your project? because i need example for ussd command ,...thanks

I think message is in hex representation of unicode characters
Your message is

Acc Bal 0.0000 USD Exp:06/03/14.0TXTs Exp:-.0Bonus SMS Exp:-.0Free SMSs Exp:-.0.00USD Bonus airtime exp:-.New SIM 0.00USD,0SMS, 0.00MB, 0MMS Exp:-. 0TM SMSs

Simply conver string from hex into bytes and interpret it as unicode string.
   
Comments
CPallini 14-Jan-14 4:51am
   
5.
I managed to solve it last year, anyway, thanks for the response.
   
Comments
Ehsan Waris 5-Nov-14 14:09pm
   
can you share you code please? I need some help in sending ussd codes through gsm... and i can't find any useful tutorial or hrlp.
Member 10888987 11-Feb-15 4:19am
   
Can you tell me how did you solved this.
Member 11431150 28-Feb-15 19:15pm
   
You can use the function split to split the data.
For Example in VB.Net :

Dim strData as string = "Mydata1,Mydata2,MyData3"
Dim mSplit() as string = strData.Split(",")

in line 2 mSplit is an array. The value of mSplit now is :

mSplit(0) = "Mydata1"
mSplit(1) = "Mydata2"
mSplit(2) = "Mydata3"
Before you send USSD with AT Command please set modem or Handphone to Text mode, with


AT+CMGF=1 this set the modem to (text mode)


AT+CMGF=0 this set the modem to (PDU mode)

I hope you understand
   
v2
Comments
RashmitaS 1-Apr-15 6:43am
   
I am trying to send USSD code for Balance Inquiry from Hyperterminal using Huawei GSM modem.

I am getting an error [+CME ERROR: 100] when I use the code AT+CUSD=1,"*901#",15

So I changed my code to AT+CUSD=1,"2a39303123",15

Now the response is

OK
+CUSD: 2

But there is no expected Response like "Balance:Rs. 46.84.Ek ko dui offer! Matra Rs. 12* ma 18MB data.Yo dainik data pack kharid garna *17123# dial garnuhos"

which I receive when I send the same USSD code from Modem application. Kindly help.
Member 2281771 11-Aug-16 17:57pm
   
I am still having the same issue. I get only +CUSD: 2 , but there is no data supplied.
Please advice how can i get the required data , like Balance:....
Try switch your chips to another provider, I have same problem before.
   
Comments
Richard MacCutchan 23-Dec-17 3:37am
   
Answered FOUR years ago.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900