DELL
2025-04-28 e6eb7fb0af366e370f125668d62e89eb0004f517
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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;
    }
}