/** * 创建标记信息 * * @return */ public static FeMessage createMarkMsg(EcgMark mark) { if (mark.getTypeGroup() == EcgMark.TYPE_GROUP_STATUS) { byte body[] = new byte[FeMessage.getBodyLength(FeMessage.TYPE_STATUS, 0, 0)]; body[0] = 0; body[1] = 0; System.arraycopy(MessageUtils.shortToBytes(mark.getType()), 0, body, 2, 2); System.arraycopy(MessageUtils.shortToBytes(mark.getValue()), 0, body, 4, 2); return new FeMessage(FeMessage.TYPE_STATUS, body); } else if (mark.getTypeGroup() == EcgMark.TYPE_GROUP_PHYSIO) { byte body[] = new byte[FeMessage.getBodyLength(FeMessage.TYPE_ANALYSIS_PHSIO, 0, 0)]; if (mark.getType() == EcgMark.PHYSIO_HR) { System.arraycopy(MessageUtils.shortToBytes(1), 0, body, 0, 2); } else if (mark.getType() == EcgMark.PHYSIO_BR) { System.arraycopy(MessageUtils.shortToBytes(2), 0, body, 0, 2); } else { System.arraycopy(MessageUtils.shortToBytes(mark.getType()), 0, body, 0, 2); } System.arraycopy(MessageUtils.shortToBytes(mark.getValue()), 0, body, 2, 2); return new FeMessage(FeMessage.TYPE_ANALYSIS_PHSIO, body); } else { return null; } }
/** * 创建认证反馈消息 * * @return */ public static FeMessage createRegAckMsg(Device dev) { byte body[] = new byte[FeMessage.getBodyLength(FeMessage.TYPE_REGISTER_ACK, 0, 0)]; System.arraycopy(dev.getId(), 0, body, 0, 8); /*test code */ body[0] = (byte) 0x00ff; body[1] = (byte) 0x00ff; System.arraycopy(MessageUtils.shortToBytes(dev.getModel()), 0, body, 8, 2); body[10] = (byte) (dev.getStreamLen() & 0x00ff); System.arraycopy(MessageUtils.shortToBytes(dev.getSps()), 0, body, 11, 2); /* *send back the key pair */ /* * test code */ dev.setKeyPair("0000000000000000".getBytes()); System.arraycopy(dev.getKeyPair(), 0, body, 16, 16); return new FeMessage(FeMessage.TYPE_REGISTER_ACK, body); }