Processing SMS from GPS trackers using GSM modems
When the logger received a message, it should split the incoming text message into several separate parser values.
For example, the figure below shows a simple SMS message from a GPS tracker with basic info:
[790477207XX]<CR><LF>
352848024311173@2011.09.02 11:19:06@48.715569@44.522743@85@2@5@N/A@7@0<CR><LF>
[190477207XX] – sender of the text message.
<CR><LF> - ASCII carriage return and line feed characters.
Message text.
<CR><LF> - the text of the message ends with the ASCII carriage return and line feed characters.
The format of the message text depends on the tracker model. In this example, the message has the following format:
<imei>@<time>@<fix_lat>@<fix_lon>@<fix_angle>@<fix_speed>@<fix_satellites>@<bat_status>@<alarm_on>@<alarm_off>
All values in this text message are separated by the "@" character.
Fig. 1 Incoming SMS
You can use the "ASCII Data Parser" parser from the installation package to parse it. You should enable this parser on the "Query Parse Filter" tab (fig. 2).
Fig. 2 GPS tracker SMS. Selecting the parser
Then you should open the parser configuration dialog box (fig. 3) using the "Setup" button.
Fig. 3 GPS tracker SMS. Parser configuration
Select the To split data packets by sign characters option.
Then you should specify "#0D#0A" in the "Sign data packets ending". It corresponds to the hexadecimal codes of the ASCII <CR> and <LF> characters.
The following filter rule allows parsing data packets only and discards the sender's info (fig. 4).
Fig. 4 Filter
You should specify the text message's fields on the "Data parsing" tab (fig. 5).
Fig. 5 Parser variables
You should add the description of all values you want to extract from the message to the tree of parser variables. You can see one of the values in figure 5.
- Variable name – this name will be used later in the filter and data export plugins. The name may contain only Latin letters.
- Data processing type – this option determines how the parser should extract the value from the message text. A special character in this example separates all values. So select the corresponding data processing type.
- Data type - defines the data type of the extracted value. IMEI is a string of characters in this example, which corresponds to the String type. Later, the parser will apply formatting rules depending on the selected data type: trim spaces from strings, convert a timestamp using the specified date and time format.
- Positive integers – Word
- Positive and negative decimal number – Integer
- Real-valued numbers – Float
- Date – Date
- Time – Time
- Date and time – Datatime
- Default value – this value will be used when there is no such value in the text message, or it is impossible to convert it into the selected data type. The default value must correspond to the selected data type. For example, you cannot specify the default value for integers that consists not of digits.
- Field separator – specify the value separator for the previously selected data processing type. It is the "@" character in this example.
- Number - this number is the position of the value in the text message. The number of the first value is one.
Add the descriptions of all values that you need to extract from the text message in this way. The order of variables in the tree does not matter.
Use the "Date and time" field on the "Data format" tab (fig. 6) to specify the date and time format for the value extracted from the text message. This format will be used to convert the date and time string into the value of the Datetime type. If the format is specified incorrectly, an error message will appear in the program. You can find the detailed description of the characters used in the date and time format in the help file.
Fig. 6 Format options for strings and timestamp in SMS message
You should check the parser after you configure it.
1. To do it, click the "OK" button to save the changes.
2. Enable the DDE server data export plugin (fig. 7)
Fig. 7 Data export plugin
3. Click the "OK" button to save the changes.
4. Wait until a new text message is received and displayed in the program's main window.
5. Open the Program options dialog box and double-click the DDE server data export plugin. Switch to the "Active variables" tab in the DDE server dialog box (fig. 8). This list must contain the configured variables of the parser and their values. Here you can check whether the parser is configured correctly and change its options if necessary.
Fig. 8 Parsed SMS from a GPS tracker
Related articles: Processing SMS from GPS trackers using GSM modems
Installation
Configuration