|
@@ -136,79 +136,6 @@ public class YiTongGpsServerHandler extends HexBinaryAcceptanceHandlerAdapter {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void resolveCommandCopyMSG(ByteBuf in, Channel channel, Integer length) {
|
|
|
- byte readByte = in.readByte();
|
|
|
- int checkCode = in.readInt();
|
|
|
- if (checkCode != 0) {
|
|
|
- logger.error("illegal checkcode [{}]", checkCode);
|
|
|
- } else {
|
|
|
- // byte codingType = in.readByte();
|
|
|
- byte[] coypByes = new byte[length - 14];
|
|
|
- in.readBytes(coypByes);
|
|
|
- String copyStr = new String(coypByes);
|
|
|
- logger.info("设备指令回复 [{}]", copyStr);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void resolveWarningMsg(ByteBuf in, String deviceId) {
|
|
|
- YiTongGpsForWarnDevice yiTongGPSDevice = new YiTongGpsForWarnDevice();
|
|
|
- StringBuffer dateTimeStrBuf = new StringBuffer();
|
|
|
- int indexOfDateTime = 0;
|
|
|
- while (indexOfDateTime < DATA_SIZE) {
|
|
|
- byte b = in.readByte();
|
|
|
- dateTimeStrBuf.append(NumUtil.byte2String(b));
|
|
|
- indexOfDateTime++;
|
|
|
- }
|
|
|
- // 日期
|
|
|
- yiTongGPSDevice.setDate(dateTimeStrBuf.toString());
|
|
|
- // gps信息卫星数
|
|
|
- yiTongGPSDevice.setGpsCount(in.readByte());
|
|
|
- // 维度
|
|
|
- yiTongGPSDevice.setLat(in.readInt());
|
|
|
- // 经度
|
|
|
- yiTongGPSDevice.setLng(in.readInt());
|
|
|
- // 速度
|
|
|
-// yiTongGPSDevice.setSpeedbyte(in.readByte());
|
|
|
- // 航向
|
|
|
- yiTongGPSDevice.setCourseStatus(in.readShort());
|
|
|
- in.readByte();
|
|
|
- // 国家代号
|
|
|
- yiTongGPSDevice.setMcc(in.readShort());
|
|
|
- // 移动网号码
|
|
|
- yiTongGPSDevice.setMnc(in.readByte());
|
|
|
- // 位置区码
|
|
|
- yiTongGPSDevice.setLac(in.readShort());
|
|
|
- in.readMedium();
|
|
|
- yiTongGPSDevice.setTerminalMsg((int) in.readByte());
|
|
|
- yiTongGPSDevice.setElectric((int) in.readByte());
|
|
|
- yiTongGPSDevice.setGmsSign((int) in.readByte());
|
|
|
- yiTongGPSDevice.setWarningReason((int) in.readByte());
|
|
|
- in.readByte();
|
|
|
- yiTongGPSDevice.setDeviceId(deviceId);
|
|
|
- // 写文件操作
|
|
|
- String deviceStr = yiTongGPSDevice.buildDeviceStr();
|
|
|
-
|
|
|
- FileUtils.dataStorage(deviceStr.getBytes(), dataPath, prefixName);
|
|
|
- }
|
|
|
-
|
|
|
- private void resolveVoltageMSG(ByteBuf in, Channel channel) {
|
|
|
- String deviceId = channelDeviceMap.get(channel);
|
|
|
- byte subMsgType = in.readByte();
|
|
|
- if (VOLTAGE_SUB_MSG == subMsgType) {
|
|
|
- short voltage = in.readShort();
|
|
|
- Double voltageDouble = NumUtil.toFixed2Place((double) voltage);
|
|
|
- String date = DateUtil.formatDate2String(DateUtil.calculateByHour(new Date(), -8));
|
|
|
- YiTongGPSDevice yiTongGPSDevice = buildYiTongGpsDevcie(voltageDouble, deviceId, date);
|
|
|
- String deviceStr = YiTongGPSDevice.buildDeviceStr(yiTongGPSDevice);
|
|
|
- FileUtils.dataStorage(deviceStr.getBytes(), dataPath, prefixName);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private YiTongGPSDevice buildYiTongGpsDevcie(Double voltageDouble, String deviceId, String date) {
|
|
|
- return new YiTongGPSDevice(deviceId, date, null, null, null, null, null, null, null, null, null, null, null,
|
|
|
- null, null, null, voltageDouble, 0);
|
|
|
- }
|
|
|
-
|
|
|
private void resolveLoginMSG(ByteBuf in, Channel channel) {
|
|
|
byte[] deviceIdBytes = new byte[8];
|
|
|
in.readBytes(deviceIdBytes);
|
|
@@ -222,50 +149,6 @@ public class YiTongGpsServerHandler extends HexBinaryAcceptanceHandlerAdapter {
|
|
|
reply(channel, LOGIN_MSG);
|
|
|
}
|
|
|
|
|
|
- private void resolveLocationMSG(ByteBuf in, String deviceId) throws Exception {
|
|
|
- YiTongGPSDevice yiTongGPSDevice = new YiTongGPSDevice();
|
|
|
- StringBuffer dateTimeStrBuf = new StringBuffer();
|
|
|
- int indexOfDateTime = 0;
|
|
|
- while (indexOfDateTime < DATA_SIZE) {
|
|
|
- byte b = in.readByte();
|
|
|
- dateTimeStrBuf.append(NumUtil.byte2String(b));
|
|
|
- indexOfDateTime++;
|
|
|
- }
|
|
|
- // 日期
|
|
|
- yiTongGPSDevice.setDate(dateTimeStrBuf.toString());
|
|
|
- // gps信息卫星数
|
|
|
- yiTongGPSDevice.setGpsCount(in.readByte());
|
|
|
- // 维度
|
|
|
- yiTongGPSDevice.setLat(in.readInt());
|
|
|
- // 经度
|
|
|
- yiTongGPSDevice.setLng(in.readInt());
|
|
|
- // 速度
|
|
|
- yiTongGPSDevice.setSpeedbyte(in.readByte());
|
|
|
- // 航向
|
|
|
- yiTongGPSDevice.setCourseStatus(in.readShort());
|
|
|
- // 国家代号
|
|
|
- yiTongGPSDevice.setMcc(in.readShort());
|
|
|
- // 移动网号码
|
|
|
- yiTongGPSDevice.setMnc(in.readByte());
|
|
|
- // 位置区码
|
|
|
- yiTongGPSDevice.setLac(in.readShort());
|
|
|
- // 移动基站Cell Tower ID
|
|
|
- yiTongGPSDevice.setCellId(in.readMedium());
|
|
|
- yiTongGPSDevice.setAcc(in.readByte());
|
|
|
- // 数据上报模式 0x00:定时上报,0x01:定距上报,0x02:拐点上传,0x03:ACC状态改变上传,0X08:开机上报位置信息
|
|
|
- yiTongGPSDevice.setReportModel(in.readByte());
|
|
|
- // 0x01:实时 0x00:补传
|
|
|
- yiTongGPSDevice.setIsmendMsg(in.readByte());
|
|
|
- double mileage = NumUtil.toFixed2Place((double) in.readInt() / 1000);
|
|
|
- // 里程设备默认是关闭的,需要指令,设备端才发送
|
|
|
- yiTongGPSDevice.setDeviceId(deviceId);
|
|
|
- yiTongGPSDevice.setMileage(mileage);
|
|
|
- yiTongGPSDevice.setDataType(1);
|
|
|
- // 写文件操作
|
|
|
- String deviceStr = YiTongGPSDevice.buildDeviceStr(yiTongGPSDevice);
|
|
|
- FileUtils.dataStorage(deviceStr.getBytes(), dataPath, prefixName);
|
|
|
- }
|
|
|
-
|
|
|
private void reply(Channel channel, byte msgType) {
|
|
|
|
|
|
ByteBuf buffer = Unpooled.buffer();
|