Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
917122a
Use random tie-breaker value for ICE connectivity compatibility
dsugisawa-mixi Jan 28, 2026
8eb0a9a
Add FAT library build target and plain TCP transport support
dsugisawa-mixi Jan 29, 2026
19be961
Add BUILD.md with FAT library build instructions
dsugisawa-mixi Jan 29, 2026
f66ffc2
Suppress unknown attribute warning for SOFTWARE (0x8022)
dsugisawa-mixi Jan 29, 2026
04f2eed
Fix binding request timeout by updating keepalive on all data received
dsugisawa-mixi Jan 29, 2026
769fbfa
Flush stdout in onmessage callback by adding newline at end
dsugisawa-mixi Jan 29, 2026
f0e691f
Add Unity UPM package with native plugins for iOS/Android/macOS
dsugisawa-mixi Jan 30, 2026
a26f5d2
Add Unity macOS sample project with signaling support
dsugisawa-mixi Jan 30, 2026
f93772c
Translate README to English
dsugisawa-mixi Jan 30, 2026
f265d66
Translate UPM README to English
dsugisawa-mixi Jan 30, 2026
6a4585f
Move Unity sample to examples/unity/macos
dsugisawa-mixi Jan 30, 2026
f896ab6
Add Unity temp files to .gitignore and remove from tracking
dsugisawa-mixi Jan 30, 2026
ca45c6f
Remove Unity Temp folder from tracking
dsugisawa-mixi Jan 30, 2026
b9c052e
Add SampleScene and update packages-lock.json
dsugisawa-mixi Jan 30, 2026
87928f2
Add Editor UI setup tool and improve logging
dsugisawa-mixi Jan 30, 2026
f025c9e
Add RP2040 baremetal example with lwIP/mbedTLS support
dsugisawa-mixi Feb 2, 2026
f2300a8
Add overview section to RP2040 baremetal README
dsugisawa-mixi Feb 2, 2026
59c4f2f
Add patches for RP2040 baremetal third-party libraries
dsugisawa-mixi Feb 2, 2026
8373f14
Add automatic patch application for RP2040 baremetal build
dsugisawa-mixi Feb 2, 2026
5223ce6
Add DNS resolution and optimize memory for RP2040 baremetal
dsugisawa-mixi Feb 2, 2026
e236339
Add CLOCKS_PER_SEC definition for pico-sdk runtime.c
dsugisawa-mixi Feb 2, 2026
9a86ee4
Add environment variable configuration for RP2040 build
dsugisawa-mixi Feb 2, 2026
c7b0ce5
Optimize mbedtls config for RP2040 memory constraints
dsugisawa-mixi Feb 2, 2026
1b51b84
Add Pico 2 (RP2350) support for baremetal example
dsugisawa-mixi Feb 2, 2026
9c91946
Add explicit UART initialization for RP2350 compatibility
dsugisawa-mixi Feb 2, 2026
98e7436
Add UART config and LED blink diagnostics for RP2350
dsugisawa-mixi Feb 2, 2026
45461a3
Fix SSL transport for RP2040 baremetal and update board config
dsugisawa-mixi Feb 3, 2026
2f750cd
Fix ports.c to use lwIP netif directly for RP2040 baremetal
dsugisawa-mixi Feb 3, 2026
ae366df
Add UDP receive FIFO and improve select() polling for RP2040 baremetal
dsugisawa-mixi Feb 3, 2026
a750989
Enable DTLS peer certificate and add SCTP error diagnostics
dsugisawa-mixi Feb 3, 2026
7977111
Fix select.h header inclusion order for Linux cross-compile
dsugisawa-mixi Feb 3, 2026
a9a52f9
Add SO_REUSEADDR to SCTP socket to fix bind error
dsugisawa-mixi Feb 3, 2026
4ad1f4a
Add detailed logging to SCTP association creation for debugging
dsugisawa-mixi Feb 3, 2026
ee0450f
Add SCTP bind debugging logs and RP2040 hardware RNG support to usrsc…
dsugisawa-mixi Feb 3, 2026
64bc682
Fix sockaddr_conn layout mismatch for RP2040 lwIP
dsugisawa-mixi Feb 3, 2026
e4bc031
Update README with detailed patch descriptions
dsugisawa-mixi Feb 3, 2026
38b5c8f
Add LED blink feedback for DataChannel TX/RX and document compatibili…
dsugisawa-mixi Feb 3, 2026
5657fb4
Add timing measurement logs for WebRTC connection phases
dsugisawa-mixi Feb 4, 2026
3327153
Add detailed WiFi connection timing logs
dsugisawa-mixi Feb 4, 2026
65cb187
Support rp2040 target Compile.
dsugisawa-mixi Feb 4, 2026
d568968
Disable debug LED blinks for accurate timing measurement
dsugisawa-mixi Feb 5, 2026
40c22aa
Add HID USB example for RP2040/RP2350
dsugisawa-mixi Feb 6, 2026
c12e4c6
update cloud tunnel URI
dsugisawa-mixi Feb 6, 2026
c944bd3
debugging
dsugisawa-mixi Feb 6, 2026
4500a1c
Parse mouse JSON in onmessage and push command to FIFO
dsugisawa-mixi Feb 6, 2026
fa130ed
Merge branch 'main' of github.com:dsugisawa-mixi/libpeer
dsugisawa-mixi Feb 6, 2026
5cf4f79
Use cJSON for JSON parsing in onmessage instead of manual string search
dsugisawa-mixi Feb 6, 2026
7860c10
Merge branch 'main' of github.com:dsugisawa-mixi/libpeer
dsugisawa-mixi Feb 6, 2026
3b323c2
Move USB HID init after WiFi/WebRTC init to fix Pico 2 W GPIO/PIO con…
dsugisawa-mixi Feb 6, 2026
3457ab8
Merge branch 'main' of github.com:dsugisawa-mixi/libpeer
dsugisawa-mixi Feb 6, 2026
9501468
Split cyw43_arch_init from wifi_init to fix iPhone init order
dsugisawa-mixi Feb 6, 2026
50ee101
Merge branch 'main' of github.com:dsugisawa-mixi/libpeer
dsugisawa-mixi Feb 6, 2026
206c952
Call tud_task() in all polling loops to fix iPhone EP0 panic
dsugisawa-mixi Feb 6, 2026
615d390
Merge branch 'main' of github.com:dsugisawa-mixi/libpeer
dsugisawa-mixi Feb 6, 2026
2ae01b4
Remove tud_hid_ready guard in hid_task for FIFO debugging
dsugisawa-mixi Feb 6, 2026
01376e6
Merge branch 'main' of github.com:dsugisawa-mixi/libpeer
dsugisawa-mixi Feb 6, 2026
6ee1514
Clear USB DPRAM and registers before tusb_init to fix cold-boot EP0 p…
dsugisawa-mixi Feb 6, 2026
7cff58f
update path.
dsugisawa-mixi Feb 6, 2026
69940e4
Merge branch 'main' of github.com:dsugisawa-mixi/libpeer
dsugisawa-mixi Feb 6, 2026
6923b6d
Adjust timing, tud_task, and peer_connection_loop
dsugisawa-mixi Feb 7, 2026
ad92b10
Split USB and WebRTC into separate cores to fix EP0 PANIC
dsugisawa-mixi Feb 8, 2026
42d87ed
Move CYW43/WiFi/WebRTC init to core1 and wait for USB mount
dsugisawa-mixi Feb 8, 2026
a41ae70
Replace custom FIFO with pico-sdk queue_t
dsugisawa-mixi Feb 8, 2026
2f24bff
adjust timing, core0(WebRTC), and core1(USB-HID device)
dsugisawa-mixi Feb 9, 2026
70a6c82
support TLS1.3(mbedtls)
dsugisawa-mixi Feb 10, 2026
a2ccbfd
Add scene detection example with reference snapshots
dsugisawa-mixi Feb 12, 2026
c6efcbd
Add HID-USB auto-test scripts for Monster Strike automation
dsugisawa-mixi Feb 12, 2026
cf23f3c
update URI
dsugisawa-mixi Feb 12, 2026
7cbc9ee
Refactor HID auto-test: consolidate into scene-detect and add snapshots
dsugisawa-mixi Feb 12, 2026
99af727
delete template samples.
dsugisawa-mixi Feb 13, 2026
a5eabe8
Add batch command support for HID mouse operations
dsugisawa-mixi Feb 13, 2026
d53c7df
Add packet seq number, similarity guard, and FSM fixes
dsugisawa-mixi Feb 13, 2026
172c86c
Add keepalive jitter, random ephemeral port, and scene-detect improve…
dsugisawa-mixi Feb 13, 2026
f4f9829
Add watchdog reboot on disconnect and update README with architecture…
dsugisawa-mixi Feb 16, 2026
9dd5bc6
Add README for scene-detect module
dsugisawa-mixi Feb 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
build
# Build work directories (not the final artifacts)
build/
_build/

