Examples
AhaKey X1
Works with Nexting · keyboard case
Nexting Devices SDK · AhaKey X1 integration guide
Connect AhaKey keys and its device microphone to Nexting
This guide defines how an integrated AhaKey X1 will control a remote Agent as a third-party Nexting device. The target path carries AhaKey microphone audio through a CH582/CH58x-targeted firmware port and BLE into the Nexting App, never through a substituted phone microphone. The exact production controller, PCM binding, and board verification are still pending.
What the public devices/ directory is
The devices/ directory on GitHub is the public contract between hardware developers and the Nexting App. It is not the App or cloud source. A device uses this contract to declare capabilities, send physical input, and receive bounded state. The official App owns authorization, speech-to-text, Agent selection, and the remote session.
| Area | Current public 0.4 | Still pending |
|---|---|---|
| SPEC.md / schemas / protocol/vectors | Ten profiles including device-audio/1 wire rules, schema, and vectors | No further wire change; board evidence is still pending |
| sdk/c / reference/js | Portable C99 SDK, JavaScript reference, device-audio codecs, fragmentation, and receive bounds | Product Host remains the official Nexting App |
| firmware | Zephyr reference boards plus the AhaKey adapter, CH58x-targeted port, Device Info template, and transport descriptor | Production PCM bind, target build, and physical-board verification |
| tests / CI | Protocol, firmware-build, export, boundary, audio simulator, loss, timeout, flow-control, and invalid-input coverage | iPhone/Android unknown-stream fail-closed parity |
| docs | 0.4 how-to guides, interfaces, evidence levels, and AhaKey integration/bring-up guides | A board-verified claim is not made |
The actual data path
physical voice key
→ AhaKey microphone
→ CH582/CH58x-targeted firmware port: PCM16 / 16 kHz / mono
→ IMA ADPCM + CRC32C + BLE fragmentation
→ Nexting App: reassembly, decode, speech-to-text
→ Agent selected when recording began
→ App / LED / OLED state feedbackAhaKey is the nearby input device; the Agent may run on another computer. The keyboard never receives Agent credentials, internal session IDs, account data, or cloud routes. Those remain inside the Nexting App and its trusted Host.
Hardware capability mapping
| X1 hardware | Target Nexting interface | Behavior |
|---|---|---|
| Approval keys | approval/1 | Answers the pending request as Allow or Deny |
| General keys | keys/1 slots 0–3 | Sends Host-defined generic key actions |
| Physical lever | keys/1 slot 7 | Press away from rest, release on return |
| LED strip | status/1 | Shows working, waiting, complete, or error |
| OLED 160×80 | text/1 | Shows bounded title and body text |
| Battery Service 0x180F | Device Info | Reports battery capability to the App |
| Device microphone + physical voice key | device-audio/1 | PCM16 → IMA ADPCM → encrypted BLE → App |
A production AhaKey integration must bind the physical voice key. It may reuse a configurable key or use a separate input. The public protocol does not dictate the product layout, and Device Info declares only capabilities that exist and have passed hardware verification.
How the Nexting App stays vendor-neutral
The App core has no AhaKey model branch and does not parse stock AhaKey commands. It handles Device Info, generic profiles, and four logical channels. AhaKey GATT UUIDs and A0–A3 opcodes live only in a declarative transport descriptor and the firmware adapter. A future device can use different UUIDs, chips, and controls while reusing the same App audio and Agent pipeline.
Three integration modes
| Mode | What changes | Keys/lights/display | Device microphone |
|---|---|---|---|
| Compatibility Tunnel firmware (preferred) | Add a narrow layer to X1 firmware while preserving the stock 0x7340 service | Core-tested adapter; target build and board verification pending | Production PCM hook and hardware verification pending |
| Native Nexting GATT | Add the standard Nexting service to X1 firmware | Protocol path defined; target build and board verification pending | Production PCM hook and hardware verification pending |
| Stock firmware + bridge dongle | Leave keyboard firmware untouched and add a BLE dongle | Design only; dongle implementation and board test pending | Unavailable unless stock firmware exposes real PCM |
device-audio/1.Connection and recording lifecycle
Pair, bond, and encrypt
The App connects only after the signed-in user explicitly authorizes the third-party device. Revocation, logout, or disconnect terminates capture and clears temporary state.Read Device Info
The device declares identity, controls, display, battery, and the exact profiles it implements. Undeclared capabilities stay disabled.Load the transport descriptor
The descriptor maps vendor GATT onto control_down, control_up, audio_up, and flow_down. The App above that layer sees logical channels only.Prepare the recording session
The App sends audio_config to say authorization and buffers are ready. It may prepare capture, but it cannot remotely start the AhaKey microphone.Start from the physical key
The firmware creates audio_begin and uploads frames only after physical input. The App decodes them into its existing speech-to-text and Agent-send path.Stop, cancel, and wipe on failure
A release at or after 450 ms submits. A release before 450 ms latches recording and the next physical press submits. Cancel, timeout, disconnect, CRC failure, or a credit stall ends and wipes the stream. A stale result cannot enter a new device or Agent session.
device-audio/1 rules that matter
| Item | Rule |
|---|---|
| Sampling | PCM16, 16 kHz, mono; 320 samples per 20 ms frame |
| Encoding | IMA ADPCM with sequence, sample position, and CRC32C per frame |
| Transport | Bonded and encrypted BLE; at least a 64-byte ATT payload, MTU 247 preferred |
| Flow control | 8 initial credits, at most 10 queued frames, cancel after a continuous 500 ms stall |
| Fragmentation | At most 4 fragments per logical frame |
| Sequence | 0…5999; sample index must equal sequence × 320 and final sample count must match exactly |
| Loss | Ignore duplicates; insert 20 ms silence for one missing frame; abort after 3 consecutive or 10 total missing frames |
| Integrity failure | Experimental 0.4 requires bad CRC, unknown stream, inconsistent fragments, invalid ADPCM metadata, or uncertain sample position to abort and wipe the stream; unknown-stream fail-closed parity is still pending in the mobile development builds |
| Duration | 120 seconds maximum; reconnect never restores a recording |
| Privacy | Only physical device input may begin capture; always-on capture and pre-key pre-roll are forbidden |
| Phone microphone | The device-audio/1 path does not request, start, or fall back to the phone microphone |
voice/1 keeps its existing meaning: lifecycle control for the Host or phone microphone, with no audio bytes.device-audio/1 is a separately negotiated profile carrying audio sampled by the physical device itself. They are not interchangeable.
What the CH58x-targeted firmware port must connect
Public AhaKey release and flashing material targets the CH582 family and CH58x tooling, but no public BOM, schematic, or chip-marking evidence confirms the exact production controller. Experimental 0.4 implements encoding, fragmentation, flow control, lifecycle, and the Compatibility Tunnel. A production port must connect microphone, BLE, and display callbacks; no Agent or Nexting App logic belongs in the keyboard.
devices/sdk/c/include/nexting_device.h
devices/sdk/c/src/nexting_device.c
devices/sdk/c/include/nexting_device_audio.h
devices/sdk/c/src/nexting_device_audio.c
devices/firmware/ahakey-x1/CMakeLists.txt
devices/firmware/ahakey-x1/ahakey_proto.h
devices/firmware/ahakey-x1/ahakey_proto.c
devices/firmware/ahakey-x1/nexting_ahakey_adapter.hnotify_7344(...); // BLE notify
vendor_7343_write(...); // preserve stock command handling
microphone_start(...); // PCM16 / 16 kHz / mono / 320 samples
microphone_stop(...); // user submits
microphone_cancel(...); // stop now and wipe DMA / ring buffers
render_audio_state(...); // ready / receiving / transcribing / submitted / errorThe upstream public firmware repository supplies CH582 release HEX files and flashing instructions, but not buildable v1.1.0 production source, a schematic, or a public PCM callback. This guide therefore does not invent a final ADC/I2S/PDM symbol. Bind it after production source and a physical unit are available.
Connecting the keys
Stock HID key assignments remain configurable and can be saved to flash. This is a reference mapping for approvals and generic keys, not a required product layout. A production port must call the physical audio entry point for the chosen voice key.
Key1 → F18 approval/1 Allow
Key2 → F19 approval/1 Deny
Key3 → F13 keys/1 slot 0
Key4 → F14 keys/1 slot 1
lever keys/1 slot 7 (press / release)
voice down nexting_ahakey_port_voice_pressed(...)
voice up nexting_ahakey_port_voice_released(...)
voice cancel nexting_ahakey_port_voice_cancel(...)Current availability and evidence
Verify each item when hardware arrives
Confirm the controller and wire PCM
Confirm the production controller from the physical unit or vendor BOM, connect its real microphone driver, and verify every sampling, frame-size, and pre-key capture rule above.Wire physical input and state
Call the voice press/release entry points and visibly render ready, receiving, transcribing, submitted, and error.Publish real Device Info
Set a stable per-device UUID and real firmware version. Declare device-audio/1 only after microphone tests pass.Exercise both phone platforms
Verify start, tap-to-latch, release-to-submit, cancel, disconnect, and reconnect on iPhone and Android.Prove the audio source
Complete a recording with phone microphone permission disabled and capture BLE evidence tying audio_begin and frames to the physical key and device.Stress the failure paths
Stop credits and inject loss or CRC faults. Verify every flow-control, loss, cancellation, queue, and wipe limit in the table above.