@Override public ByteBuf writeIntLE(int value) { buf.writeIntLE(value); return this; }
@Override public ByteBuf writeIntLE(int value) { buf.writeIntLE(value); return this; }
public Buffer appendIntLE(int i) { buffer.writeIntLE(i); return this; }
public Buffer appendUnsignedIntLE(long i) { buffer.writeIntLE((int) i); return this; }
/** * Write 4 byte fixed length integer to byte buffers. * * @see <a href="https://dev.mysql.com/doc/internals/en/integer.html#packet-Protocol::FixedLengthInteger">FixedLengthInteger</a> * * @param value 4 byte fixed length integer */ public void writeInt4(final int value) { byteBuf.writeIntLE(value); }
/** * Write 4 byte fixed length integer to byte buffers. * * @see <a href="https://dev.mysql.com/doc/internals/en/integer.html#packet-Protocol::FixedLengthInteger">FixedLengthInteger</a> * * @param value 4 byte fixed length integer */ public void writeInt4(final int value) { byteBuf.writeIntLE(value); }
/** * Sets the specified 32-bit floating point number at the current * {@code writerIndex} in Little Endian Byte Order and increases * the {@code writerIndex} by {@code 4} in this buffer. * If {@code this.writableBytes} is less than {@code 4}, {@link #ensureWritable(int)} * will be called in an attempt to expand capacity to accommodate. */ public ByteBuf writeFloatLE(float value) { return writeIntLE(Float.floatToRawIntBits(value)); }
@Override public ByteBuf writeIntLE(int value) { byteBuf.writeIntLE(value); return this; }
@Override public ByteBuf writeIntLE(int value) { buf.writeIntLE(value); return this; }
/** * Sets the specified 32-bit floating point number at the current * {@code writerIndex} in Little Endian Byte Order and increases * the {@code writerIndex} by {@code 4} in this buffer. * If {@code this.writableBytes} is less than {@code 4}, {@link #ensureWritable(int)} * will be called in an attempt to expand capacity to accommodate. */ public ByteBuf writeFloatLE(float value) { return writeIntLE(Float.floatToRawIntBits(value)); }
/** * Calculates and writes the 4-byte checksum to the output buffer * * @param slice The data to calculate the checksum for * @param out The output buffer to write the checksum to */ private static void calculateAndWriteChecksum(ByteBuf slice, ByteBuf out) { out.writeIntLE(calculateChecksum(slice)); } }
/** * Sets the specified 32-bit floating point number at the current * {@code writerIndex} in Little Endian Byte Order and increases * the {@code writerIndex} by {@code 4} in this buffer. * * @throws IndexOutOfBoundsException * if {@code this.writableBytes} is less than {@code 4} */ public ByteBuf writeFloatLE(float value) { return writeIntLE(Float.floatToRawIntBits(value)); }
/** * Calculates and writes the 4-byte checksum to the output buffer * * @param slice The data to calculate the checksum for * @param out The output buffer to write the checksum to */ private static void calculateAndWriteChecksum(ByteBuf slice, ByteBuf out) { out.writeIntLE(calculateChecksum(slice)); } }
/** * Calculates and writes the 4-byte checksum to the output buffer * * @param slice The data to calculate the checksum for * @param out The output buffer to write the checksum to */ private static void calculateAndWriteChecksum(ByteBuf slice, ByteBuf out) { out.writeIntLE(calculateChecksum(slice)); } }
private void requestArchive(Channel channel) { if (lastIndex == 0) { lastIndex = newIndex; } else if (newIndex > lastIndex) { ByteBuf request = Unpooled.buffer(12); request.writeShortLE(MSG_LOG_SYNC); request.writeShortLE(4); request.writeIntLE((int) lastIndex); request.writeIntLE(0); channel.writeAndFlush(new NetworkMessage(request, channel.remoteAddress())); } }
private void sendReply(Channel channel, ByteBuf data) { if (channel != null) { ByteBuf header = Unpooled.buffer(16); header.writeCharSequence(prefix, StandardCharsets.US_ASCII); header.writeIntLE((int) deviceUniqueId); header.writeIntLE((int) serverId); header.writeShortLE(data.readableBytes()); header.writeByte(checksum(data)); header.writeByte(checksum(header)); channel.writeAndFlush(new NetworkMessage(Unpooled.wrappedBuffer(header, data), channel.remoteAddress())); } }
private ByteBuf encodeText(String uniqueId, String text) { ByteBuf buf = Unpooled.buffer(256); buf.writeByte(0x01); buf.writeShortLE(uniqueId.length() + text.length() + 11); buf.writeByte(0x03); // imei tag buf.writeBytes(uniqueId.getBytes(StandardCharsets.US_ASCII)); buf.writeByte(0x04); // device id tag buf.writeShortLE(0); // not needed if imei provided buf.writeByte(0xE0); // index tag buf.writeIntLE(0); // index buf.writeByte(0xE1); // command text tag buf.writeByte(text.length()); buf.writeBytes(text.getBytes(StandardCharsets.US_ASCII)); buf.writeShortLE(Checksum.crc16(Checksum.CRC16_MODBUS, buf.nioBuffer(0, buf.writerIndex()))); return buf; }
private void requestArchive(Channel channel) { if (lastIndex == 0) { lastIndex = newIndex; } else if (newIndex > lastIndex) { ByteBuf request = Unpooled.buffer(14); request.writeShortLE(MSG_REQUEST_LOG_RECORDS); request.writeShortLE(6); request.writeIntLE((int) lastIndex); request.writeShortLE(512); request.writeIntLE(Checksum.crc32(request.nioBuffer(0, 10))); channel.writeAndFlush(new NetworkMessage(request, channel.remoteAddress())); } }
private void sendSimpleMessage(Channel channel, short type) { ByteBuf request = Unpooled.buffer(8); request.writeShortLE(type); request.writeShortLE(0); request.writeIntLE(Checksum.crc32(request.nioBuffer(0, 4))); channel.writeAndFlush(new NetworkMessage(request, channel.remoteAddress())); }
private Object processSingle(DeviceSession deviceSession, Channel channel, ByteBuf buf) { ParseResult result = parsePosition(deviceSession, buf); ByteBuf response = Unpooled.buffer(8); response.writeCharSequence("*<T", StandardCharsets.US_ASCII); response.writeIntLE((int) result.getId()); sendReply(channel, response); if (result.getPosition().getFixTime() == null) { return null; } return result.getPosition(); }