packet

package
v0.0.0-...-9792e72 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crypto

type Crypto interface {
	VerifyPacket(pkt *Packet) error
	Decrypt(data []byte) ([]byte, error)
	Encrypt(data []byte) ([]byte, error)
	NewPacket(data []byte) (*Packet, error)
}

func NewCrypto

func NewCrypto(deviceID uint32, deviceToken []byte, initialStamp uint32, stampTime time.Time, clock clock.Clock) (
	Crypto, error)
type Header struct {
	Magic    uint16
	Length   uint16
	F1       uint32 // Unknown field.
	DeviceID uint32
	Stamp    uint32
	Checksum []byte `struc:"[16]byte"`
}

See https://github.com/OpenMiHome/mihome-binary-protocol/blob/master/doc/PROTOCOL.md for documentation

type Meta

type Meta struct {
	DecodeTime time.Time
	Addr       *net.UDPAddr
}

Meta provides (optional) additional context about incoming packets.

type Packet

type Packet struct {
	Meta   Meta
	Header Header
	Data   []byte
}

func Decode

func Decode(data []byte, addr *net.UDPAddr) (*Packet, error)

func New

func New(deviceId uint32, deviceToken []byte, stamp uint32, data []byte) *Packet

New creates a new packet

func NewHello

func NewHello() *Packet

func (*Packet) CalcChecksum

func (p *Packet) CalcChecksum() ([]byte, error)

func (*Packet) DataLength

func (p *Packet) DataLength() int

func (*Packet) HasZeroChecksum

func (p *Packet) HasZeroChecksum() bool

func (*Packet) Serialize

func (p *Packet) Serialize() []byte

func (*Packet) Verify

func (p *Packet) Verify(deviceToken []byte) error

func (*Packet) WriteChecksum

func (p *Packet) WriteChecksum() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL