Use random tie-breaker value for ICE connectivity compatibility#258
Open
dsugisawa-mixi wants to merge 73 commits intosepfy:mainfrom
Open
Use random tie-breaker value for ICE connectivity compatibility#258dsugisawa-mixi wants to merge 73 commits intosepfy:mainfrom
dsugisawa-mixi wants to merge 73 commits intosepfy:mainfrom
Conversation
dsugisawa-mixi
commented
Jan 28, 2026
- Generate random 64-bit tie-breaker for ICE binding requests instead of fixed 0
- Improves connectivity with libjuice (libdatachannel) which does not accept tie-breaker value of 0
- RFC 8445, uniformly distributed between 0 and (2^64) − 1 (that is, a 64-bit positive integer)
- Add fat_library target to combine all static libs into libpeer_fat.a - Add tcp_transport for non-TLS signaling connections (http/mqtt schemes) - Simplify generic example to DataChannel-only demo
Previously, binding_request_time was only updated when receiving STUN Binding Requests from the remote peer. This caused connections to timeout after CONFIG_KEEPALIVE_TIMEOUT even when other data (RTP/RTCP/DTLS) was actively flowing. Now update the keepalive timestamp whenever any valid data is received in PEER_CONNECTION_COMPLETED state, preventing spurious disconnections.
- Add cmake/unity/CMakeLists.txt for cross-platform Unity builds - Add build scripts for each platform: - build_ios.sh: Device (arm64) + Simulator (arm64) xcframework - build_android.sh: arm64-v8a, armeabi-v7a, x86_64 shared libs - build_macos.sh: Universal binary bundle with codesign/notarization - Add UPM package (jp.co.mixi.libpeer) with: - Pre-built native plugins for all platforms - C# P/Invoke bindings (LibPeer.cs) - Unity meta files for proper asset importing Install via: https://github.com/dsugisawa-mixi/libpeer.git?path=upm/jp.co.mixi.libpeer
- Add new rp2040-baremetal example project with CMake build system - Include POSIX compatibility shims for socket, pthread, and inet APIs - Configure lwIP and mbedTLS for embedded environment - Update socket layer to support lwIP backend - Update Unity sample scene
- Implement getaddrinfo/freeaddrinfo using lwIP dns_gethostbyname - Fix -include flags to apply only to C/C++ (not assembler) - Reduce lwIP memory usage (PBUF_POOL_SIZE, TCP_WND, TCP_SND_BUF)
Reduce RAM usage for TLS/DTLS on RP2040's 264KB RAM: - Reduce SSL buffers from 16KB to 4KB each (~24KB saved) - Limit ECC curves to P-256, P-384, Curve25519 (from 12 curves) - Use ECDHE key exchange only (no RSA key exchange) - Disable debug and unused features (MD5, DHM, PKCS5) - Enable memory-saving options (AES_ROM_TABLES, SHA256_SMALLER) Maintains Cloudflare TLS 1.2 and WebRTC DTLS compatibility.
- Change PICO_BOARD from pico_w to pico2_w - Update project name to rp2350bm - Increase SSL buffers to 16KB (RP2350 has 520KB RAM) - Let pico-sdk auto-detect TinyUSB MCU configuration
Initialize UART0 with 115200 baud on GP0/GP1 before stdio_init_all() to ensure serial output works on Pico 2 W (RP2350).
- Add explicit UART pin/baud definitions in CMakeLists.txt - Add LED blink after cyw43 init (3 blinks) for diagnostics - Add LED blink after WiFi connect (10 blinks) for diagnostics
- Add RP2040-specific recv_timeout using cyw43_arch_poll - Fix operator precedence bug in tcp_socket_connect return check - Add error handling for host resolution failure - Update .envrc to use pico2_w board and new signaling URL
- Replace single UDP receive buffer with 8-entry FIFO to handle multiple incoming packets without dropping - Update select() stub to poll cyw43_arch_poll() during timeout period, giving lwIP time to process incoming packets and fire callbacks
…flict Also add JSON parse logging, increase bMaxPower to 500mA, and add debug prefix to hid_task output.
cyw43 -> board_init/tusb_init -> WiFi connect -> WebRTC Avoids both GPIO/PIO conflict and iPhone EP0 panic.
tud_task() was only called after PEER_CONNECTION_COMPLETED, leaving ~13s without USB processing. iPhone USB host triggers EP0 panic when requests go unhandled.
core0: tud_task + hid_task + LED (always polling, never blocks) core1: cyw43_arch_poll + peer_connection_loop + datachannel TX
cyw43_arch_init() on core1 so background worker IRQs never block core0's USB interrupts. Wait for tud_mounted() before launching core1 to ensure EP0 enumeration completes cleanly.
Use queue_try_add/queue_try_remove for multicore-safe inter-core communication without manual critical sections.
- Move automation logic from auto-test/home.py, initial.py into scene-detect/common.py - Update scene.py with expanded scene detection and action handling - Add reference snapshots for quest, event, home, and reward scenes - Make API base URL configurable via SFU_API_BASE env var - Add HID_W/HID_H dimensions to .envrc
Send mouse commands in random-sized batches with padding instead of one-by-one to reduce request overhead. Update C-side to accept both single command and commands array in JSON payload.
…ments - Randomize keepalive interval (±20%) to avoid synchronized traffic - Seed PRNG from board_millis before WebRTC init - Increase queue size to 128 and simplify HID mouse report - Add random ephemeral UDP port selection for RP2040 (socket.c) - Relax FSM thresholds for normal-quest-uijin and karyu states - Add reward_next periodic dispatch and mouse click via 'm' key
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.