Code Monkey home page Code Monkey logo

teltonika-fm-parser's Introduction

Teltonika FM-XXXX Parser

Build Status Scrutinizer Code Quality CodeFactor Latest Stable Version Total Downloads

This repository is object oriented library to translate Teltonika protocols.

You could use this library in your server, it will help you talk with Teltonika devices.

It was build with Teltonika protocols v2.10 documentation.

Requirements:

{
    "require": {
        "php": ">=7.0"
    },
    "require-dev": {
        "phpunit/phpunit": "^5.7"
    }
}

Usage:

$parser = new FmParser('tcp');

// Decode IMEI
$imei = $parser->decodeImei($payload);

// Decode Data Packet
$packet = $parser->decodeData($payload);

Examples

TCP

	$parser = new FmParser('tcp');
	$socket = stream_socket_server("tcp://0.0.0.0:8043", $errno, $errstr);
	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());

			// Decline packet
			// fwrite($conn, Reply::reject());
			
			// Read Data
			$payload = fread($conn, 1024);
			$packet = $parser->decodeData($payload);

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

			// Close connection
			fclose($conn);
		}

		fclose($socket);
	}
}

License:

Public domain

teltonika-fm-parser's People

Contributors

algirdas-iterato avatar gricob avatar uro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

teltonika-fm-parser's Issues

Understanding how this works

Hi All,

I'm trying to figure out how all this works I have an FMT100, that I want to read the acl packet and parse it.

Does this library provide a TCP server for the fmt100 to connect to?

code is not viewed

while deploying code to server, forbidden message shown. no access to view . please help me

Not getting Proper data

hello,
I have static data getting from device in Hex format.
I get attached array which is not provide gps data.
Can you help me?
While I used another lib. I get some data and some is also wrong (another lib https://github.com/wsilence/gps_bones)
decode.txt

decodeData($payload); $packet = (array) $packet; echo '
';
print_r($packet);
exit;

Tracker sends same records again and again

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);
        }

Int16 read problem

I have TAT100 GPS device.

I got error: Cannot read 16-bit int, it exceeds the boundary of the file
this error gives PhpBinaryReader
caller is Codec8Extended.decodeIoProperties

hexdec data is:

00000000000004d18e0f0000018655db97a0010e7e94b72366763f000000000000000000000a000400f000001502004502012f00000400b5000000b600000018000000431bb2000100f1000060e100014e2f00000000000000c700000000018655e12968010e7e94b72366763f000000000000000000000a000400f000001502004502012f00000400b5000000b600000018000000431bba000100f1000060e100014e2f00000000000000c700000000018655e6b748010e7e94b72366763f000000000000000000000a000400f000001502004502012f00000400b5000000b600000018000000431bba000100f1000060e100014e2f00000000000000c700000000018655ec3d58010e7e94b72366763f000000000000000000000a000400f000001502004502012f00000400b5000000b600000018000000431bba000100f1000060e100014e2f00000000000000c700000000018655f1c750010e7e94b72366763f000000000000000000000a000400f001001501004502012f00000400b5000000b600000018000000431b95000100f1000060e100014e2f00000000000000c700000000018655f75148010e7e94b72366763f000000000000000000000a000400f000001502004502012f00000400b5000000b600000018000000431b95000100f1000060e100014e2f00000000000000c700000000018655fcd758010e7e94b72366763f000000000000000000000a000400f000001502004502012f00000400b5000000b600000018000000431b91000100f1000060e100014e2f00000000000000c700000000018656026150010e7e94b72366763f000000000000000000000a000400f000001502004502012f00000400b5000000b600000018000000431b91000100f1000060e100014e2f00000000000000c70000000001865607eb48010e7e94b72366763f000000000000000000000a000400f000001501004502012f00000400b5000000b600000018000000431b91000100f1000060e100014e2f00000000000000c7000000000186560d7540010e7e94b72366763f000000000000000000000a000400f000001502004502012f00000400b5000000b600000018000000431b95000100f1000060e100014e2f00000000000000c700000000018656130320010e7e94b72366763f000000000000000000000a000400f001001502004502012f00000400b5000000b600000018000000431bb2000100f1000060e100014e2f00000000000000c7000000000186561894e8010e7e94b72366763f000000000000000000000a000400f001001502004502012f00000400b5000000b600000018000000431bba000100f1000060e100014e2f00000000000000c7000000000186561e22c8010e7e94b72366763f000000000000000000000a0004

Received packet problems

In the example
$payload = fread($conn, 1024);
If the packet is bigger than 1024 don't works fine

Solution tested:

$payload="";

			while( !feof( $conn ) ) {
		 $payload.=fread( $conn, 1024 ) ;
		}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.