there is no standard brand independent protocol for sending sms messages via directly connected devices
(hey, i've been professionally involved in this business for a while )
blueznl: Are you sure there is no standard?
I've tried quite a few mobiles with my "MessageGameServer" (written in PureBasic) from the Nokia 402 (early phone) to the latest Philips, etc
without any problems!
I found that there is a semi-standard using modem type AT commands that work on most phones with the appropriate modem driver. This is usually bundled with the phone, available for download somewhere or at cost with something like Nokia Data Suite.
Some phones don't need a modem driver - like the Nokia Communicator or some others with infrared ports. Others do, almost all USB connected and really old phones (such as the 402) phones will need a driver - this "driver" will convert the high level AT commands to low level commands for the actual phone. The modem drivers usually set up a virtual COM port that you can send the AT commands to...
I can't give out the complete code (its a working commercial program), but...
I use this to init most phones:
Code: Select all
Procedure InitSMS(Handle)
NiceOutput(#GamePlay,"Initialising SMS modem")
SendSerial(Handle,"ATZ","Init phone modem")
SendSerial(Handle,"AT+IFC=0,0","No flow control")
SendSerial(Handle,"ATE1","Turn on echo")
SendSerial(Handle,"AT+CREG","Get network status")
SendSerial(Handle,"AT+CSQ","Check signal strength") ; needs to return 12 or better for reliable connection
SendSerial(Handle,"AT+CRC=1","Extended ring information")
SendSerial(Handle,"AT+CNMI=1,2","Pass along incoming messages")
SendSerial(Handle,"AT+CMGF=1","Set text mode")
EndProcedure
You will have to make your own SendSerial procedure - but you get the idea...
Here are some replies:
Code: Select all
Case "CSQ"
NiceOutput(#GamePlay,"SMS modem signal strength:"+SerialParam$+Chr(13)+Chr(10))
Case "CMGS"
NiceOutput(#GamePlay,"SMS message sent, reference #:"+SerialParam$+Chr(13)+Chr(10))
Case "CMT"
WaitMessage=#TRUE
Case "CRING"
NiceOutput(#GamePlay,"SMS modem reports incoming call! Type:"+SerialParam$+Chr(13)+Chr(10))
This is for command replies:
Code: Select all
If SerialCommand$="OK"
NiceOutput(#GamePlay,"SMS modem reports the command executed 'okay'"+Chr(13)+Chr(10))
EndIf
If serialCommand$="ERROR"
NiceOutput(#GamePlay,"SMS modem reports 'Error' - command not supported by modem"+Chr(13)+Chr(10))
EndIf
and finally this will send the actual SMS:
Code: Select all
SendSerial(Handle,"AT+CMGS="+Chr(34)+TelephoneNo$+Chr(34),"Set telephone number")
SendSerial(Handle,SmsMessage$+Chr(26),"Send message with CTRL-Z")
Hopefully there are enough clues here to get you started....
-Anthony