package safeluck.drive.evaluation.platformMessage;
|
|
|
import android.text.TextUtils;
|
|
import com.anyun.im_lib.util.ByteUtil;
|
|
import safeluck.drive.evaluation.platformMessage.DriveExamProtocol;
|
|
/**
|
* 注册消息
|
* MyApplication2
|
* Created by lzw on 2019/12/17. 17:51:44
|
* 邮箱:632393724@qq.com
|
* All Rights Saved! Chongqing AnYun Tech co. LTD
|
*/
|
public class RegisterMessage extends DriveExamProtocol {
|
|
/**
|
* 1.1.1 终端注册
|
* 消息ID:0x0100。
|
* 起始字节
|
* 字段
|
* 数据类型
|
* 描述及要求
|
* 0
|
* 省域ID
|
* WORD
|
* 终端所在地省ID
|
* 2
|
* 市县域ID
|
* WORD
|
* 终端所在地市ID
|
* 4
|
* 终端型号
|
* BYTE[20]
|
* 20个字节,此终端型号由制造商自行定义,位数不足20位的,后补“0X00”
|
* 24
|
* 终端出厂序列号
|
* BYTE[8]
|
* 8个字节,由大写字母和数字组成,此终端ID由制造商自行定义,位数不足时,后补“0X00”
|
* 32
|
* IMEI
|
* BYTE[15]
|
* 国际移动设备标识,ASCII码
|
*/
|
private static final int BODY_LENGTH = 55;
|
|
private short proviceId;
|
private short cityid;
|
private String model;//终端型号
|
private String sn;//出厂序列号
|
private String imei;//
|
|
/**
|
* 构造函数
|
*
|
* @param msg_id 消息ID
|
*/
|
public RegisterMessage(short msg_id) {
|
super(msg_id);
|
}
|
|
public static int getBodyLength() {
|
return BODY_LENGTH;
|
}
|
|
public short getProviceId() {
|
return proviceId;
|
}
|
|
public void setProviceId(short proviceId) {
|
this.proviceId = proviceId;
|
}
|
|
public short getCityid() {
|
return cityid;
|
}
|
|
public void setCityid(short cityid) {
|
this.cityid = cityid;
|
}
|
|
public String getModel() {
|
return model;
|
}
|
|
public void setModel(String model) {
|
this.model = model;
|
}
|
|
public String getSn() {
|
return sn;
|
}
|
|
public void setSn(String sn) {
|
this.sn = sn;
|
}
|
|
public String getImei() {
|
return imei;
|
}
|
|
public void setImei(String imei) {
|
this.imei = imei;
|
}
|
|
@Override
|
protected short msgBodyLength() {
|
return BODY_LENGTH;
|
}
|
|
|
@Override
|
protected byte[] createMessageBody() {
|
int pos = 0;
|
byte[] messageBody = new byte[BODY_LENGTH];
|
//省域ID
|
byte[] provinceIdBytes = ByteUtil.shortGetBytes(proviceId);
|
System.arraycopy(provinceIdBytes,0,messageBody,pos,provinceIdBytes.length);
|
pos += provinceIdBytes.length;
|
//市域ID
|
byte[] cityIdBytes = ByteUtil.shortGetBytes(cityid);
|
System.arraycopy(cityIdBytes,0,messageBody,pos,cityIdBytes.length);
|
pos += cityIdBytes.length;
|
//model
|
byte[] modelBytes = !TextUtils.isEmpty(model)?model.getBytes():"".getBytes();
|
System.arraycopy(modelBytes,0,messageBody,pos,modelBytes.length);
|
pos += 20;
|
|
//sn
|
byte[] snBytes = !TextUtils.isEmpty(sn)?sn.getBytes():"".getBytes();
|
System.arraycopy(snBytes,0,messageBody,pos,snBytes.length);
|
pos += 16;
|
|
//IMEI
|
byte[] imeiBytes = !TextUtils.isEmpty(imei)?imei.getBytes():"".getBytes();
|
System.arraycopy(imeiBytes,0,messageBody,pos,imeiBytes.length);
|
|
return messageBody;
|
}
|
}
|