Connecting to USB 3G modem and sending SMS with PHP

Nebula picture Nebula · Feb 9, 2012 · Viewed 7.2k times · Source

I've read most of the posts regarding this matter but I find nothing that is relevant to my problem.

I don't know how to connect to the modem with php code. I would greatly appreciate any help or links to where I can find the code.

I have a Sierra Wireless 3G modem. It is connected to Port_#0006.Hub_#0003

I found that the commands sent to the modem should look something like below

AT+CMGF=1
OK<br>
AT+CMGS="+31123456789"
> This is the text message.→
+CMGS: 198
OK

Answer

Eugen Rieck picture Eugen Rieck · Feb 9, 2012

In most cases the Wireless modem will create a virtual serial port

  • On Windows look at device manager, View->Devices by Connection and follow the tree back from the modem to find the COMn port (n being what you need to identify).
  • On linux look for /dev/ttyUSBn (again n being what you need to identify).

You can then fopen() the device file (\\.\comn on Windows, /dev/ttyUSBn on Linux) and fwrite() your comands there.