Add protobuf support and refactor WebSocket message handling#40
Merged
Add protobuf support and refactor WebSocket message handling#40
Conversation
…ket handling - Updated `pyproject.toml` to include `grpcio-tools` and `protobuf` dependencies. - Added generated protobuf files for WebSocket messages in `stackchan_server/generated_protobuf`. - Implemented `protobuf_ws.py` for encoding and parsing WebSocket messages. - Refactored `speak.py` to utilize new protobuf message encoding for audio WAV messages. - Updated `ws_proxy.py` to handle protobuf messages and removed legacy struct-based message handling. - Enhanced error handling for invalid protobuf messages in WebSocket communication.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request migrates the CoreS3 firmware and server communication protocol from a custom binary format to a Protocol Buffers (protobuf)-based WebSocket protocol. It updates both documentation and code to reflect the new protobuf message structure, replaces legacy enums and message handling with generated protobuf types, and adds build tooling for protobuf code generation for both Python and firmware. The changes standardize and modernize the protocol, improving maintainability and interoperability.
Protocol migration to protobuf:
WebSocketMessageper binary frame, replacing the previous hand-written binary header and enums. All message kinds (audio, state, servo, etc.) are now defined inprotobuf/websocket-message.protoand referenced in code via generated types. [1] [2] [3] [4] [5]AGENTS.md,docs/websocket_protocols_ja.md) is updated to describe the protobuf-based protocol, including message structures, enums, and field names, with legacy binary protocol references removed. [1] [2] [3] [4] [5] [6]Firmware and codebase updates:
protocols.hpp,listening.hpp,speaking.hpp,servo.hpp) are replaced with generated protobuf types (e.g.,stackchan_websocket_v1_MessageType,stackchan_websocket_v1_ServoOperation). Helper functions for encoding/decoding protobuf messages and handling audio/servo messages are introduced. [1] [2] [3] [4] [5] [6]uint16_ttouint32_tto match the protobuf field definition. [1] [2]Build and tooling improvements:
protobuf-python) and firmware (protobuf-firmware), including cleaning targets. The firmware uses nanopb for C/C++ protobuf support.websocket-message.pb.c) is added for firmware compilation.