use of org.traccar.NetworkMessage in project traccar by tananaev.
the class Pt60ProtocolDecoder method sendResponse.
private void sendResponse(Channel channel, SocketAddress remoteAddress, String format, int type, String imei) {
if (channel != null) {
String message;
String time = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
if (format.equals("G")) {
message = String.format("@G#@,V01,38,%s,@R#@", time);
} else {
message = String.format("@B#@|01|%03d|%s|0|%s|@E#@", type + 1, imei, time);
}
channel.writeAndFlush(new NetworkMessage(message, remoteAddress));
}
}
use of org.traccar.NetworkMessage in project traccar by tananaev.
the class R12wProtocolDecoder method sendResponse.
private void sendResponse(Channel channel, String type, String id, String data) {
if (channel != null) {
String sentence = String.format("$HX,%s,%s,%s,#", type, id, data);
sentence += String.format(",%02x,\r\n", Checksum.xor(sentence));
channel.writeAndFlush(new NetworkMessage(sentence, channel.remoteAddress()));
}
}
use of org.traccar.NetworkMessage in project traccar by tananaev.
the class RaceDynamicsProtocolDecoder method sendResponse.
private void sendResponse(Channel channel, SocketAddress remoteAddress, int type) {
if (channel != null) {
String response = String.format("$GPRMC,%1$d,%2$td%2$tm%2$ty,%2$tH%2$tM%2$tS,%3$s,\r\n", type, new Date(), imei);
channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
use of org.traccar.NetworkMessage in project traccar by tananaev.
the class SanulProtocolDecoder method sendResponse.
private void sendResponse(Channel channel, int type) {
if (channel != null) {
ByteBuf response = Unpooled.buffer();
// header
response.writeByte(0xaa);
// reserved
response.writeShortLE(0x85da);
// length
response.writeShortLE(15);
// edition
response.writeByte(1);
response.writeShortLE(MSG_RESPONSE);
response.writeShortLE(type);
// command id
response.writeIntLE(0);
// status
response.writeByte(0);
// result length
response.writeByte(0);
// result data ?
response.writeIntLE(0x20000);
channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
use of org.traccar.NetworkMessage in project traccar by tananaev.
the class Pt215ProtocolDecoder method sendResponse.
private void sendResponse(Channel channel, SocketAddress remoteAddress, int type, ByteBuf content) {
if (channel != null) {
ByteBuf response = Unpooled.buffer();
response.writeByte('X');
response.writeByte('X');
response.writeByte(content != null ? 1 + content.readableBytes() : 1);
response.writeByte(type);
if (content != null) {
response.writeBytes(content);
content.release();
}
response.writeByte('\r');
response.writeByte('\n');
channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
Aggregations