Search code examples
smsat-commandsim800

Can AT+CMGS be cancelled without ESC?


Is it possible to have AT+CMGS commands cancelled by some control code other than ESC?

I need it because ESC is intercepted by the attached equipment for its own use and never gets to the modem. And, I can't change that.

Unfortunately, CTRL-Z will send even an empty message, or else I could backspace enough to clear the message and do CTRL-Z to abort.

The relevant "AT command set" manual is no help.


Solution

  • According to TS 127 005 specification, it seems that there's no way to configure the character for SMS sending abortion.

    Anyway I can suggest a workaround, based on three different commands:

    • +CMGW - Write Message To Memory
    • +CMGD - Delete Message
    • +CMSS - Send Message From Storage

    So basically, instead of using +CMGS that sends the message in one step

    1. Write the SMS to memory with +CMGW (same syntax of +CMGS). After the SMS contents closure with the CTRL-Z character, its answer is

      +CMGW: <index>
      

      where <index> is the message location index in the current memory storage

    2. Actually send it with

      AT+CMSS=index
      
    3. Delete the SMS with

      AT+CMGD=index
      

      Since memory slots are limited, you will have to delete it anyway. If you realize that the message you are composing during +CMGW phase is wrong, store it anyway with CTRL-Z and skip the actual sending.

    As you can see, the entire procedure is performed without using the ESC character (0x1B), can be easily automated and doesn't require much more time to be executed.