Short Message Service (SMS) Using Visual C# 2005, Visual Basic Express
Short Message Service (SMS) Using Visual C# 2005, Visual Basic Express
This paper describes object-oriented access to the Short Message Service (SMS). SMS is one of the GSM Data Services provided by a Network Short Messages perator. !t enab"es yo# to send and receive
The progra$ was tested #sing the Nokia %& S#ite and the Nokia '()*. The '()* then f#nctions as a $ode$ for yo#r %& &o$$#nications +pp"ications, enab"ing yo# to send and receive SMS. The progra$ sho#"d work with any phones that co$e with $ode$ drivers. The "atest driver (asse$b"y ver -.*.(((-.(.'/* #pdated .* 0an (**1) has a"so been tested with the Sa$s#ng SG2-3/.*.
+"tho#gh the e4a$p"e is given in &5, with a "itt"e trans"ation, yo# sho#"d get it working with 6is#a" 7asic 34press or 6is#a" 7asic (**)
Down"oad SMS fo"der 3$antSMS(**).8ip ('k7. 34tract the entire fo"der to yo#r %&
e!o "rogra!
&'
install the !o$e! $river so#t(are that co!es (ith %our !o)ile phone' Rea$ %our phone !anual or visit the phone !anu#acturer*s (e)site #or installation in#or!ation
2' 3.
connect %our phone to the co!puter +no( the co!! port nu!)er %our phone !o$e! is connecte$ to' ,oto the control panel an$ clic+ on Modem and Phone Options
Microsoft Visual C# .NET 2005 !ust alrea$% )e installe$' Cop% the entire Sms #ol$er to %our "C'
2.
Set the Co!! "ort 1o to the one that is in$icate$ #or %our phone !o$e!' Clic+ on the Connect to Phone chec+ )ox to connect to the phone' 2our phone shoul$ repl% (ith so!e status in the !essage )ox' Clic+ on Query )utton an$ %our phone shoul$ respon$ (ith its i$enti#ication'
3.
Sen$ a !essage to another phone )% +e%ing in %our !essage an$ phone nu!)er an$ then
clic+ the Send )utton' 3' 4o receive an SMS, 5ust sen$ a !essage to %our phone that is connecte$ to the co!puter'
4he !essage shoul$ appear in the !essage )ox' 3' 6# %ou have success#ull% sen$ an$ receive SMS, (e can no( anal%se the C# progra!'
SMS Co!ponent
4he SMS co!ponent ena)les %ou to sen$ an$ receive Short Messages using a ,SM !o$e! or a phone that has !o$e! #unction'
Open method
sms!.Open$text ox,.Text)-
bool Open(string Portnum Parameters "ortnu! 8 4he co!! port nu!)er the ,SM !o$e! is connecte$ to' !eturn Value true i# open is success#ul other(ise #alse
Close method
sms!.Close$)Close the ,SM !o$e! connection'
"oi# Close(
Query method
sms!.Query$)9se$ to i$enti#% the ,SM !o$e!' .hen the ,SM replies, the onReceived event occurs an$ the i$enti#ication string is assigne$ to the sresult propert%'
"oi# $uer%(
Send method
sms!.Send$text ox!.Text& text ox/.Text)4he Send !etho$ is use$ to sen$ an SMS to another phone' 4(o strings are passe$, one #or the !essage an$ the other #or the phone nu!)er'
s!sg 8 !essage string that is sent to the $estination phone sphone 8 string o# the phone nu!)er o# the $estination phone
sresult Property
The $essage or stat#s fro$ the $ode$ is ret#rned as a string and assigned to the sres#"t property'
public string sresult )get*+ Propert% Value
onReceived Event
The event occ#rs when the $ode$ receives an SMS $essage or reports a stat#s or acknow"edge$ent. The infor$ation is stored in the sres#"t property. private void sms!"onReceived$ob%ect sender& 'vent(r#s e) * Control.Check0or1lle#alCrossThreadCalls 2 +alselabel!.Text 2 sms!.sresult.
4his Check0or1lle#alCrossThreadCalls propert% is ne( in the '1E4 0ra!e(or+ version 2'0' ,ets or sets a value in$icating (hether to catch calls on the (rong threa$ that access a control*s :an$le propert%' 6# le#t as $e#ault true, %ou (ill get the #ollo(ing runti!e error' ;Cross8threa$ operation not vali$< Control la)el& accesse$ #ro! a threa$ other than the threa$ it (as create$ on';
7.
(T( (T4 (T5 (T7 (TM (TO (TP (TT (T:CST( (T:CRC
(ns3er Command 4ial Command 5an# 6p Call Monitor Speaker 7oudness Monitor Speaker Mode 8o On97ine Set Pulse 4ial as 4e+ault Set Tone 4ial as 4e+ault Select Type o+ (ddress Cellular Result Codes
Select 0lo3 Control 4e+ine Communications Mode Option 4e+ine 4SR Option 4T'94C' Character 0ramin# 4T'94C' 7ocal 0lo3 Control 0ixed 4T' Rate
Service
(T:C71P (T:CR (T:4R (T:17RR Callin# 7ine 1denti+ication Presentation Service Reportin# Control 4ata Compression Reportin# 4T'94C' 7ocal Rate Reportin#
Miscellaneous Commands
(D Re9'xecute Command 7ine (TE Command 5elp (TFC Start SMS 1nterpreter (TFT 'nter SMS lock Mode Protocol (TF= (ctivate =./Gbis Mode (TFBO@1(T'ST Test Command (T:C'SP 'nter SMS lock Mode Protocol