I am developing a console based listening app for my GPS tracker in C#, my GPS tracker is configured to send packets on the server with specific port, where my application runs. Now the thing is according to the protocol document of GPS103
It very first sends the string like ##,12345678999121,A
which I have already received in my application, but after receiving this string I have to send "LOAD" to my GPS tracker from app which will again Responded by GPS tracker by sending message Logon Success.
Issue: I have to send the command after receiving first string, but I never get a reply from the GPS Tracker.
namespace PakTrackingListenerApp_tk103_
{
class Program
{
static void Main(string[] args)
{
TcpListener listener = new TcpListener(1000);
System.Net.ServicePointManager.Expect100Continue = false;
listener.Start();
while (true)
{
Console.WriteLine("Waiting for a connection");
TcpClient client = listener.AcceptTcpClient();
StreamReader sr = new StreamReader(client.GetStream());
StreamWriter sw = new StreamWriter(client.GetStream());
try
{
string request = sr.ReadLine();
Console.WriteLine("GPS Command" + request);
string[] tokens = request.Split(',');
string response = "LOAD";
if (tokens[0] == "##")
{
response = "LOAD";
Console.WriteLine("Token" + tokens[0]);
}
sw.WriteLine(response);
sw.Flush();
}
catch (Exception e)
{
Console.WriteLine("Exception :" +e.Message);
}
client.Close();
}
}
}
}