AT+CMGS - Can not excape text input mode - sms

I am using PuTTY to connect to an industrial cellular router , to send SMS via AT-Commands.
In PuTTY, I select Telnet and connect to the IP-Address of the router on port 23:
Router loging: root
Password: ****
# gsmat ATE1 // turn echo on
OK
# gsmat AT+CMGF=1 // switch to text mode (0 = PDU mode)
OK
# gsmat AT+CMGS=\"0664XXXXXXXX" // "tel. number"
> Test message [ENTER] // new line (expected)
> [Ctrl-Z] // nothing happens, also with Alt+0026, etc.
> [Ctrl-D]
> -sh: syntax error: unterminated quoted string
#
I normaly the SMS should send on Ctrl+Z (according to documentation, forums, etc.), but nothing happens.
So i tried the following:
ASCII code: [Alt+0026] for substitute (Ctrl+Z), nothing happens, also with Hex: 0x1A
Copy and past [SUB] from Notepad++, nothing happens (copy and paste normal text into PuTTY works fine)
[Ctrl-Y] as suggested in some forum, maybe because german keyboard layout (also nothing happens)
[Ctrl-D], syntax error, input escapes, but of course sending failes
I also tried different tools like Hyperterminal, SSH from CMD, Hercules tool, ...
Has anyone an other idea how to escape this text input mode in this situation?
My goal is to send an SMS autmatically via an C# service and there I just add (char)26 to my input and it works.
inputString = message.Length > 160 ? message.Substring(0, 160) : message;
inputString += (char)26;
connector.Write(inputString);
Any suggestions are appreciated
Screenshot: PuTTY connection settings
Screenshot: PuTTY terminal input

What I do is send SMS via PDU mode. It's a little more effort, but much better for automatic SMS sending.

According to several Internet sources, such as this one CTRL+Z is a shortcut that makes you
Put whatever you are running into a suspended background process. Type fg to restore it
which seems exactly what you are experiencing: CTRL+Z character is actually never sent, and that's the reason why the modem never sends its response.
As far as I know, sending ASCII 0x1A (decimal 26) should be correctly recognized by PuTTY. But since you already tried it there must be some other issue, and a different attempt has to be done.
Fortunately, process suspend feature can be disabled: as shown in PuTTY user guide that functionality is called Keyboard sends Telnet special commands.
In order to disable it:
Open PuTTy Configuration
Category Connection -> Telnet
Unflag Keyboard sends Telnet special commands option

It seems the problem is associated with the SMSC number.
AT+CSCA="+SMSC number"\r\n solved the problem

Related

Huawei Cdma Modem, How can send sms via C# App OR AT command

I've huawei EC156 cdma modem, I tried to send SMS via AT commands with many commands, But always received response "command not support".
I have used the following commands:
1- AT+CMGS
2- AT + GWWC
Also, I didn't find any C# Libraries dealing with cdma modems.
You definitely need to check the AT commands user manual of your device and check their syntax.
AT+CMGS has two different modes:
in PDU mode its syntax is AT+CMGS=<PDU>
in text mode it is AT+CMGS=< dest phone number>
In both cases AT+CMGS is wrong, and operation not supported is the error you get for a wrong syntax (after setting verbose error mode with AT+CMEE=2).
There are plenty of questions showing the correct AT commands sequence required to send an SMS, for example this one.
I summarize that sequence here briefly:
Some things ti check before starting:
Make sure that the SIM is inserted
Make sure that the PIN code has been correctly inserted (by issuing AT+CPIN? you have to receive the READY response)
Make sure that the device is correctly registered to the network (by issuing AT+CREG? you have to receive the +CREG: 0,1 response)
Then:
Switch to text mode by issuing AT+CMGF=1
Tell to the device the phone number you want send the SMS to, by issuing AT+CMGS=<PHONE NUMBER>. The device will output the > prompt character
Write your text
Close the SMS by providing the Ctrl-Z character (0x1A ASCII code)
On success, the response +CMGS: <N> will be displayed, with N in the range 0-255 meaning the progressive ID of sent messages

Telnet client negotiation not working properly

I am designing telnet client, which negotiates telnet options. I send desired commands to server, and process server's requests and responses. But at least color terminal identification has no effect: remote Linux server continues sending data without color ESC sequences until I explicitly tell it (through its dialog) that my client supports color.
However windows telnet and hyperterminal is being fed by the color information just after telnet negotiation, and I am looking for what they do I do not. Here's what I see:
telnet
hyperterminal
I see that server performs 255 cursor right and 255 cursor down, and then requests cursor position report, and client reports ESC [ 24;80R (which is correct), and just after this server starts color communication.
Here's what my client does
It does not have ESC [ R command supported, and does not respond for reporting cursor position. I must say that server seem to wait for several seconds for something exactly at the time when it performs these right/down cursor movements.
If it the issue why I do not have color data from the server, or there's something else you can see in the operation of my client?
Interesting that I have a video of another client which also is not expected to support ESC R command, but I see server starts sending ESC color codes after negotiation. So I have a feeling that it may not be this cursor report command issue.
Answer: after implementation of the "report position" response of the client to the server, server sends ESC color sequences now. Thus this functionality was vital for the general client-server handshaking.

Error on checking balance via USSD

I've been trying to check my balance from by 3g modem via AT commands and seem to be stuck.
The device infomation is as follows:
Manufacturer: QUALCOMM INCORPORATED
Model: M6281
Revision: SSD_M6281A-0.0.1 1 [Oct 02 2008 07:00:00]
The modem has USSD capability (advertised and also present in the factory installed dashboard).
I am connecting via putty to COM4 serial port which is my modems application port. All AT commands are working fine but I am getting an error on issuing the following via putty:
AT+CUSD=1,"*111#",15
This returns a simple "ERROR". *111# is my carrier's balance check code. I suspect that there is a formatting error somewhere but I can't figure out where.
Note: If I issue a blank ussd command:
AT+CUSD=1,"",15
then I get an OK (although I later get a response +CME ERROR: retry operation) ... If I write anything within the quotation marks however, it returns an "ERROR".
Ok, I finally found the way to fix this. Apparently there was a problem in the encoding. Here is what I did:
AT+CSCS="GSM" // change character set to GSM
AT+CUSD=1,"*111#",15 // Issued balance check ussd code
It now works fine.
The default encoding was UCS2, I'd appreciate if someone can share how to convert ussd codes to UCS2 encoding in putty.
Have you tried issuing request by AT+CUSD=1,"*111#" ? (without last parameter)
AT cmmands sometimes differ due to manufacturer implementation.

How to translate incoming Telnet data from external device into VB6

I made a connection to a external device.
The problem is that the feedback I get right after establishing connection is kind of as ASCII code:
ÿý↑
After checking theese sites:
Telnet
ASCII
Charsets
US-ASCII
Convert
I found out that:
ÿ is 255 which stands for IAC (Interpret as Command) and
ý is 253 which stands for DO and
↑ is 24 which stands for Cancel.
To send back commands to the terminal I do this:
winsck.SendData Chr(255) 'IAC
winsck.SendData Chr(252) 'WONT
winsck.SendData Chr(24) 'CANCEL
To translate an ASCII code to a char I made the following code:
lblChar = Asc(txtASCII)
To translate a char to an ASCII code I made the following code:
lblASCII = Chr(txtChar)
I want data from the terminal and modify them, but first I have to get through this ASCII coding.
How it normally works in cmd.exe:
I write telnet followed by the ipaddress of destination:
telnet (ipaddress of the terminal)
then cmd asks me for the password. After that I would be ready to write commands. Normally I write like
lm -h
then it would send me a lot of data. I want to do the same with my VB6 program.
After sending the terminal "IAC WON'T CANCEL" I got back:
ÿþ↑ÿû ÿûᶫÿý
As I have trying to translate it and I came to this result:
IAC - DON'T - CANCEL - IAC - WILL (space) IAC - WILL - END OF TEXT - IAC - DO
and after sending the terminal "IAC WILL CANCEL"
I got back: ÿú↑ ÿð= "IAC - Subnegotiation of the indicated option follows - CANCEL (space) IAC - End of subnegotiation parameters"
Seriously what does it mean - what should I answer back?
Thanks in advance
It appears that your device acts as a Telnet server and you need to implement a client in VB6.
Have you looked at Telnet Client UserControl yet?
Since those looks like Telnet commands and you mention that you can get out data if you connect via Telnet I assume you'd have to write a Telnet client. I'd suggest beginning with doing a search for telnet RFC if you go down this route and possibly telnet client vb6 too.
However, another alternative might be to automate a telnet client like Putty, this question might be helpful with that: How to run a command file in PuTTY using automatic login in a command prompt?

How to send SMS from Mac terminal via GSM modem?

I have Mio A701 communicator that I would like to use as GSM modem for sending SMS from my Mac.
What I've found so far is that one just can send an AT commands directly from terminal to special ports like /dev/ttyUSB0 if modem is connected via USB port or /dev/rfcomm0 if connection is handled via bluetooth.
My problem is that when I try to issue a command I get a "permission denied" response:
"AT+CMGS=test\r" > /dev/ttyUSB0
-bash: /dev/ttyUSB0: Permission denied
Also "ls /dev" shows that neither ttyUSB0 nor rfcomm0 files are present there so I can't update permissions on these files.
Any help would be greatly appreciated, thanks in advance.
Update: problem is solved.
First of all Mio A701 appears to be wrong choice since it does not support AT commands for sending SMS.
This PHP code works fine with Nokia 3310c connected via bluetooth:
$number="<phone number in international format with + sign>";
$message="Hello World\ntest"; // as far as I've tested \n successfully turns into a line break in SMS on Mio, Nokia and Alcatel phones
$port="/dev/tty.phone"; // this path was set in "Mac preferences" -> bluetooth -> "configure ports" for selected device
if($fd = fopen($port, 'a')) {
fwrite($fd, "AT+CMGF=1\r"); // text mode for SMS
sleep(2);
fwrite($fd, "AT+CMGS=\"$number\"\r");
sleep(2);
fwrite($fd, "$message\032");
sleep(2);
$fh = null;
} else
echo "Phone unreachable";
best way to send sms and ussd messages is to install smstools3 (not smstools) and build on the sample scripts.
Try smsd utility from smstools package, hope it will help

Resources