Skip to content

feat: add SF_CONTROLLER_DEBUG env var for WebSocket lifecycle debug logging - #3

Open
cavonlee wants to merge 2 commits into
masterfrom
fix/add-debug-logging
Open

feat: add SF_CONTROLLER_DEBUG env var for WebSocket lifecycle debug logging#3
cavonlee wants to merge 2 commits into
masterfrom
fix/add-debug-logging

Conversation

@cavonlee

Copy link
Copy Markdown
Contributor

What

Add debug logging toggle via SF_CONTROLLER_DEBUG=1 env var to trace full
WebSocket lifecycle in sunfounder_controller.

Why

Android App connects successfully (WS handshake OK, camera stream OK) but
joystick/button data never arrives. Need to debug the comms pipeline without
modifying user code.

Changes

  • _debug() helper prints timestamped messages only when SF_CONTROLLER_DEBUG=1
  • Logs: connection (IP, total clients, headers), every recv (raw content + byte count), every send (payload + byte count), parse result (keys + Heart field), errors at each stage, disconnection (code + total message count)
  • Fix stale tmp reference: reset tmp = None each iteration to avoid reusing old data after recv timeout

Usage

SF_CONTROLLER_DEBUG=1 python3 12.app_control.py

Tested

  • Compile check (py_compile)
  • DEBUG env var: ON / OFF / unset / invalid values
  • _debug function isolation test
  • QA code review ✅

铁锤 added 2 commits July 29, 2026 17:47
- Add _debug() helper controlled by SF_CONTROLLER_DEBUG=1
- Log connection, recv (content+bytes), send (payload+bytes), parse, errors, close
- Fix stale tmp reference across recv timeout by resetting tmp=None each iteration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant