'John Henderson[_2_ Wrote:
> ;511530']dongtrien wrote:
> -
> i'm use
>
> AT
> OK
> AT+CMGF=1
> OK
> AT+CMGS="0902563xxx"
> OK-
> you sent something...
> -
>
> return OK, but why i not found Incoming message to the phone number
> 0902563xxx ?-
>
> When you enter the command:
>
> AT+CMGS="0902563xxx"
>
> the E63 should reply with a "" prompt. At that point, you type
> the text to be sent, but you don't press the Enter key.
>
> Instead, you give the E63 the ctrl-Z character. This is
> character 26 decimal.
>
> The E63 should then respond by sending the text and giving you a
> message reference number, like this:
>
> +CMGS: 44
>
> Unless you get that reference number, you should assume that the
> SMS was not sent.
>
> What preference have you got set for the SMS carrier moce,
> circuit-switched or packet-switched? The command:
>
> AT+CGSMS?
>
> will tell us.
thank you, I forgot to type Ctrl-Z character, I now It send good with
hyperterminal but I changed to language C#.net, it was error "Response
received is incomplete," you see my code committee know why ? note: E63
modem connected to very good
Code:
--------------------
public bool sendMsg(SerialPort port, string PhoneNo, string Message)
{
bool isSend = false;
try
{
string recievedData = ExecCommand(port,"AT", 300, "No phone connected"); // Error here: recievedData = "Response received is incomplete"
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"); //3 seconds
if (recievedData.EndsWith("\r\nOK\r\n"))
{
isSend = true;
}
else if (recievedData.Contains("ERROR"))
{
isSend = false;
}
return isSend;
}
catch (Exception ex)
{
throw ex;
}
}
public string ExecCommand(SerialPort port,string command, int responseTimeout, string errorMessage)
{
try
{
port.DiscardOutBuffer();
port.DiscardInBuffer();
receiveNow.Reset();
port.Write(command + "\r");
string input = ReadResponse(port, responseTimeout);
if ((input.Length == 0) || ((!input.EndsWith("\r\n> ")) && (!input.EndsWith("\r\nOK\r\n"))))
throw new ApplicationException("No success message was received.");
return input;
}
catch (Exception ex)
{
throw ex;
}
}
public string ReadResponse(SerialPort port,int timeout)
{
string buffer = string.Empty;
try
{
do
{
if (receiveNow.WaitOne(timeout, false))
{
string t = port.ReadExisting();
buffer += t;
}
else
{
if (buffer.Length > 0)
throw new ApplicationException("Response received is incomplete.");
else
throw new ApplicationException("No data received from phone.");
}
}
while (!buffer.EndsWith("\r\nOK\r\n") && !buffer.EndsWith("\r\n> ") && !buffer.EndsWith("\r\nERROR\r\n"));
}
catch (Exception ex)
{
throw ex;
}
return buffer;
}
--------------------
--
dongtrien