-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathp_0x9105.go
More file actions
56 lines (48 loc) · 1.33 KB
/
p_0x9105.go
File metadata and controls
56 lines (48 loc) · 1.33 KB
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
package model
import (
"fmt"
"github.com/cuteLittleDevil/go-jt808/protocol"
"github.com/cuteLittleDevil/go-jt808/protocol/jt808"
"github.com/cuteLittleDevil/go-jt808/shared/consts"
"strings"
)
type P0x9105 struct {
BaseHandle
// ChannelNo 逻辑通道号
ChannelNo byte `json:"channelNo"`
// PackageLossRate 丢包率 当前传输通道的丢包率,数值乘以100之后取整部分
PackageLossRate byte `json:"packageLossRate"`
}
func (p *P0x9105) Protocol() consts.JT808CommandType {
return consts.P9105AudioVideoControlStatusNotice
}
func (p *P0x9105) ReplyProtocol() consts.JT808CommandType {
return consts.T0001GeneralRespond
}
func (p *P0x9105) Parse(jtMsg *jt808.JTMessage) error {
body := jtMsg.Body
if len(body) != 2 {
return protocol.ErrBodyLengthInconsistency
}
p.ChannelNo = body[0]
p.PackageLossRate = body[1]
return nil
}
func (p *P0x9105) Encode() []byte {
data := make([]byte, 2)
data[0] = p.ChannelNo
data[1] = p.PackageLossRate
return data
}
func (p *P0x9105) HasReply() bool {
return false
}
func (p *P0x9105) String() string {
return strings.Join([]string{
"数据体对象:{",
fmt.Sprintf("\t%s:[%x]", p.Protocol(), p.Encode()),
fmt.Sprintf("\t[%02x]逻辑通道号:[%d]", p.ChannelNo, p.ChannelNo),
fmt.Sprintf("\t[%02x]丢包率:[%d]", p.PackageLossRate, p.PackageLossRate),
"}",
}, "\n")
}