package com.njzscloud.common.localizer.jt808.message;

import cn.hutool.core.util.CharsetUtil;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

@Getter
@Setter
@ToString
@Accessors(chain = true)
public class TerminalAuthMessage {
    private String authCode;

    public TerminalAuthMessage(byte[] bytes) {
        ByteBuf body = Unpooled.wrappedBuffer(bytes);
        byte[] authCodeBytes = new byte[body.readableBytes()];
        body.readBytes(authCodeBytes);
        this.authCode = new String(authCodeBytes, CharsetUtil.CHARSET_GBK);
        body.release();
    }
}
