3

Please what is the AT commands in PHP compatible with Huawei USB Modem ?

i need to use these commands in script then i can send sms using the Huawei USB Modem.

thanks

Dr-SeMSeM
  • 41
  • 1
  • 2
  • 1
    It may be possible to talk to a modem from PHP to some extent, but you want to use a command-line tool to do it. Look up how to communicate with your modem using a tool for your OS – Pekka Sep 08 '11 at 15:44

2 Answers2

4

The first thing you need to do is to open up the serial port with PHP. There is a class for doing this: http://code.google.com/p/php-serial/

Once open, it is as simple as this:

$serial->sendMessage("AT+CMGS=\"+1231231234\"\nHello");

Obviously, the AT commands can vary from device to device, so you will need to find out the commands for your specific device.

Brad
  • 159,648
  • 54
  • 349
  • 530
  • +1 although under Windows you can just hope your message was sent, the Windows implementation is write only in its present form. – fvu Sep 08 '11 at 15:50
  • @fvu, that is correct. You don't know of a better serial class by chance, do you? The only other method I can think of (outside of `exec()`), would be to invoke a COM object. – Brad Sep 08 '11 at 15:53
  • see my response for a radically different approach - issue #1 in the issue list proposes a solution to the writeonly problem that's so simple it's almost incredible... Not sure what's going on there. – fvu Sep 08 '11 at 15:57
2

A saner approach would be to delegate SMS management to a specialized software, because in my experience there's more to do to manage SMS sends than just throwing a couple of bytes to a modem

  • network availability checks and the corresponding retries to optimize your delivery rate
  • capability to receive SMS'es
  • multipart messages
  • routing
  • ...

I suggest the most excellent SMSTools it's a server software compatible with Linux and Windows, it talks with your application via regular ASCII files in specific directories (in, out, failed, ...) and has a host of other advanced functions.

To send a basic sms with default options you just have to create a text file like this one

To: 155512345

Hello, this is the text of the SMS

in the out-spool directory, on Linux that's /var/spool/sms/outgoing unless you reconfigure that path.

Best of all it's free and open source.

fvu
  • 32,488
  • 6
  • 61
  • 79