As of 06-06-2008

Reading SMS from modem/ Testing

SMSReader.jpg

Task 9 - Completed

I decided to rewrite this module from scratch to illuminate any problem associate with SMS reading. I feel the reason for current inconsistency is moving to available memory location and then monitoring it. The new system would always monitor memory location 0 and above. After reading all the SMS it will then delete all the SMS in the system.

I have tested the application with some of the lab members (6) sending SMS at the same time. The application received all the SMS send by them.

I will let the application run for few days continuously to see whether there are any issues in that.

SMSReader_screen.jpg

“settings.cfg” file is located inside “Data” folder. It should be situated same folder as the exe file. “settings.cfg” contains the port number to which the modem is connected. Normally it is port “0”.

AT Commands

Following AT command is used to read all the SMS received

at+cmgl="ALL"

To delete SMS;
at+cmgd=location,number

number

0. Meaning: Delete only the SMS message stored at the location index from the message storage area. This is the default value.
1. Meaning: Ignore the value of index and delete all SMS messages whose status is "received read" from the message storage area.
2. Meaning: Ignore the value of index and delete all SMS messages whose status is "received read" or "stored sent" from the message storage area.
3. Meaning: Ignore the value of index and delete all SMS messages whose status is "received read", "stored unsent" or "stored sent" from the message storage area.
4. Meaning: Ignore the value of index and delete all SMS messages from the message storage area.

Modem Output

Out put from the modem may look like this

+CMGL: 1,"REC READ","+88888804387",,"08/05/12,16:28:45+32"

Janaka:this is a test message janaka

By locating a known marker (+CMGL:) we can extract data. The data contains exact pattern. By locating commas “,” relative to +CMGL: entire message can be found.

Task 10 - Working on

The SMS received by the application has to written to a database so that it can be processed by other applications. The SMS will be written to the sms table and its status = 0. This can be used to identify who to process the SMS next.

status = 0 -> SMS Processor application
status = 1 -> Display application

The SMS will also be logged. The SMS will be logged in table “sms_log”. The information in the log file would be telephone number, data and time, the SMS received. Earlier system we logged the SMS in a file. This log file was created daily basis when the application started. This is a safe solution for the Singapore Science Centre since they close down the system daily basis. If the application never stops it may cause a problem. Therefore writing to a database seems the best solution.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.