Documentation ¶
Overview ¶
Package protocol 用于JT808协议中的信令包的传输、编码和解码实现。
Index ¶
Constants ¶
View Source
const (
// 标识位[2] + 消息头[21] + 消息体[1023 * 2(转义预留)] + 校验码[1] + 标识位[2]
MaxFrameLen = 2 + 21 + 1023*2 + 1 + 2
)
Variables ¶
View Source
var ( ErrMsgIDNotSupportted = errors.New("Msg id is not supportted") // 消息ID无法处理,应忽略 ErrNotAuthorized = errors.New("Not authorized") // server校验鉴权不通过 ErrActiveClose = errors.New("Active close") // client无法继续处理,应主动关闭连接 )
View Source
var ( ErrEmptyPacket = errors.New("Empty packet") ErrVerifyFailed = errors.New("Verify failed") ErrEncodeType = errors.New("Error data type") )
View Source
var (
ErrFrameReadEmpty = errors.New("Read empty frame")
)
Functions ¶
This section is empty.
Types ¶
type CheckDeviceJob ¶
type CheckDeviceJob struct {
// contains filtered or unexported fields
}
func (*CheckDeviceJob) JobID ¶
func (j *CheckDeviceJob) JobID() string
func (*CheckDeviceJob) Run ¶
func (j *CheckDeviceJob) Run()
type FrameHandler ¶
type FrameHandler interface { Recv(ctx context.Context) (FramePayload, error) // data -> frame,并写入io.Writer Send(FramePayload) error // 从io.Reader中提取frame payload,并返回给上层 }
type FramePayload ¶
type FramePayload []byte
type JT808FrameHandler ¶
type JT808FrameHandler struct {
// contains filtered or unexported fields
}
func NewJT808FrameHandler ¶
func NewJT808FrameHandler(conn net.Conn) *JT808FrameHandler
func (*JT808FrameHandler) Recv ¶
func (fh *JT808FrameHandler) Recv(ctx context.Context) (FramePayload, error)
func (*JT808FrameHandler) Send ¶
func (fh *JT808FrameHandler) Send(payload FramePayload) error
type JT808MsgProcessor ¶
type JT808MsgProcessor struct {
// contains filtered or unexported fields
}
处理jt808消息的Handler方法
func NewJT808MsgProcessor ¶
func NewJT808MsgProcessor() *JT808MsgProcessor
func (*JT808MsgProcessor) Process ¶
func (mp *JT808MsgProcessor) Process(ctx context.Context, pkt *model.PacketData) (*model.ProcessData, error)
type JT808PacketCodec ¶
type JT808PacketCodec struct { }
func NewJT808PacketCodec ¶
func NewJT808PacketCodec() *JT808PacketCodec
func (*JT808PacketCodec) Decode ¶
func (pc *JT808PacketCodec) Decode(payload []byte) (*model.PacketData, error)
Decode JT808 packet.
反转义 -> 校验 -> 反序列化
type KeepaliveTimer ¶
type KeepaliveTimer struct {
// contains filtered or unexported fields
}
func NewKeepaliveTimer ¶
func NewKeepaliveTimer() *KeepaliveTimer
func (*KeepaliveTimer) Cancel ¶
func (t *KeepaliveTimer) Cancel(devicePhone string)
func (*KeepaliveTimer) Jobs ¶
func (t *KeepaliveTimer) Jobs() []*gron.Entry
func (*KeepaliveTimer) Register ¶
func (t *KeepaliveTimer) Register(devicePhone string)
type MsgProcessor ¶
type MsgProcessor interface {
Process(ctx context.Context, pkt *model.PacketData) (*model.ProcessData, error)
}
处理消息的Handler接口
type PacketCodec ¶
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
tcp/udp 消息处理组
func NewPipeline ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.