teltonika-fm-parser icon indicating copy to clipboard operation
teltonika-fm-parser copied to clipboard

Tracker sends same records again and again

Open lukasreusch opened this issue 3 years ago • 14 comments

Hey guys,

I am trying to collect some data from my FMB965. In general I am able to collect the data and writing it to a database.

But I have the problem, that tracker sends the same records again and again. The Last Server Response Time in the Configurator says 01.01.1970 01:00:00 (so, never?).

Something wrong with the Acknowledge-stuff?

Thank you!!

        $ip = env('SOCKET_SERVER_IP');
        $port = env('SOCKET_SERVER_PORT');

        $parser = new FmParser('tcp');
        $socket = stream_socket_server("tcp://$ip:$port", $errno, $errstr);
        $this->info("Listening to tcp://{$ip}:{$port}...");
        if (!$socket) {
            throw new \Exception("$errstr ($errno)");
        } else {
            while ($conn = stream_socket_accept($socket)) {
    
                // Read IMEI
                $payload = fread($conn, 1024);
                $imei = $parser->decodeImei($payload);
    
                // Accept packet
                fwrite($conn, Reply::accept());
    
                // Read Data
                $payload="";
                while( !feof( $conn ) ) {
                    $payload .= fread( $conn, 1024 ) ;
                }

                $packet = $parser->decodeData($payload);
    
                fwrite($conn, $parser->encodeAcknowledge($packet));

                foreach ($packet->getAvlDataCollection()->getAvlData() as $avlData) {
                    $gps = $avlData->getGpsElement();
                    // Create it in DB
                    $this->info('Record created');
                }
                fclose($conn);
            }
    
            fclose($socket);
        }

lukasreusch avatar Jul 09 '22 12:07 lukasreusch

I've now debugged a little bit more. The number of data bytes, sent with the payload, is matching the count of records I create from the data. And this, is matching the numberOfData of the collectino. So, I don't see any problems here.

Even if I use the numberOfData-bytes from the payload directly and return it with pack('N', ...), the tracker ignores it....

lukasreusch avatar Jul 10 '22 07:07 lukasreusch

@uro can you help?

lukasreusch avatar Jul 14 '22 21:07 lukasreusch

Hey @lukasreusch

Hmm, thinking about it now. It looks like the tracker is not acknowledging received data and resending it.

Just in case, could you confirm on the teltonika configurator that the device can receive data? I see this as a problem if the amount of received data is 0. Otherwise, we can validate the checksums.

uro avatar Aug 14 '22 16:08 uro

Hi,

I believe the same problem appeared to me. When the tracker sends the AVL package it hopes to get a response with a count of packages that were received.

`[2022.10.06 14:23:07]-[NETWORK.PARSER] Parsing data from 0 socket, data len: 5

DUMP DATA START: 01 00 00 00 15 DUMP DATA END

[2022.10.06 14:23:07]-[NETWORK.PARSER] Server: 0, Record ACK received: 16777216, expected 21`

Don't know why, but the tracker receives "01" at the beginning of message.

algirdas-iterato avatar Oct 06 '22 14:10 algirdas-iterato

Hey @algirdas-iterato did you solve this issue?

uro avatar Sep 21 '23 09:09 uro

Hi @uro or anyone with solution to this issue. i write below code but yet still i receive the same gps location again and again

fwrite($conn,"\x01");
fwrite($conn, $parser->encodeAcknowledge($packet));
 fwrite($conn, Reply::accept());

Anyone with a solution to this?``

salboy avatar Oct 25 '23 19:10 salboy

@salboy

I don't have any teltonika device atm. As you can find in the docs, the device will resend the payload if the confirmation checksum that you reply with does not match.

I would validate what data you use to calculate the checksum. Then I would check what they expect.

[2022.10.06 14:23:07]-[NETWORK.PARSER] Server: 0, Record ACK received: 16777216, expected 21`

This example shows an obvious problem here. Just check why they want you to send them 21. Is there something we're not reading from the device?

I would also check for any updates to the teltonika software; maybe there is a new contract and something changed on the communication level.

I can implement some changes but won't do the early debugging. Please help to find the issue. Thanks

uro avatar Oct 25 '23 20:10 uro

@uro Here is my linkedin www.linkedin.com/in/salieu-sallah-a63575b4 please connect and debug if possible .

Thanks

salboy avatar Oct 27 '23 09:10 salboy

Hi @uro

I have the same problem with the FMB965. It continue to sent the same records.

Did you solve your problem?

Thanks in advance

MPE-Danitech avatar Jan 26 '24 09:01 MPE-Danitech

@lukasreusch @salboy @uro @MPE-Danitech

I got the same problem and solved it by providing the time to the device (FMxxx) to process the acknowledge from the server. Just add a sleep(1) between the fwrite and fclose was enough :

fwrite($conn, $parser->encodeAcknowledge($packet));

sleep(1)

fclose($conn);

I hope it helps!

youb22 avatar Apr 20 '24 08:04 youb22

Thanks @du22. I'll try that next time I play with the FMB965.

MPE-Danitech avatar Apr 22 '24 05:04 MPE-Danitech