Download Source Code

1.Introduction to Development Package

This development is mainly aimed at AOVX products, a toolkit for decoding device uplink data and packaging platform downlink control commands. Adopting the Java SpringBoot2. x framework.
The development mainly achieved the unpacking of device reported data, converting the binary stream data reported by the device into JSON strings.

2.Introduction to Source Code

The project name is: jt808 decode, and the method entry class is DataParse.

This class includes two methods:
(1) receiveData(String rowData): Receives the raw data (hexadecimal) reported by the device and converts the data into a JSON string.
(2) splitData(String rowData): To unpack and explain the raw data reported by the device, and return an introduction to unpacking and segmentation.

The project includes three package files:
(1) constant: defines some constants or enumeration definitions used in the process of parsing device raw data.

(2) model: defines some entity classes during the decoding process.

(3)utils:method toolkit, which contains some method classes used during the unpacking process.

2.1.receiveData(String rowData)

Call different parsing methods based on different message IDs for parsing:

/**
     * Receive the data reported by the device (hex) and parse it into a JSON string
     * @param rowData Data reported by the device (hex)
     * @return json
     */
    public static String receiveData(String rowData) throws Exception {
        if(StringUtils.isBlank(rowData)){
            return null;
        }
        //Convert Hex string to ByteBuf
        ByteBuf byteBuf = Unpooled.wrappedBuffer(ByteBufUtil.decodeHexDump(rowData));
        Object obj= Jt808PacketUtil.decodeJt808Packet(byteBuf);
        String resultJson="";
        if(obj==null){
            ReferenceCountUtil.release(byteBuf);
            return null;
        }else{
            Jt808Message jt808Msg= Jt808ProtocolDecoder.decode((ByteBuf)obj);
            switch (jt808Msg.getMsgId()){
                case 0x0001:
                    CommonReplyParam commonReplyParam= Message0001Parser.parse(jt808Msg,jt808Msg.getMsgBody());
                    resultJson=JSON.toJSONString(commonReplyParam);
                    break;
                case 0x0002:
                    Heartbeat heartbeat= Message0002Parser.parse(jt808Msg);
                    heartbeat.setReplyMsg(Jt808PacketUtil.reply8001(jt808Msg));
                    resultJson=JSON.toJSONString(heartbeat);
                    break;
                case 0x0100:
                    TerminalRegisterInfo registerInfo=Message0100Parser.parse(jt808Msg,jt808Msg.getMsgBody());
                    registerInfo.setReplyMsg(Jt808PacketUtil.reply8100(jt808Msg,registerInfo.getAuthCode()));
                    resultJson=JSON.toJSONString(registerInfo);
                    break;
                case 0x0102:
                    TerminalAuthInfo authInfo=Message0102Parser.parse(jt808Msg,jt808Msg.getMsgBody());
                    authInfo.setReplyMsg(Jt808PacketUtil.reply8001(jt808Msg));
                    resultJson=JSON.toJSONString(authInfo);
                    break;
                case 0x0104:
                    DeviceParam deviceParam=Message0104Parser.parse(jt808Msg,jt808Msg.getMsgBody());
                    resultJson=JSON.toJSONString(deviceParam);
                    break;
                case 0x0200:
                    Location location= Message0200Parser.parse(jt808Msg,jt808Msg.getMsgBody());
                    location.setReplyMsg(Jt808PacketUtil.reply8001(jt808Msg));
                    resultJson=JSON.toJSONString(location);
                    break;
                case 0x0900:
                    PassThroughData throughData=Message0900Parser.parser(jt808Msg,jt808Msg.getMsgBody());
                    resultJson=JSON.toJSONString(throughData);
                    break;
                default:
                    break;
            }
        }
        return resultJson;
    }

0x0001 CommonReplyParam

package com.jt808.decode.model;

import lombok.Data;

/**
 * Terminal general response
 * @author Mr.Li
 * @date 2023-03-03
 */
@Data
public class CommonReplyParam {
    /**
     * Terminal S/N
     */
    private String terminalNum;
    /**
     * Default 0x0001
     */
    private String hexMsgId;
    /**
     * The serial number of the current 0x0001 message
     */
    private int msgFlowId;
    /**
     * Response command serial number
     */
    private int replyMsgFlowId;
    /**
     * Response command message Id
     */
    private String replyMessageId;
    /**
     * Response result
     * 0: Success
     * 1: Failed
     * 2: Message incorrect
     * 3: Not supported
     */
    private int result;
}

0x0002 Heartbeat

package com.jt808.decode.model;

import lombok.Data;

/**
 * 心跳包实体类
 * @author Mr.Li
 * @date 2023-03-03
 */
@Data
public class Heartbeat {
    /**
     * Terminal S/N
     */
    private String terminalNum;
    /**
     * Default 0x0002
     */
    private String hexMsgId;
    /**
     * The serial number of the current 0x0002 message
     */
    private int msgFlowId;
    /**
     * The command that the platform needs to respond to the device
     */
    private String replyMsg;
}

0x0100 TerminalRegisterInfo

package com.jt808.decode.model;

import lombok.Data;

/**
 * <p>Description: JT808 terminal registration information</p>
 *
 * @author Mr.Li
 * @date 2023-03-03
 */
@Data
public class TerminalRegisterInfo {
    /**
     * Terminal S/N
     */
    private String terminalNum;

    /**
     * Default 0x0100
     */
    private String hexMsgId;

    /**
     * The serial number of the current 0x0100 message
     */
    private int msgFlowId;

    /**
     * province Id
     */
    private int provinceId;

    /**
     * city Id
     */
    private int cityId;

    /**
     * producer Id
     */
    private String producerId;

    /**
     * terminal Model Type
     */
    private String terminalModelType;

    /**
     * terminal id
     */
    private String terminalCode;

    /**
     * vehicle Plate Color
     */
    private int vehiclePlateColor;

    /**
     * vehicle No
     */
    private String vehicleNo;

    /**
     * Authentication code
     */
    private String authCode;

    /**
     * Terminal IMEI
     */
    private String imeiCode;

    /**
     * Software version number
     */
    private String softwareVersion;

    /**
     * The command that the platform needs to respond to the device
     */
    private String replyMsg;
}

