quick update:naglagay ako ng handshaking option, http://www.badongo.com/file/23874165
Sending Command: ATDelay: 100msecReceived Reply:OK===========================Sending Command: AT+CMGF=1Delay: 100msecReceived Reply:OK===========================Sending Command: +CMSS: 4Delay: 100msecReceived Reply:=================================================================END===========
Ang galing po ninyo master.. +1. Nag try po ako mag send ng msg gamit nyan pero hindi ko kaya. Heto po yung resulta.Code: [Select]Sending Command: ATDelay: 100msecReceived Reply:OK===========================Sending Command: AT+CMGF=1Delay: 100msecReceived Reply:OK===========================Sending Command: +CMSS: 4Delay: 100msecReceived Reply:=================================================================END===========yung msg ko po na save na sa sim memory #4. Ang msg ay nag check lang ng balance ng load ko. Para di ma bawasan ang load ko, hehe. Paano ba ito gawin master? Sorry for being so noob.
AT+CMGF=1|TRUE|500|NoneAT+CMGL="REC UNREAD"|TRUE|3000|Just to show wala pang unread messagesAT+CMSS=18|TRUE|5000|NoneAT+CMGL="REC UNREAD"|TRUE|3000|None
Sending Command: AT+CMGF=1Delay: 500msecReceived Reply:OK===========================Sending Command: AT+CMGL="REC UNREAD"Delay: 3000msecReceived Reply:OK===========================Sending Command: AT+CMSS=18Delay: 5000msecReceived Reply:+CMSS: 0OK+CMTI: "SM",28===========================Sending Command: AT+CMGL="REC UNREAD"Delay: 3000msecReceived Reply:+CMGL: 28,"REC UNREAD","7176796669",,"10/08/14,11:20:08+32"Your Account Balance as of 08/14/2010 11:20 is 0.00 You also have 0 remaining FREE texts.OK=================================================================END===========
Ang ganda mo talaga sis. Baka naman pwede pakisend na rin source code mo.
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.IO.Ports;using System.IO;namespace AT_Command_Script_Processor{ public partial class frmATScriptProcessor : Form { const string FRM_TITLE="AT Command Script Processor 00.08.01"; public frmATScriptProcessor() { InitializeComponent(); } private void frmATScriptProcessor_Load(object sender, EventArgs e) { this.Text=FRM_TITLE; tssStatusScrFile.Text=""; cmbSerial.Items.Clear(); cmbSerial.Items.AddRange(SerialPort.GetPortNames()); if(cmbSerial.Items.Count!=0) cmbSerial.SelectedIndex=0; cmbBaud.Items.Clear(); cmbBaud.Items.AddRange(new string[]{"9600","19200","115200"}); cmbBaud.SelectedIndex=0; cmbHandShaking.Items.Clear(); cmbHandShaking.Items.AddRange(new string[]{"None","RequestToSend","RequestToSendXOnXOff","XOnXOff"}); cmbHandShaking.SelectedIndex=0; } private void btnOpenFile_Click(object sender, EventArgs e) { if(ofdScriptFile.ShowDialog()==DialogResult.OK) { //txtScriptFile.Text=ofdScriptFile.FileName; tssStatusScrFile.Text=ofdScriptFile.FileName; } } private void btnRun_Click(object sender, EventArgs e) { string SCRFile=tssStatusScrFile.Text.Trim(); txtResult.Clear(); Application.DoEvents(); if(File.Exists(SCRFile)==true) { SerialPort mySer=new SerialPort(cmbSerial.SelectedItem.ToString(),int.Parse(cmbBaud.SelectedItem.ToString())); mySer.Handshake=(Handshake)Enum.Parse( typeof(Handshake),cmbHandShaking.SelectedItem.ToString()); mySer.WriteTimeout=1000; try { string [] FileAllLines=File.ReadAllLines(SCRFile); try {mySer.Open();} catch { MessageBox.Show("Error Opening Serial Port!"); return; } btnRun.Enabled=false; foreach(string x in FileAllLines) { string temp=x.Trim(); if(temp.StartsWith(@"//")) continue; string [] spliString=temp.Split(new char[]{'|'},StringSplitOptions.RemoveEmptyEntries); if(spliString.Length!=4) continue; int delay=0; bool boolReadRx=false; string ATcmd=""; try { delay=int.Parse(spliString[2].Trim()); boolReadRx=Convert.ToBoolean(spliString[1].Trim()); ATcmd=spliString[0].Trim(); } catch { MessageBox.Show("Error Parsing Data, Please Recheck AT Script File: " + temp,FRM_TITLE,MessageBoxButtons.OK,MessageBoxIcon.Stop); return; } mySer.DiscardInBuffer(); txtResult.AppendText("Sending Command: " + ATcmd); txtResult.AppendText("\r\n"); try { mySer.Write(ATcmd); mySer.Write(new byte[]{0x0D},0,1); } catch { MessageBox.Show("Error Sending Data to GSM Modem!",FRM_TITLE,MessageBoxButtons.OK,MessageBoxIcon.Stop); return; } txtResult.AppendText("Delay: " + delay + "msec"); txtResult.AppendText("\r\n"); System.Threading.Thread.Sleep(delay); if(boolReadRx) { string readSer=mySer.ReadExisting(); if(chkShowEndHex.Checked) { for(int ctr=0;ctr<0x20;ctr++) { readSer =readSer.Replace(String.Format("{0}",(char)ctr),String.Format("<0x{0:X2}>",ctr)); } } txtResult.AppendText("Received Reply:\r\n"); txtResult.AppendText(readSer); txtResult.AppendText("\r\n"); } txtResult.AppendText("===========================\r\n"); } } finally { btnRun.Enabled=true; mySer.Dispose(); System.GC.Collect(); } txtResult.AppendText("===========================\r\n"); txtResult.AppendText("===========END===========\r\n"); } else { if(SCRFile==String.Empty) MessageBox.Show("Choose file first!",FRM_TITLE,MessageBoxButtons.OK,MessageBoxIcon.Stop); else MessageBox.Show("File does not exist!",FRM_TITLE,MessageBoxButtons.OK,MessageBoxIcon.Stop); } } private void btnCopyToClipBoard_Click(object sender, EventArgs e) { if(txtResult.Text.Length!=0) { Clipboard.Clear(); Clipboard.SetText(txtResult.Text); } } }}
written in C#:Code: [Select]using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.IO.Ports;using System.IO;namespace AT_Command_Script_Processor{ public partial class frmATScriptProcessor : Form { const string FRM_TITLE="AT Command Script Processor 00.08.01"; public frmATScriptProcessor() { InitializeComponent(); } private void frmATScriptProcessor_Load(object sender, EventArgs e) { this.Text=FRM_TITLE; tssStatusScrFile.Text=""; cmbSerial.Items.Clear(); cmbSerial.Items.AddRange(SerialPort.GetPortNames()); if(cmbSerial.Items.Count!=0) cmbSerial.SelectedIndex=0; cmbBaud.Items.Clear(); cmbBaud.Items.AddRange(new string[]{"9600","19200","115200"}); cmbBaud.SelectedIndex=0; cmbHandShaking.Items.Clear(); cmbHandShaking.Items.AddRange(new string[]{"None","RequestToSend","RequestToSendXOnXOff","XOnXOff"}); cmbHandShaking.SelectedIndex=0; } private void btnOpenFile_Click(object sender, EventArgs e) { if(ofdScriptFile.ShowDialog()==DialogResult.OK) { //txtScriptFile.Text=ofdScriptFile.FileName; tssStatusScrFile.Text=ofdScriptFile.FileName; } } private void btnRun_Click(object sender, EventArgs e) { string SCRFile=tssStatusScrFile.Text.Trim(); txtResult.Clear(); Application.DoEvents(); if(File.Exists(SCRFile)==true) { SerialPort mySer=new SerialPort(cmbSerial.SelectedItem.ToString(),int.Parse(cmbBaud.SelectedItem.ToString())); mySer.Handshake=(Handshake)Enum.Parse( typeof(Handshake),cmbHandShaking.SelectedItem.ToString()); mySer.WriteTimeout=1000; try { string [] FileAllLines=File.ReadAllLines(SCRFile); try {mySer.Open();} catch { MessageBox.Show("Error Opening Serial Port!"); return; } btnRun.Enabled=false; foreach(string x in FileAllLines) { string temp=x.Trim(); if(temp.StartsWith(@"//")) continue; string [] spliString=temp.Split(new char[]{'|'},StringSplitOptions.RemoveEmptyEntries); if(spliString.Length!=4) continue; int delay=0; bool boolReadRx=false; string ATcmd=""; try { delay=int.Parse(spliString[2].Trim()); boolReadRx=Convert.ToBoolean(spliString[1].Trim()); ATcmd=spliString[0].Trim(); } catch { MessageBox.Show("Error Parsing Data, Please Recheck AT Script File: " + temp,FRM_TITLE,MessageBoxButtons.OK,MessageBoxIcon.Stop); return; } mySer.DiscardInBuffer(); txtResult.AppendText("Sending Command: " + ATcmd); txtResult.AppendText("\r\n"); try { mySer.Write(ATcmd); mySer.Write(new byte[]{0x0D},0,1); } catch { MessageBox.Show("Error Sending Data to GSM Modem!",FRM_TITLE,MessageBoxButtons.OK,MessageBoxIcon.Stop); return; } txtResult.AppendText("Delay: " + delay + "msec"); txtResult.AppendText("\r\n"); System.Threading.Thread.Sleep(delay); if(boolReadRx) { string readSer=mySer.ReadExisting(); if(chkShowEndHex.Checked) { for(int ctr=0;ctr<0x20;ctr++) { readSer =readSer.Replace(String.Format("{0}",(char)ctr),String.Format("<0x{0:X2}>",ctr)); } } txtResult.AppendText("Received Reply:\r\n"); txtResult.AppendText(readSer); txtResult.AppendText("\r\n"); } txtResult.AppendText("===========================\r\n"); } } finally { btnRun.Enabled=true; mySer.Dispose(); System.GC.Collect(); } txtResult.AppendText("===========================\r\n"); txtResult.AppendText("===========END===========\r\n"); } else { if(SCRFile==String.Empty) MessageBox.Show("Choose file first!",FRM_TITLE,MessageBoxButtons.OK,MessageBoxIcon.Stop); else MessageBox.Show("File does not exist!",FRM_TITLE,MessageBoxButtons.OK,MessageBoxIcon.Stop); } } private void btnCopyToClipBoard_Click(object sender, EventArgs e) { if(txtResult.Text.Length!=0) { Clipboard.Clear(); Clipboard.SetText(txtResult.Text); } } }}medyo magulo pa yung code... I will optimize it pag may time