SMS

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
akee
Enthusiast
Enthusiast
Posts: 496
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

SMS

Post by akee »

Anyone have a code sample that uses only PB and Win32 to send SMS?

I know there a lot of DLLs and ActiveX components out there. They cost $$$.
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

You need a phoneprovider to send SMS.
akee
Enthusiast
Enthusiast
Posts: 496
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Clearer PIC

Post by akee »

Hroudtwolf, I already have that. What I mean is let's say I have a PC connected to a hand phone and I have valid subscription. I want to be able to send a SMS.

Ex. If you have a Nokia phone, you have the utility Nokia PC Suite which can send SMS. I would like to use PB to write just the SMS part without any SDK or ActiveX objects. I saw some samples with oxygen software but it is a component.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

well i dont think many users will have any use of this. I dont even have a pc-connector cable to my cellfones. And not all phones are nokia ;)
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

small hint:

use Sysinternals Portmon and listen to
the serial port that is connected to your
hand phone
(formerly known in germany as Handy).

Then let the nokia suite send a sms and
you capture all output from the serial port.
SPAMINATOR NR.1
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

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 :-))

however, there are some other (low cost) solutions...

the cheapest way is probably an 'option firstfone' or similar pcmcia card, they use an expanded hayes command set that will allow you to send and receive messages (remember the at dt era?)

as an alternative, there are a few external boxes (also using hayes or similar) that take a simcard and become a (sort of) modem

there are several (low cost) sms service providers that offer you an http or tcp/ip interface to send and receive messages, pricing isn't that bad, though it depends on your volume
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

there might be some free Email ones. Then program a small email sender in purebasic and then send.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

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? :shock:

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.... :D

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

doubledutch: yes i am :-) but that has never stopped manufacturers to copy from each other :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Blueznl: Your right, its a pity they never all got together and agreed. It looks like there is no properly agreed standard - it just seems to have been formed over time, some phones understand some commands, others all... Most however, can get to the stage where they can send an actual SMS :)

Akee: You may need to delete the recieved SMS from the phone using the message id number received... There are clues on the net on how to do this... ;)

There is also another method of using the AT commands to send text messages with pictures - not mms - but a "nokia" standard that seems to have been adopted by some others. This is more complex, but is worth looking into if you have some time to spare.

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
stbi
New User
New User
Posts: 3
Joined: Thu Mar 31, 2005 10:27 am
Location: Stuttgart, Germany

Post by stbi »

There are some mobile phones that can be treated like a modem. You can talk to them via AT-commands. The command set is usually expanded to handle phone commands like send message. I use a Siemens T35i to send and receive SMS. The T35i is afaik a standard S35i mobile phone without display and keypad. There is a command reference available as PDF on the net.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

There are some mobile phones that can be treated like a modem. You can talk to them via AT-commands. The command set is usually expanded to handle phone commands like send message.
stbi: checkout the code above, it uses these extra AT commands... ;)

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
stbi
New User
New User
Posts: 3
Joined: Thu Mar 31, 2005 10:27 am
Location: Stuttgart, Germany

Post by stbi »

DoubleDutch wrote:stbi: checkout the code above, it uses these extra AT commands... ;)
:oops: sorry, has been overlooked by me ... you already mentioned it ... I need some coffee, badly :oops:
akee
Enthusiast
Enthusiast
Posts: 496
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Post by akee »

DoubleDutch wrote:Akee: You may need to delete the recieved SMS from the phone using the message id number received... There are clues on the net on how to do this... ;)
Thanks DoubleDutch. Will look at it... ;)
Post Reply