Contributing Protocol Documentation
This guide explains how to add new device protocol documentation to STPIHKAL.
Quick Start
- Create a brand directory (if it doesn't exist):
stpihkal/protocols/<brand-slug>/ - Copy
stpihkal/protocols/_template.mdtostpihkal/protocols/<brand-slug>/index.md - Fill in the template with protocol details
- Add
config_reffrontmatter if a device-config-v4 YAML exists for this device - Build and verify:
yarn build
Directory Structure
stpihkal/protocols/
<brand-slug>/
index.md # Protocol documentation (single-protocol brands)
For the rare multi-protocol brand:
stpihkal/protocols/
<brand-slug>/
index.md # Brand overview page
<protocol-1>.md # First protocol
<protocol-2>.md # Second protocol
- Brand slug: lowercase kebab-case (e.g.,
we-vibe,hot-octopuss) - Every brand gets its own directory
- Most brands have a single protocol — use
index.mddirectly as the protocol page (copy from_template.md) - Multi-protocol brands only (e.g., erostek, kiiroo, libo, magic-motion) use a separate
index.mdoverview + individual protocol files (see_brand-template.md)
Creating a Single-Protocol Brand (most common)
Copy _template.md to stpihkal/protocols/<brand>/index.md and fill in the sections.
Required frontmatter:
---
title: <Device/Protocol Name>
brand: <brand-slug>
transport: btle # btle | serial | network | usb
config_ref: <file>.yml # device-config-v4 YAML filename (if exists)
config_identifier: null # specific device identifier, or null for all
---
Creating a Multi-Protocol Brand (rare)
Only needed when a brand has multiple distinct protocols (different command sets, not just device variants).
- Create
index.mdfrom_brand-template.mdwith brand overview and device table - Create individual protocol files from
_template.md
Frontmatter Fields
| Field | Required | Description |
|---|---|---|
title | Yes | Display name for the page |
brand | Yes | Brand slug (matches directory name) |
transport | Yes | Communication type: btle, serial, network, or usb |
config_ref | No | Filename in data/device-config/ (e.g., svakom.yml) |
config_identifier | No | Specific device identifier, or null for all devices |
config_ref and config_identifier
The config_ref field links to a device-config-v4 YAML file. When set, the build system automatically injects a Device Configuration section with BLE names, service maps, features, and device variants.
- Set
config_refto the YAML filename (just the filename, not a path) - Set
config_identifiertonullto show all device configurations - Set
config_identifierto a specific identifier (e.g.,"ERIKA") to show only that device's config
To find if a YAML exists for your device, check data/device-config/ after running the sync script.
Template Sections
BLE Profile (BLE devices only)
Include a structured YAML code block documenting the BLE GATT profile:
ble_names: ["<NAME>"]
services:
- uuid: "<service-uuid>"
characteristics:
- uuid: "<char-uuid>"
properties: [write]
role: tx
description: "Command endpoint"
- uuid: "<char-uuid>"
properties: [notify]
role: rx
description: "Response/notification endpoint"
This block is human-authored from reverse engineering. It complements (but doesn't replace) the auto-injected Device Configuration section.
Device Configuration
Add this placeholder comment where you want the auto-generated content:
<!-- Auto-populated from device-config-v4 at build time -->
The remark plugin replaces this with tables and data from the device-config-v4 YAML.
Commands
Document each command with:
- Description of what the command does
- Byte format (hex notation)
- Byte table with description and valid ranges
- Response format (if applicable)
Handling Incomplete Information
Use these conventions for unknown or unconfirmed data:
- Use
???orunknownin YAML blocks for unknown values - Label unconfirmed commands with (Unconfirmed) in the heading
- Add caveats in the Notes section about data quality
- Link to the GitHub issue for ongoing reverse engineering
Data Pipeline
Syncing Device Config Data
Run the sync script to copy device-config-v4 YAML from the sibling buttplug repo:
./scripts/sync-device-config.sh
This copies YAML files from ../buttplug/crates/buttplug_server_device_config/device-config-v4/protocols/ into data/device-config/. The data directory is gitignored.
Build Verification
Always verify after adding or modifying docs:
yarn build
Check the console for [remark-device-config] messages confirming your config_ref was found and processed.
Importing from GitHub Issues
Many protocols are documented in GitHub issues at buttplugio/stpihkal. When importing:
- Create the brand directory
- Copy
_template.mdto<brand>/index.md - Extract BLE details (names, UUIDs, characteristics) into the BLE Profile YAML block
- Extract command bytes into the Commands section with byte tables
- Link the original issue in the Sources section
- Mark any unconfirmed information appropriately
- Check for a matching device-config-v4 YAML and set
config_ref
Non-BLE Protocols
For serial, USB, or network protocols:
- Set
transportappropriately in frontmatter - Skip the BLE Profile section
- No
config_ref(device-config-v4 only covers BLE currently) - Document the communication protocol (baud rate, packet format, etc.) in the Commands section