0x0102 TerminalAuthInfo

package com.jt808.decode.model;

import lombok.Data;

/**
 * <p>Description: JT808 terminal authentication information</p>
 *
 * @author Mr.Li
 * @date 2023-03-03
 */
@Data
public class TerminalAuthInfo {
    /**
     * Terminal S/N
     */
    private String terminalNum;

    /**
     * Default 0x0102
     */
    private String hexMsgId;

    /**
     * The serial number of the current 0x0102 message
     */
    private int msgFlowId;

    /**
     * Authentication code
     */
    private String authCode;

    /**
     * Terminal IMEI
     */
    private String imeiCode;

    /**
     * Software version number
     */
    private String softwareVersion;

    /**
     * The command that the platform needs to respond to the device
     */
    private String replyMsg;
}

0x0104 DeviceParam

package com.jt808.decode.model;

import lombok.Data;

import java.util.Map;

/**
 * Terminal parameter query response
 *
 * @author Mr.Li
 * @date 2023-03-03
 */
@Data
public class DeviceParam {
    /**
     * Terminal S/N
     */
    private String terminalNum;

    /**
     * Default 0x0104
     */
    private String hexMsgId;

    /**
     * The serial number of the current 0x0104 message
     */
    private int msgFlowId;

    /**
     * Response serial number
     */
    private int replyMsgFlowId;

    /**
     * Number of parameters
     */
    private int itemCount;

    /**
     * parameter map
     */
    private Map<String, Object> itemMap;
}

0x0200 Location

package com.jt808.decode.model;

import com.jt808.decode.constant.AlarmTypeEnum;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Location Data
 *
 * @author Mr.Li
 * @date 2023-03-03
 */
@Data
public class Location {
    /**
     * Terminal S/N
     */
    private String terminalNum;

    /**
     * Default 0x0200
     */
    private String hexMsgId;

    /**
     * The serial number of the current 0x0200 message
     */
    private int msgFlowId;

    /**
     * location Type (0:Not positioned; 1:GPS positioning)
     */
    private Integer locationType=-1;

    /**
     * ACC Status 0:ACC Off;1:ACC on (V effective)
     */
    private Integer acc = -1;

    /**
     * latitude(WGS84)
     */
    private Double lat;

    /**
     * longitude(WGS84)
     */
    private Double lon;

    /**
     * altitude(Unit: m)
     */
    private Integer altitude;

    /**
     * speed(Unit:km/h)
     */
    private Double speed;

    /**
     * direction(0~360;0:North)
     */
    private Integer direction;

    /**
     * mileage(Unit:km)
     */
    private Double mileage= 0.0;

    /**
     * Base station cell code set(mcc,mnc,lac,ci,rssi)
     */
    private List<String> lbsCells;

    /**
     * Device data packaging time(GMT+0)
     */
    private String gnssTime;

    /**
     * Server receiving data time(GMT+0)
     */
    private String recvTime;

    /**
     * Battery Percentage
     */
    private Integer battery = 0;

    /**
     * voltage(Unit:V)
     */
    private Double voltage = 0.0;

    /**
     * GSM signal value
     */
    private Integer gsmValue = 0;

    /**
     * Number of satellites during GPS positioning
     */
    private Integer gnssValue = 0;

    /**
     * Alarm type enumeration set
     */
    private List<AlarmTypeEnum> alarmTypeList = new ArrayList<>();

    /**
     * Map of the current device status
     */
    private Map<String,Integer> statusMap;

    /**
     * Map of device expansion information
     */
    private Map<String,Object> expandMap;

    /**
     * The command that the platform needs to respond to the device
     */
    private String replyMsg;
}

AlarmTypeEnum

package com.jt808.decode.constant;

import lombok.Getter;

/**
 * <p>Description: Terminal Alarm enum</p>
 *
 * @author Mr.Li
 * @date 2023-03-03
 */
public enum AlarmTypeEnum implements BaseEnum<String> {
    ALARM_0("Emergency", "0"),
    ALARM_1("Speed Alarm", "1"),
    ALARM_2("Fatigue driving", "2"),
    ALARM_3("Danger warning", "3"),
    ALARM_4("GNSS module failure", "4"),
    ALARM_5("GNSS antenna disconnected", "5"),
    ALARM_6("GNSS antenna short circuit", "6"),
    ALARM_7("Undervoltage of main power supply", "7"),
    ALARM_8("Power failure of main power supply", "8"),
    ALARM_9("Display failure", "9"),
    ALARM_10("TTS module failure", "10"),
    ALARM_11("Camera fault", "11"),
    ALARM_12("Road transport certificate IC card module failure", "12"),
    ALARM_13("Overspeed warning", "13"),
    ALARM_14("Fatigue driving warning", "14"),
    ALARM_15("Removal alarm", "15"),
    ALARM_16("Vibration alarm", "16"),
    ALARM_18("Accumulated driving overtime of the day", "18"),
    ALARM_19("Overtime parking", "19"),
    ALARM_20("Access area", "20"),
    ALARM_21("Access route", "21"),
    ALARM_22("Insufficient/too long driving time", "22"),
    ALARM_23("Route deviation alarm", "23"),
    ALARM_24("Vehicle VSS failure", "24"),
    ALARM_25("Fuel quantity is abnormal", "25"),
    ALARM_26("Vehicle stolen", "26"),
    ALARM_27("Illegal ignition of vehicle", "27"),
    ALARM_28("Illegal vehicle displacement", "28"),
    ALARM_29("Collision warning", "29"),
    ALARM_30("Rollover warning", "30"),
    ALARM_31("Illegal door opening alarm", "31"),
    CUSTOM_ALARM_1("SOS", "200"),
    CUSTOM_ALARM_2("Temp&humidity alarm", "201"),
    CUSTOM_ALARM_4("Light alarm", "203"),
    CUSTOM_ALARM_5("Water immersion alarm", "204"),
    CUSTOM_ALARM_6("Low battery", "205"),
    CUSTOM_ALARM_7("One button alarm", "206"),
    CUSTOM_ALARM_8("Release the one button alarm", "207"),
    CUSTOM_ALARM_9("Rapid acceleration", "208"),
    CUSTOM_ALARM_10("Sharp deceleration", "209"),
    CUSTOM_ALARM_11("Sharp turn", "210"),
    CUSTOM_ALARM_12("Device abnormal", "211"),
    CUSTOM_ALARM_13("Pressure alarm", "212"),
    CUSTOM_ALARM_14("Jamming alarm", "213"),
    CUSTOM_ALARM_15("NoJamming alarm", "214"),
    CUSTOM_ALARM_16("Idling alarm", "215"),
    CUSTOM_ALARM_17("NoIdling alarm", "216"),
    CUSTOM_ALARM_18("Low speed", "217"),
    CUSTOM_ALARM_19("Abnormal angle", "218"),
    CUSTOM_ALARM_20("Flat fall alarm", "219"),
    CUSTOM_ALARM_21("Corner drop alarm", "220"),
    CUSTOM_ALARM_22("Overturn alarm", "221"),
    CUSTOM_ALARM_23("Motion", "222"),
    CUSTOM_ALARM_24("External temp alarm", "223");