# IDE
.idea/
.vscode/
*.swp
*.swo
*~

# macOS
.DS_Store
._*

# Unity
**/Library/
**/Logs/
**/Temp/
**/obj/
**/UserSettings/
*.csproj
*.sln
*.slnx
mono_crash.*.json
147 changes: 147 additions & 0 deletions BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Building libpeer

This document describes how to build libpeer, including the FAT library that combines all dependencies into a single static library.

## Prerequisites

- CMake 3.16 or higher
- C compiler (GCC or Clang)
- Git
- Bash shell

### Installing dependencies on Ubuntu/Debian

```bash
sudo apt -y install git cmake build-essential
```

### Installing dependencies on macOS

```bash
brew install cmake
```

## Clone the Repository

Clone the repository with all submodules:

```bash
git clone --recursive git@github.com:dsugisawa-mixi/libpeer.git
cd libpeer
```

If you already cloned without `--recursive`, initialize submodules:

```bash
git submodule update --init --recursive
```

## Build Steps

### 1. Configure CMake

```bash
cmake -S . -B build
```

#### Build Options

| Option | Default | Description |
|--------|---------|-------------|
| `ENABLE_TESTS` | OFF | Enable building tests |
| `BUILD_SHARED_LIBS` | OFF | Build shared libraries |
| `ADDRESS_SANITIZER` | OFF | Build with AddressSanitizer |
| `MEMORY_SANITIZER` | OFF | Build with MemorySanitizer |
| `THREAD_SANITIZER` | OFF | Build with ThreadSanitizer |
| `UNDEFINED_BEHAVIOR_SANITIZER` | OFF | Build with UndefinedBehaviorSanitizer |


