If I have a GSM modem with 6 ports and each port inserted a SIM card,how can I send sms with random port?
Here is a simple code:
include "php_serial_class.php";
$serial=new phpSerial();
$serial->deviceSet("/dev/ttyUSB0");
$serial->deviceOpen();
//continue....
?>
So now the sms will sent through Port 1(ttyUSB0).What can I add or edit the script so that it can be sent with random port? Such as if Port 1 is busy or sending other sms then it will change to port 2...
I tried something like this:
if(!$serial->deviceOpen())
{
$serial->deviceSet("/dev/ttyUSB1");
}
and it won't works.. Thanks in advance.
You wouldn't know if device is busy unless you try to open it, so you have to check it one step with deviceOpen
method. Example:
$ports = range(0,5);
shuffle($ports);
$serial = new phpSerial();
foreach($ports as $port){
if($serial->deviceSet("/dev/ttyUSB{$port}")){
if($serial->deviceOpen()){
// send sms
break; // break the loop after sending sms
}
}
}