    @Getter
    private String desc;

    private String value;

    AlarmTypeEnum(String desc, String value) {
        this.desc = desc;
        this.value = value;
    }

    @Override
    public String getValue() {
        return value;
    }

    public static AlarmTypeEnum fromValue(Integer value) {
        String valueStr = String.valueOf(value);
        for (AlarmTypeEnum alarmTypeEnum : values()) {
            if (alarmTypeEnum.getValue().equals(valueStr)) {
                return alarmTypeEnum;
            }
        }
        return null;
    }
}

statusMap key Jt808StatusConstant

package com.jt808.decode.constant;

/**
 * Status bit information
 * @author Mr.Li
 * @date 2023-03-03
 */
public class Jt808StatusConstant {
    private Jt808StatusConstant() {
    }
    /**
     * 0: Operation status; 1: Shutdown status
     */
    public static final String OPERATE = "operate";
    /**
     * 0: The longitude and latitude are not encrypted by the confidential plug-in; 1: Longitude and latitude have been encrypted by confidential plug-in
     */
    public static final String CONFIDENTIAL ="confidential";
    /**
     * 0: Empty; 1: Half load; 2: Reserved; 3: Full load
     */
    public static final String LOAD ="load";
    /**
     * 0: The vehicle oil circuit is normal; 1: Vehicle oil circuit is disconnected
     */
    public static final String OIL_CIRCUIT ="oil_circuit";
    /**
     * 0: The vehicle circuit is normal; 1: Vehicle circuit disconnected
     */
    public static final String OIL_ELECTRIC ="oil_electric";
    /**
     * 0: Door unlocking; 1: Door locking
     */
    public static final String DOOR_LOCK ="door_lock";
    /**
     * 0: Normal data; 1: TOW data
     */
    public static final String NORMAL_DATA ="normal_data";
    /**
     * 0: Real time data; 1: Blind area data
     */
    public static final String REALTIME_DATA ="realtime_data";
    public static final String POWERED = "powered";
    public static final String AWAKEN="awaken";
}

expandMap key Jt808ExpandConstant

package com.jt808.decode.constant;

/**
 * 808 expand information Map,Key
 *
 * @author Mr.Li
 * @date 2023-03-03
 */
public class Jt808ExpandConstant {
    private Jt808ExpandConstant() {
    }
    /**
     * Oil level value, liters, if there are multiple oil levels, use ";" separate
     */
    public static final String FUEL = "fuel";
    /**
     * Speed acquired by tachograph
     */
    public static final String RECODER_SPEED = "recoder_speed";
    /**
     * Events requiring manual response
     */
    public static final String RESPONSE_EVENT = "response_event";
    /**
     * Tyre pressure, unit: pa; Use ";" separate
     */
    public static final String TYRE = "tyre";
    /**
     *Temperature in the compartment
     */
    public static final String CARRIAGE_TEMPERATURE = "carriage_temperature";
    /**
     * Description of over speed alarm
     */
    public static final String SPEED_ALARM_DESCRIBE="speed_alarm_describe";
    /**
     * Entry/exit area/route alarm description
     */
    public static final String GIS_ALARM_DESCRIBE="gis_alarm_describe";
    /**
     * Signal status bit
     */
    public static final String SIGNAL_STATUS="signal_status";
    /**
     * IO Status bit
     */
    public static final String IO_STATUS="io_status";
    /**
     * Analog quantity
     */
    public static final String ANALOG_QUANTITY="analog_quantity";
    /**
     * external voltage
     */
    public static final String EXTERNAL_VOLTAGE="external_voltage";
    /**
     * software version
     */
    public static final String SOFTWARE_VERSION="software_version";
    /**
     * bluetooth information
     */
    public static final String BLUETOOTH="bluetooth";
    /**
     * WIFI information
     */
    public static final String WIFI="wifi";
    /**
     * GPIO Status
     */
    public static final String GPIO="GPIO";
    /**
     * sensor information
     */
    public static final String SENSOR="sensor";
    /**
     * device information
     */
    public static final String DEVICE="device";
    /**
     * illumination alarm describe
     */
    public static final String LIGHT_ALARM_DESCRIBE="light_alarm_describe";
    /**
     * temperature alarm describe
     */
    public static final String TEMP_ALARM_DESCRIBE="temp_alarm_describe";
    /**
     * ext temperature alarm describe
     */
    public static final String EXT_TEMP_ALARM_DESCRIBE="ext_temp_alarm_describe";
    /**
     * meter data information
     */
    public static final String METER="meter";
    /**
     * charge status(0:invalid;1:uncharged;2: Charging;3:Fully charged;4:Abnormal charging)
     */
    public static final String BATTERY_CHARGE="battery_charge";
    /**
     * auxiliary information
     */
    public static final String AUXILIARY="auxiliary";

}
expandMap value BLUETOOTH Info
package com.jt808.decode.constant;

/**
 * Bluetooth info
 *
 * @author Mr.Li
 * @date 2023-03-03
 */
public class BluetoothConstant {
    private BluetoothConstant() {
    }
    public static final String MAC="mac";
    public static final String RSSI="rssi";
    public static final String NAME="name";
    public static final String FWVER="fwVer";
    public static final String VOLTAGE="voltage";
    public static final String TEMPERATURE="temperature";
    public static final String HUMIDITY="humidity";
    public static final String SENSOR="sensor";
}
expandMap value WIFI Info
    public static final String MAC="mac";
    public static final String RSSI="rssi";
expandMap value SENSOR Info
package com.jt808.decode.constant;

/**
 * Sensor information
 * @author Mr.Li
 * @date 2022-09-21
 */
public class SensorConstant {
    private SensorConstant() {
    }
    public static final String DATA_TYPE="data_type";
    public static final String LIGHT="light";
    public static final String TEMPERATURE="temperature";
    public static final String HUMIDITY="humidity";
    public static final String ACCELEROMETER="accelerometer";
    /**
     * High temperature threshold
     */
    public static final String TEMP_MAX="temp_max";
    /**
     * Low temperature threshold
     */
    public static final String TEMP_MIN="temp_min";
    /**
     * High humidity threshold
     */
    public static final String HUM_MAX="hum_max";
    /**
     * Low humidity threshold
     */
    public static final String HUM_MIN="hum_min";
    /**
     * Illumination threshold
     */
    public static final String LIGHT_LIMIT="light_Limit";
    /**
     * Pressure Unit:Pa
     */
    public static final String PRESSURE="pressure";
}
expandMap value DEVICE Info
package com.jt808.decode.constant;

/**
 * Device information
 * @author Mr.Li
 * @date 2022-09-21
 */
public class DeviceConstant {
    private DeviceConstant() {
    }
    /**
     * work model
     * 0: Periodic mode
     * 1: Trigger mode
     * 2: Tracking mode+Trigger mode
     * 3: Clock mode+Trigger mode
     * 4: Periodic mode+Trigger mode
     */
    public static final String WORK_MODEL="work_model";
    public static final String IMEI="imei";
    public static final String ICCID="iccid";
    public static final String DEVICE_TYPE="device_type";
}
expandMap value AUXILIARY Info
package com.jt808.decode.constant;

/**
 * Auxiliary information
 * @author Mr.Li
 * @date 2022-09-27
 */
public class AuxiliaryConstant {
    public AuxiliaryConstant(){
    }
    public static final String POSITION_AGE="position_age";
    public static final String ACC_DURATION="acc_duration";
    public static final String HDOP="hdop";
    public static final String GNSS_TIME="gnss_time";
    public static final String STATE_REGISTER_INFO="state_register_info";
    public static final String SAMPLE_TIME = "sample_time";
    public static final String REPORT_TIME = "report_time";
    public static final String EXT_TEMP = "ext_temp";
    public static final String EXT_TEMP_MAX = "ext_temp_max";
    public static final String EXT_TEMP_MIN = "ext_temp_min";
}

0x0900 PassThroughData

package com.jt808.decode.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

/**
 * <p>Description: Transparent transmission of data</p>
 *
 * @author Mr.Li
 * @date 2023-03-15
 */
@Data
public class PassThroughData {
    /**
     * terminal S/N
     */
    private String terminalNum;

    /**
     * Default 0x0900
     */
    private String hexMsgId;

    /**
     * The serial number of the current 0x0900 message
     */
    private int msgFlowId;

    /**
     * Transparent message type
     */
    private int msgType;

    /**
     * Transparent message content
     */
    private String msgContent;

    /**
     * The command that the platform needs to respond to the device
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String replyMsg;
}

if msgType==0x54 then msgContent is SensorLogData

package com.jt808.decode.model;

import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * 0x54 sensor log data
 * @author Mr.Li
 * @date 2023-03-15
 */
@Data
public class SensorLogData {
    /**
     * location Type (0:Not positioned; 1:GPS positioning)
     */
    private Integer locationType=-1;

    /**
     * ACC Status 0:ACC Off;1:ACC on (V effective)
     */
    private Integer acc = -1;

    /**
     *latitude(WGS84)
     */
    private Double lat;

    /**
     * longitude(WGS84)
     */
    private Double lon;

    /**
     * altitude(Unit: m)
     */
    private Integer altitude;

    /**
     * speed(Unit:km/h)
     */
    private Double speed;

    /**
     * direction(0~360;0:North)
     */
    private Integer direction;

    /**
     * Device data packaging time(GMT+0)
     */
    private String gnssTime;

