AstraProtocolXParser 1.0.1

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package AstraProtocolXParser --version 1.0.1
                    
NuGet\Install-Package AstraProtocolXParser -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AstraProtocolXParser" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AstraProtocolXParser" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="AstraProtocolXParser" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AstraProtocolXParser --version 1.0.1
                    
#r "nuget: AstraProtocolXParser, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AstraProtocolXParser@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AstraProtocolXParser&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=AstraProtocolXParser&version=1.0.1
                    
Install as a Cake Tool

astra-protocol-x-parser-net6

An official lightweight .NET package for parsing data from Astra Telematics IoT devices.

This package is maintained by Astra Telematics and is currently up-to-date with Protocol X V2.8 although only supports the selected modules listed below.

Supported Data Modules
  • Device Power
  • GPS Data
  • Digital I/O
  • Analogue Inputs
  • Driver Behaviour
  • Driver ID
  • Signal Quality
  • GSM Network Info
  • Geofences
  • Temperature + Humidity Sensors
  • Astra Generic Debug Data
Please contact support@astratelematics.com if you would like support for a different module added

Installation

Available for easy installatio via Nuget, just search for "AstraProtocolXParser"

Basic example

This is a simple barebones .NET TCP server and is not meant for production use
using System.Net.Sockets;
using AstraProtocolXParser;

TcpListener tcpListener = new TcpListener(System.Net.IPAddress.Any, 2010);
List<Client> tcpClients = new List<Client>();

tcpListener.Start();

Console.WriteLine("started, listening on port 2010...");

for (;;)
{
    Client? newClient = null;
    if (tcpListener.Pending())
    {
        Console.WriteLine("new connection, accepting...");
        newClient = new Client(tcpListener.AcceptTcpClient());
        new Thread(new ThreadStart(newClient.run)).Start();
        tcpClients.Add(newClient);
    }

    Thread.Sleep(100);
}

class Client
{
    public TcpClient socket;
    public byte[] buffer = new byte[2048];
    public int bufferIndex = 0;
    public ManualResetEvent readResetEvent = new(false);

    public Client(TcpClient socket)
    {
        this.socket = socket;
    }

    public async void run()
    {
        int i;
        byte[] ackBuffer = { 0x06 };

        while (socket.Connected)
        {
            try
            {
                socket.GetStream().BeginRead(buffer, 0, buffer.Length, readCallback, this);

                if (readResetEvent.WaitOne(1000, false))
                {
                    readResetEvent.Reset();

                    Console.WriteLine($"{bufferIndex} bytes rxd");

                    string? error = null;
                    AstraProtocolXPacket? packet = AstraProtocolXPacket.fromBytes(buffer, bufferIndex, ref error);

                    if (packet != null)
                    {
                        if (packet.isLogin && packet.deviceData != null)
                        {
                            Console.WriteLine($"device logged in imei:{packet.deviceData.imei}, model:{packet.deviceData.model}, fw:{packet.deviceData.firmwareVersion}, csum:{packet.deviceData.settingsChecksum}");
                        }
                        else if (packet.reports.Count > 0)
                        {
                            Console.WriteLine($"{packet.reports.Count} reports parsed");
                            for (i = 0; i < packet.reports.Count; i++)
                            {
                                Console.WriteLine($" > sequence:{packet.reports[i].sequenceNumber}");

                                if (packet.reports[i].gpsData != null)
                                {
                                    Console.WriteLine($"   latitude:{packet.reports[i].gpsData!.latitude}, longitude: {packet.reports[i].gpsData!.longitude}");
                                }
                            }
                        }
                    }

                    if (error != null)
                    {
                        Console.WriteLine($"error parsing: {error}");
                    }

                    // ack
                    try
                    {
                        await socket.GetStream().WriteAsync(ackBuffer, 0, ackBuffer.Length);
                        await socket.GetStream().FlushAsync();
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            catch (Exception)
            {

            }

        }

        Console.WriteLine("disconnected");
    }

    private void readCallback(IAsyncResult ar)
    {
        Client? _client = ar.AsyncState as Client;

        try
        {
            if (_client != null)
            {
                if (_client.socket != null)
                {
                    _client.bufferIndex = _client.socket.GetStream().EndRead(ar);
                }
            }
        }
        catch (Exception)
        {
        }
        finally
        {
            if (_client != null)
            {
                _client.readResetEvent.Set();
            }
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated