I'm implementing a custom protocol for a GPS device I received from China.
The GPS sends a Sync Request to the server like this:
S168#862240656514739#0001#001d#SYNC:0-766-23-1;STATUS:84,100$
Then it waits for a response from the server....
My protocol receives it and creates the response but it never gets sent.
Could someone help me find the reason?
In the traccar log I see my "ACK Armed for sending" text but not the traccar prot > device one.
My ACK code is:
private void sendAck(Channel channel,SocketAddress remoteAddress, String imei, String serialNumber, String type) {
if (channel != null && channel.isActive() && channel.isWritable()) {
String utcTime = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
String ackContent = String.format("ACK^%s,%s", type, utcTime);
String lengthHex = String.format("%04x", ackContent.length());
String response = String.format("S168#%s#%s#%s#%s$", imei, serialNumber, lengthHex, ackContent);
channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
LOGGER.log(Level.INFO, "ACK Armed for sending: " + response + channel.isActive());
}
else {
LOGGER.log(Level.INFO, "Error");
}
}
Are you sure it's a new protocol?
Hi Anton!
I hope you're doing well.
You're telling me it's already implemented? I honestly couldn't find the equivalent!
Did I search wrong?
OMG!
I found it, it's called S168!
Now the problem I see is that the GPS is waiting for the SYNC response and until it receives it, it oscillates between connected and disconnected.
But it's a good start!
I'm implementing a custom protocol for a GPS device I received from China.
The GPS sends a Sync Request to the server like this:
Then it waits for a response from the server....
My protocol receives it and creates the response but it never gets sent.
Could someone help me find the reason?
In the traccar log I see my "ACK Armed for sending" text but not the traccar prot > device one.
My ACK code is:
private void sendAck(Channel channel,SocketAddress remoteAddress, String imei, String serialNumber, String type) { if (channel != null && channel.isActive() && channel.isWritable()) { String utcTime = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); String ackContent = String.format("ACK^%s,%s", type, utcTime); String lengthHex = String.format("%04x", ackContent.length()); String response = String.format("S168#%s#%s#%s#%s$", imei, serialNumber, lengthHex, ackContent); //channel.writeAndFlush(response); channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress())); LOGGER.log(Level.INFO, "ACK Armed for sending: " + response + channel.isActive()); } else { LOGGER.log(Level.INFO, "Error"); } }