    /**
     * Sensor info List
     */
    private List<Map<String,Object>> sensorList;
}
Sensor info
package com.jt808.decode.constant;

/**
 * Sensor information
 * @author Mr.Li
 * @date 2022-09-21
 */
public class SensorConstant {
    private SensorConstant() {
    }
    public static final String DATA_TYPE="data_type";
    public static final String LIGHT="light";
    public static final String TEMPERATURE="temperature";
    public static final String HUMIDITY="humidity";
    public static final String ACCELEROMETER="accelerometer";
    /**
     * High temperature threshold
     */
    public static final String TEMP_MAX="temp_max";
    /**
     * Low temperature threshold
     */
    public static final String TEMP_MIN="temp_min";
    /**
     * High humidity threshold
     */
    public static final String HUM_MAX="hum_max";
    /**
     * Low humidity threshold
     */
    public static final String HUM_MIN="hum_min";
    /**
     * Illumination threshold
     */
    public static final String LIGHT_LIMIT="light_Limit";
    /**
     * Pressure Unit:Pa
     */
    public static final String PRESSURE="pressure";
}

2.2.splitData(String rowData)

Explanation of splitting data according to protocol content format.

/**
     * Introduction to the data unpacking process for hex strings reported by devices
     * @param rowData Data reported by the device (hex)
     * @return
     */
    public static List<String> splitData(String rowData){
        if(StringUtils.isBlank(rowData)){
            return null;
        }
        List<String> dataArr=new ArrayList<>();
        //Convert Hex string to ByteBuf
        ByteBuf byteBuf = Unpooled.wrappedBuffer(ByteBufUtil.decodeHexDump(rowData));
        Object obj= Jt808PacketUtil.decodeJt808Packet(byteBuf);
        if(obj==null){
            ReferenceCountUtil.release(byteBuf);
            return null;
        }else{
            ByteBuf msgBuf= (ByteBuf) obj;
            dataArr.add(String.format("%s-->%s",NumberUtil.hexStr(msgBuf.readUnsignedByte(),2),"Start Flag"));
            int msgId=msgBuf.readUnsignedShort();
            dataArr.add(String.format("%s-->%s",NumberUtil.hexStr(msgId,4),"Message ID"));
            //message body properties
            short msgBodyAttr = msgBuf.readShort();
            //Version ID (version ID 0 refers to the version in 2011 and 1 refers to the version in 2019)
            int versionFlag = (msgBodyAttr & 0b01000000_00000000)>0?1:0;
            //is multi packet?
            boolean multiPacket = (msgBodyAttr & 0b00100000_00000000) > 0;
            dataArr.add(String.format("%s-->%s",NumberUtil.hexStr(msgBodyAttr,4),"Properties of Message Body"));
            //Terminal phone number array,JT808-2019 is 10 bytes
            byte[] phoneNumberArr;
            if (versionFlag == 1) {
                dataArr.add(String.format("%s-->%s",NumberUtil.hexStr(msgBuf.readUnsignedByte(),2),"Protocol Version"));
                phoneNumberArr = new byte[10];
            } else {
                phoneNumberArr = new byte[6];
            }
            msgBuf.readBytes(phoneNumberArr);
            dataArr.add(String.format("%s-->%s",ByteBufUtil.hexDump(phoneNumberArr),"Device Number"));
            //Message serial number
            int msgFlowId = msgBuf.readUnsignedShort();
            dataArr.add(String.format("%s-->%s",NumberUtil.hexStr(msgFlowId,4),"Message serial number"));
            //multi packet?
            if (multiPacket) {
                dataArr.add(String.format("%s-->%s",NumberUtil.hexStr(msgBuf.readUnsignedShort(),4),"Packet Total Count"));
                dataArr.add(String.format("%s-->%s",NumberUtil.hexStr(msgBuf.readUnsignedShort(),4),"Packet Order"));
            }
            //message body length
            int msgBodyLen = msgBodyAttr & 0b00000011_11111111;
            if(msgBodyLen>msgBuf.readableBytes()-2){
                byte[] msgBodyArr=new byte[msgBuf.readableBytes()-2];
                msgBuf.readBytes(msgBodyArr);
                dataArr.add(String.format("%s-->%s",ByteBufUtil.hexDump(msgBodyArr),"Insufficient message body length!"));
            }else{
                ByteBuf msgBodyBuf =msgBuf.readSlice(msgBuf.readableBytes()-2);
                switch (msgId){
                    case 0x0001:
                        dataArr.add(String.format("%s-->%s",NumberUtil.hexStr(msgBodyBuf.readShort(),4),"Response serial number"));
                        dataArr.add(String.format("%s-->%s",NumberUtil.hexStr(msgBodyBuf.readShort(),4),"Response message ID"));
                        dataArr.add(String.format("%s-->%s",NumberUtil.hexStr(msgBodyBuf.readShort(),2),"Results (0: success; 1: failure; 2: message error; 3: not supported)"));
                        break;
                    case 0x0002:
                        if(msgBodyBuf.readableBytes()>0){
                            byte[] msgBodyArr=new byte[msgBodyBuf.readableBytes()];
                            msgBodyBuf.readBytes(msgBodyArr);
                            dataArr.add(String.format("%s-->%s",ByteBufUtil.hexDump(msgBodyArr),"Message Body"));
                        }
                        break;
                    case 0x0100:
                        if(versionFlag == 1){
                            SplitUtil.splitTerminalRegisterInfo(msgBodyBuf,dataArr);
                        }else{
                            SplitUtil.splitTerminalRegisterInfo2019(msgBodyBuf,dataArr);
                        }
                        break;
                    case 0x0102:
                        SplitUtil.splitAuthInfo(msgBodyBuf,dataArr,versionFlag);
                        break;
                    case 0x0104:
                        SplitUtil.splitTerminalParameterResponse(msgBodyBuf,dataArr);
                        break;
                    case 0x0200:
                        SplitUtil.splitLocationInfo(msgBodyBuf,dataArr);
                        break;
                    case 0x0900:
                        dataArr.add(String.format("%s-->%s",NumberUtil.hexStr(msgBodyBuf.readUnsignedByte(),2),"Transparent message type"));
                        if(msgBodyBuf.readableBytes()>0){
                            byte [] msgContentArr=new byte[msgBodyBuf.readableBytes()];
                            msgBodyBuf.readBytes(msgContentArr);
                            dataArr.add(String.format("%s-->%s",ByteBufUtil.hexDump(msgContentArr),"Transparent message content"));
                        }
                        break;
                    default:
                        byte[] msgBodyArr=new byte[msgBodyBuf.readableBytes()];
                        msgBodyBuf.readBytes(msgBodyArr);
                        dataArr.add(String.format("%s-->%s",ByteBufUtil.hexDump(msgBodyArr),"Message Body"));
                        break;
                }
            }
            dataArr.add(String.format("%s-->%s",NumberUtil.hexStr(msgBuf.readUnsignedByte(),2),"Check Code"));
            dataArr.add(String.format("%s-->%s",NumberUtil.hexStr(msgBuf.readUnsignedByte(),2),"End Flag"));
        }
        return dataArr;
    }

3.test

3.1.Decoding method effect

Use Example 0x0200:

