-
Notifications
You must be signed in to change notification settings - Fork 0
feat(triki-controller): pluggable transport + Node NobleTransport (receive outside the browser) #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
228a26d
feat(triki-controller): pluggable transport + Node NobleTransport
ebce322
feat(triki-controller): TrikiTransport v2 — attach/detach contract, c…
Fl0p 2302457
feat(triki-controller): production NobleTransport — cancellable conne…
Fl0p 19f01fb
docs(triki-controller): transport contract v2, Node options, README; …
Fl0p b87f8cb
chore(triki-controller): bump to 0.3.0 — 0.2.0 is already published
Fl0p e5ff2a5
docs(triki-controller): make the ReplayTransport example honor the tr…
Fl0p 5dbb6e7
fix(triki-controller): harden the connect lifecycle — second-review f…
Fl0p File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /** | ||
| * Receive the Triki IMU stream in Node — no browser required. | ||
| * | ||
| * Prerequisites (from the package directory): | ||
| * npm install @abandonware/noble # optional native dependency | ||
| * npm run build # produces dist/node.js | ||
| * | ||
| * Then run: | ||
| * node example/node.mjs | ||
| * | ||
| * macOS grants Bluetooth access per-app, so the first run prompts the terminal | ||
| * (or your IDE) for permission. | ||
| */ | ||
| import { TrikiController, NobleTransport, ConnectAbortedError } from "../dist/node.js"; | ||
|
|
||
| const triki = new TrikiController({ transport: new NobleTransport() }); | ||
|
|
||
| triki.on("connectionchange", (state) => console.log("[state]", state)); | ||
| triki.on("rate", (hz) => console.log("[rate]", hz, "Hz")); | ||
| triki.on("orientation", ({ euler }) => { | ||
| const f = (n) => n.toFixed(1).padStart(7); | ||
| console.log(`roll ${f(euler.roll)} pitch ${f(euler.pitch)} yaw ${f(euler.yaw)}`); | ||
| }); | ||
|
|
||
| process.on("SIGINT", () => { | ||
| triki.disconnect(); // kicks off the BLE teardown (fire-and-forget inside the transport) | ||
| // The 'disconnected' event fires synchronously, BEFORE the HCI disconnect is sent — | ||
| // so give the radio a moment instead of exiting from the event. | ||
| setTimeout(() => process.exit(0), 300); | ||
| }); | ||
|
|
||
| console.log("Scanning for a TRIKI token… (Ctrl+C to quit)"); | ||
| try { | ||
| await triki.connect(); // 15 s scan budget by default; Ctrl+C mid-scan rejects | ||
| } catch (err) { | ||
| if (err instanceof ConnectAbortedError) process.exit(0); // user quit during the scan | ||
| console.error("[connect]", err instanceof Error ? err.message : err); | ||
| process.exit(1); | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.