use of sugar.free.sightparser.applayer.descriptors.history_frames.HistoryFrame in project SightRemote by TebbeUbben.
the class ReadHistoryFramesMessage method parse.
@Override
protected void parse(ByteBuf byteBuf) throws Exception {
historyFrames = new ArrayList<>();
byteBuf.shift(2);
int frameCount = byteBuf.readUInt16LE();
for (int i = 0; i < frameCount; i++) {
int length = byteBuf.readUInt16LE();
short eventType = byteBuf.readShort();
ByteBuf eventBuf = new ByteBuf(length - 2);
eventBuf.putBytes(byteBuf.readBytes(length - 2));
long eventNumber = eventBuf.getUInt32LE(8);
if (eventNumber > latestEventNumber)
latestEventNumber = eventNumber;
Class<? extends HistoryFrame> clazz = HistoryFrame.HISTORY_FRAMES.get(eventType);
if (clazz != null) {
HistoryFrame historyFrame = clazz.newInstance();
historyFrame.parseHeader(eventBuf);
historyFrame.parse(eventBuf);
historyFrames.add(historyFrame);
} else
Log.d("SightServiceHistory", "UNKNOWN HISTORY FRAME: EVENT TYPE: " + eventType + " CONTENT: " + Hex.toHexString(eventBuf.getBytes()));
}
}
Aggregations