    @Test
    public void receiveData() throws Exception {
        String rowData="7E020000CA593054482897004800000000B0080010000000000000000000000000000023030110180430019E310100F00E0136019A04C14B10000083039F03F22C414F56585F414D3330302D474C5F48322E305F424739354D334C415230324130345F56322E302E343A763135F423542160033C41C354216000E04DC33CB74B797D02B8C0F4C114700274BD3EB74B797D02BEBBF60A00090000000000000000F70400000DE3F81D04086459305448289789320420000012218671414D3330302D474C0000F912000F000000000000000000000000000000008C7E";
        String parseDataJson=dataParser.receiveData(rowData);
        System.out.println("ParseData:"+parseDataJson);
    }

Output Content:

{
    "acc": 0,
    "alarmTypeList": [],
    "altitude": 0,
    "battery": 0,
    "direction": 0,
    "expandMap": {
        "wifi": "[{\"rssi\":-61,\"mac\":\"54:21:60:03:3c:41\"},{\"rssi\":-61,\"mac\":\"54:21:60:00:e0:4d\"},{\"rssi\":-64,\"mac\":\"3c:b7:4b:79:7e:b8\"},{\"rssi\":-67,\"mac\":\"f4:c1:14:70:02:74\"},{\"rssi\":-69,\"mac\":\"3e:b7:4b:79:7e:be\"}]",
        "auxiliary": "{\"gnss_time\":\"000000000000\",\"acc_duration\":0,\"position_age\":0,\"hdop\":0}",
        "sensor": "[{\"light\":0,\"accelerometer\":\"x:0,y:0,z:0\",\"data_type\":0}]",
        "software_version": "\"AOVX_AM300-GL_H2.0_BG95M3LAR02A04_V2.0.4:v15\"",
        "device": "{\"iccid\":\"89320420000012218671\",\"imei\":\"0864593054482897\",\"device_type\":\"AM300-GL\\u0000\\u0000\",\"work_model\":4}"
    },
    "gnssTime": "2023-03-01T10:18:04Z",
    "gnssValue": 0,
    "gsmValue": 158,
    "hexMsgId": "0x0200",
    "lat": 0.0,
    "lbsCells": "310,410,33539,79776528,159",
    "locationType": 0,
    "lon": 0.0,
    "mileage": 0.0,
    "msgFlowId": 72,
    "recvTime": "2023-04-27T08:34:11.902Z",
    "replyMsg": "7e80010005593054482897004800480200004c7e",
    "speed": 0.0,
    "statusMap": {
        "operate": 1,
        "load": 0,
        "realtime_data": 1,
        "oil_electric": 0,
        "normal_data": 0,
        "door_lock": 0,
        "oil_circuit": 0,
        "confidential": 0
    },
    "terminalNum": "593054482897",
    "voltage": 3.555
}

Use Example 0x0900:

    @Test
    public void receiveData() throws Exception {
        String rowData="7E090003F1487060048435004A54100000000000000000000000000000000000240127090058001F2401270744580BC400C900FE0000FFE0002000900409001F2401270745570BC400C900FF0000FFE0001000100409001F2401270746570BC400C900FC000000200010FFE80409001F2401270747570BC400C901090000FFC00020FFF00409001F2401270748570BC400C9010C00000018000800780409001F2401270749570BC400C9010700000020FFF8FFF80409001F2401270750570BC400C901030000FFE8002000100409001F2401270751570BC400C9010700000020002000A00409001F2401270752570BC400C900FF00000000FFE8FF800409001F2401270753580BC400C9010000000030FFD800100409001F2401270754580BC400C901010000FFF8FFF0FFF00409001F2401270755580BC400C9010400000018FFF800080409001F2401270756570BC400C901010000FFD0000000A00409001F2401270757570BC400C9010600000010FFD0FFA80409001F2401270758580BC400C9010300000020FFD0FF980409001F2401270759580BC400C90100000000000000FFE00409001F2401270800580BC400C9010000000010FFC0FFF80409001F2401270801570BC400C2010100000010003800B80409001F2401270802590BC400C2010100000000FFE8FFB80409001F2401270803580BC400C200FD000000200030FFE00409001F2401270804580BC400C700FD00000018FFF0FF880409001F2401270805580BC400C700FF0000FFC8001800A00409001F2401270806580BC400C700F80000FFF0FFF8FFD80409001F2401270807570BC400C700FB000000000038FFB00409001F2401270808580BC400C701010000FFD0FFD0FFE80409001F2401270816580BC400C701010000FFE0FFE0FFB80409001F2401270817580BC400C7010200000000FFE800100409001F2401270818580BC400C701010000FFD8FFF8FFE00409001F2401270819580BC400C701020000FFE0FFE0FFA80409001F2401270820580BC400C701020000FFF0FFF0FFB80409001F2401270830580BC400C201030000FFC0001000800409001F2401270831580BC400C801020000FFC8001800380409001F2401270832580BC400C801030000FFD0FFE8FFE00409001F2401270833580BC400C801000000FFF8FFD800200409001F2401270834580BC400C80101000000180020FFF00409001F2401270845580BC400C301000000FFD0FFE0FFB80409001F2401270846580BC400C300FF00000000FFF0FF980409001F2401270847580BC400C301010000FFC00018FFE8040A001F2401270848580BC400C301000000FFE8FFD0FFD0040A001F2401270849580BC400C300FE0000FFC8FFD0FF80040A001F2401270900580BC400C300FE00000020FFE0FFB80409517E";
        String parseDataJson=dataParser.receiveData(rowData);
        System.out.println("ParseData:"+parseDataJson);
    }

Output Content:

{
    "hexMsgId": "0x0900",
    "msgContent": "{\"acc\":0,\"altitude\":0,\"direction\":0,\"gnssTime\":\"2024-01-27T09:00:58Z\",\"lat\":0.0,\"locationType\":0,\"lon\":0.0,\"sensorList\":[{\"dateTime\":\"2024-01-27T07:44:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-32,y:32,z:144\",\"temperature\":\"20.1\",\"humidity\":\"25.4\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:45:57Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-32,y:16,z:16\",\"temperature\":\"20.1\",\"humidity\":\"25.5\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:46:57Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:32,y:16,z:-24\",\"temperature\":\"20.1\",\"humidity\":\"25.2\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:47:57Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-64,y:32,z:-16\",\"temperature\":\"20.1\",\"humidity\":\"26.5\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:48:57Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:24,y:8,z:120\",\"temperature\":\"20.1\",\"humidity\":\"26.8\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:49:57Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:32,y:-8,z:-8\",\"temperature\":\"20.1\",\"humidity\":\"26.3\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:50:57Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-24,y:32,z:16\",\"temperature\":\"20.1\",\"humidity\":\"25.9\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:51:57Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:32,y:32,z:160\",\"temperature\":\"20.1\",\"humidity\":\"26.3\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:52:57Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:0,y:-24,z:-128\",\"temperature\":\"20.1\",\"humidity\":\"25.5\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:53:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:48,y:-40,z:16\",\"temperature\":\"20.1\",\"humidity\":\"25.6\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:54:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-8,y:-16,z:-16\",\"temperature\":\"20.1\",\"humidity\":\"25.7\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:55:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:24,y:-8,z:8\",\"temperature\":\"20.1\",\"humidity\":\"26.0\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:56:57Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-48,y:0,z:160\",\"temperature\":\"20.1\",\"humidity\":\"25.7\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:57:57Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:16,y:-48,z:-88\",\"temperature\":\"20.1\",\"humidity\":\"26.2\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:58:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:32,y:-48,z:-104\",\"temperature\":\"20.1\",\"humidity\":\"25.9\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T07:59:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:0,y:0,z:-32\",\"temperature\":\"20.1\",\"humidity\":\"25.6\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:00:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:16,y:-64,z:-8\",\"temperature\":\"20.1\",\"humidity\":\"25.6\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:01:57Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:16,y:56,z:184\",\"temperature\":\"19.4\",\"humidity\":\"25.7\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:02:59Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:0,y:-24,z:-72\",\"temperature\":\"19.4\",\"humidity\":\"25.7\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:03:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:32,y:48,z:-32\",\"temperature\":\"19.4\",\"humidity\":\"25.3\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:04:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:24,y:-16,z:-120\",\"temperature\":\"19.9\",\"humidity\":\"25.3\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:05:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-56,y:24,z:160\",\"temperature\":\"19.9\",\"humidity\":\"25.5\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:06:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-16,y:-8,z:-40\",\"temperature\":\"19.9\",\"humidity\":\"24.8\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:07:57Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:0,y:56,z:-80\",\"temperature\":\"19.9\",\"humidity\":\"25.1\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:08:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-48,y:-48,z:-24\",\"temperature\":\"19.9\",\"humidity\":\"25.7\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:16:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-32,y:-32,z:-72\",\"temperature\":\"19.9\",\"humidity\":\"25.7\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:17:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:0,y:-24,z:16\",\"temperature\":\"19.9\",\"humidity\":\"25.8\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:18:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-40,y:-8,z:-32\",\"temperature\":\"19.9\",\"humidity\":\"25.7\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:19:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-32,y:-32,z:-88\",\"temperature\":\"19.9\",\"humidity\":\"25.8\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:20:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-16,y:-16,z:-72\",\"temperature\":\"19.9\",\"humidity\":\"25.8\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:30:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-64,y:16,z:128\",\"temperature\":\"19.4\",\"humidity\":\"25.9\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:31:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-56,y:24,z:56\",\"temperature\":\"20.0\",\"humidity\":\"25.8\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:32:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-48,y:-24,z:-32\",\"temperature\":\"20.0\",\"humidity\":\"25.9\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:33:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-8,y:-40,z:32\",\"temperature\":\"20.0\",\"humidity\":\"25.6\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:34:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:24,y:32,z:-16\",\"temperature\":\"20.0\",\"humidity\":\"25.7\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:45:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-48,y:-32,z:-72\",\"temperature\":\"19.5\",\"humidity\":\"25.6\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:46:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:0,y:-16,z:-104\",\"temperature\":\"19.5\",\"humidity\":\"25.5\",\"pressure\":103300},{\"dateTime\":\"2024-01-27T08:47:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-64,y:24,z:-24\",\"temperature\":\"19.5\",\"humidity\":\"25.7\",\"pressure\":103400},{\"dateTime\":\"2024-01-27T08:48:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-24,y:-48,z:-48\",\"temperature\":\"19.5\",\"humidity\":\"25.6\",\"pressure\":103400},{\"dateTime\":\"2024-01-27T08:49:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:-56,y:-48,z:-128\",\"temperature\":\"19.5\",\"humidity\":\"25.4\",\"pressure\":103400},{\"dateTime\":\"2024-01-27T09:00:58Z\",\"light\":3012,\"ext_temp\":\"0.0\",\"accelerometer\":\"x:32,y:-32,z:-72\",\"temperature\":\"19.5\",\"humidity\":\"25.4\",\"pressure\":103300}],\"speed\":0.0}",
    "msgFlowId": 74,
    "msgType": 84,
    "replyMsg": "7e80010005487060048435004a004a090000607e",
    "terminalNum": "487060048435"
}

msgContent:

{
    "acc": 0,
    "altitude": 0,
    "direction": 0,
    "gnssTime": "2024-01-27T09:00:58Z",
    "lat": 0.0,
    "locationType": 0,
    "lon": 0.0,
    "sensorList": [{
        "dateTime": "2024-01-27T07:44:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-32,y:32,z:144",
        "temperature": "20.1",
        "humidity": "25.4",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:45:57Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-32,y:16,z:16",
        "temperature": "20.1",
        "humidity": "25.5",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:46:57Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:32,y:16,z:-24",
        "temperature": "20.1",
        "humidity": "25.2",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:47:57Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-64,y:32,z:-16",
        "temperature": "20.1",
        "humidity": "26.5",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:48:57Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:24,y:8,z:120",
        "temperature": "20.1",
        "humidity": "26.8",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:49:57Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:32,y:-8,z:-8",
        "temperature": "20.1",
        "humidity": "26.3",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:50:57Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-24,y:32,z:16",
        "temperature": "20.1",
        "humidity": "25.9",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:51:57Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:32,y:32,z:160",
        "temperature": "20.1",
        "humidity": "26.3",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:52:57Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:0,y:-24,z:-128",
        "temperature": "20.1",
        "humidity": "25.5",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:53:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:48,y:-40,z:16",
        "temperature": "20.1",
        "humidity": "25.6",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:54:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-8,y:-16,z:-16",
        "temperature": "20.1",
        "humidity": "25.7",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:55:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:24,y:-8,z:8",
        "temperature": "20.1",
        "humidity": "26.0",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:56:57Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-48,y:0,z:160",
        "temperature": "20.1",
        "humidity": "25.7",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:57:57Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:16,y:-48,z:-88",
        "temperature": "20.1",
        "humidity": "26.2",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:58:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:32,y:-48,z:-104",
        "temperature": "20.1",
        "humidity": "25.9",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T07:59:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:0,y:0,z:-32",
        "temperature": "20.1",
        "humidity": "25.6",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:00:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:16,y:-64,z:-8",
        "temperature": "20.1",
        "humidity": "25.6",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:01:57Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:16,y:56,z:184",
        "temperature": "19.4",
        "humidity": "25.7",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:02:59Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:0,y:-24,z:-72",
        "temperature": "19.4",
        "humidity": "25.7",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:03:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:32,y:48,z:-32",
        "temperature": "19.4",
        "humidity": "25.3",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:04:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:24,y:-16,z:-120",
        "temperature": "19.9",
        "humidity": "25.3",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:05:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-56,y:24,z:160",
        "temperature": "19.9",
        "humidity": "25.5",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:06:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-16,y:-8,z:-40",
        "temperature": "19.9",
        "humidity": "24.8",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:07:57Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:0,y:56,z:-80",
        "temperature": "19.9",
        "humidity": "25.1",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:08:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-48,y:-48,z:-24",
        "temperature": "19.9",
        "humidity": "25.7",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:16:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-32,y:-32,z:-72",
        "temperature": "19.9",
        "humidity": "25.7",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:17:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:0,y:-24,z:16",
        "temperature": "19.9",
        "humidity": "25.8",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:18:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-40,y:-8,z:-32",
        "temperature": "19.9",
        "humidity": "25.7",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:19:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-32,y:-32,z:-88",
        "temperature": "19.9",
        "humidity": "25.8",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:20:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-16,y:-16,z:-72",
        "temperature": "19.9",
        "humidity": "25.8",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:30:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-64,y:16,z:128",
        "temperature": "19.4",
        "humidity": "25.9",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:31:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-56,y:24,z:56",
        "temperature": "20.0",
        "humidity": "25.8",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:32:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-48,y:-24,z:-32",
        "temperature": "20.0",
        "humidity": "25.9",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:33:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-8,y:-40,z:32",
        "temperature": "20.0",
        "humidity": "25.6",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:34:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:24,y:32,z:-16",
        "temperature": "20.0",
        "humidity": "25.7",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:45:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-48,y:-32,z:-72",
        "temperature": "19.5",
        "humidity": "25.6",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:46:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:0,y:-16,z:-104",
        "temperature": "19.5",
        "humidity": "25.5",
        "pressure": 103300
    }, {
        "dateTime": "2024-01-27T08:47:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-64,y:24,z:-24",
        "temperature": "19.5",
        "humidity": "25.7",
        "pressure": 103400
    }, {
        "dateTime": "2024-01-27T08:48:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-24,y:-48,z:-48",
        "temperature": "19.5",
        "humidity": "25.6",
        "pressure": 103400
    }, {
        "dateTime": "2024-01-27T08:49:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:-56,y:-48,z:-128",
        "temperature": "19.5",
        "humidity": "25.4",
        "pressure": 103400
    }, {
        "dateTime": "2024-01-27T09:00:58Z",
        "light": 3012,
        "ext_temp": "0.0",
        "accelerometer": "x:32,y:-32,z:-72",
        "temperature": "19.5",
        "humidity": "25.4",
        "pressure": 103300
    }],
    "speed": 0.0
}

3.2.Effect of unpacking method

Use Example:

