![]() ![]() It returns OK or ERRORĪT CMGF=1\r: set the device to operate in SMS text mode (0=PDU mode and 1=text mode). It answers CPIN: READY or CPIN: SIM PIN if we need to insert the pin numberĪT CMGS=””\rControl-Z : to send a SMS (in php we have Control-Z with chr(26)). So if you dive into Sms_Http class you will find TCP socket’s functions.Īnd finally I will do a brief excerpt of AT commands used to send /read SMSs:ĪT CPIN?\r : checks if SIM has the pin code. With the TCP server mode I can read/write from the serial device with the standard socket functions. #PHP SERIAL PORT COMMUNICATION LINUX KERNEL PC#They allow you to create a fake serial port on your PC and work exactly in the same way than if you have your device connected with a serial cable. Serial/Ethernet converters normally have different operational modes. $sms = Sms::factory($serial)->insertPin($pin) We can run it with a script similar than the Dummy one, thanks to dependency injection: For Sms_Serial I’ve use the great library (with a slight modifications) of Rémy Sanchez to read/write serial port in PHP (you can find it here). Now we only need to create Sms_Serial and Sms_Http. Our Sms class sends a fake sms using Sms_Dummy The purpose of that is to test the main class (Sms.php) First we’re going to create a Dummy Mock object, sharing the same interface than the others. That means our Sms class will work exactly in the same way with one interface or another. It takes in the constructor (via dependency injection) the HTTP wrapper or the serial one (both with the same interface). The idea is the following one: We are going to create a main class called Sms. The idea is enable the operations when device is connected via serial cable and also when it’s connected thought a serial/ethernet converter. ![]() Because of that I will create a dual library. I prefer to connect those devices using serial/ethernet converters. Serial/USB cables cannot be very long (2 or 3 meters). I don’t like to connect directly those devices to the PC/server. Modern GSM modems have a USB port, and even we can use serial/USB converters. Modern PCs sometimes dont’t have serial ports. So we need to connect our PC/server with a serial cable to the device. Normally those kind of devices uses a serial interface. That’s means we can send (and read) SMSs and create scripts to perform those operations. They’ve got a SIM card and we can do the same things we can do with a mobile phone, but using AT and AT commands programmatically. GSM modems are similar than normal modems. There are few of them if we google a little bit. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |