0
votes

I'm using a device like this: https://www.google.com/search?q=GPRS+Modem&sxsrf=ACYBGNSaamI0HqEjZrM-ew59nRYv5lctEQ:1580550102344&source=lnms&tbm=isch&sa=X&ved=2ahUKEwjt8Jj7h7DnAhWwUN4KHebwDy0Q_AUoAXoECA0QAw&biw=1536&bih=754

I want to send an SMS message using Phpserial class, I've already searched and followed some instructions on how to implement it. To make sure, I've downloaded an AT Tester to try sending message from my phone to my device and it was successful.

Now I want to implement it in PHP and I tried using Phpserial class. I am using windows OS and when I tried it, it returns no error but I didn't received any message. I tried to check console and network, it has no response and it returns no error i think?

Here is the code:

<?php
    require('PhpSerial.php');

    $num_send = $_POST['number'];
    $txt = $_POST['txt_msg'];      

    $serial = new PhpSerial;

    if($serial->deviceSet("COM4")){
        $serial->confBaudRate(9600);
        $serial->confParity("none");
        $serial->confCharacterLength(8);
        $serial->confStopBits(1);
        $serial->confFlowControl("none");
        if($serial->deviceOpen()){
            $serial->sendMessage("AT+CMGF=1\n\r"); 
            $serial->sendMessage("AT+cmgs=\"".$num_send."\"\n\r");
            $serial->sendMessage(" ".$txt." \n\r");

        $serial->sendMessage(chr(26));

        //wait for modem to send message
        sleep(7);
        $read=$serial->readPort();
        $serial->deviceClose();
        echo "Success";
        }
    }        
?>

The code above has no errors but I didn't received any message. Why ?

1
And how PC is supposed to send an SMS message from a serial port? According to an article you can send SMS only from a phone that’s connected to PC, or an SMS gateway. I assume you used the first through connecting the phone via serial cable - then the question is what you have received back from calling sendMessage for each time?Daniel Protopopov
@DanielProtopopov im using this device google.com/…:Jc John
Showing us the actual traffic sniffed from the AT port would be helpful. I mean both commands sent an received responses.Roberto Caboni
So do you confirm that with the AT tester you correctly received the SMS? In this case it can only be caused by an error in the program (for example: the destination number is wrong)Roberto Caboni

1 Answers

0
votes

If use AT-Tester and success send, You need the accepted command and Characters from GPRS device best way sniff transfer packet from AT-Tester to GPRS Modem. Serial Port Monitor or freeserialanalyzer.com Free Best tools for detect the accepted command and Characters. Only generate liked packet monitored.