Major Refactoring and code restructuring for a cleaner API

This commit is contained in:
Jonas Köritz 2019-08-28 17:54:52 +02:00
parent a33f4d2b6d
commit 77032b98cd
4 changed files with 556 additions and 25 deletions

View file

@ -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