├── .gitignore ├── GPS Listener Parser ├── AsynchronousIoServer.cs ├── DBLogic │ ├── DBUtils.cs │ ├── Data.cs │ └── GPSdata.cs ├── GPS Listener Parser.csproj ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Settings.Designer.cs │ └── Settings.settings ├── Scripts │ └── DatabaseScript.sql ├── Teltonika │ ├── FMXXXX_Parser.cs │ ├── GH3000Parser.cs │ ├── ParserBase.cs │ └── TeltonikaDevicesParser.cs ├── Utils │ └── SMSsender.cs └── app.config ├── GPS TCP Listener Parser.sln ├── LICENSE ├── README.md └── Server Listener Tests ├── GPSTest.csproj ├── Properties └── AssemblyInfo.cs ├── bin └── Release │ ├── GPSParser.exe │ ├── GPSParser.pdb │ ├── GPSTest.dll │ └── GPSTest.pdb └── obj └── Release ├── DesignTimeResolveAssemblyReferencesInput.cache ├── GPSTest.csproj.FileListAbsolute.txt ├── GPSTest.csprojResolveAssemblyReference.cache ├── GPSTest.dll └── GPSTest.pdb /.gitignore: -------------------------------------------------------------------------------- 1 | # Download this file using PowerShell v3 under Windows with the following comand: 2 | # Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore 3 | # or wget: 4 | # wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.sln.docstates 10 | 11 | # Build results 12 | 13 | [Dd]ebug/ 14 | [Rr]elease/ 15 | x64/ 16 | build/ 17 | [Bb]in/ 18 | [Oo]bj/ 19 | 20 | # NuGet Packages 21 | *.nupkg 22 | # The packages folder can be ignored because of Package Restore 23 | **/packages/* 24 | # except build/, which is used as an MSBuild target. 25 | !**/packages/build/ 26 | # Uncomment if necessary however generally it will be regenerated when needed 27 | #!**/packages/repositories.config 28 | 29 | # MSTest test Results 30 | [Tt]est[Rr]esult*/ 31 | [Bb]uild[Ll]og.* 32 | 33 | *_i.c 34 | *_p.c 35 | *.ilk 36 | *.meta 37 | *.obj 38 | *.pch 39 | *.pdb 40 | *.pgc 41 | *.pgd 42 | *.rsp 43 | *.sbr 44 | *.tlb 45 | *.tli 46 | *.tlh 47 | *.tmp 48 | *.tmp_proj 49 | *.log 50 | *.vspscc 51 | *.vssscc 52 | .builds 53 | *.pidb 54 | *.log 55 | *.scc 56 | 57 | # OS generated files # 58 | .DS_Store* 59 | Icon? 60 | 61 | # Visual C++ cache files 62 | ipch/ 63 | *.aps 64 | *.ncb 65 | *.opensdf 66 | *.sdf 67 | *.cachefile 68 | 69 | # Visual Studio profiler 70 | *.psess 71 | *.vsp 72 | *.vspx 73 | 74 | # Guidance Automation Toolkit 75 | *.gpState 76 | 77 | # ReSharper is a .NET coding add-in 78 | _ReSharper*/ 79 | *.[Rr]e[Ss]harper 80 | 81 | # TeamCity is a build add-in 82 | _TeamCity* 83 | 84 | # DotCover is a Code Coverage Tool 85 | *.dotCover 86 | 87 | # NCrunch 88 | *.ncrunch* 89 | .*crunch*.local.xml 90 | 91 | # Installshield output folder 92 | [Ee]xpress/ 93 | 94 | # DocProject is a documentation generator add-in 95 | DocProject/buildhelp/ 96 | DocProject/Help/*.HxT 97 | DocProject/Help/*.HxC 98 | DocProject/Help/*.hhc 99 | DocProject/Help/*.hhk 100 | DocProject/Help/*.hhp 101 | DocProject/Help/Html2 102 | DocProject/Help/html 103 | 104 | # Click-Once directory 105 | publish/ 106 | 107 | # Publish Web Output 108 | *.Publish.xml 109 | 110 | # Windows Azure Build Output 111 | csx 112 | *.build.csdef 113 | 114 | # Windows Store app package directory 115 | AppPackages/ 116 | 117 | # Others 118 | *.Cache 119 | ClientBin/ 120 | [Ss]tyle[Cc]op.* 121 | ~$* 122 | *~ 123 | *.dbmdl 124 | *.[Pp]ublish.xml 125 | *.pfx 126 | *.publishsettings 127 | modulesbin/ 128 | tempbin/ 129 | 130 | # EPiServer Site file (VPP) 131 | AppData/ 132 | 133 | # RIA/Silverlight projects 134 | Generated_Code/ 135 | 136 | # Backup & report files from converting an old project file to a newer 137 | # Visual Studio version. Backup files are not needed, because we have git ;-) 138 | _UpgradeReport_Files/ 139 | Backup*/ 140 | UpgradeLog*.XML 141 | UpgradeLog*.htm 142 | 143 | # vim 144 | *.txt~ 145 | *.swp 146 | *.swo 147 | 148 | # svn 149 | .svn 150 | 151 | # Remainings from resolvings conflicts in Source Control 152 | *.orig 153 | 154 | # SQL Server files 155 | **/App_Data/*.mdf 156 | **/App_Data/*.ldf 157 | **/App_Data/*.sdf 158 | 159 | 160 | #LightSwitch generated files 161 | GeneratedArtifacts/ 162 | _Pvt_Extensions/ 163 | ModelManifest.xml 164 | 165 | # ========================= 166 | # Windows detritus 167 | # ========================= 168 | 169 | # Windows image file caches 170 | Thumbs.db 171 | ehthumbs.db 172 | 173 | # Folder config file 174 | Desktop.ini 175 | 176 | # Recycle Bin used on file shares 177 | $RECYCLE.BIN/ 178 | 179 | # Mac desktop service store files 180 | .DS_Store 181 | 182 | # SASS Compiler cache 183 | .sass-cache 184 | 185 | # Visual Studio 2014 CTP 186 | **/*.sln.ide 187 | 188 | # Visual Studio temp something 189 | .vs/ 190 | 191 | # VS 2015+ 192 | *.vc.vc.opendb 193 | *.vc.db 194 | 195 | **/node_modules/* 196 | 197 | ##### 198 | # End of core ignore list, below put you custom 'per project' settings (patterns or path) 199 | ##### -------------------------------------------------------------------------------- /GPS Listener Parser/AsynchronousIoServer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Net.Sockets; 6 | using System.Net; 7 | using System.Collections.ObjectModel; 8 | using GPSParser.Teltonika; 9 | 10 | namespace GPSParser 11 | { 12 | public class AsynchronousIoServer 13 | { 14 | private Socket _serverSocket; 15 | private int _port; 16 | private ObservableCollection _connections = new ObservableCollection(); 17 | 18 | public AsynchronousIoServer(int port) 19 | { 20 | _port = port; 21 | _connections.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(_connections_CollectionChanged); 22 | } 23 | 24 | void _connections_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) 25 | { 26 | Console.Title = _connections.Count + " devices connected"; 27 | } 28 | 29 | private void SetupServerSocket() 30 | { 31 | //IPHostEntry localMachineInfo = 32 | // Dns.GetHostEntry(Dns.GetHostName()); 33 | //IPEndPoint myEndpoint = new IPEndPoint( 34 | // localMachineInfo.AddressList[3], _port); 35 | //_serverSocket = new Socket(myEndpoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); 36 | //_serverSocket.Bind(myEndpoint); 37 | 38 | string IP = GPSParser.Properties.Settings.Default.IPaddress; 39 | IPEndPoint myEndpoint = new IPEndPoint(IPAddress.Parse(IP), _port); 40 | 41 | _serverSocket = new Socket(myEndpoint.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); 42 | _serverSocket.Bind(myEndpoint); 43 | 44 | _serverSocket.Listen((int)SocketOptionName.MaxConnections); 45 | } 46 | private class ConnectionInfo 47 | { 48 | public Socket Socket; 49 | public byte[] Buffer; 50 | public bool isPartialLoaded; 51 | public List TotalBuffer; 52 | public string IMEI; 53 | } 54 | 55 | public void Start() 56 | { 57 | SetupServerSocket(); 58 | // number of simultaneous connections can be accepted 59 | for (int i = 0; i < 2000; i++) 60 | _serverSocket.BeginAccept(new 61 | AsyncCallback(AcceptCallback), _serverSocket); 62 | } 63 | 64 | private void AcceptCallback(IAsyncResult result) 65 | { 66 | ConnectionInfo connection = new ConnectionInfo(); 67 | try 68 | { 69 | // Finish Accept operation 70 | Socket s = (Socket)result.AsyncState; 71 | connection.Socket = s.EndAccept(result); 72 | connection.Buffer = new byte[1024]; 73 | // add connection to connection list 74 | lock (_connections) 75 | { 76 | _connections.Add(connection); 77 | } 78 | 79 | // Start BeginReceive operation on connected device and make new BeginAccept operation on socket 80 | // for accept new connectionrequests. 81 | connection.Socket.BeginReceive(connection.Buffer, 82 | 0, connection.Buffer.Length, SocketFlags.None, 83 | new AsyncCallback(ReceiveCallback), connection); 84 | _serverSocket.BeginAccept(new AsyncCallback(AcceptCallback), result.AsyncState); 85 | } 86 | catch (SocketException exc) 87 | { 88 | CloseConnection(connection); 89 | Console.WriteLine("Socket exception: " + 90 | exc.SocketErrorCode); 91 | } 92 | catch (Exception exc) 93 | { 94 | CloseConnection(connection); 95 | Console.WriteLine("Exception: " + exc); 96 | } 97 | } 98 | 99 | private void ReceiveCallback(IAsyncResult result) 100 | { 101 | ConnectionInfo connection = (ConnectionInfo)result.AsyncState; 102 | try 103 | { 104 | //get a number of received bytes 105 | int bytesRead = connection.Socket.EndReceive(result); 106 | if (bytesRead > 0) 107 | { 108 | //because device sends data with portions we need summary all portions to total buffer 109 | if (connection.isPartialLoaded) 110 | { 111 | connection.TotalBuffer.AddRange(connection.Buffer.Take(bytesRead).ToList()); 112 | } 113 | else 114 | { 115 | if (connection.TotalBuffer != null) 116 | connection.TotalBuffer.Clear(); 117 | connection.TotalBuffer = connection.Buffer.Take(bytesRead).ToList(); 118 | } 119 | //-------- Get Length of current received data ---------- 120 | string hexDataLength = string.Empty; 121 | 122 | //Skip four zero bytes an take next four bytes with value of AVL data array length 123 | connection.TotalBuffer.Skip(4).Take(4).ToList().ForEach(delegate(byte b) { hexDataLength += String.Format("{0:X2}", b); }); 124 | 125 | int dataLength = Convert.ToInt32(hexDataLength, 16); 126 | // 127 | //bytesRead = 17 when parser receive IMEI from device 128 | //if datalength encoded in data > then total buffer then is a partial data a device will send next part 129 | //we send confirmation and wait next portion of data 130 | if (dataLength + 12 > connection.TotalBuffer.Count && bytesRead != 17) 131 | { 132 | connection.isPartialLoaded = true; 133 | connection.Socket.Send(new byte[] { 0x01 }); 134 | connection.Socket.BeginReceive(connection.Buffer, 0, connection.Buffer.Length, SocketFlags.None, 135 | new AsyncCallback(ReceiveCallback), connection); 136 | return; 137 | } 138 | 139 | bool isDataPacket = true; 140 | 141 | //when device send AVL data first 4 bytes is 0 142 | string firstRourBytes = string.Empty; 143 | connection.TotalBuffer.Take(4).ToList().ForEach(delegate(byte b) { firstRourBytes += String.Format("{0:X2}", b); }); 144 | if (Convert.ToInt32(firstRourBytes, 16) > 0) 145 | isDataPacket = false; 146 | 147 | // if is true then is AVL data packet 148 | // else that a IMEI sended 149 | if (isDataPacket) 150 | { 151 | if (GPSParser.Properties.Settings.Default.ShowDiagnosticMessages) 152 | { 153 | //all data we convert this to string in hex format only for diagnostic 154 | StringBuilder data = new StringBuilder(); 155 | connection.TotalBuffer.ForEach(delegate(byte b) { data.AppendFormat("{0:X2}", b); }); 156 | Console.WriteLine("<" + data); 157 | } 158 | TeltonikaDevicesParser decAVL = new TeltonikaDevicesParser(GPSParser.Properties.Settings.Default.ShowDiagnosticMessages); 159 | decAVL.OnDataReceive += new Action(decAVL_OnDataReceive); 160 | //if CRC not correct number of data returned by AVL parser = 0; 161 | int numberOfData = decAVL.Decode(connection.TotalBuffer, connection.IMEI); 162 | if (!connection.isPartialLoaded) 163 | { 164 | // send to device number of received data for confirmation. 165 | if (numberOfData > 0) 166 | connection.Socket.Send(new byte[] { 0x00, 0x00, 0x00, Convert.ToByte(numberOfData) }); 167 | else 168 | //send 0 number of data if CRC not correct for resend data from device 169 | connection.Socket.Send(new byte[] { 0x00, 0x00, 0x00, 0x00 }); 170 | } 171 | decAVL.OnDataReceive -= new Action(decAVL_OnDataReceive); 172 | Console.WriteLine("Modem ID: " + connection.IMEI + " send data"); 173 | } 174 | else 175 | { 176 | //if is not data packet then is it IMEI info send from device 177 | connection.IMEI = Encoding.ASCII.GetString(connection.TotalBuffer.Skip(2).ToArray()); 178 | connection.Socket.Send(new byte[] { 0x01 }); 179 | Console.WriteLine("Modem ID: " + connection.IMEI + " connected"); 180 | } 181 | // Get next data portion from device 182 | connection.Socket.BeginReceive(connection.Buffer, 0, connection.Buffer.Length, SocketFlags.None, 183 | new AsyncCallback(ReceiveCallback), connection); 184 | }//if all data received then close connection 185 | else CloseConnection(connection); 186 | } 187 | catch (SocketException exc) 188 | { 189 | CloseConnection(connection); 190 | Console.WriteLine("Socket exception: " + exc.SocketErrorCode); 191 | } 192 | catch (Exception exc) 193 | { 194 | CloseConnection(connection); 195 | Console.WriteLine("Exception: " + exc); 196 | } 197 | } 198 | 199 | void decAVL_OnDataReceive(string obj) 200 | { 201 | Console.WriteLine(obj); 202 | } 203 | 204 | private void CloseConnection(ConnectionInfo ci) 205 | { 206 | ci.Socket.Close(); 207 | lock (_connections) 208 | { 209 | _connections.Remove(ci); 210 | Console.WriteLine("Modem ID: " + ci.IMEI + " disconnected"); 211 | } 212 | } 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /GPS Listener Parser/DBLogic/DBUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Data.SqlClient; 6 | using System.Data; 7 | 8 | namespace GPSParser.DBLogic 9 | { 10 | public class DBUtils 11 | { 12 | private string connectionString; 13 | public DBUtils() 14 | { 15 | connectionString = GetConnectionString(); 16 | } 17 | public string GetConnectionString() 18 | { 19 | return GPSParser.Properties.Settings.Default.GPS_TrackingConnectionString; 20 | } 21 | 22 | //----------------------------------------------------------------------------------// 23 | //**********************************************************************************// 24 | //----------------------------------------------------------------------------------// 25 | public SqlCommand InitSP(string spname) 26 | { 27 | SqlCommand command = new SqlCommand(); 28 | command.Connection = new SqlConnection(GetConnectionString()); 29 | command.Connection.Open(); 30 | command.CommandText = spname; 31 | command.CommandType = System.Data.CommandType.StoredProcedure; 32 | command.Parameters.Add(new SqlParameter("Result", System.Data.SqlDbType.Int)).Direction = System.Data.ParameterDirection.ReturnValue; 33 | return command; 34 | } 35 | public SqlCommand InitQuery(string sql) 36 | { 37 | SqlCommand command = new SqlCommand(); 38 | command.Connection = new SqlConnection(GetConnectionString()); 39 | command.Connection.Open(); 40 | command.CommandText = sql; 41 | command.CommandType = System.Data.CommandType.Text; 42 | return command; 43 | } 44 | 45 | public void ExecSP(SqlCommand sp) 46 | { 47 | sp.ExecuteNonQuery(); 48 | 49 | if (!sp.Parameters[0].Value.Equals(0)) 50 | throw new Exception("Stored procedure (" + sp.CommandText + ") result error: " + sp.Parameters[0].Value.ToString()); 51 | } 52 | 53 | public object ExecFunction(SqlCommand sp) 54 | { 55 | sp.ExecuteNonQuery(); 56 | return sp.Parameters[0].Value; 57 | } 58 | 59 | public void ExecQuery(SqlCommand InitQuery) 60 | { 61 | try 62 | { 63 | InitQuery.ExecuteNonQuery(); 64 | } 65 | catch (Exception ex) 66 | { 67 | throw new Exception("Exception while store in db: " + ex.ToString()); 68 | } 69 | finally 70 | { 71 | FreeSP(InitQuery); 72 | } 73 | } 74 | 75 | public SqlDataReader OpenSP(SqlCommand sp) 76 | { 77 | return sp.ExecuteReader(CommandBehavior.CloseConnection); 78 | } 79 | 80 | public void FreeSP(SqlCommand sp) 81 | { 82 | if (sp == null) return; 83 | sp.Connection.Close(); 84 | sp.Dispose(); 85 | sp = null; 86 | } 87 | } 88 | 89 | 90 | } 91 | -------------------------------------------------------------------------------- /GPS Listener Parser/DBLogic/Data.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Globalization; 6 | using System.Data.SqlClient; 7 | 8 | namespace GPSParser.DBLogic 9 | { 10 | public class Data 11 | { 12 | public void SaveGPSPositionFMXXXX(GPSdata gpsPos) 13 | { 14 | DBUtils db = new DBUtils(); 15 | SqlCommand sp = db.InitSP("SaveGPSpointFMXXXX"); 16 | sp.Parameters.AddWithValue("@priority", gpsPos.Priority.Value); 17 | 18 | sp.Parameters.AddWithValue("@device_id", gpsPos.IMEI); 19 | sp.Parameters.AddWithValue("@latitude", gpsPos.Lat.Value); 20 | sp.Parameters.AddWithValue("@longitude", gpsPos.Long.Value); 21 | sp.Parameters.AddWithValue("@altitude", gpsPos.Altitude); 22 | sp.Parameters.AddWithValue("@speed", gpsPos.Speed); 23 | sp.Parameters.AddWithValue("@direction", gpsPos.Direction); 24 | sp.Parameters.AddWithValue("@satellites", gpsPos.Satellites); 25 | sp.Parameters.AddWithValue("@rtc_time", gpsPos.Timestamp.Value); 26 | try 27 | { 28 | db.ExecSP(sp); 29 | } 30 | catch (Exception ex) 31 | { 32 | 33 | } 34 | finally 35 | { 36 | db.FreeSP(sp); 37 | } 38 | } 39 | 40 | public void SaveGPSPositionGH3000(GPSdata gpsPos) 41 | { 42 | DBUtils db = new DBUtils(); 43 | 44 | SqlCommand sp = db.InitSP("SaveGPSpointFMXXXX"); 45 | sp.Parameters.AddWithValue("@priority", gpsPos.Priority.Value); 46 | 47 | sp.Parameters.AddWithValue("@device_id", gpsPos.IMEI); 48 | sp.Parameters.AddWithValue("@latitude", gpsPos.Lat.Value); 49 | sp.Parameters.AddWithValue("@longitude", gpsPos.Long.Value); 50 | sp.Parameters.AddWithValue("@altitude", gpsPos.Altitude); 51 | sp.Parameters.AddWithValue("@speed", gpsPos.Speed); 52 | sp.Parameters.AddWithValue("@direction", gpsPos.Direction); 53 | sp.Parameters.AddWithValue("@satellites", gpsPos.Satellites); 54 | sp.Parameters.AddWithValue("@rtc_time", gpsPos.Timestamp.Value); 55 | try 56 | { 57 | db.ExecSP(sp); 58 | } 59 | catch (Exception ex) 60 | { 61 | 62 | } 63 | finally 64 | { 65 | db.FreeSP(sp); 66 | } 67 | } 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /GPS Listener Parser/DBLogic/GPSdata.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace GPSParser.DBLogic 7 | { 8 | public class GPSdata 9 | { 10 | 11 | private int _ID; 12 | public int ID 13 | { 14 | get { return _ID; } 15 | set { _ID = value; } 16 | } 17 | 18 | private string _IMEI; 19 | public string IMEI 20 | { 21 | get { return _IMEI; } 22 | set { _IMEI = value; } 23 | } 24 | 25 | private System.Nullable _timestamp; 26 | public System.Nullable Timestamp 27 | { 28 | get { return _timestamp; } 29 | set { _timestamp = value; } 30 | } 31 | 32 | private System.Nullable _priority; 33 | public System.Nullable Priority 34 | { 35 | get { return _priority; } 36 | set { _priority = value; } 37 | } 38 | 39 | private System.Nullable _long; 40 | public System.Nullable Long 41 | { 42 | get { return _long; } 43 | set { _long = value; } 44 | } 45 | 46 | private System.Nullable _lat; 47 | public System.Nullable Lat 48 | { 49 | get { return _lat; } 50 | set { _lat = value; } 51 | } 52 | 53 | private System.Nullable _altitude; 54 | public System.Nullable Altitude 55 | { 56 | get { return _altitude; } 57 | set { _altitude = value; } 58 | } 59 | 60 | private System.Nullable _direction; 61 | public System.Nullable Direction 62 | { 63 | get { return _direction; } 64 | set { _direction = value; } 65 | } 66 | 67 | private System.Nullable _satellites; 68 | public System.Nullable Satellites 69 | { 70 | get { return _satellites; } 71 | set { _satellites = value; } 72 | } 73 | 74 | private System.Nullable _speed; 75 | public System.Nullable Speed 76 | { 77 | get { return _speed; } 78 | set { _speed = value; } 79 | } 80 | 81 | private System.Nullable _localAreaCode; 82 | public System.Nullable LocalAreaCode 83 | { 84 | get { return _localAreaCode; } 85 | set { _localAreaCode = value; } 86 | } 87 | 88 | private System.Nullable _cellID; 89 | public System.Nullable CellID 90 | { 91 | get { return _cellID; } 92 | set { _cellID = value; } 93 | } 94 | 95 | private System.Nullable _gsmSignalQuality; 96 | public System.Nullable GsmSignalQuality 97 | { 98 | get { return _gsmSignalQuality; } 99 | set { _gsmSignalQuality = value; } 100 | } 101 | 102 | private System.Nullable _operatorCode; 103 | public System.Nullable OperatorCode 104 | { 105 | get { return _operatorCode; } 106 | set { _operatorCode = value; } 107 | } 108 | 109 | private byte event_IO_element_ID; 110 | public byte Event_IO_element_ID 111 | { 112 | get { return event_IO_element_ID; } 113 | set { event_IO_element_ID = value; } 114 | } 115 | 116 | private Dictionary _IO_Elements_1B = new Dictionary(); 117 | public Dictionary IO_Elements_1B 118 | { 119 | get { return _IO_Elements_1B; } 120 | set { _IO_Elements_1B = value; } 121 | } 122 | 123 | private Dictionary _IO_Elements_2B = new Dictionary(); 124 | public Dictionary IO_Elements_2B 125 | { 126 | get { return _IO_Elements_2B; } 127 | set { _IO_Elements_2B = value; } 128 | } 129 | 130 | private Dictionary _IO_Elements_4B = new Dictionary(); 131 | public Dictionary IO_Elements_4B 132 | { 133 | get { return _IO_Elements_4B; } 134 | set { _IO_Elements_4B = value; } 135 | } 136 | 137 | private Dictionary _IO_Elements_8B = new Dictionary(); 138 | public Dictionary IO_Elements_8B 139 | { 140 | get { return _IO_Elements_8B; } 141 | set { _IO_Elements_8B = value; } 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /GPS Listener Parser/GPS Listener Parser.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 9.0.30729 7 | 2.0 8 | {5D94AC34-AAEF-4858-B0A4-5872CCF2F891} 9 | Exe 10 | Properties 11 | GPSParser 12 | GPSParser 13 | v4.0 14 | 512 15 | 16 | 17 | 18 | 19 | 3.5 20 | 21 | 22 | 23 | 24 | true 25 | full 26 | false 27 | bin\Debug\ 28 | DEBUG;TRACE 29 | prompt 30 | 4 31 | AllRules.ruleset 32 | 33 | 34 | pdbonly 35 | true 36 | bin\Release\ 37 | TRACE 38 | prompt 39 | 4 40 | AllRules.ruleset 41 | 42 | 43 | 44 | 45 | 3.5 46 | 47 | 48 | 3.5 49 | 50 | 51 | 52 | 3.5 53 | 54 | 55 | 3.5 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | True 71 | True 72 | Settings.settings 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | SettingsSingleFileGenerator 85 | Settings.Designer.cs 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 100 | -------------------------------------------------------------------------------- /GPS Listener Parser/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using System.Net.Sockets; 4 | using System.Text; 5 | using System.Threading; 6 | using System.Linq; 7 | using System.Collections.Generic; 8 | using GPSParser; 9 | using System.Net.Sockets; 10 | using GPSParser.Teltonika; 11 | 12 | public class MultiRecv 13 | { 14 | public static void Main() 15 | { 16 | Console.Write("Port to listen: "); 17 | int port = Convert.ToInt32(Console.ReadLine()); 18 | Console.WriteLine("Creating server..."); 19 | 20 | AsynchronousIoServer Serv = new AsynchronousIoServer(port); 21 | Serv.Start(); 22 | 23 | Console.ReadLine(); 24 | } 25 | } -------------------------------------------------------------------------------- /GPS Listener Parser/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Socket")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Socket")] 13 | [assembly: AssemblyCopyright("Copyright © 2010")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e3bfe7ee-0677-4e37-a301-13c4cb0085d8")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /GPS Listener Parser/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.296 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace GPSParser.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] 29 | [global::System.Configuration.DefaultSettingValueAttribute("Data Source=DAVID-PC;Initial Catalog=GPS_Tracking;Integrated Security=True")] 30 | public string GPS_TrackingConnectionString { 31 | get { 32 | return ((string)(this["GPS_TrackingConnectionString"])); 33 | } 34 | } 35 | 36 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 37 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 38 | [global::System.Configuration.DefaultSettingValueAttribute("93.73.188.160")] 39 | public string IPaddress { 40 | get { 41 | return ((string)(this["IPaddress"])); 42 | } 43 | } 44 | 45 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 46 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 47 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 48 | public bool ShowDiagnosticMessages { 49 | get { 50 | return ((bool)(this["ShowDiagnosticMessages"])); 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /GPS Listener Parser/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | <?xml version="1.0" encoding="utf-16"?> 7 | <SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 8 | <ConnectionString>Data Source=DAVID-PC;Initial Catalog=GPS_Tracking;Integrated Security=True</ConnectionString> 9 | <ProviderName>System.Data.SqlClient</ProviderName> 10 | </SerializableConnectionString> 11 | Data Source=DAVID-PC;Initial Catalog=GPS_Tracking;Integrated Security=True 12 | 13 | 14 | 93.73.188.160 15 | 16 | 17 | True 18 | 19 | 20 | -------------------------------------------------------------------------------- /GPS Listener Parser/Scripts/DatabaseScript.sql: -------------------------------------------------------------------------------- 1 | USE [GPS_Tracking] 2 | GO 3 | /****** Object: Table [dbo].[GPS_Log] Script Date: 4/6/2019 8:02:06 PM ******/ 4 | SET ANSI_NULLS ON 5 | GO 6 | SET QUOTED_IDENTIFIER ON 7 | GO 8 | CREATE TABLE [dbo].[GPS_Log]( 9 | [Id] [int] IDENTITY(1,1) NOT NULL, 10 | [DeviceId] [varchar](50) NOT NULL, 11 | [DeviceTimeStamp] [datetime2](7) NULL, 12 | [ServerTimestamp] [datetime2](7) NULL, 13 | [Long] [decimal](12, 9) NULL, 14 | [Lat] [decimal](12, 9) NULL, 15 | [Altitude] [int] NULL, 16 | [Direction] [int] NULL, 17 | [Satellites] [int] NULL, 18 | [Speed] [int] NULL, 19 | CONSTRAINT [PK_GPS_Log] PRIMARY KEY CLUSTERED 20 | ( 21 | [Id] ASC 22 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 23 | ) ON [PRIMARY] 24 | GO 25 | /****** Object: Table [dbo].[GPS_Real] Script Date: 4/6/2019 8:02:07 PM ******/ 26 | SET ANSI_NULLS ON 27 | GO 28 | SET QUOTED_IDENTIFIER ON 29 | GO 30 | CREATE TABLE [dbo].[GPS_Real]( 31 | [DeviceId] [varchar](50) NOT NULL, 32 | [ServerTimestamp] [datetime2](7) NULL, 33 | [DeviceTimeStamp] [datetime2](7) NULL, 34 | [Long] [decimal](12, 9) NULL, 35 | [Lat] [decimal](12, 9) NULL, 36 | [Altitude] [int] NULL, 37 | [Direction] [int] NULL, 38 | [Satellites] [int] NULL, 39 | [Speed] [int] NULL, 40 | CONSTRAINT [PK_GPS_Real] PRIMARY KEY CLUSTERED 41 | ( 42 | [DeviceId] ASC 43 | )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 44 | ) ON [PRIMARY] 45 | GO 46 | /****** Object: StoredProcedure [dbo].[SaveGPSpointFMXXXX] Script Date: 4/6/2019 8:02:07 PM ******/ 47 | SET ANSI_NULLS ON 48 | GO 49 | SET QUOTED_IDENTIFIER ON 50 | GO 51 | 52 | 53 | -- ============================================= 54 | -- Author: 55 | -- Create date: 56 | -- Description: 57 | -- ============================================= 58 | CREATE PROCEDURE [dbo].[SaveGPSpointFMXXXX] 59 | -- Add the parameters for the stored procedure here 60 | @priority TINYINT , 61 | @device_id CHAR(15) , 62 | @latitude FLOAT , 63 | @longitude FLOAT , 64 | @altitude SMALLINT , 65 | @speed SMALLINT , 66 | @direction SMALLINT , 67 | @satellites TINYINT , 68 | @rtc_time DATETIME2 69 | AS 70 | BEGIN 71 | -- SET NOCOUNT ON added to prevent extra result sets from 72 | -- interfering with SELECT statements. 73 | SET NOCOUNT ON ; 74 | 75 | -- CHECK IF IS A REAL POSITION POINT OR LOGED POINT FROM DEVICE 76 | IF EXISTS (SELECT 1 FROM dbo.GPS_Real where DeviceId = @device_id) 77 | BEGIN 78 | -- TRY UPDATE table row 79 | UPDATE dbo.GPS_Real 80 | SET Lat = @latitude , 81 | Long = @longitude , 82 | Altitude = @altitude , 83 | Speed = @speed , 84 | Direction = @direction , 85 | [Satellites] = @satellites , 86 | DeviceTimeStamp = @rtc_time, 87 | ServerTimestamp = GETDATE() 88 | WHERE DeviceId = @device_id AND DeviceTimeStamp < @rtc_time 89 | 90 | END 91 | ELSE 92 | BEGIN 93 | -- CHECK IF TABLE ROW NOT UPDATES BECAUSE NOT EXISTS THEN INSERT 94 | BEGIN 95 | INSERT INTO dbo.GPS_Real 96 | ( DeviceId , 97 | Long , 98 | Lat , 99 | Altitude , 100 | Direction , 101 | Satellites , 102 | Speed , 103 | DeviceTimeStamp , 104 | ServerTimestamp 105 | ) 106 | VALUES ( @device_id , -- DeviceId - char(15) 107 | @longitude , -- Long - float 108 | @latitude , -- Lat - float 109 | @altitude , -- Altitude - smallint 110 | @direction , -- Direction - smallint 111 | @satellites , -- Satellites - tinyint 112 | @speed , -- Speed - smallint 113 | @rtc_time , -- DeviceTimeStamp - datetime 114 | GETDATE() 115 | ) 116 | END 117 | 118 | END 119 | -- AFTER UPDATE OR ADD ROW IN GPS_REAL INSERT ROW TO GPS_LOG TABLE 120 | INSERT INTO dbo.GPS_Log 121 | ( DeviceId , 122 | Long , 123 | Lat , 124 | Altitude , 125 | Direction , 126 | Satellites , 127 | Speed , 128 | DeviceTimeStamp, 129 | ServerTimestamp 130 | ) 131 | VALUES ( @device_id , -- DeviceId - char(15) 132 | @longitude , -- Long - float 133 | @latitude , -- Lat - float 134 | @altitude , -- Altitude - smallint 135 | @direction , -- Direction - smallint 136 | @satellites , -- Satellites - tinyint 137 | @speed , -- Speed - smallint 138 | @rtc_time , -- DeviceTimeStamp - datetime 139 | GETDATE() 140 | ) 141 | END 142 | 143 | 144 | GO 145 | -------------------------------------------------------------------------------- /GPS Listener Parser/Teltonika/FMXXXX_Parser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using GPSParser.DBLogic; 6 | 7 | namespace GPSParser.Teltonika 8 | { 9 | public class FMXXXX_Parser : ParserBase 10 | { 11 | public FMXXXX_Parser(bool showDiagnosticInfo) 12 | { 13 | _showDiagnosticInfo = showDiagnosticInfo; 14 | } 15 | public override int DecodeAVL(List receiveBytes, string IMEI) 16 | { 17 | string hexDataLength = string.Empty; 18 | receiveBytes.Skip(4).Take(4).ToList().ForEach(delegate(byte b) { hexDataLength += String.Format("{0:X2}", b); }); 19 | int dataLength = Convert.ToInt32(hexDataLength, 16); 20 | // byte[] test = receiveBytes.Skip(4).Take(4).ToArray(); 21 | // Array.Reverse(test); 22 | // int dataLength = BitConverter.ToInt32(test, 0); 23 | 24 | ShowDiagnosticInfo("Data Length: -----".PadRight(40, '-') + " " + dataLength); 25 | int codecId = Convert.ToInt32(receiveBytes.Skip(8).Take(1).ToList()[0]); 26 | ShowDiagnosticInfo("Codec ID: -----".PadRight(40, '-') + " " + codecId); 27 | int numberOfData = Convert.ToInt32(receiveBytes.Skip(9).Take(1).ToList()[0]); ; 28 | ShowDiagnosticInfo("Number of data: ----".PadRight(40, '-') + " " + numberOfData); 29 | 30 | int tokenAddress = 10; 31 | for (int n = 0; n < numberOfData; n++) 32 | { 33 | GPSdata gpsData = new GPSdata(); 34 | string hexTimeStamp = string.Empty; 35 | receiveBytes.Skip(tokenAddress).Take(8).ToList().ForEach(delegate(byte b) { hexTimeStamp += String.Format("{0:X2}", b); }); 36 | long timeSt = Convert.ToInt64(hexTimeStamp, 16); 37 | 38 | DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0); 39 | DateTime timestamp = origin.AddMilliseconds(Convert.ToDouble(timeSt)); 40 | 41 | ShowDiagnosticInfo("Timestamp: -----".PadRight(40, '-') + " " + timestamp.ToLongDateString() + " " + timestamp.ToLongTimeString()); 42 | 43 | int priority = Convert.ToInt32(receiveBytes.Skip(tokenAddress + 8).Take(1).ToList()[0]); 44 | ShowDiagnosticInfo("Priority: ------------".PadRight(40, '-') + " " + priority); 45 | 46 | string longt = string.Empty; 47 | receiveBytes.Skip(tokenAddress + 9).Take(4).ToList().ForEach(delegate(byte b) { longt += String.Format("{0:X2}", b); }); 48 | double longtitude = ((double)Convert.ToInt32(longt, 16)) / 10000000; 49 | ShowDiagnosticInfo("Longtitude: -----".PadRight(40, '-') + " " + longtitude); 50 | 51 | string lat = string.Empty; 52 | receiveBytes.Skip(tokenAddress + 13).Take(4).ToList().ForEach(delegate(byte b) { lat += String.Format("{0:X2}", b); }); 53 | double latitude = ((double)Convert.ToInt32(lat, 16)) / 10000000; 54 | ShowDiagnosticInfo("Latitude: -----".PadRight(40, '-') + " " + latitude); 55 | 56 | string alt = string.Empty; 57 | receiveBytes.Skip(tokenAddress + 17).Take(2).ToList().ForEach(delegate(byte b) { alt += String.Format("{0:X2}", b); }); 58 | int altitude = Convert.ToInt32(alt, 16); 59 | ShowDiagnosticInfo("Altitude: -----".PadRight(40, '-') + " " + altitude); 60 | 61 | string ang = string.Empty; 62 | receiveBytes.Skip(tokenAddress + 19).Take(2).ToList().ForEach(delegate(byte b) { ang += String.Format("{0:X2}", b); }); 63 | int angle = Convert.ToInt32(ang, 16); 64 | ShowDiagnosticInfo("Angle: -----".PadRight(40, '-') + " " + angle); 65 | 66 | int satellites = Convert.ToInt32(receiveBytes.Skip(tokenAddress + 21).Take(1).ToList()[0]); 67 | ShowDiagnosticInfo("Satellites: -----".PadRight(40, '-') + " " + satellites); 68 | 69 | string sp = string.Empty; 70 | receiveBytes.Skip(tokenAddress + 22).Take(2).ToList().ForEach(delegate(byte b) { sp += String.Format("{0:X2}", b); }); 71 | int speed = Convert.ToInt32(sp, 16); 72 | ShowDiagnosticInfo("Speed: -----".PadRight(40, '-') + " " + speed); 73 | 74 | byte event_IO_element_ID = (byte)Convert.ToInt32(receiveBytes.Skip(tokenAddress + 24).Take(1).ToList()[0]); 75 | gpsData.Event_IO_element_ID = event_IO_element_ID; 76 | ShowDiagnosticInfo("IO element ID of Event generated: ------".PadRight(40, '-') + " " + event_IO_element_ID); 77 | 78 | int IO_element_in_record = Convert.ToInt32(receiveBytes.Skip(tokenAddress + 25).Take(1).ToList()[0]); 79 | ShowDiagnosticInfo("IO_element_in_record: --------".PadRight(40, '-') + " " + IO_element_in_record); 80 | 81 | 82 | if (IO_element_in_record != 0) 83 | { 84 | int currentCursor = tokenAddress + 26; 85 | 86 | int IO_Elements_1B_Quantity = Convert.ToInt32(receiveBytes.Skip(currentCursor).Take(1).ToList()[0]); 87 | ShowDiagnosticInfo("1 byte IO element in record: --------".PadRight(40, '-') + " " + IO_Elements_1B_Quantity); 88 | 89 | 90 | for (int IO_1 = 0; IO_1 < IO_Elements_1B_Quantity; IO_1++) 91 | { 92 | var parameterID = (byte)Convert.ToInt32(receiveBytes.Skip(currentCursor + 1 + IO_1 * 2).Take(1).ToList()[0]); 93 | var IO_Element_1B = (byte)Convert.ToInt32(receiveBytes.Skip(currentCursor + 2 + IO_1 * 2).Take(1).ToList()[0]); 94 | gpsData.IO_Elements_1B.Add(parameterID, IO_Element_1B); 95 | ShowDiagnosticInfo("IO element 1B ID: --------".PadRight(40, '-') + " " + parameterID); 96 | ShowDiagnosticInfo(IO_1 + "'st 1B IO element value: --------".PadRight(40 - IO_1.ToString().Length, '-') + " " + IO_Element_1B); 97 | } 98 | currentCursor += IO_Elements_1B_Quantity * 2 + 1; 99 | 100 | int IO_Elements_2B_Quantity = Convert.ToInt32(receiveBytes.Skip(currentCursor).Take(1).ToList()[0]); 101 | ShowDiagnosticInfo("2 byte IO element in record: --------".PadRight(40, '-') + " " + IO_Elements_2B_Quantity); 102 | 103 | for (int IO_2 = 0; IO_2 < IO_Elements_2B_Quantity; IO_2++) 104 | { 105 | var parameterID = (byte)Convert.ToInt32(receiveBytes.Skip(currentCursor + 1 + IO_2 * 3).Take(1).ToList()[0]); 106 | string value = string.Empty; 107 | receiveBytes.Skip(currentCursor + 2 + IO_2 * 3).Take(2).ToList().ForEach(delegate(byte b) { value += String.Format("{0:X2}", b); }); 108 | var IO_Element_2B = Convert.ToInt16(value, 16); 109 | gpsData.IO_Elements_2B.Add(parameterID, IO_Element_2B); 110 | ShowDiagnosticInfo("IO element 2B ID: --------".PadRight(40, '-') + " " + parameterID); 111 | ShowDiagnosticInfo(IO_2 + "'st 2B IO element value: --------".PadRight(40 - IO_2.ToString().Length, '-') + " " + IO_Element_2B); 112 | } 113 | currentCursor += IO_Elements_2B_Quantity * 3 + 1; 114 | 115 | int IO_Elements_4B_Quantity = Convert.ToInt32(receiveBytes.Skip(currentCursor).Take(1).ToList()[0]); 116 | ShowDiagnosticInfo("4 byte IO element in record: --------".PadRight(40, '-') + " " + IO_Elements_4B_Quantity); 117 | 118 | for (int IO_4 = 0; IO_4 < IO_Elements_4B_Quantity; IO_4++) 119 | { 120 | var parameterID = (byte)Convert.ToInt32(receiveBytes.Skip(currentCursor + 1 + IO_4 * 5).Take(1).ToList()[0]); 121 | string value = string.Empty; 122 | receiveBytes.Skip(currentCursor + 2 + IO_4 * 5).Take(4).ToList().ForEach(delegate(byte b) { value += String.Format("{0:X2}", b); }); 123 | var IO_Element_4B = Convert.ToInt32(value, 16); 124 | gpsData.IO_Elements_4B.Add(parameterID, IO_Element_4B); 125 | ShowDiagnosticInfo("IO element 4B ID: --------".PadRight(40, '-') + " " + parameterID); 126 | ShowDiagnosticInfo(IO_4 + "'st 4B IO element value: --------".PadRight(40 - IO_4.ToString().Length, '-') + " " + IO_Element_4B); 127 | } 128 | currentCursor += IO_Elements_4B_Quantity * 5 + 1; 129 | 130 | int IO_Elements_8B_Quantity = Convert.ToInt32(receiveBytes.Skip(currentCursor).Take(1).ToList()[0]); 131 | ShowDiagnosticInfo("8 byte IO element in record: --------".PadRight(40, '-') + " " + IO_Elements_8B_Quantity); 132 | 133 | for (int IO_8 = 0; IO_8 < IO_Elements_8B_Quantity; IO_8++) 134 | { 135 | var parameterID = (byte)Convert.ToInt32(receiveBytes.Skip(currentCursor + 1 + IO_8 * 9).Take(1).ToList()[0]); 136 | string value = string.Empty; 137 | receiveBytes.Skip(currentCursor + 2 + IO_8 * 9).Take(8).ToList().ForEach(delegate(byte b) { value += String.Format("{0:X2}", b); }); 138 | var IO_Element_8B = Convert.ToInt64(value, 16); 139 | gpsData.IO_Elements_8B.Add(parameterID, IO_Element_8B); 140 | ShowDiagnosticInfo("IO element 8B ID: --------".PadRight(40, '-') + " " + parameterID); 141 | ShowDiagnosticInfo(IO_8 + "'st 8B IO element value: --------".PadRight(40 - IO_8.ToString().Length, '-') + " " + IO_Element_8B); 142 | } 143 | 144 | tokenAddress += 30 + IO_Elements_1B_Quantity * 2 + 145 | IO_Elements_2B_Quantity * 3 + IO_Elements_4B_Quantity * 5 146 | + IO_Elements_8B_Quantity * 9; 147 | } 148 | else 149 | { 150 | tokenAddress += 30; 151 | } 152 | 153 | Data dt = new Data(); 154 | 155 | gpsData.Altitude = (short)altitude; 156 | gpsData.Direction = (short)angle; 157 | gpsData.Lat = latitude; 158 | gpsData.Long = longtitude; 159 | gpsData.Priority = (byte)priority; 160 | gpsData.Satellites = (byte)satellites; 161 | gpsData.Speed = (short)speed; 162 | gpsData.Timestamp = timestamp; 163 | gpsData.IMEI = IMEI.Substring(0, 15); 164 | dt.SaveGPSPositionFMXXXX(gpsData); 165 | 166 | } 167 | //CRC for check of data correction and request again data from device if it not correct 168 | string crcString = string.Empty; 169 | receiveBytes.Skip(dataLength + 8).Take(4).ToList().ForEach(delegate(byte b) { crcString += String.Format("{0:X2}", b); }); 170 | int CRC = Convert.ToInt32(crcString, 16); 171 | ShowDiagnosticInfo("CRC: -----".PadRight(40, '-') + " " + CRC); 172 | //We must skeep first 8 bytes and last 4 bytes with CRC value. 173 | int calculatedCRC = GetCRC16(receiveBytes.Skip(8).Take(receiveBytes.Count - 12).ToArray()); 174 | ShowDiagnosticInfo("Calculated CRC: -------".PadRight(40, '-') + " " + calculatedCRC); 175 | ShowDiagnosticInfo("||||||||||||||||||||||||||||||||||||||||||||||||"); 176 | if (calculatedCRC == CRC) 177 | return numberOfData; 178 | else 179 | { 180 | ShowDiagnosticInfo("Incorect CRC "); 181 | return 0; 182 | } 183 | } 184 | private int GetCRC16(byte[] buffer) 185 | { 186 | return GetCRC16(buffer, buffer.Length, 0xA001); 187 | } 188 | private int GetCRC16(byte[] buffer, int bufLen, int polynom) 189 | { 190 | polynom &= 0xFFFF; 191 | int crc = 0; 192 | for (int i = 0; i < bufLen; i++) 193 | { 194 | int data = buffer[i] & 0xFF; 195 | crc ^= data; 196 | for (int j = 0; j < 8; j++) 197 | { 198 | if ((crc & 0x0001) != 0) 199 | { 200 | crc = (crc >> 1) ^ polynom; 201 | } 202 | else 203 | { 204 | crc = crc >> 1; 205 | } 206 | } 207 | } 208 | return crc & 0xFFFF; 209 | } 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /GPS Listener Parser/Teltonika/GH3000Parser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using GPSParser.DBLogic; 6 | using GPSParser.Utils; 7 | using System.Globalization; 8 | 9 | namespace GPSParser.Teltonika 10 | { 11 | public class GH3000Parser : ParserBase 12 | { 13 | [Flags] 14 | public enum GlobalMask 15 | { 16 | GPSelement = 0x01, 17 | IO_Element_1B = 0x02, 18 | IO_Element_2B = 0x04, 19 | IO_Element_4B = 0x08 20 | } 21 | [Flags] 22 | public enum GPSmask 23 | { 24 | LatAndLong = 0x01, 25 | Altitude = 0x02, 26 | Angle = 0x04, 27 | Speed = 0x08, 28 | Sattelites = 0x10, 29 | LocalAreaCodeAndCellID = 0x20, 30 | SignalQuality = 0x40, 31 | OperatorCode = 0x80 32 | } 33 | 34 | public GH3000Parser(bool showDiagnosticInfo) 35 | { 36 | _showDiagnosticInfo = showDiagnosticInfo; 37 | } 38 | public override int DecodeAVL(List receiveBytes, string IMEI) 39 | { 40 | string hexDataLength = string.Empty; 41 | receiveBytes.Skip(4).Take(4).ToList().ForEach(delegate(byte b) { hexDataLength += String.Format("{0:X2}", b); }); 42 | int dataLength = Convert.ToInt32(hexDataLength, 16); 43 | ShowDiagnosticInfo("Data Length: ----- " + dataLength); 44 | int codecId = Convert.ToInt32(receiveBytes.Skip(8).Take(1).ToList()[0]); 45 | ShowDiagnosticInfo("Codec ID: ----- " + codecId); 46 | int numberOfData = Convert.ToInt32(receiveBytes.Skip(9).Take(1).ToList()[0]); ; 47 | ShowDiagnosticInfo("Number of data: ---- " + numberOfData); 48 | 49 | int nextPacketStartAddress = 10; 50 | Data dt = new Data(); 51 | 52 | for (int n = 0; n < numberOfData; n++) 53 | { 54 | string hexTimeStamp = string.Empty; 55 | receiveBytes.Skip(nextPacketStartAddress).Take(4).ToList().ForEach(delegate(byte b) { hexTimeStamp += String.Format("{0:X2}", b); }); 56 | 57 | //ShowDiagnosticInfo(bit_30_timestamp); 58 | var result = Convert.ToInt64(hexTimeStamp, 16) & 0x3FFFFFFF; 59 | long timeSt = Convert.ToInt64(result); 60 | // long timeSt = Convert.ToInt64(Convert.ToString(Convert.ToInt32(hexTimeStamp, 16), 2).Substring(2, 30), 2); 61 | //long timeSt = Convert.ToInt64(hexTimeStamp.Substring(2, 30), 16); 62 | 63 | // For GH3000 time is seconds from 2007.01.01 00:00:00 64 | DateTime origin = new DateTime(2007, 1, 1, 0, 0, 0, 0); 65 | DateTime timestamp = origin.AddSeconds(Convert.ToDouble(timeSt)); 66 | 67 | //DateTime timestamp = DateTime.FromBinary(timeSt); 68 | ShowDiagnosticInfo("Timestamp: ----- " + timestamp.ToLongDateString() + " " + timestamp.ToLongTimeString()); 69 | 70 | int priority = (Convert.ToByte(hexTimeStamp.Substring(0, 2), 16) & 0xC0) / 64;//Convert.ToInt32(receiveBytes.Skip(nextPacketStartAddress + 8).Take(1)); 71 | ShowDiagnosticInfo("Priority: ------------ " + priority); 72 | 73 | // If ALARM send SMS 74 | // if (priority == 2) 75 | // SMSsender.SendSms(dt.GetAlarmNumberFromModemId(IMEI), "5555555", "Alarm button pressed", 3, true); 76 | 77 | GlobalMask globalMask = (GlobalMask)receiveBytes.Skip(nextPacketStartAddress + 4).Take(1).First(); 78 | GPSmask gpsMask = (GPSmask)receiveBytes.Skip(nextPacketStartAddress + 5).Take(1).First(); 79 | 80 | GPSdata gpsData = new GPSdata(); 81 | gpsData.Priority = (byte)priority; 82 | gpsData.Timestamp = timestamp; 83 | int gpsElementDataAddress = 0; 84 | if ((globalMask & GH3000Parser.GlobalMask.GPSelement) != 0) 85 | { 86 | if ((gpsMask & GH3000Parser.GPSmask.LatAndLong) != 0) 87 | { 88 | gpsElementDataAddress = 6; 89 | string longt = string.Empty; 90 | receiveBytes.Skip(nextPacketStartAddress + gpsElementDataAddress + 4).Take(4).ToList().ForEach(delegate(byte b) { longt += String.Format("{0:X2}", b); }); 91 | float longtitude = GetFloatIEE754(receiveBytes.Skip(nextPacketStartAddress + gpsElementDataAddress + 4).Take(4).ToArray()); 92 | ShowDiagnosticInfo("Longtitude: ----- " + longtitude); 93 | 94 | string lat = string.Empty; 95 | receiveBytes.Skip(nextPacketStartAddress + gpsElementDataAddress).Take(4).ToList().ForEach(delegate(byte b) { lat += String.Format("{0:X2}", b); }); 96 | float latitude = GetFloatIEE754(receiveBytes.Skip(nextPacketStartAddress + gpsElementDataAddress).Take(4).ToArray()); 97 | ShowDiagnosticInfo("Latitude: ----- " + latitude); 98 | gpsElementDataAddress += 8; 99 | gpsData.Lat = latitude; 100 | gpsData.Long = longtitude; 101 | } 102 | if ((gpsMask & GH3000Parser.GPSmask.Altitude) != 0) 103 | { 104 | string alt = string.Empty; 105 | receiveBytes.Skip(nextPacketStartAddress + gpsElementDataAddress).Take(2).ToList().ForEach(delegate(byte b) { alt += String.Format("{0:X2}", b); }); 106 | int altitude = Convert.ToInt32(alt, 16); 107 | ShowDiagnosticInfo("Altitude: ----- " + altitude); 108 | gpsElementDataAddress += 2; 109 | gpsData.Altitude = (short)altitude; 110 | } 111 | 112 | if ((gpsMask & GH3000Parser.GPSmask.Angle) != 0) 113 | { 114 | string ang = string.Empty; 115 | receiveBytes.Skip(nextPacketStartAddress + gpsElementDataAddress).Take(1).ToList().ForEach(delegate(byte b) { ang += String.Format("{0:X2}", b); }); 116 | int angle = Convert.ToInt32(ang, 16); 117 | angle = Convert.ToInt32(angle * 360.0 / 256.0); 118 | ShowDiagnosticInfo("Angle: ----- " + angle); 119 | gpsElementDataAddress += 1; 120 | gpsData.Direction = (short)angle; 121 | } 122 | 123 | if ((gpsMask & GH3000Parser.GPSmask.Speed) != 0) 124 | { 125 | string sp = string.Empty; 126 | receiveBytes.Skip(nextPacketStartAddress + gpsElementDataAddress).Take(1).ToList().ForEach(delegate(byte b) { sp += String.Format("{0:X2}", b); }); 127 | int speed = Convert.ToInt32(sp, 16); 128 | ShowDiagnosticInfo("Speed: ----- " + speed); 129 | gpsElementDataAddress += 1; 130 | gpsData.Speed = (short)speed; 131 | } 132 | 133 | if ((gpsMask & GH3000Parser.GPSmask.Sattelites) != 0) 134 | { 135 | int satellites = Convert.ToInt32(receiveBytes.Skip(nextPacketStartAddress + gpsElementDataAddress).Take(1).ToList()[0]); 136 | ShowDiagnosticInfo("Satellites: ----- " + satellites); 137 | gpsElementDataAddress += 1; 138 | gpsData.Satellites = (byte)satellites; 139 | } 140 | 141 | if ((gpsMask & GH3000Parser.GPSmask.LocalAreaCodeAndCellID) != 0) 142 | { 143 | string localArea = string.Empty; 144 | receiveBytes.Skip(nextPacketStartAddress + gpsElementDataAddress).Take(2).ToList().ForEach(delegate(byte b) { localArea += String.Format("{0:X2}", b); }); 145 | int localAreaCode = Convert.ToInt32(localArea, 16); 146 | ShowDiagnosticInfo("Local area code: ----- " + localAreaCode); 147 | gpsElementDataAddress += 2; 148 | gpsData.LocalAreaCode = (short)localAreaCode; 149 | 150 | string cell_ID = string.Empty; 151 | receiveBytes.Skip(nextPacketStartAddress + gpsElementDataAddress).Take(2).ToList().ForEach(delegate(byte b) { cell_ID += String.Format("{0:X2}", b); }); 152 | int cellID = Convert.ToInt32(cell_ID, 16); 153 | ShowDiagnosticInfo("Cell ID: ----- " + localAreaCode); 154 | gpsElementDataAddress += 2; 155 | gpsData.CellID = (short)cellID; 156 | } 157 | 158 | if ((gpsMask & GH3000Parser.GPSmask.SignalQuality) != 0) 159 | { 160 | string gsmQua = string.Empty; 161 | receiveBytes.Skip(nextPacketStartAddress + gpsElementDataAddress).Take(1).ToList().ForEach(delegate(byte b) { gsmQua += String.Format("{0:X2}", b); }); 162 | int gsmSignalQuality = Convert.ToInt32(gsmQua, 16); 163 | ShowDiagnosticInfo("GSM signal quality: ----- " + gsmSignalQuality); 164 | gpsElementDataAddress += 1; 165 | gpsData.GsmSignalQuality = (byte)gsmSignalQuality; 166 | } 167 | 168 | if ((gpsMask & GH3000Parser.GPSmask.OperatorCode) != 0) 169 | { 170 | string opCode = string.Empty; 171 | receiveBytes.Skip(nextPacketStartAddress + gpsElementDataAddress).Take(4).ToList().ForEach(delegate(byte b) { opCode += String.Format("{0:X2}", b); }); 172 | int operatorCode = Convert.ToInt32(opCode, 16); 173 | ShowDiagnosticInfo("Operator code: ----- " + operatorCode); 174 | gpsElementDataAddress += 4; 175 | gpsData.OperatorCode = operatorCode; 176 | } 177 | } 178 | nextPacketStartAddress += gpsElementDataAddress; 179 | if ((globalMask & GH3000Parser.GlobalMask.IO_Element_1B) != 0) 180 | { 181 | byte quantityOfIOelementData = receiveBytes.Skip(nextPacketStartAddress).Take(1).First(); 182 | nextPacketStartAddress += 1; 183 | for (int i = 0; i < quantityOfIOelementData; i++) 184 | { 185 | byte parameterID = receiveBytes.Skip(nextPacketStartAddress).Take(1).First(); 186 | ShowDiagnosticInfo("IO element 1B ID: -----".PadRight(40, '-') + " " + parameterID); 187 | byte parameterValue = receiveBytes.Skip(nextPacketStartAddress + 1).Take(1).First(); 188 | ShowDiagnosticInfo("IO element 1B value: -----".PadRight(40, '-') + " " + parameterValue); 189 | gpsData.IO_Elements_1B.Add(parameterID, parameterValue); 190 | nextPacketStartAddress += 2; 191 | 192 | //--------------alarm send by sms 193 | if (parameterID == 222) 194 | { 195 | string message = string.Empty; 196 | 197 | //switch (parameterValue) 198 | //{ 199 | // case 5: 200 | // message = "Man-down sensor activated from " + IMEI + " at this place " + "http://maps.google.com/maps?q=" + gpsData.Lat.Value.ToString(CultureInfo.InvariantCulture) + "," + gpsData.Long.Value.ToString(CultureInfo.InvariantCulture); 201 | // SMSsender.SendSms(dt.GetAlarmNumberFromModemId(IMEI), "55555555", message, 3, true); 202 | // break; 203 | // case 1: 204 | // message = "Emergency button activated from " + IMEI + " at this place " + "http://maps.google.com/maps?q=" + gpsData.Lat.Value.ToString(CultureInfo.InvariantCulture) + "," + gpsData.Long.Value.ToString(CultureInfo.InvariantCulture); 205 | // SMSsender.SendSms(dt.GetAlarmNumberFromModemId(IMEI), "55555555", message, 3, true); 206 | // break; 207 | //} 208 | 209 | } 210 | 211 | //------------------- end 212 | } 213 | } 214 | 215 | if ((globalMask & GH3000Parser.GlobalMask.IO_Element_2B) != 0) 216 | { 217 | byte quantityOfIOelementData = receiveBytes.Skip(nextPacketStartAddress).Take(1).First(); 218 | nextPacketStartAddress += 1; 219 | for (int i = 0; i < quantityOfIOelementData; i++) 220 | { 221 | byte parameterID = receiveBytes.Skip(nextPacketStartAddress).Take(1).First(); 222 | ShowDiagnosticInfo("IO element 2B ID: -----".PadRight(40, '-') + " " + parameterID); 223 | string value = string.Empty; 224 | receiveBytes.Skip(nextPacketStartAddress + 1).Take(2).ToList().ForEach(delegate(byte b) { value += String.Format("{0:X2}", b); }); 225 | short parameterValue = (short)Convert.ToInt32(value, 16); 226 | ShowDiagnosticInfo("IO element 2B value: -----".PadRight(40, '-') + " " + parameterValue); 227 | gpsData.IO_Elements_2B.Add(parameterID, parameterValue); 228 | nextPacketStartAddress += 3; 229 | } 230 | } 231 | if ((globalMask & GH3000Parser.GlobalMask.IO_Element_4B) != 0) 232 | { 233 | byte quantityOfIOelementData = receiveBytes.Skip(nextPacketStartAddress).Take(1).First(); 234 | nextPacketStartAddress += 1; 235 | for (int i = 0; i < quantityOfIOelementData; i++) 236 | { 237 | byte parameterID = receiveBytes.Skip(nextPacketStartAddress).Take(1).First(); 238 | ShowDiagnosticInfo("IO element 4B ID: -----".PadRight(40, '-') + " " + parameterID); 239 | string value = string.Empty; 240 | receiveBytes.Skip(nextPacketStartAddress + 1).Take(4).ToList().ForEach(delegate(byte b) { value += String.Format("{0:X2}", b); }); 241 | int parameterValue = Convert.ToInt32(value, 16); 242 | ShowDiagnosticInfo("IO element 4B value: -----".PadRight(40, '-') + " " + parameterValue); 243 | gpsData.IO_Elements_4B.Add(parameterID, parameterValue); 244 | nextPacketStartAddress += 5; 245 | } 246 | } 247 | 248 | gpsData.IMEI = IMEI.Substring(0, 15); 249 | dt.SaveGPSPositionGH3000(gpsData); 250 | 251 | } 252 | int numberOfData1 = Convert.ToInt32(receiveBytes.Skip(nextPacketStartAddress).Take(1).ToList()[0]); 253 | 254 | //CRC for check of data correction and request again data from device if it not correct 255 | string crcString = string.Empty; 256 | receiveBytes.Skip(dataLength + 8).Take(4).ToList().ForEach(delegate(byte b) { crcString += String.Format("{0:X2}", b); }); 257 | int CRC = Convert.ToInt32(crcString, 16); 258 | ShowDiagnosticInfo("CRC: -----".PadRight(40, '-') + " " + CRC); 259 | //We must skeep first 8 bytes and last 4 bytes with CRC value. 260 | int calculatedCRC = GetCRC16(receiveBytes.Skip(8).Take(receiveBytes.Count - 12).ToArray()); 261 | ShowDiagnosticInfo("Calculated CRC: -------".PadRight(40, '-') + " " + calculatedCRC); 262 | ShowDiagnosticInfo("||||||||||||||||||||||||||||||||||||||||||||||||"); 263 | if (calculatedCRC == CRC) 264 | return numberOfData; 265 | else 266 | { 267 | ShowDiagnosticInfo("Incorect CRC "); 268 | return 0; 269 | } 270 | } 271 | public float GetFloatIEE754(byte[] array) 272 | { 273 | Array.Reverse(array); 274 | return BitConverter.ToSingle(array, 0); 275 | } 276 | private int GetCRC16(byte[] buffer) 277 | { 278 | return GetCRC16(buffer, buffer.Length, 0xA001); 279 | } 280 | private int GetCRC16(byte[] buffer, int bufLen, int polynom) 281 | { 282 | polynom &= 0xFFFF; 283 | int crc = 0; 284 | for (int i = 0; i < bufLen; i++) 285 | { 286 | int data = buffer[i] & 0xFF; 287 | crc ^= data; 288 | for (int j = 0; j < 8; j++) 289 | { 290 | if ((crc & 0x0001) != 0) 291 | { 292 | crc = (crc >> 1) ^ polynom; 293 | } 294 | else 295 | { 296 | crc = crc >> 1; 297 | } 298 | } 299 | } 300 | return crc & 0xFFFF; 301 | } 302 | } 303 | } 304 | -------------------------------------------------------------------------------- /GPS Listener Parser/Teltonika/ParserBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace GPSParser.Teltonika 7 | { 8 | public abstract class ParserBase 9 | { 10 | public event Action OnDataReceive; 11 | protected bool _showDiagnosticInfo; 12 | 13 | public void ShowDiagnosticInfo(string message) 14 | { 15 | if (_showDiagnosticInfo) 16 | OnDataReceive.Invoke(message); 17 | } 18 | 19 | public abstract int DecodeAVL(List receiveBytes, string IMEI); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /GPS Listener Parser/Teltonika/TeltonikaDevicesParser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using GPSParser.DBLogic; 6 | 7 | namespace GPSParser.Teltonika 8 | { 9 | public class TeltonikaDevicesParser 10 | { 11 | public event Action OnDataReceive; 12 | private bool _showDiagnosticInfo; 13 | public TeltonikaDevicesParser(bool showDiagnosticInfo) 14 | { 15 | _showDiagnosticInfo = showDiagnosticInfo; 16 | } 17 | public void ShowDiagnosticInfo(string message) 18 | { 19 | if (_showDiagnosticInfo) 20 | OnDataReceive.Invoke(message); 21 | } 22 | public int Decode(List receiveBytes, string IMEI) 23 | { 24 | ParserBase parser = null; 25 | //Get codec ID and initialize appropriate parser 26 | var codecID = Convert.ToInt32(receiveBytes.Skip(8).Take(1).ToList()[0]); 27 | switch(codecID) 28 | { 29 | case 8: 30 | parser = new FMXXXX_Parser(_showDiagnosticInfo); 31 | break; 32 | case 7: 33 | parser = new GH3000Parser(_showDiagnosticInfo); 34 | break; 35 | default: 36 | throw new Exception("Unsupported device type code: " + codecID); 37 | } 38 | parser.OnDataReceive += ShowDiagnosticInfo; 39 | int result = parser.DecodeAVL(receiveBytes, IMEI); 40 | parser.OnDataReceive -= ShowDiagnosticInfo; 41 | return result; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /GPS Listener Parser/Utils/SMSsender.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace GPSParser.Utils 7 | { 8 | public static class SMSsender 9 | { 10 | public static void SendSms(string recipients, string origin, string message, int priority, bool secure) 11 | { 12 | 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /GPS Listener Parser/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 192.168.0.110 17 | 18 | 19 | True 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /GPS TCP Listener Parser.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{050C3A52-6725-4022-9EC7-9AE007741E09}" 7 | ProjectSection(SolutionItems) = preProject 8 | GPS Parser.vsmdi = GPS Parser.vsmdi 9 | Local.testsettings = Local.testsettings 10 | TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings 11 | EndProjectSection 12 | EndProject 13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GPS Listener Parser", "GPS Listener Parser\GPS Listener Parser.csproj", "{5D94AC34-AAEF-4858-B0A4-5872CCF2F891}" 14 | EndProject 15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GPSTest", "Server Listener Tests\GPSTest.csproj", "{AE0B44BF-D89D-4417-9B1F-5C89B83A2A22}" 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {5D94AC34-AAEF-4858-B0A4-5872CCF2F891}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {5D94AC34-AAEF-4858-B0A4-5872CCF2F891}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {5D94AC34-AAEF-4858-B0A4-5872CCF2F891}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {5D94AC34-AAEF-4858-B0A4-5872CCF2F891}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {AE0B44BF-D89D-4417-9B1F-5C89B83A2A22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {AE0B44BF-D89D-4417-9B1F-5C89B83A2A22}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {AE0B44BF-D89D-4417-9B1F-5C89B83A2A22}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {AE0B44BF-D89D-4417-9B1F-5C89B83A2A22}.Release|Any CPU.Build.0 = Release|Any CPU 31 | EndGlobalSection 32 | GlobalSection(SolutionProperties) = preSolution 33 | HideSolutionNode = FALSE 34 | EndGlobalSection 35 | GlobalSection(TestCaseManagementSettings) = postSolution 36 | CategoryFile = GPS Parser.vsmdi 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GPS-Listener-Parser 2 | GPS TCP Listener and parser for Teltonika Devices 3 | -------------------------------------------------------------------------------- /Server Listener Tests/GPSTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 7 | 8 | 2.0 9 | {AE0B44BF-D89D-4417-9B1F-5C89B83A2A22} 10 | Library 11 | Properties 12 | GPSTest 13 | GPSTest 14 | v4.0 15 | 512 16 | {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 3.5 40 | 41 | 42 | 43 | 44 | False 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | {5D94AC34-AAEF-4858-B0A4-5872CCF2F891} 53 | GPS Parser 54 | 55 | 56 | 57 | 64 | -------------------------------------------------------------------------------- /Server Listener Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("GPSTest")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("GPSTest")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("52d00ff6-5ea0-4c57-bc7a-e638149e58b5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Server Listener Tests/bin/Release/GPSParser.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpaceQuantum/GPS-Listener-Parser/d2acc94154b3cb8e37d7af3c81b29beebd17fbef/Server Listener Tests/bin/Release/GPSParser.exe -------------------------------------------------------------------------------- /Server Listener Tests/bin/Release/GPSParser.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpaceQuantum/GPS-Listener-Parser/d2acc94154b3cb8e37d7af3c81b29beebd17fbef/Server Listener Tests/bin/Release/GPSParser.pdb -------------------------------------------------------------------------------- /Server Listener Tests/bin/Release/GPSTest.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpaceQuantum/GPS-Listener-Parser/d2acc94154b3cb8e37d7af3c81b29beebd17fbef/Server Listener Tests/bin/Release/GPSTest.dll -------------------------------------------------------------------------------- /Server Listener Tests/bin/Release/GPSTest.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpaceQuantum/GPS-Listener-Parser/d2acc94154b3cb8e37d7af3c81b29beebd17fbef/Server Listener Tests/bin/Release/GPSTest.pdb -------------------------------------------------------------------------------- /Server Listener Tests/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpaceQuantum/GPS-Listener-Parser/d2acc94154b3cb8e37d7af3c81b29beebd17fbef/Server Listener Tests/obj/Release/DesignTimeResolveAssemblyReferencesInput.cache -------------------------------------------------------------------------------- /Server Listener Tests/obj/Release/GPSTest.csproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- 1 | E:\Projects\gps-parser\Server Listener Tests\bin\Release\GPSTest.dll 2 | E:\Projects\gps-parser\Server Listener Tests\bin\Release\GPSTest.pdb 3 | E:\Projects\gps-parser\Server Listener Tests\bin\Release\GPSParser.exe 4 | E:\Projects\gps-parser\Server Listener Tests\bin\Release\GPSParser.pdb 5 | E:\Projects\gps-parser\Server Listener Tests\obj\Release\GPSTest.csprojResolveAssemblyReference.cache 6 | E:\Projects\gps-parser\Server Listener Tests\obj\Release\GPSTest.dll 7 | E:\Projects\gps-parser\Server Listener Tests\obj\Release\GPSTest.pdb 8 | -------------------------------------------------------------------------------- /Server Listener Tests/obj/Release/GPSTest.csprojResolveAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpaceQuantum/GPS-Listener-Parser/d2acc94154b3cb8e37d7af3c81b29beebd17fbef/Server Listener Tests/obj/Release/GPSTest.csprojResolveAssemblyReference.cache -------------------------------------------------------------------------------- /Server Listener Tests/obj/Release/GPSTest.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpaceQuantum/GPS-Listener-Parser/d2acc94154b3cb8e37d7af3c81b29beebd17fbef/Server Listener Tests/obj/Release/GPSTest.dll -------------------------------------------------------------------------------- /Server Listener Tests/obj/Release/GPSTest.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SpaceQuantum/GPS-Listener-Parser/d2acc94154b3cb8e37d7af3c81b29beebd17fbef/Server Listener Tests/obj/Release/GPSTest.pdb --------------------------------------------------------------------------------