Beranda > Delphi > Membuat Aplikasi SMS dengan Delphi

Membuat Aplikasi SMS dengan Delphi

Membaca sebuah artikel tentang sending SMS menggunakan fasilitas AT Command membuat saya tertarik utk mendevelope
sebuah aplikasi send and receive sms yang sederhana.

Hardware tambahan yg di perlukan adalah semua GSM Modem, saya menggunakan Modem Wavecom,
sedangkan component tambahan yang saya pakai di Delphi adalah TComDriver dan AfPortControls, sebuah componen yg selalu
saya gunakan jika membuat program yang berinteraksi dengan sebuah COM Port di PC.

Pada dasarnya sintax yang perlu kita kirim ke modem melalu jalur komunikasi Com adalah :

1. AT+CMGF=1 [Enter]
2. AT+CMGS= <No HP tujuan> [Enter]
3. Tuliskan Pesan yang hendak anda kirim [Ctrl+Z].

Perhatikan Sample Design Form berikut :
SMS Application Design

Berikut Isi Source Codenya :

unit FrmUtama;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComDrv32, AfPortControls, ComCtrls, XPMan;

type
TForm1 = class(TForm)
Label1: TLabel;
EditHPno: TEdit;
Memo1: TMemo;
btnSend: TButton;
AfPortComboBox1: TAfPortComboBox;
Memolog: TMemo;
COMM1: TCommPortDriver;
btnReadSMS: TButton;
StatusBar1: TStatusBar;
XPManifest1: TXPManifest;
procedure Comm1ReceiveData(Sender: TObject; DataPtr: Pointer;
DataSize: Cardinal);
procedure btnSendClick(Sender: TObject);
procedure btnReadSMSClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
gRevData:String;

implementation

{$R *.dfm}

function GetPortNum(id : Integer) : TComPortNumber;
begin
case id of
1 : Result := pnCom1;
2 : Result := pnCom2;
3 : Result := pnCom3;
4 : Result := pnCom4;
5 : Result := pnCom5;
6 : Result := pnCom6;
7 : Result := pnCom7;
8 : Result := pnCom8;
9 : Result := pnCom9;
10 : Result := pnCom10;
11 : Result := pnCom11;
12 : Result := pnCom12;
13 : Result := pnCom13;
14 : Result := pnCom14;
15 : Result := pnCom15;
16 : Result := pnCom16;
17 : Result := pnCom17;
18 : Result := pnCom18;
19 : Result := pnCom19;
20 : Result := pnCom20;
end;
end;

procedure TForm1.btnReadSMSClick(Sender: TObject);
var s: string;
begin
memolog.Clear;
Comm1.Disconnect;
COMM1.ComPort:= GetPortNum(AfPortComboBox1.ComNumber);
Comm1.Connect;
memolog.Lines.Add(’Read Inbox from Port :’+IntToStr(AfPortComboBox1.ComNumber));

s:= ‘AT+CMGF=1′;
Comm1.SendString(S+#13);

s:= ‘AT+CMGL=”ALL”’;
Comm1.SendString(S+#13);

Application.ProcessMessages;
Comm1.Disconnect;
end;

procedure TForm1.btnSendClick(Sender: TObject);
var S: String;
begin
memolog.Clear;
Comm1.Disconnect;
COMM1.ComPort:= GetPortNum(AfPortComboBox1.ComNumber);
Comm1.Connect;
memolog.Lines.Add(’Get Connected to Port :’+IntToStr(AfPortComboBox1.ComNumber));

s:= ‘AT+CMGF=1′;
Comm1.SendString(S+#13);

s:= ‘AT+CMGS=’+EditHPno.Text;
Comm1.SendString(S);
Comm1.SendString(#13);

s:= Memo1.Text;
Comm1.SendString(S+#26);
end;

procedure TForm1.Comm1ReceiveData(Sender: TObject; DataPtr: Pointer;
DataSize: Cardinal);
var

iCount : Integer;
sTemp : String;
begin

for iCount := 1 to DataSize do
begin
sTemp := gRevData;
if sTemp ‘’ then memolog.Lines.Add(’Recv :’+sTemp);
end;
end;

end.

Sumber : http://hendrojulianto.blogsome.com/category/delphi-programming/
Iklan
Kategori:Delphi
  1. hadi
    November 14, 2008 pukul 3:48 am

    dari mana saya bisa download komponen TComDriver dan AfPortControls?

  2. April 12, 2012 pukul 10:30 am

    mohon penjelasan lebih lanjut tentang komponen tersebut!

  3. Juli 20, 2013 pukul 1:56 am

    I’m not sure where you’re getting your information, but good topic.

    I needs to spend some time learning much more or understanding more.
    Thanks for wonderful info I was looking for this info for my mission.

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: