1

I need to access my ZTE Modem to access the SIM ToolKit. I've searched a lot. Nothing is working for me. I need to execute following AT commands from PHP:

AT+CUSD=1,'*111#',15.

Success response from terminal

I've tried from command prompt and it works. just could not execute that command from PHP. That should be simple.

require "php_serial.class.php";
$serial = new phpSerial;
$serial->deviceSet("COM6");
$serial->confBaudRate(115200);

// Then we need to open it
$serial->deviceOpen();

// To write into
$serial->sendMessage("AT+CMGF=1\n\r"); 
$serial->sendMessage("AT+cmgs=\"+92234444444\"\n\r");
$serial->sendMessage("sms text\n\r");
$serial->sendMessage(chr(26));

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

I don't know why but I couldn't find a solution though I've installed DIO, PHP_Serial and many more tools from GitHub.

If couldn't explain my problem correctly, please check the following link. This guy had same problem. but that solution is not working for me.

Similar Problem , the solution works for others, not for me!!

Community
  • 1
  • 1

1 Answers1

0

We have exactly the same problem but I managed to fix this.

// From this Code
$serial->sendMessage("AT+CMGF=1\n\r"); 
$serial->sendMessage("AT+cmgs=\"+92234444444\"\n\r");
$serial->sendMessage("sms text\n\r");
$serial->sendMessage(chr(26));

// Change it to
$serial->sendMessage("AT+CMGF=1"); 
$serial->sendMessage(chr(13));
$serial->sendMessage('AT+cmgs="+92234444444"');
$serial->sendMessage(chr(13));
$serial->sendMessage("sms text");
$serial->sendMessage(chr(26));

I don't know why it has to be like this. My theory is that If you are running your server in Windows it can't detect that \n\r are ascii code 13 or 26 unlike in Linux Servers. I figured from this https://www.diafaan.com/sms-tutorials/gsm-modem-tutorial/at-cmgs-text-mode/ link that AT+ commands syntax has to be that way ^_^

Cheers!