private static void parseHardwareInfo(Holder holder, ChannelHandlerContext ctx,
String[] messageParts,
HardwareStateHolder state, int msgId) {
HardwareInfo hardwareInfo = new HardwareInfo(messageParts);
int newHardwareInterval = hardwareInfo.heartbeatInterval;
log.trace("Info command. heartbeat interval {}", newHardwareInterval);
OTAManager otaManager = holder.otaManager;
int hardwareIdleTimeout = holder.limits.hardwareIdleTimeout;
if (hardwareIdleTimeout != 0 && newHardwareInterval > 0 && newHardwareInterval != hardwareIdleTimeout) {
int newReadTimeout = NumberUtil.calcHeartbeatTimeout(newHardwareInterval);
log.debug("Changing read timeout interval to {}", newReadTimeout);
ctx.pipeline().replace(IdleStateHandler.class,
"H_IdleStateHandler_Replaced", new IdleStateHandler(newReadTimeout, 0, 0));
}
DashBoard dashBoard = state.dash;
Device device = state.device;
if (device != null) {
otaManager.initiateHardwareUpdate(ctx, state.userKey, hardwareInfo, dashBoard, device);
device.hardwareInfo = hardwareInfo;
dashBoard.updatedAt = System.currentTimeMillis();
}
ctx.writeAndFlush(ok(msgId), ctx.voidPromise());
}