Recent

Author Topic: SMS sender in Lazarus (via GSM connected via USB)  (Read 12070 times)

skaner1900

  • Jr. Member
  • **
  • Posts: 59
SMS sender in Lazarus (via GSM connected via USB)
« on: December 17, 2011, 05:39:14 pm »
Hi!

How send SMS from my mobile phone, connected to PC by USB, through application wrote in Lazarus ? !

I must create something like Microsoft SMS Sender.

Help me! Please! :(

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: SMS sender in Lazarus (via GSM connected via USB)
« Reply #1 on: December 17, 2011, 05:58:38 pm »
Is this for Windows CE? Which version? For which phone? Do you already have any links about how this could be done in C or C++?

WinCE programming tips wiki doesnt seam to have yet anything about this: http://wiki.lazarus.freepascal.org/WinCE_Programming_Tips

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: SMS sender in Lazarus (via GSM connected via USB)
« Reply #2 on: December 17, 2011, 06:15:33 pm »
TurboPower AsyncPro has a GSM component for Delphi with components for sending and reading SMS messages. AFAIK it hasn't been ported to lazarus yet. You could use synaser from the synapse library for the com port part.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: SMS sender in Lazarus (via GSM connected via USB)
« Reply #3 on: December 17, 2011, 06:21:27 pm »
Aha ... so it is desktop Windows then ... I'll move to the appropriate subforum.

avra

  • Hero Member
  • *****
  • Posts: 1479
    • Additional info
Re: SMS sender in Lazarus (via GSM connected via USB)
« Reply #4 on: December 19, 2011, 03:17:32 pm »
Your easiest path would be to connect some old Nokia phone via data cable to RS232 or via RS232<=>USB cable and send AT commands to the phone. It's very simple, and you can read about it here:
http://www.developer.nokia.com/Community/Wiki/Using_AT_commands_to_send_and_read_SMS
After hardware is connected properly, you can make a working SMS demo in an hour.

Using smart phones (especially if you want it to be universal and work on most of the smartphone platforms) really complicates things a looooot and requests far more knowledge and work.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

fredycc

  • Sr. Member
  • ****
  • Posts: 265
Re: SMS sender in Lazarus (via GSM connected via USB)
« Reply #5 on: December 19, 2011, 04:08:43 pm »
Your easiest path would be to connect some old Nokia phone via data cable to RS232 or via RS232<=>USB cable and send AT commands to the phone. It's very simple, and you can read about it here:
http://www.developer.nokia.com/Community/Wiki/Using_AT_commands_to_send_and_read_SMS
After hardware is connected properly, you can make a working SMS demo in an hour.
...

Yes, Is like avra said, In Lazarus I use Synapse to works with a GSM modem: download here: http://synapse.ararat.cz/doku.php/download, there are two ways for send a SMS; PDU and Text Mode, Text Mode is easy implement with AT commands, for example:

Quote

var
  gsm:TBlockSerial;
  GSMaddress : String;
...

  GSMaddress := <<the phone number to send sms>>;
  gsm:=tblockserial.Create;
  gsm.config(460800,8,'N',1,false,true);   <-- Config modem values

  Try
     gsm.Connect(Edit1.Text);                   <-- COM Port
     gsm.ATCommand('AT+CMGF=1');        <-- Text Mode
     gsm.SendString('AT+CMGS="' + GSMaddress + '"'+ #$0D);

     sleep(100);
     gsm.SendString(Memo2.Text + #$1A);  <-- Send SMS
     memo1.lines.Add('SMS sended!');
     sleep(100);

     gsm.CloseSocket;
     gsm.Free;
  except
    on E : Exception do begin
      gsm.free;
      memo1.lines.Add(UTF8Encode(E.Message));
    end;
  end;

PDU Mode:

Quote
  gsm:=tblockserial.Create;
  gsm.config(460800,8,'N',1,false,true);
  gsm.Connect(Edit1.Text);                    <-- COM Port
  gsm.ATCommand('AT+CMGF=0');        <-- PDU format

  gsm.ATCommand('AT+CMGS=25');
  sleep(100);
  gsm.SendString('0821134901001014F011000C9124543130857300000B0CC57362D56C2E53072BF50D' +   #$1A);
  sleep(100);
  gsm.CloseSocket;
http://www.developershome.com/sms/operatingMode.asp
http://www.dreamfabric.com/sms/

Just check the name of COM Port where modem is detected.

Regards




avra

  • Hero Member
  • *****
  • Posts: 1479
    • Additional info
Re: SMS sender in Lazarus (via GSM connected via USB)
« Reply #6 on: December 20, 2011, 08:26:13 am »
...there are two ways for send a SMS; PDU and Text Mode, Text Mode is easy implement with AT commands...
Yes, that's why I said to use old Nokia instead of an old Siemens GSM phone  :D

That's a DIY recommended cheap approach with an old recycled phone. If you need it in a commercial project, you will probably want to buy a new GSM modem.
« Last Edit: December 20, 2011, 08:30:24 am by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

padiazg

  • Newbie
  • Posts: 2
Re: SMS sender in Lazarus (via GSM connected via USB)
« Reply #7 on: April 13, 2012, 04:29:25 pm »
I'm working in something that uses this feature, in a couple of days I can post an example of how I handle this.