Search in sources :

Example 26 with ByteBuf

use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.

the class ServiceChallengeMessage method getData.

@Override
protected byte[] getData() throws Exception {
    ByteBuf byteBuf = new ByteBuf(3);
    byteBuf.putByte(serviceID);
    byteBuf.putShort(version);
    return byteBuf.getBytes();
}
Also used : ByteBuf(sugar.free.sightparser.pipeline.ByteBuf)

Example 27 with ByteBuf

use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.

the class OpenHistoryReadingSessionMessage method getData.

@Override
protected byte[] getData() throws Exception {
    ByteBuf byteBuf = new ByteBuf(8);
    byteBuf.putShort(historyType.getValue());
    byteBuf.putShort(readingDirection.getValue());
    byteBuf.putUInt32LE(offset);
    return byteBuf.getBytes();
}
Also used : ByteBuf(sugar.free.sightparser.pipeline.ByteBuf)

Example 28 with ByteBuf

use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.

the class DismissAlertMessage method getData.

@Override
protected byte[] getData() throws Exception {
    ByteBuf byteBuf = new ByteBuf(2);
    byteBuf.putUInt16LE(alertID);
    return byteBuf.getBytes();
}
Also used : ByteBuf(sugar.free.sightparser.pipeline.ByteBuf)

Example 29 with ByteBuf

use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.

the class StandardBolusMessage method getData.

@Override
protected byte[] getData() throws Exception {
    ByteBuf data = new ByteBuf(22);
    data.putShort((short) 0x2503);
    data.putShort((short) 0x1F00);
    data.putShort((short) 0x1F00);
    data.putShort((short) 0x0000);
    data.putUInt16LE(Helpers.roundDoubleToInt(amount * 100D));
    data.putShort((short) 0x0000);
    data.putShort((short) 0x0000);
    data.putShort((short) 0x0000);
    data.putUInt16LE(Helpers.roundDoubleToInt(amount * 100D));
    data.putShort((short) 0x0000);
    data.putShort((short) 0x0000);
    return data.getBytes();
}
Also used : ByteBuf(sugar.free.sightparser.pipeline.ByteBuf)

Example 30 with ByteBuf

use of sugar.free.sightparser.pipeline.ByteBuf in project SightRemote by TebbeUbben.

the class AppLayerMessage method serialize.

public byte[] serialize() throws Exception {
    byte[] data = getData();
    ByteBuf byteBuf = new ByteBuf(4 + data.length + (outCRC() ? 2 : 0));
    byteBuf.putByte(VERSION);
    byteBuf.putByte(getService().getServiceID());
    byteBuf.putShort(getCommand());
    byteBuf.putBytes(data);
    if (outCRC())
        byteBuf.putUInt16LE(Cryptograph.calculateCRC(data));
    return byteBuf.getBytes();
}
Also used : ByteBuf(sugar.free.sightparser.pipeline.ByteBuf)

Aggregations

ByteBuf (sugar.free.sightparser.pipeline.ByteBuf)35 SuppressLint (android.annotation.SuppressLint)3 InvalidAuthCRCError (sugar.free.sightparser.error.InvalidAuthCRCError)2 InvalidNonceError (sugar.free.sightparser.error.InvalidNonceError)2 InvalidTrailerError (sugar.free.sightparser.error.InvalidTrailerError)2 CustomEvent (com.crashlytics.android.answers.CustomEvent)1 BigInteger (java.math.BigInteger)1 HistoryFrame (sugar.free.sightparser.applayer.descriptors.history_frames.HistoryFrame)1 AppLayerMessage (sugar.free.sightparser.applayer.messages.AppLayerMessage)1 AuthLayerMessage (sugar.free.sightparser.authlayer.AuthLayerMessage)1 CRCAuthLayerMessage (sugar.free.sightparser.authlayer.CRCAuthLayerMessage)1 DataMessage (sugar.free.sightparser.authlayer.DataMessage)1 InvalidAppCRCError (sugar.free.sightparser.error.InvalidAppCRCError)1 InvalidAppVersionError (sugar.free.sightparser.error.InvalidAppVersionError)1 InvalidAuthVersionError (sugar.free.sightparser.error.InvalidAuthVersionError)1 UnknownAppErrorCodeError (sugar.free.sightparser.error.UnknownAppErrorCodeError)1 UnknownAppMessageError (sugar.free.sightparser.error.UnknownAppMessageError)1 UnknownAuthMessageError (sugar.free.sightparser.error.UnknownAuthMessageError)1 UnknownServiceError (sugar.free.sightparser.error.UnknownServiceError)1