    @Test
    public void splitData() throws Exception {
        String rowData="7E020000CA593054482897004800000000B0080010000000000000000000000000000023030110180430019E310100F00E0136019A04C14B10000083039F03F22C414F56585F414D3330302D474C5F48322E305F424739354D334C415230324130345F56322E302E343A763135F423542160033C41C354216000E04DC33CB74B797D02B8C0F4C114700274BD3EB74B797D02BEBBF60A00090000000000000000F70400000DE3F81D04086459305448289789320420000012218671414D3330302D474C0000F912000F000000000000000000000000000000008C7E";

        List<String> splitDataList=dataParser.splitData(rowData);
        System.out.println("SplitData:"+splitDataList);
    }

Output Content:

[
7E- - > Start Flag, 
0200-- > Message ID, 
00 CA-- > Properties of Message Body, 
593054482897-- > Device Number, 
0048-- > Message serial number, 
00000000-- > Alarm flag, 
B0080010-- > Terminal status, 
00000000-- > Latitude, 
00000000-- > Longitude, 
0000-- > Altitude, 
2303-- > Speed, 
1101804-- > Direction, 
30019e310100-- > Datetime, 
F0-- > Extension ID, 
0E- - > Extension information length, 
0136019a04c14b10000083039f03-- > Extension information, 
F2-- > Extension ID, 
2C-- > Extension information length, 
414f56585f414d3330302d474c5f48322e305f424739354d334c415230324130345f56322e302e343a763135-- > Extension information, 
F4-- > Extension ID, 
23-- > Extension information length, 
542160033c41c354216000e04dc33cb74b797eb8c0f4c114700274bd3eb74b797ebebb-- > Extension information, 
F6-- > Extension ID, 
0A-- > Extension information length, 
00090000000000000000-- > Extension information, 
F7-- > Extension ID, 
04-- > Extension information length, 
00000de3-- > Extension information, 
F8-- > Extension ID, 
1D-- > Extension information length, 
04086459305448289789320420000012218671414d3330302d474c0000-- > Extension information, 
F9-- > Extension ID, 
12-- > Extension information length, 
000f00000000000000000000000000000000-- > Extension information, 
8 C-- > Check Code, 
7E- - > End Flag
]

4.Protocol packaging

4.1.Packaging method encodeCommand(String paramsJson)


Parameter input json string

4.2.Parameter JSON description

{"msgFlowId":1,"msgId":33027,"params":{1:10,61488:"AT+QUERY?"},"terminalNum":"12345678901"}
Field Name Field Type Field Description
terminalNum String Device S/N
msgFlowId int serial number(1~65535)
msgId int Protocol defined message ID,such as:0x8103,0x8104,0x8105
params Map key:value;wherein,key:Command ID,value:Configured values

0x8103 (setting device parameters)

Corresponding params, command IDs that can be set, and descriptions of the values passed in.

0x8104 (query device parameters)

params is null

0x8105(Control commands)

4.3.Example of packaging method

This method takes 0x8103 as an example, while setting the heartbeat interval and sending AT commands
The corresponding JSON string is as follows:

{"msgFlowId":1,"msgId":33027,"params":{1:10,61488:"AT+QUERY?"},"terminalNum":"12345678901"}

作者:admin  创建时间:2023-04-27 17:00
最后编辑:admin  更新时间:2024-10-08 16:21