Search code examples
phpparsingtcpgpssocketserver

Teltonika FM1100 GSM device Avl Data Ack


1) GPS FM1100 Module sends the following data

IMEI
123456788927333

2) We send 01 as binary to the GPS module ( IMEI no.accepted, we tell the module to send the raw data)

3) The GPS send the below raw data

Raw Data
00000000000000ff08060000014e0fcd6c30011eb91b3a0f0db2f400120019090000010402010002000118000001c700000013000000014e102471e2011eb91b3a0f0db2f4001500190b0000010402010102000118000001c700000000000000014e10396d22011eb804c50f11f254fffd0000080000010402010002000118000001c700000000000000014e10e4c5c8011eb804c50f11f25400000000000000010402010102000118000001c700000000000000014e10f90df8011eb340ff0f045796000d0000090000010402010002000118000001c70000001a000000014e14605ba4011eb340ff0f045796001c0000090000010402010102000118000001c700000000000600001880

Below is the parsed data, After parsing we are sending no. of data received ex: 6 as acknowledgement to the GPS module Array ( [timestamp] => 2015-06-10 04:38:48 [priority] => 1 [lng] => 51.5064245 [lat] => 25.1942671 [altitude] => 42 [angle] => 100 [statilite] => 10 [speed] => 0 [is_io_generated] => 1 [io_data] => Array ( [No IO Rec] => 04 [Data] => Array ( [0] => Array ( [No Rec One Byte] => 2 [Data] => Array ( [0] => Array ( [key] => 1 [val] => 1 )

                                [1] => Array
                                    (
                                        [key] => 2
                                        [val] => 0
                                    )

                            )

                    )

                [1] => Array
                    (
                        [No Rec Two Byte] => 1
                        [Data] => Array
                            (
                                [0] => Array
                                    (
                                        [key] => 24
                                        [val] => 0
                                    )

                            )

                    )

                [2] => Array
                    (
                        [No Rec Four Byte] => 1
                        [Data] => Array
                            (
                                [0] => Array
                                    (
                                        [key] => 199
                                        [val] => 0
                                    )

                            )

                    )

                [3] => Array
                    (
                        [No Rec Eight Byte] => 0
                        [Data] => Array
                            (
                            )

                    )

            )

    )

)

4) We are able to parse the data and send the acknowledgement to the GPS Module

5) But the GPS Module keeps sending the old data repeatedly in spite of send correct acknowledgement data.

We are not sure whether we are sending the acknowledgement data in the correct format mentioned in the GPS module manual.

Please help on this regard.

        if(strlen($rdata) == 15){
           $this->imei = $rdata; // imei number from the gps module
           $codata = pack("H*", "01"); // accept the connection and tell to the gps module to send the data
           $this->server->send('current client socket', $codata); //send to the gps module
        }else{
           $bh = bin2hex($rdata); // from gps module rawdata bin to hex
           $sql = $this->sqlparsingfm($bh); // parsing data

           $sdata = $data["norecord"]; // parsed data from the GPS module. no of record received

           $hex = str_pad($sdata, 8, "0", STR_PAD_LEFT);
           // $hex = "0x06";
           // $hex = pack("H*", "0x06");

           $this->server->send($e->parameters->idClient, $hex);
        }

?>

Below is the GPS Module Documentation link

Page no 7. Communication with Server section. Sending response back to the module

http://www.sourceforge.net/p/opengts/discussion/579834/thread/6fd0ffe8/6213/attachment/FMXXXX%20Protocols%20v2.10.pdf


Solution

  • First, don't use pack when it's not necessary. So, replace:

    $codata = pack("H*", "01"); // accept the connection and tell to the gps module to send the data
    $this->server->send('current client socket', $codata); //send to the gps module
    

    with

    $this->server->send('current client socket', "\x01");
    

    Next, to send a correct packet confirmation, change

    $this->server->send($e->parameters->idClient, $hex);
    

    to

    $this->server->send($e->parameters->idClient, pack('N', $sdata));
    

    and that should fix everything.