package com.dev.bybb;
|
|
import java.nio.ByteBuffer;
|
import java.nio.ByteOrder;
|
|
import com.dev.bts.data.FBS9100_ComBase;
|
import com.dev.bts.data.FBS9100_Crc16;
|
|
public class Bybb_Param {
|
private final int BYTE_LEN = 40;
|
public byte[] ip_addr = new byte[4];
|
public byte[] net_mask = new byte[4];
|
public byte[] gate_way = new byte[4];
|
public int board_id;
|
public int led_light_lev;
|
public byte[] hearbeat_tarip_addr = new byte[4];
|
public int hearbeat_tarip_port;
|
public int[] backup = new int[8];
|
public int crc16;
|
|
public boolean update_page_show_en = false;
|
public boolean write_parm_res = false;
|
public boolean resboot_op_res = false;
|
|
public boolean putByteBuffer(ByteBuffer bbf) {
|
boolean res = false;
|
if(bbf.limit() < 40) {
|
return res;
|
}
|
|
int crc0 = bbf.getShort(BYTE_LEN-2) & 0xFFFF;
|
bbf.position(0);
|
int crc1 = FBS9100_Crc16.CalCRC16(bbf, (BYTE_LEN-2)) & 0xFFFF;
|
if(crc0 != crc1) {
|
return false;
|
}
|
|
bbf.position(0);
|
for(int n=0; n<4; n++) {
|
ip_addr[n] = bbf.get();
|
}
|
for(int n=0; n<4; n++) {
|
net_mask[n] = bbf.get();
|
}
|
for(int n=0; n<4; n++) {
|
gate_way[n] = bbf.get();
|
}
|
|
board_id = FBS9100_ComBase.changeShortToInt(bbf.getShort());
|
led_light_lev = FBS9100_ComBase.changeShortToInt(bbf.getShort());
|
for(int n=0; n<4; n++) {
|
hearbeat_tarip_addr[n] = bbf.get();
|
}
|
hearbeat_tarip_port = FBS9100_ComBase.changeShortToInt(bbf.getShort());
|
|
res = true;
|
|
return res;
|
}
|
|
public ByteBuffer getByteBuffer() {
|
ByteBuffer bbf = ByteBuffer.allocate(BYTE_LEN);
|
bbf.order(ByteOrder.LITTLE_ENDIAN);
|
|
for(int n=0; n<4; n++) {
|
bbf.put(ip_addr[n]);
|
}
|
for(int n=0; n<4; n++) {
|
bbf.put(net_mask[n]);
|
}
|
for(int n=0; n<4; n++) {
|
bbf.put(gate_way[n]);
|
}
|
|
bbf.putShort(FBS9100_ComBase.changeIntToShort(board_id));
|
bbf.putShort(FBS9100_ComBase.changeIntToShort(led_light_lev));
|
|
for(int n=0; n<4; n++) {
|
bbf.put(hearbeat_tarip_addr[n]);
|
}
|
bbf.putShort(FBS9100_ComBase.changeIntToShort(hearbeat_tarip_port));
|
|
for(int n=0; n<backup.length; n++) {
|
bbf.putShort(FBS9100_ComBase.changeIntToShort(backup[n]));
|
}
|
|
crc16 = FBS9100_Crc16.CalCRC16(bbf, bbf.position());
|
bbf.putShort(FBS9100_ComBase.changeIntToShort(crc16));
|
bbf.flip();
|
|
return bbf;
|
}
|
}
|