TinyGSM icon indicating copy to clipboard operation
TinyGSM copied to clipboard

[SIM800] Recive ussd, send sms problem

Open spa-sam opened this issue 7 years ago • 11 comments

sim800

  1. When I send a request to "# 101 #" or "* 161 #", I get an empty response.
  2. When sending SMS on the phone I get a set of different characters instead of "Hello world!".

At the factory settings reset - does not help!

spa-sam avatar Mar 09 '18 18:03 spa-sam

Could you play with your modem with AT commands, and tell me what sequences work for you?

vshymanskyy avatar Mar 09 '18 18:03 vshymanskyy

With sms found out - you had to add the translation into the "gsm" encoding: bool sendSMS(const String& number, const String& text) { sendAT(GF("+CMGF=1")); waitResponse(); sendAT(GF("+CSCS="GSM"")); //add waitResponse(); sendAT(GF("+CMGS=""), number, GF(""")); ... It remains to defeat ussd ...

spa-sam avatar Mar 09 '18 18:03 spa-sam

USSD

AT+CMGF=1 OK AT+CSCS="HEX" OK AT+CUSD=1,"*101#" OK +CUSD: 2

And if: AT+CMGF=1 OK AT+CSCS="GSM" OK AT+CUSD=1,"*101#" OK +CUSD: 0, "Na Vashomu rahunku 45.01 grn. ...

spa-sam avatar Mar 09 '18 19:03 spa-sam

This issue is with the alphabet and it was discussed here Pending pull request

hubaksis avatar Mar 09 '18 19:03 hubaksis

@hubaksis indeed, looks related. I'll take a look asap

vshymanskyy avatar Mar 09 '18 19:03 vshymanskyy

@spa-sam could you verify on master branch?

vshymanskyy avatar Mar 14 '18 17:03 vshymanskyy

Ussd works only like this:

String sendUSSD(const String& code) {
    sendAT(GF("+CMGF=1"));
    waitResponse();
    sendAT(GF("+CSCS=\"GSM\""));  //    HEX to  GSM
    waitResponse();
    sendAT(GF("+CUSD=1,\""), code, GF("\""));
    if (waitResponse() != 1) {
      return "";
    }
    if (waitResponse(10000L, GF(GSM_NL "+CUSD:")) != 1) {
      return "";
    }
    stream.readStringUntil('"');
    String hex = stream.readStringUntil('"');
    stream.readStringUntil(',');
    int dcs = stream.readStringUntil('\n').toInt();
	return hex;
   /* if (dcs == 15) {
      return TinyGsmDecodeHex8bit(hex);
    } else if (dcs == 72) {
      return TinyGsmDecodeHex16bit(hex);
    } else {
      return hex;
    }*/
  }

spa-sam avatar Mar 17 '18 19:03 spa-sam

@spa-sam I am facing similar issue, everything works with AT commands as yours but the changes you made in sendUSSD function also didn't work for me. Even with "HEX" instead of "GSM" gives me the phone number but nothing with "GSM".In addition blocking these condition made things worse,now I dont get location,time and date too.Any idea what might cause the difference? I am using sim800l

kamrulroky avatar Nov 01 '18 11:11 kamrulroky

It seems to me, it depends on the specific carrier.

spa-sam avatar Nov 09 '18 10:11 spa-sam

Facing the same issue and spa-sam's solution works for me. I've modified my library, but it would be great if this was integrated into the master source

Could you maybe integrate it into the source code with an additional parameter:

sendUSSD(const String& code, bool usedcs=true){
(...)
if( ! usedcs) {
    return hex;
}
else{
    if (dcs == 15) {
      return TinyGsmDecodeHex8bit(hex);
    } else if (dcs == 72) {
      return TinyGsmDecodeHex16bit(hex);
    } else {
      return hex;
    }
}
}

so that it is usable for everyone ?

coriolanweihrauch avatar Mar 27 '19 11:03 coriolanweihrauch

modem.sendSMS_UTF16("+38067xxxxxxx", u"Привееет!", 10);

using above code i am able to send the unicode msg. but i want to cast string or char to UTF16 (char16_t). need help.

marutichintan avatar Mar 23 '21 07:03 marutichintan