0
$filename = "/dev/ttyUSB4";

    if (!$handle = fopen($filename, 'r+'))
    {
      echo "The device isn't detected";
      exit;
    }
    else
    {
      if (fwrite($handle,"AT+CMGF=1\r"))

     { 
     fwrite($handle,"AT+CMGS=\"+9465656\"".chr(26)."\r"."hiii");

        fwrite($handle,chr(26)."\r"); //i think here we need some seconds to see modem respond OK , how to wait for it here ?

      }
        else

              echo "Not called";
    }
               fclose($handle);

1-But each time it sends SMS , page requires one refresh before sending SMS again .

2-And it sends number in the SMS text instead of "hiii" .

Would you guide to solve these two problems?

Regards

1 Answers1

0

I haven't tried SMS with PHP but my guess is that it is the same as writing TCP socket servers...the reason you app requires a refresh is because after sending the SMS the PHP script reaches its exit point. Try wrapping the connection code in an infinite while loop that only breaks if an error occurs or on any special event...don't forget to set the execution timeout to 0 with set_time_limit(0) at the first line of the page.

dawyda254
  • 36
  • 8