はじめに
インストール手順と完全なマークダウンガイドが含まれる設定用質問をコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-uwb`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/uwb/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
Section titled “インストール”AI-Assisted セットアップを使用してプラグインをインストールできます。AIツールに Capgo スキルを追加するには、以下のコマンドを実行してください。
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次に、以下のプロンプトを使用してください。
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-uwb` plugin in my project.Manual Setup を使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。
bun add @capgo/capacitor-uwbbunx cap syncimport { CapacitorUwb } from '@capgo/capacitor-uwb';利用可能性を確認する
利用可能性を確認するセクションconst availability = await CapacitorUwb.isAvailable();
if (!availability.supported) { console.log('This device does not support UWB.');}iOS ペア セッション
セクション「iOS ペア セッション」- 両方のデバイスで呼び出す
getDiscoveryToken()返された base64 トークンをオフラインで交換する。 - ペア トークンでレンジを開始する。
- クリップボードにコピー
const { discoveryToken } = await CapacitorUwb.getDiscoveryToken();
await CapacitorUwb.startPeerSession({ peerDiscoveryToken: '<peer-token-base64>',});iOS セットアップ iOS セットアップ __CAPGO_KEEP_0__の機能と許可要件。
Android Controller / Controlee Session
Android Controller / Controlee セッション- コントローラーが呼び出し
startControllerSession()と、返されたrangingParametersおよびlocalAddress. - コントロールがコントロールする
rangingParametersコントロールを使用してlocalAddressコントロールが呼び出しpeerAddress. - オプションで、コントロールがコントロールのアドレスがわかったら
startControleeSession({ rangingParameters }). - コントロールに渡すことができます。
peerAddressコントロールがコントロールのアドレスがわかったら
const controller = await CapacitorUwb.startControllerSession();
await CapacitorUwb.startControleeSession({ rangingParameters: { ...controller.rangingParameters, peerAddress: controller.localAddress, },});参照 Androidの設定 ハードウェアとパーミッションの要件についてはこちらを参照してください。
更新を待つ
「更新を待つ」のセクションawait CapacitorUwb.addListener('rangingUpdate', (event) => { console.log(event.distanceMeters, event.direction);});
await CapacitorUwb.addListener('sessionStateChanged', (event) => { console.log(event.state, event.reason);});セッションを終了
「セッションを終了」のセクションawait CapacitorUwb.stopSession();真実の源
「真実の源」のセクションこのページはプラグインから生成されています。 src/definitions.ts. プラグインのTypeScript定義を更新し、プラグインリポジトリで生成された__CAPGO_KEEP_0__ドキュメントを更新してください。 bun run docgen in the plugin repository to refresh the generated API docs.