Major Refactoring and code restructuring for a cleaner API
This commit is contained in:
parent
a33f4d2b6d
commit
77032b98cd
4 changed files with 556 additions and 25 deletions
16
protocol.go
16
protocol.go
|
|
@ -2,6 +2,8 @@ package main
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/icza/bitio"
|
||||
)
|
||||
|
|
@ -13,6 +15,20 @@ type Header struct {
|
|||
MessageType uint32
|
||||
}
|
||||
|
||||
func (h *Header) String() string {
|
||||
return fmt.Sprintf("{ Header Magic=0x%X, Length=%d, MessageType=0x%X }", h.Magic, h.Length, h.MessageType)
|
||||
}
|
||||
|
||||
// Message represents a complete message from/to the camera
|
||||
type Message struct {
|
||||
Header Header
|
||||
Payload []byte
|
||||
}
|
||||
|
||||
func (m *Message) String() string {
|
||||
return fmt.Sprintf("{ Message Header=%s, Payload=\n%s\n }", m.Header, hex.Dump(m.Payload))
|
||||
}
|
||||
|
||||
// StreamHeader is a live preview message header
|
||||
type StreamHeader struct {
|
||||
Magic uint16
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue