AlexxIT/go2rtc · error

invalid HL magic

Error message

invalid HL magic: %x %x

What it means

parseK10001 received a challenge response whose magic bytes are not 'H','L' (the expected 0x48 0x4C header), so the payload is not a valid K10001 auth packet. Both offending bytes are hex-printed; raised during doKAuth.

Solutions

  1. Restart the P2P session to resynchronize the K stream
  2. Verify the device firmware speaks the K protocol version expected
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/wyze/client.go:474 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07). Data as JSON: /api/errors/ac1a9618d85f3314. Report an issue: GitHub.

Appendix: source

Thrown at pkg/wyze/client.go:474

	binary.LittleEndian.PutUint16(b[4:], KCmdSetResolution) // 10056
	binary.LittleEndian.PutUint16(b[6:], 5)                 // payload len
	b[16] = frameSize + 1                                   // frame size
	binary.LittleEndian.PutUint16(b[17:], bitrate)          // bitrate
	// b[19:21] = FPS (0 = auto)
	return b
}

func (c *Client) parseK10001(data []byte) (challenge []byte, status byte, err error) {
	if c.verbose {
		fmt.Printf("[Wyze] parseK10001: received %d bytes\n", len(data))
	}

	if len(data) < 33 {
		return nil, 0, fmt.Errorf("data too short: %d bytes", len(data))
	}

	if data[0] != 'H' || data[1] != 'L' {
		return nil, 0, fmt.Errorf("invalid HL magic: %x %x", data[0], data[1])
	}

	cmdID := binary.LittleEndian.Uint16(data[4:])
	if cmdID != KCmdChallenge {
		return nil, 0, fmt.Errorf("expected cmdID 10001, got %d", cmdID)
	}

	status = data[16]
	challenge = make([]byte, 16)
	copy(challenge, data[17:33])

	return challenge, status, nil
}

func (c *Client) parseK10003(data []byte) (*AuthResponse, error) {
	if c.verbose {
		fmt.Printf("[Wyze] parseK10003: received %d bytes\n", len(data))
	}

View on GitHub (pinned to c245815e75)