0

I am trying to send sms by using AT commands from micromax MMX310G 3G USB Manager (not modem). It has airtel sim without internet.

string recievedData = ExecCommand(port,"AT", 300, "No phone connected");
recievedData = ExecCommand(port,"AT+CMGF=1", 300, "Failed to set message format.");
String command = "AT+CMGS=\"" + PhoneNo + "\"";
recievedData = ExecCommand(port,command, 300, "Failed to accept phoneNo");         
command = Message + char.ConvertFromUtf32(26) + "\r";
recievedData = ExecCommand(port,command, 3000, "Failed to send message");

When i debug AT and AT+CMGF returning ok and other commands returning Error. Is there any different AT commands for USB manager. Same code working fine when use Aircel datacard. Do we need internet to be activated in sim to run AT commands. Your valuable comments may help in this.

Alex K.
  • 171,639
  • 30
  • 264
  • 288

1 Answers1

0

You are doing several things here that are fundamentally the wrong way to handle AT commands and you are just lucky if it ever works.

First of all, never, never, never ever use delays like the the third argument to ExecCommand. And you should also not send the data part of AT+CMGS before receiving the \r\n> prompt. See the first part of this answer for more details on those points.

And you must change the logic for processing so that you after sending a command do nothing but reading responses from the modem until you get a final result code before starting on the next command. See this answer for details on that.

Community
  • 1
  • 1
hlovdal
  • 26,565
  • 10
  • 94
  • 165