### 2. Build the Project

```bash
cmake --build build
```

This will:
- Build all third-party dependencies (mbedtls, libsrtp, usrsctp, cJSON)
- Build the main `libpeer` library
- Build the example applications

### 3. Build the FAT Library

The FAT library combines all static libraries into a single archive file, making it easier to link your application.

```bash
cmake --build build --target fat_library
```

The FAT library will be created at:

```
build/dist/lib/libpeer_fat.a
```

### Libraries Included in FAT Library

The FAT library (`libpeer_fat.a`) includes:

- `libpeer.a` - Main WebRTC library
- `libusrsctp.a` - SCTP implementation for DataChannel
- `libsrtp2.a` - Secure RTP
- `libmbedtls.a` - TLS library
- `libmbedx509.a` - X.509 certificate handling
- `libmbedcrypto.a` - Cryptographic functions
- `libcjson.a` - JSON parsing

## Using the FAT Library

Link against the FAT library in your project:

```bash
gcc -o myapp myapp.c -Ibuild/dist/include -Lbuild/dist/lib -lpeer_fat -lpthread
```

Or in CMake:

```cmake
add_executable(myapp myapp.c)
target_include_directories(myapp PRIVATE ${LIBPEER_BUILD_DIR}/dist/include)
target_link_libraries(myapp ${LIBPEER_BUILD_DIR}/dist/lib/libpeer_fat.a pthread)
```

## Cross-Compilation

To cross-compile for another platform, specify a CMake toolchain file:

```bash
cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain.cmake
cmake --build build
cmake --build build --target fat_library
```

## Build Output Structure

After building, the output directory structure is:

```
build/
├── dist/
│ ├── include/ # Header files
│ │ ├── cjson/
│ │ ├── mbedtls/
│ │ ├── srtp2/
│ │ └── usrsctp/
│ └── lib/
│ ├── libcjson.a
│ ├── libmbedcrypto.a
│ ├── libmbedtls.a
│ ├── libmbedx509.a
│ ├── libpeer_fat.a # Combined FAT library
│ ├── libsrtp2.a
│ └── libusrsctp.a
├── src/
│ └── libpeer.a # Main library
└── examples/
└── generic/
└── sample # Example application
```
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ endif()
project(peer)

option(ENABLE_TESTS "Enable tests" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(ADDRESS_SANITIZER "Build with AddressSanitizer." OFF)
option(MEMORY_SANITIZER "Build with MemorySanitizer." OFF)
option(THREAD_SANITIZER "Build with ThreadSanitizer." OFF)
Expand Down Expand Up @@ -72,6 +72,7 @@ ExternalProject_Add(cjson
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/cJSON
CMAKE_ARGS
-DCMAKE_C_FLAGS="-fPIC"
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
-DBUILD_SHARED_LIBS=off
-DENABLE_CJSON_TEST=off
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/dist
Expand All @@ -81,7 +82,8 @@ ExternalProject_Add(cjson
ExternalProject_Add(mbedtls
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/mbedtls
CMAKE_ARGS
-DCMAKE_C_FLAGS="-fPIC"
-DCMAKE_C_FLAGS=-fPIC
-DMBEDTLS_FATAL_WARNINGS=off
-DENABLE_TESTING=off
-DENABLE_PROGRAMS=off
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/dist
Expand All @@ -104,7 +106,20 @@ ExternalProject_Add(usrsctp
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/usrsctp
CMAKE_ARGS
-DCMAKE_C_FLAGS="-fPIC"
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
-Dsctp_build_programs=off
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/dist
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
)

# FAT library target (combines all static libraries into one)
set(FAT_LIB_NAME "libpeer_fat.a")
set(FAT_LIB_PATH "${CMAKE_BINARY_DIR}/dist/lib/${FAT_LIB_NAME}")

add_custom_target(fat_library
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/scripts/create_fat_library.sh
${CMAKE_BINARY_DIR}
${FAT_LIB_PATH}
DEPENDS peer
COMMENT "Creating FAT library: ${FAT_LIB_NAME}"
)
Loading