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:

Authentication decode:

// Recieve data from tcp socket
$payloadFromDevice = "000F313233343536373839303132333435";

// Decode recieved data
$decoder = new TcpDecoder();

// Check if data which we recieved are authentication or Gps records
if($decoder->isAuthentication($payloadFromDevice)){ // returns true;
    
    $imei = $decoder->decodeAuthentication($payloadFromDevice);
    echo json_encode(imei);
    
    // Check if device is authenticated in your system, and then encode response for device
    $encoder = new TcpEncoder();
    $payload = $encoder->encodeAuthentication(true); // Yes, device was authenticated successfully

    // send $payload though the socket.
}

Echo will return:

{
    "imei": "862259588834290"
}
// Now we need to wait for next data from the device

// Recieve next payload from the socket (now with data)
$tcpPayloadFromDevice = "00000000000000FE080400000113fc208dff000f14f650209cca80006f...";

// Decode it
$data = $this->decoder->decodeData($payload);

echo json_encode(data);

Echo will return:

[{
	"dateTime": {
		"date": "2007-07-25 06:46:38.000000",
		"timezone_type": 3,
		"timezone": "UTC"
	},
	"priority": 0,
	"gpsData": {
		"longitude": 25.3032016,
		"latitude": 54.7146368,
		"altitude": 111,
		"angle": 214,
		"satellites": 4,
		"speed": 4,
		"hasGpsFix": true
	}
}, {
	"dateTime": {
		"date": "2007-07-25 06:46:38.000000",
		"timezone_type": 3,
		"timezone": "UTC"
	},
	"priority": 0,
	"gpsData": {
		"longitude": 25.3032016,
		"latitude": 54.7146368,
		"altitude": 111,
		"angle": 214,
		"satellites": 4,
		"speed": 4,
		"hasGpsFix": true
	}
}]

See tests for more examples!

Todo:

  • Implement TCP protocol (encode and decode)
  • Implement gps sensors data (IOElement)
  • Implement UDP protocol (encode and decode)
  • Implement SMS protocol

License:

Public domain

teltonika-fm-parser's People

Contributors

uro avatar gricob avatar

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.