diff --git a/documentation/network/ble/ble.md b/documentation/network/ble/ble.md index 39c6ace05..b7b9f15fa 100644 --- a/documentation/network/ble/ble.md +++ b/documentation/network/ble/ble.md @@ -1,41 +1,41 @@ # BLE Copyright 2017-2024 Moddable Tech, Inc.
-Revised: September 10, 2024 - -## About This Document -This document describes the Moddable SDK Bluetooth Low Energy (BLE) modules. Both client (master) and server (slave) roles are supported on Espressif ESP32, Silicon Labs Blue Gecko, Qualcomm QCA4020, and Nordic nRF52 devices. - -> **Note:** A BLE server/slave is also commonly referred to as a BLE peripheral. The terms *server*, *slave* and *peripheral* in this document are used interchangeably. - -## Table of Contents -* [Adding BLE to a Project](#addingble) -* [Using BLE](#usingble) -* [BLE Client](#bleclient) - * [Class BLEClient](#classbleclient) - * [Class Client](#classclient) - * [Class Service](#classservice) - * [Class Characteristic](#classcharacteristic) - * [Class Descriptor](#classdescriptor) - * [Class Advertisement](#classadvertisement) - * [Class Bytes](#classbytes) -* [BLE Server](#bleserver) - * [Class BLEServer](#classbleserver) - * [GATT Services](#gattservices) -* [BLE Security](#blesecurity) - * [Class SM](#classsm) -* [BLE Whitelisting](#blewhitelisting) - * [Class GAPWhitelist](#classgapwhitelist) -* [BLE Apps on ESP32 Platform](#esp32platform) -* [BLE Apps on Blue Gecko Platform](#geckoplatform) -* [BLE Example Apps](#exampleapps) +改訂: 2024年9月10日 + +## このドキュメントについて +このドキュメントは、Moddable SDKのBluetooth Low Energy (BLE) モジュールについて説明します。Espressif ESP32、Silicon Labs Blue Gecko、Qualcomm QCA4020、およびNordic nRF52デバイスで、クライアント(マスター)とサーバー(スレーブ)の両方の役割がサポートされています。 + +> **注:** BLEサーバー/スレーブは、一般的にBLEペリフェラルとも呼ばれます。このドキュメントでは、*サーバー*、*スレーブ*、および*ペリフェラル*という用語は同義に使用されています。 + +## 目次 +* [プロジェクトにBLEを追加する](#addingble) +* [BLEの使用](#usingble) +* [BLEクライアント](#bleclient) + * [BLEClientクラス](#classbleclient) + * [Clientクラス](#classclient) + * [Serviceクラス](#classservice) + * [Characteristicクラス](#classcharacteristic) + * [Descriptorクラス](#classdescriptor) + * [Advertisementクラス](#classadvertisement) + * [Bytesクラス](#classbytes) +* [BLEサーバー](#bleserver) + * [BLEServerクラス](#classbleserver) + * [GATTサービス](#gattservices) +* [BLEセキュリティ](#blesecurity) + * [SMクラス](#classsm) +* [BLEホワイトリスト](#blewhitelisting) + * [GAPWhitelistクラス](#classgapwhitelist) +* [ESP32プラットフォームでのBLEアプリ](#esp32platform) +* [Blue GeckoプラットフォームでのBLEアプリ](#geckoplatform) +* [BLE例示アプリ](#exampleapps) -## Adding BLE to a Project -The BLE client and server are implemented as separate modules to accommodate the limited memory and storage available on embedded devices. BLE applications instantiate a BLE client or BLE server, but never both. +## プロジェクトにBLEを追加する +BLEクライアントとサーバーは、組み込みデバイスで利用可能な限られたメモリとストレージに対応するために、別々のモジュールとして実装されています。BLEアプリケーションは、BLEクライアントまたはBLEサーバーのいずれかをインスタンス化しますが、両方を同時に使用することはありません。 -Pre-made manifests are available for the BLE client and BLE server. Add them to the `include` array of your application's manifest to use them in your project. +BLEクライアントとBLEサーバー用の事前作成されたマニフェストが利用可能です。これらをプロジェクトで使用するには、アプリケーションのマニフェストの`include`配列に追加してください。 -To add the BLE client to a project: +プロジェクトにBLEクライアントを追加するには: ```jsonc "include": [ @@ -44,7 +44,7 @@ To add the BLE client to a project: ], ``` -To add the BLE server to a project: +プロジェクトにBLEサーバーを追加するには: ```jsonc "include": [ @@ -54,9 +54,9 @@ To add the BLE server to a project: ``` -## Using BLE +## BLEの使用 -BLE applications typically subclass `BLEClient` or `BLEServer` and then add device and/or application specific code. The following BLE client example subclasses `BLEClient` to scan for and discover peripherals: +BLEアプリケーションは通常、`BLEClient`または`BLEServer`をサブクラス化し、その後にデバイスやアプリケーション固有のコードを追加します。次のBLEクライアントの例では、`BLEClient`をサブクラス化して、周辺機器をスキャンして発見します: ```javascript import BLEClient from "bleclient"; @@ -76,7 +76,7 @@ class Scanner extends BLEClient { let scanner = new Scanner; ``` -The following BLE server example subclasses `BLEServer` to advertise the device as a BLE Health Thermometer peripheral: +次のBLEサーバーの例では、`BLEServer`をサブクラス化して、デバイスをBLE健康体温計周辺機器としてアドバタイズします: ```javascript import BLEServer from "bleserver"; @@ -94,8 +94,8 @@ let htm = new HealthThermometerService; ``` -## BLE Client -A BLE client can connect to one or more BLE peripherals. The maximum number of concurrent connections is defined at build time and ultimately limited by what the underlying embedded platform supports. To override the default maximum of two connections, override the `max_connections` value in the manifest `defines` section: +## BLE クライアント +BLEクライアントは、1つ以上のBLEペリフェラルに接続できます。 同時接続の最大数はビルド時に定義され、最終的には基盤となる組み込みプラットフォームがサポートするものによって制限されます。 デフォルトの最大接続数である2を上書きするには、マニフェストの `defines` セクションで `max_connections` 値を上書きします: ```json "defines": { @@ -105,16 +105,16 @@ A BLE client can connect to one or more BLE peripherals. The maximum number of c }, ``` -A BLE client typically performs the following steps to receive notifications from a BLE peripheral: +BLEクライアントは通常、BLEペリフェラルから通知を受け取るために次の手順を実行します: -1. Start scanning for peripherals -2. Find the peripheral of interest by matching the advertised complete name or UUID(s) in the scan response -3. Establish a connection with the peripheral -4. Discover the primary service(s) of interest -5. Discover the characteristic(s) within the service(s) of interest -6. Enable notifications for characteristic(s) of interest +1. ペリフェラルのスキャンを開始する +2. スキャン応答でアドバタイズされた完全な名前またはUUIDを一致させて、目的のペリフェラルを見つける +3. ペリフェラルとの接続を確立する +4. 目的のプライマリサービスを発見する +5. 目的のサービス内のキャラクタリスティックを発見する +6. 目的のキャラクタリスティックに対して通知を有効にする -The following code from the [powermate](../../../examples/network/ble/powermate) example app shows a typical client flow: +[powermate](../../../examples/network/ble/powermate) サンプルアプリの次のコードは、典型的なクライアントフローを示しています: ```javascript const DEVICE_NAME = 'PowerMate Bluetooth'; @@ -151,22 +151,22 @@ class PowerMate extends BLEClient { } ``` -A BLE client is fundamentally asynchronous and results are always delivered to the `BLEClient` class callback methods, e.g. `onReady`, `onConnected`, etc. above. The following sections describe the BLE client classes, properties, and callbacks. +BLEクライアントは基本的に非同期であり、結果は常に`BLEClient`クラスのコールバックメソッド(例:上記の`onReady`、`onConnected`など)に配信されます。以下のセクションでは、BLEクライアントクラス、プロパティ、およびコールバックについて説明します。 -## Class BLEClient +## BLEClientクラス -The `BLEClient` class provides access to the BLE client features. +`BLEClient`クラスはBLEクライアント機能へのアクセスを提供します。 ```javascript import BLEClient from "bleclient"; ``` -### Functions +### 関数 #### `onReady()` -Applications must wait for the `onReady` callback before calling other `BLEClient` functions: +アプリケーションは他の`BLEClient`関数を呼び出す前に`onReady`コールバックを待つ必要があります: ```javascript class Client extends BLEClient { @@ -181,32 +181,32 @@ let client = new BLEClient; #### `startScanning([params])` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `params` | `object` | Object containing scan properties. +| `params` | `object` | スキャンプロパティを含むオブジェクト。 -The `params` object contains the following properties: +`params`オブジェクトには以下のプロパティが含まれます: -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `active` | `boolean` | Set `true` for active scanning, `false` for passive scanning. Default is `true`. -| `duplicates` | `boolean` | Set `true` to receive all advertising packets, `false` to filter out multiple advertising packets received from the same peripheral device. Default is `true`. -| `filterPolicy` | `number` | Filter policy applied to scan. Default is `GAP.ScanFilterPolicy.NONE` (no filtering). Refer to the [BLE whitelisting](#blewhitelisting) section for details. -| `interval` | `number` | Scan interval value in units of 0.625 ms. Default is `0x50`. -| `window` | `number` | Scan window value in units of 0.625 ms. Default is `0x30`. +| `active` | `boolean` | アクティブスキャンの場合は`true`、パッシブスキャンの場合は`false`を設定します。デフォルトは`true`です。 +| `duplicates` | `boolean` | すべてのアドバタイジングパケットを受信する場合は`true`、同じ周辺機器から受信した複数のアドバタイジングパケットをフィルタリングする場合は`false`を設定します。デフォルトは`true`です。 +| `filterPolicy` | `number` | スキャンに適用されるフィルタポリシー。デフォルトは`GAP.ScanFilterPolicy.NONE`(フィルタリングなし)です。詳細は[BLEホワイトリスト](#blewhitelisting)セクションを参照してください。 +| `interval` | `number` | 0.625 ms単位のスキャン間隔値。デフォルトは`0x50`です。 +| `window` | `number` | 0.625 ms単位のスキャンウィンドウ値。デフォルトは`0x30`です。 -The `filterPolicy` parameter can be one of the following: +`filterPolicy` パラメータは以下のいずれかになります: -| Name | Description | +| 名前 | 説明 | | --- | :--- | -| `GAP.ScanFilterPolicy.NONE` | No filtering. -| `GAP.ScanFilterPolicy.WHITELIST` | Receive advertisements only from whitelist devices. -| `GAP.ScanFilterPolicy.NOT_RESOLVED_DIRECTED` | Receive all undirected advertisements and all directed advertisements where the initiator address is a resolvable private address. -| `GAP.ScanFilterPolicy.WHITELIST_NOT_RESOLVED_DIRECTED` | Receive advertisements only from whitelist devices and all directed advertisements where the initiator address is a resolvable private address. +| `GAP.ScanFilterPolicy.NONE` | フィルタリングなし。 +| `GAP.ScanFilterPolicy.WHITELIST` | ホワイトリストデバイスからのみアドバタイズを受信。 +| `GAP.ScanFilterPolicy.NOT_RESOLVED_DIRECTED` | すべての非指向アドバタイズと、イニシエータアドレスが解決可能なプライベートアドレスであるすべての指向アドバタイズを受信。 +| `GAP.ScanFilterPolicy.WHITELIST_NOT_RESOLVED_DIRECTED` | ホワイトリストデバイスからのみアドバタイズを受信し、イニシエータアドレスが解決可能なプライベートアドレスであるすべての指向アドバタイズを受信。 -The `startScanning` function enables scanning for nearby peripherals. +`startScanning` 関数は、近くのペリフェラルをスキャンするために使用されます。 -If no `params` argument is provided, the default scan properties are used: +`params` 引数が提供されない場合、デフォルトのスキャンプロパティが使用されます: ```javascript class Scanner extends BLEClient { @@ -219,7 +219,7 @@ class Scanner extends BLEClient { } ``` -Passing in a `params` object overrides the defaults. This example uses passive scanning at a 70ms interval: +`params` オブジェクトを渡すことでデフォルトを上書きします。この例では、70msの間隔でパッシブスキャンを使用しています: ```javascript class Scanner extends BLEClient { @@ -235,13 +235,13 @@ class Scanner extends BLEClient { #### `onDiscovered(device)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `device` | `object` | A `device` object. See the section [Class Client](#classclient) for more information. | +| `device` | `object` | `device` オブジェクト。詳細は [Clientクラス](#classclient) セクションを参照してください。 | -The `onDiscovered` callback function is called one or more times for each peripheral device discovered. +`onDiscovered` コールバック関数は、発見された各周辺機器に対して1回以上呼び出されます。 -To connect to a device named "Brian" from the `onDiscovered` callback: +`onDiscovered` コールバックから「Brian」という名前のデバイスに接続するには: ```javascript onDiscovered(device) { @@ -254,17 +254,17 @@ onDiscovered(device) { *** #### `stopScanning()` -The `stopScanning` function disables scanning for nearby peripherals. +`stopScanning` 関数は、近くの周辺機器のスキャンを無効にします。 *** #### `connect(device)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `device` | `object` | A `device` object. See the section [Class Client](#classclient) for more information. | +| `device` | `object` | `device` オブジェクト。詳細は [Clientクラス](#classclient) セクションを参照してください。 | -The `connect` function initiates a connection request between the `BLEClient` and a target peripheral `device`. +`connect` 関数は、`BLEClient` とターゲット周辺 `device` 間の接続要求を開始します。 ```javascript onDiscovered(device) { @@ -279,36 +279,37 @@ onConnected(device) { #### `onConnected(device)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `device` | `object` | A `device` object. See the section [Class Client](#classclient) for more information. | +| `device` | `object` | `device` オブジェクト。詳細は [Clientクラス](#classclient) セクションを参照してください。 | -The `onConnected` callback function is called when the client connects to a target peripheral `device`. +`onConnected` コールバック関数は、クライアントがターゲット周辺 `device` に接続したときに呼び出されます。 *** #### `onDisconnected(device)` -| Argument | Type | Description | + +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `device` | `object` | A `device` object. See the section [Class Client](#classclient) for more information. | +| `device` | `object` | `device` オブジェクト。詳細は [Clientクラス](#classclient) セクションを参照してください。 | -The `onDisconnected` callback is called when the connection is closed. +`onDisconnected` コールバックは接続が閉じられたときに呼び出されます。 *** #### `securityParameters` -BLE clients can optionally request link-layer security to protect data transferred between devices. The `securityParameters` property accessor function is used to configure the device security requirements and I/O capabilities. +BLEクライアントは、デバイス間で転送されるデータを保護するために、リンク層のセキュリティをオプションで要求できます。`securityParameters` プロパティアクセサ関数は、デバイスのセキュリティ要件とI/O機能を設定するために使用されます。 -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `encryption` | `boolean` | Optional property to enable encryption. Default is `true` -| `bonding` | `boolean` | Optional property to enable bonding. Default is `false` -| `mitm` | `boolean` | Optional property to enable man-in-the-middle (MITM) protection. Default is `false` -| `ioCapability` | `object` | Optional `IOCapability` instance to configure the device I/O capabilities. Default is `IOCapability.NoInputNoOutput`. See the section [Class SM](#classsm) for more information. +| `encryption` | `boolean` | 暗号化を有効にするためのオプションプロパティ。デフォルトは `true` | +| `bonding` | `boolean` | ボンディングを有効にするためのオプションプロパティ。デフォルトは `false` | +| `mitm` | `boolean` | 中間者攻撃 (MITM) 保護を有効にするためのオプションプロパティ。デフォルトは `false` | +| `ioCapability` | `object` | デバイスの I/O 機能を設定するためのオプションの `IOCapability` インスタンス。デフォルトは `IOCapability.NoInputNoOutput`。詳細は [Class SM](#classsm) セクションを参照してください。 -To request MITM protection with encryption for a display-only device. The device will display a passkey when requested: +ディスプレイのみのデバイスに対して、暗号化によるMITM保護を要求します。デバイスは要求されたときにパスキーを表示します: ```javascript import {IOCapability} from "sm"; @@ -318,7 +319,7 @@ onReady() { } ``` -To request MITM protection with encryption and bonding for a device with both a display and keyboard. The device will request a passkey to be entered and encryption keys will be saved: +ディスプレイとキーボードの両方を備えたデバイスに対して、暗号化とボンディングによるMITM保護を要求します。デバイスはパスキーの入力を要求し、暗号化キーが保存されます: ```javascript import {IOCapability} from "sm"; @@ -330,43 +331,43 @@ onReady() { *** -> **Note:** The `BLEClient` object hosts all callbacks for classes used with `BLEClient`. +> **注:** `BLEClient` オブジェクトは、`BLEClient` で使用されるクラスのすべてのコールバックをホストします。 -## Class Client -An instance of the `Client` class is instantiated by `BLEClient` and provided to the host app in the `BLEClient` `onDiscovered` and `onConnected` callbacks. While applications never instantiate a `Client` class instance directly, applications do call `Client` class functions to perform GATT service/characteristic discovery, negotiate a higher MTU and close the peripheral connection. +## Clientクラス +`Client` クラスのインスタンスは `BLEClient` によってインスタンス化され、`BLEClient` の `onDiscovered` および `onConnected` コールバックでホストアプリに提供されます。アプリケーションは `Client` クラスのインスタンスを直接インスタンス化することはありませんが、`Client` クラスの関数を呼び出してGATTサービス/キャラクタリスティックのディスカバリーを行い、より高いMTUをネゴシエートし、ペリフェラル接続を閉じます。 -### Properties +### プロパティ -| Name | Type | Description | +| 名前 | 型 | 説明 | | --- | --- | :--- | -| `connection` | `number` | Connection identifier. -| `address` | `object` | Instance of [Bytes](#classbytes) class containing Bluetooth address bytes. -| `addressType` | `number` | Bluetooth address type. Refer to `GAP.AddressType` for details. -| `scanResponse` | `object` | Instance of [Advertisement](#classadvertisement) class containing advertisement and scan response packet values. -| `rssi` | `number` | Discovered device signal strength. +| `connection` | `number` | 接続識別子。 | +| `address` | `object` | Bluetooth アドレスバイトを含む [Bytes](#classbytes) クラスのインスタンス。 | +| `addressType` | `number` | Bluetooth アドレスタイプ。詳細は `GAP.AddressType` を参照してください。 | +| `scanResponse` | `object` | アドバタイズおよびスキャン応答パケットの値を含む [Advertisement](#classadvertisement) クラスのインスタンス。 | +| `rssi` | `number` | 発見されたデバイスの信号強度。 | -### Functions +### 関数 #### `exchangeMTU(mtu)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `mtu` | `number` | Requested MTU value | +| `mtu` | `number` | 要求されたMTU値 | -Use the `exchangeMTU ` function to request a higher MTU once the peripheral connection has been established. +`exchangeMTU` 関数を使用して、ペリフェラル接続が確立された後により高いMTUを要求します。 *** #### `onMTUExchanged(device, mtu)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `device` | `object` | A `device` object. See the section [Class Client](#classclient) for more information. | -| `mtu` | `number` | Exchanged MTU value | +| `device` | `object` | `device` オブジェクト。詳細は [Clientクラス](#classclient) セクションを参照してください。 | +| `mtu` | `number` | 交換されたMTU値 | -The `onMTUExchanged` callback function is called when the MTU exchange procedure has been completed. +`onMTUExchanged` コールバック関数は、MTU交換手続きが完了したときに呼び出されます。 -To request an increased MTU size of 250: +MTUサイズを250に増やすよう要求するには: ```javascript onConnected(device) { @@ -381,20 +382,20 @@ onMTUExchanged(device, mtu) { *** #### `readRSSI()` -Use the `readRSSI` function to read the connected peripheral's signal strength. +`readRSSI` 関数を使用して、接続されたペリフェラルの信号強度を読み取ります。 *** #### `onRSSI(device, rssi)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `device` | `object` | A `device` object. See the section [Class Client](#classclient) for more information. | -| `rssi` | `number` | Received signal strength | +| `device` | `object` | `device` オブジェクト。詳細は [Clientクラス](#classclient) セクションを参照してください。 | +| `rssi` | `number` | 受信信号強度 | -The `onRSSI` callback function is called when the peripheral signal strength is read. +`onRSSI` コールバック関数は、ペリフェラルの信号強度が読み取られたときに呼び出されます。 -To read the signal strength of the connected device: +接続されたデバイスの信号強度を読み取るには: ```javascript onConnected(device) { @@ -408,38 +409,38 @@ onRSSI(device, rssi) { *** #### `discoverAllPrimaryServices()` -Use the `discoverAllPrimaryServices` function to discover all the peripheral's GATT primary services. Discovered services are returned to the `onServices` callback. +`discoverAllPrimaryServices` 関数を使用して、ペリフェラルのすべてのGATTプライマリサービスを発見します。発見されたサービスは `onServices` コールバックに返されます。 *** #### `discoverPrimaryService(uuid)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `uuid` | `object` | A [Bytes](#classbytes) object containing the UUID to discover | +| `uuid` | `object` | 発見する UUID を含む [Bytes](#classbytes) オブジェクト | -Use the `discoverPrimaryService` function to discover a single GATT primary service by UUID. +`discoverPrimaryService` 関数を使用して、UUIDによって単一のGATTプライマリサービスを発見します。 *** #### `findServiceByUUID(uuid)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `uuid` | `object` | A [Bytes](#classbytes) object containing the Service UUID to find | +| `uuid` | `object` | 見つけるサービス UUID を含む [Bytes](#classbytes) オブジェクト | -The `findServiceByUUID` function finds and returns the service identified by `uuid`. This function searches the `services` property array. +`findServiceByUUID` 関数は、`uuid` によって識別されるサービスを見つけて返します。この関数は `services` プロパティ配列を検索します。 *** #### `onServices(services)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `services` | `array` | An array of `service` objects, or an empty array if no services are discovered. See the section [Class Service](#classservice) for more information. | +| `services` | `array` | `service` オブジェクトの配列、またはサービスが見つからなかった場合は空の配列です。詳細は [Serviceクラス](#classservice) のセクションを参照してください。 | -The `onServices` callback function is called when service discovery completes. If `findServiceByUUID` was called to find a single service, the `services` array contains the single service found. +`onServices` コールバック関数は、サービスの検出が完了したときに呼び出されます。`findServiceByUUID` が単一のサービスを見つけるために呼び出された場合、`services` 配列には見つかった単一のサービスが含まれます。 -To discover all primary services: +すべてのプライマリサービスを検出するには: ```javascript onConnected(device) { @@ -450,7 +451,7 @@ onServices(services) { } ``` -To discover a single primary service: +単一のプライマリサービスを検出するには: ```javascript const SERVICE_UUID = uuid`0xFF00`; @@ -463,12 +464,12 @@ onServices(services) { trace("found service\n"); } ``` -> **Note:** The `uuid` tagged template allows applications to represent UUID values as strings. Refer to the [Bytes](#classbytes) class section for details. +> **注:** `uuid` タグ付きテンプレートは、アプリケーションが UUID 値を文字列として表現することを可能にします。詳細は [Bytes](#classbytes) クラスのセクションを参照してください。 *** #### `close()` -The `close` function terminates the peripheral connection. +`close` 関数は、ペリフェラル接続を終了します。 ```javascript onConnected(device) { @@ -481,57 +482,58 @@ onDisconnected() { ``` -## Class Service -The `Service` class provides access to a single peripheral GATT service. +## Serviceクラス +`Service` クラスは、単一のペリフェラルGATTサービスへのアクセスを提供します。 + +### プロパティ -### Properties -| Name | Type | Description | +| 名前 | タイプ | 説明 | | --- | --- | :--- | -| `connection` | `number` | Connection identifier. -| `uuid` | `object` | Instance of [Bytes](#classbytes) class containing service UUID. -| `start` | `number` | Starting handle of included characteristics. -| `end` | `number` | Ending handle of included characteristics. -| `characteristics` | `array` | Array of service characteristics discovered. +| `connection` | `number` | 接続識別子。 +| `uuid` | `object` | サービスUUIDを含む[Bytes](#classbytes)クラスのインスタンス。 +| `start` | `number` | 含まれるキャラクタリスティックの開始ハンドル。 +| `end` | `number` | 含まれるキャラクタリスティックの終了ハンドル。 +| `characteristics` | `array` | 発見されたサービスキャラクタリスティックの配列。 -### Functions +### 関数 #### `discoverAllCharacteristics()` -Use the `discoverAllCharacteristics()` function to discover all the service characteristics. Discovered characteristics are returned to the `onCharacteristics` callback. +`discoverAllCharacteristics()`関数を使用して、すべてのサービスキャラクタリスティックを発見します。発見されたキャラクタリスティックは`onCharacteristics`コールバックに返されます。 *** #### `discoverCharacteristic(uuid)` -| Argument | Type | Description | +| 引数 | タイプ | 説明 | | --- | --- | :--- | -| `uuid` | `object` | A [Bytes](#classbytes) object containing the Characteristic UUID to discover | +| `uuid` | `object` | 発見するキャラクタリスティックUUIDを含む[Bytes](#classbytes)オブジェクト | -Use the `discoverCharacteristic` function to discover a single service characteristic by UUID. +`discoverCharacteristic`関数を使用して、UUIDで単一のサービスキャラクタリスティックを発見します。 *** #### `findCharacteristicByUUID(uuid)` -| Argument | Type | Description | +| 引数 | タイプ | 説明 | | --- | --- | :--- | -| `uuid` | `object` | A [Bytes](#classbytes) object containing the Characteristic UUID to find | +| `uuid` | `object` | 見つけるキャラクタリスティックUUIDを含む[Bytes](#classbytes)オブジェクト | -The `findCharacteristicByUUID` function finds and returns the characteristic identified by `uuid`. This function searches the `characteristics` property array. +`findCharacteristicByUUID` 関数は、`uuid` で識別されるキャラクタリスティックを見つけて返します。この関数は `characteristics` プロパティ配列を検索します。 *** #### `onCharacteristics(characteristics)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `characteristics` | `array` | An array of `characteristic` objects, or an empty array if no characteristics are discovered. See the section [Class Characteristic](#classcharacteristic) for more information. | +| `characteristics` | `array` | `characteristic` オブジェクトの配列、またはキャラクタリスティックが発見されなかった場合は空の配列です。詳細は [Characteristicクラス](#classcharacteristic) のセクションを参照してください。 | -The `onCharacteristics` callback function is called when characteristic discovery completes. If `findCharacteristicByUUID` was called to find a single characteristic, the `characteristics` array contains the single characteristic found. +`onCharacteristics` コールバック関数は、キャラクタリスティックの発見が完了したときに呼び出されます。`findCharacteristicByUUID` が単一のキャラクタリスティックを見つけるために呼び出された場合、`characteristics` 配列には見つかった単一のキャラクタリスティックが含まれます。 *** -To discover all the characteristics in the [Device Information](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.device_information.xml) service: +[Device Information](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.device_information.xml) サービス内のすべてのキャラクタリスティックを発見するには: ```javascript const DEVICE_INFORMATION_SERVICE_UUID = uuid`180A`; @@ -546,7 +548,7 @@ onCharacteristics(characteristics) { } ``` -To find the [Heart Rate Measurement](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.heart_rate_measurement.xml) characteristic in the [Heart Rate](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.heart_rate.xml) service: +[Heart Rate](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.heart_rate.xml) サービス内の [Heart Rate Measurement](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.heart_rate_measurement.xml) キャラクタリスティックを見つけるには: ```javascript const HEART_RATE_SERVICE_UUID = uuid`180A`; @@ -568,37 +570,37 @@ onCharacteristics(characteristics) { *** -## Class Characteristic -The `Characteristic` class provides access to a single service characteristic. +## Characteristicクラス +`Characteristic` クラスは、単一のサービスキャラクタリスティックへのアクセスを提供します。 -### Properties +### プロパティ -| Name | Type | Description | +| 名前 | 型 | 説明 | | --- | --- | :--- | -| `connection` | `number` | Connection identifier. -| `uuid` | `object` | Instance of [Bytes](#classbytes) class containing characteristic UUID. -| `service` | `object` | `Service` object containing characteristic. -| `handle` | `number` | Characteristic handle. -| `name` | `string` | Characteristic name defined in the optional service JSON. When the characteristic is not defined in the service JSON, this property is `undefined`. -| `type` | `string` | Characteristic type defined in the optional service JSON. When the characteristic is not defined in the service JSON, this property is `undefined`. -| `descriptors` | `array` | Array of characteristic descriptors discovered. +| `connection` | `number` | 接続識別子。 | +| `uuid` | `object` | キャラクタリスティックUUIDを含む [Bytes](#classbytes) クラスのインスタンス。 | +| `service` | `object` | キャラクタリスティックを含む `Service` オブジェクト。 | +| `handle` | `number` | キャラクタリスティックハンドル。 | +| `name` | `string` | オプションのサービスJSONで定義されたキャラクタリスティック名。キャラクタリスティックがサービスJSONで定義されていない場合、このプロパティは `undefined` です。 | +| `type` | `string` | オプションのサービスJSONで定義されたキャラクタリスティックタイプ。キャラクタリスティックがサービスJSONで定義されていない場合、このプロパティは `undefined` です。 | +| `descriptors` | `array` | 発見されたキャラクタリスティックディスクリプタの配列。 | -### Functions +### 関数 #### `discoverAllDescriptors()` -Use the `discoverAllDescriptors` function to discover all the characteristic's descriptors. Discovered descriptors are returned to the `onDescriptors` callback. +`discoverAllDescriptors` 関数を使用して、すべてのキャラクタリスティックのディスクリプタを発見します。発見されたディスクリプタは `onDescriptors` コールバックに返されます。 *** #### `onDescriptors(descriptors)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `descriptors` | `array` | An array of `descriptor` objects, or an empty array if no descriptors are discovered. See the section [Class Descriptor](#classdescriptor) for more information. | +| `descriptors` | `array` | `descriptor` オブジェクトの配列、またはディスカバリーされたディスクリプタがない場合は空の配列です。詳細は [Class Descriptor](#classdescriptor) のセクションを参照してください。 | -The `onDescriptors` callback function is called when descriptor discovery completes. +`onDescriptors` コールバック関数は、ディスクリプタのディスカバリーが完了したときに呼び出されます。 -To discover the [Characteristic Presentation Format Descriptor](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Descriptors/org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml) for a characteristic with UUID 0xFF00: +UUID 0xFF00のキャラクタリスティックに対する [Characteristic Presentation Format Descriptor](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Descriptors/org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml) をディスカバーするには: ```javascript const CHARACTERISTIC_UUID = uuid`FF00`; @@ -619,45 +621,45 @@ onDescriptors(descriptors) { *** #### `enableNotifications()` -Use the `enableNotifications` function to enable characteristic value change notifications. +`enableNotifications` 関数を使用して、キャラクタリスティックの値の変更通知を有効にします。 *** #### `onCharacteristicNotificationEnabled(characteristic)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `characteristic` | `object` | A `characteristic` object. | +| `characteristic` | `object` | `characteristic` オブジェクト。 | -The `onCharacteristicNotificationEnabled` callback function is called when notifications have been enabled for the `characteristic`. +`onCharacteristicNotificationEnabled` コールバック関数は、`characteristic` の通知が有効になったときに呼び出されます。 *** #### `disableNotifications()` -Use the `disableNotifications` function to disable characteristic value change notifications. +`disableNotifications` 関数を使用して、キャラクタリスティックの値変更通知を無効にします。 *** #### `onCharacteristicNotificationDisabled(characteristic)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `characteristic` | `object` | A `characteristic` object. | +| `characteristic` | `object` | `characteristic` オブジェクト。 | -The `onCharacteristicNotificationDisabled` callback function is called when notifications have been disabled for the `characteristic`. +`onCharacteristicNotificationDisabled` コールバック関数は、`characteristic` の通知が無効になったときに呼び出されます。 *** #### `onCharacteristicNotification(characteristic, value)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `characteristic` | `object` | A `characteristic` object. | -| `value` | `varies` | The `characteristic` value. The value is automatically converted to the `type` defined in the service JSON, when available. Otherwise `value` is an `ArrayBuffer`. | +| `characteristic` | `object` | `characteristic` オブジェクト。 | +| `value` | `varies` | `characteristic` の値。利用可能な場合、値はサービス JSON で定義された `type` に自動的に変換されます。それ以外の場合、`value` は `ArrayBuffer` です。 | -The `onCharacteristicNotification` callback function is called when notifications are enabled and the peripheral notifies the characteristic value. +`onCharacteristicNotification` コールバック関数は、通知が有効になっており、ペリフェラルがキャラクタリスティックの値を通知したときに呼び出されます。 -To enable and receive characteristic value change notifications for the [Battery Level](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.battery_level.xml) characteristic in the [Battery Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.battery_service.xml): +[Battery Level](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.battery_level.xml) キャラクタリスティックの値変更通知を有効にして受信するには、[Battery Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.battery_service.xml) を使用します。 ```javascript const BATTERY_SERVICE_UUID = uuid`180F`; @@ -683,34 +685,34 @@ onCharacteristicNotification(characteristic, value) { *** #### `readValue([auth])` -Use the `readValue` function to read a characteristic value on demand. +`readValue` 関数を使用して、必要に応じてキャラクタリスティックの値を読み取ります。 -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `auth` | `number` | Optional `SM.Authorization` applied to the read request. | +| `auth` | `number` | 読み取り要求に適用されるオプションの `SM.Authorization`。 | -The `Authorization` object contains the following properties: +`Authorization` オブジェクトには次のプロパティが含まれています: -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `None` | `number` | No authorization -| `NoMITM` | `number` | Unauthenticated encryption -| `MITM` | `number` | Authenticated encryption -| `SignedNoMITM` | `number` | Signed unauthenticated encryption -| `SignedMITM` | `number` | Signed authenticated encryption +| `None` | `number` | 認証なし | +| `NoMITM` | `number` | 認証されていない暗号化 | +| `MITM` | `number` | 認証された暗号化 | +| `SignedNoMITM` | `number` | 署名された認証されていない暗号化 | +| `SignedMITM` | `number` | 署名された認証された暗号化 | *** #### `onCharacteristicValue(characteristic, value)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `characteristic` | `object` | A `characteristic` object. | -| `value` | `varies` | The `characteristic` value read. The value `type` is defined by the service JSON, when available. Otherwise `value` is an `ArrayBuffer`. | +| `characteristic` | `object` | `characteristic` オブジェクト。 | +| `value` | `varies` | 読み取られた `characteristic` 値。値の `type` は、利用可能な場合はサービス JSON によって定義されます。それ以外の場合、`value` は `ArrayBuffer` です。 | -The `onCharacteristicValue` callback function is called when a characteristic is read by the `readValue` function. +`onCharacteristicValue` コールバック関数は、`readValue` 関数によってキャラクタリスティックが読み取られたときに呼び出されます。 -To read the [Device Name](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.gap.device_name.xml) from the [Generic Access Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.generic_access.xml): +[Generic Access Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.generic_access.xml) から [Device Name](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.gap.device_name.xml) を読み取るには: ```javascript const GENERIC_ACCESS_SERVICE_UUID = uuid`1800`; @@ -737,13 +739,13 @@ onCharacteristicValue(characteristic, value) { #### `writeWithoutResponse(value)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `value` | `varies` | The `characteristic` value to write. The value `type` is defined by the service JSON, when available. Otherwise `value` is an `ArrayBuffer` or `String`. | +| `value` | `varies` | 書き込む `characteristic` の値。`type` は、利用可能な場合はサービス JSON によって定義されます。それ以外の場合、`value` は `ArrayBuffer` または `String` です。 | -Use the `writeWithoutResponse` function to write a characteristic value on demand. +`writeWithoutResponse` 関数を使用して、要求に応じてキャラクタリスティックの値を書き込みます。 -To write the [URI](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.uri.xml) characteristic value in the [HTTP Proxy](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.http_proxy.xml) service: +[HTTP Proxy](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.http_proxy.xml) サービスで [URI](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.uri.xml) キャラクタリスティックの値を書き込むには: ```javascript const HTTP_PROXY_SERVICE_UUID = uuid`1823`; @@ -765,51 +767,51 @@ onCharacteristics(characteristics) { *** -## Class Descriptor -The `Descriptor` class provides access to a single characteristic descriptor. +## Descriptorクラス +`Descriptor` クラスは、単一のキャラクタリスティックディスクリプタへのアクセスを提供します。 -### Properties +### プロパティ -| Name | Type | Description | +| 名前 | 型 | 説明 | | --- | --- | :--- | -| `connection` | `number` | Connection identifier. -| `uuid` | `string` | Instance of [Bytes](#classbytes) class containing descriptor UUID. -| `characteristic` | `object` | `Characteristic` object containing descriptor. -| `handle` | `number` | Descriptor handle. -| `name` | `string` | Descriptor name defined in the optional service JSON. When the descriptor is not defined in the service JSON, this property is `undefined`. -| `type` | `string` | Descriptor type defined in the optional service JSON. When the descriptor is not defined in the service JSON, this property is `undefined`. +| `connection` | `number` | 接続識別子。 | +| `uuid` | `string` | ディスクリプタUUIDを含む [Bytes](#classbytes) クラスのインスタンス。 | +| `characteristic` | `object` | ディスクリプタを含む `Characteristic` オブジェクト。 | +| `handle` | `number` | ディスクリプタハンドル。 | +| `name` | `string` | オプションのサービスJSONで定義されたディスクリプタ名。サービスJSONでディスクリプタが定義されていない場合、このプロパティは `undefined` です。 | +| `type` | `string` | オプションのサービスJSONで定義されたディスクリプタタイプ。サービスJSONでディスクリプタが定義されていない場合、このプロパティは `undefined` です。 | -### Functions +### 関数 #### `readValue([auth])` -Use the `readValue` function to read a descriptor value on demand. +`readValue` 関数を使用して、必要に応じてディスクリプタの値を読み取ります。 -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `auth` | `number` | Optional `SM.Authorization` applied to the read request. | +| `auth` | `number` | 読み取り要求に適用されるオプションの `SM.Authorization`。 | -The `Authorization` object contains the following properties: +`Authorization` オブジェクトには以下のプロパティがあります: -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `None` | `number` | No authorization -| `NoMITM` | `number` | Unauthenticated encryption -| `MITM` | `number` | Authenticated encryption -| `SignedNoMITM` | `number` | Signed unauthenticated encryption -| `SignedMITM` | `number` | Signed authenticated encryption +| `None` | `number` | 認証なし | +| `NoMITM` | `number` | 認証されていない暗号化 | +| `MITM` | `number` | 認証された暗号化 | +| `SignedNoMITM` | `number` | 署名された認証されていない暗号化 | +| `SignedMITM` | `number` | 署名された認証された暗号化 | *** #### `onDescriptorValue(descriptor, value)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `descriptor ` | `object` | A `descriptor` object. | -| `value` | `varies` | The `descriptor` value read. The value `type` is defined by the service JSON, when available. Otherwise `value` is an `ArrayBuffer`. | +| `descriptor ` | `object` | `descriptor` オブジェクト。 | +| `value` | `varies` | 読み取られた `descriptor` の値。値の `type` は、利用可能な場合はサービス JSON によって定義されます。それ以外の場合、`value` は `ArrayBuffer` です。 | -The `onDescriptorValue` callback function is called when a descriptor is read by the `readValue` function. +`onDescriptorValue` コールバック関数は、`readValue` 関数によってディスクリプタが読み取られたときに呼び出されます。 -To read a descriptor with unauthenticated encryption: +認証されていない暗号化でディスクリプタを読み取るには: ```javascript import {SM, IOCapability, Authorization} from "sm"; @@ -827,13 +829,13 @@ onDescriptorValue(descriptor, value) { ``` #### `writeValue(value)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `value` | `varies` | The `descriptor` value to write. The value `type` is defined by the service JSON, when available. Otherwise `value` is an `ArrayBuffer` or `String`. | +| `value` | `varies` | 書き込む `descriptor` の値。値の `type` は、利用可能な場合はサービス JSON によって定義されます。それ以外の場合、`value` は `ArrayBuffer` または `String` です。 | -Use the `writeValue` function to write a descriptor value. +`writeValue` 関数を使用して、ディスクリプタの値を書き込みます。 -To enable characteristic value change notifications by writing 0x0001 to the [Client Characteristic Configuration](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Descriptors/org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml) descriptor: +[クライアントキャラクタリスティック設定](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Descriptors/org.bluetooth.descriptor.gatt.client_characteristic_configuration.xml)ディスクリプタに0x0001を書き込むことで、キャラクタリスティックの値の変更通知を有効にします。 ```javascript const CCCD_UUID = uuid`2902`; @@ -847,38 +849,38 @@ onDescriptors(descriptors) { } ``` -> **Note:** The `Characteristic` `enableNotifications` convenience function is typically used for this purpose, though writing the CCCD descriptor directly provides the same net result. +> **注:** `Characteristic` の `enableNotifications` 便利関数は通常この目的で使用されますが、CCCDディスクリプタを直接書き込むことでも同じ結果が得られます。 -## Class Advertisement +## Advertisementクラス -The `Advertisement` class provides accessor functions to read common advertisement and scan response data types as JavaScript properties. The class is primarily used to parse the `scanResponseData` provided to BLE clients via the `onDiscovered` callback function's `device` parameter. The accessor functions return `undefined` if the associated data type is not available in the `scanResponseData`. +`Advertisement` クラスは、一般的なアドバタイズとスキャン応答データ型をJavaScriptプロパティとして読み取るためのアクセサ関数を提供します。このクラスは主に、`onDiscovered` コールバック関数の `device` パラメータを介してBLEクライアントに提供される `scanResponseData` を解析するために使用されます。アクセサ関数は、関連するデータ型が `scanResponseData` に存在しない場合は `undefined` を返します。 -### Properties +### プロパティ -| Name | Type | Description +| 名前 | 型 | 説明 | | --- | --- | :--- | -| `buffer` | `object` | An `ArrayBuffer` containing the raw advertisement data bytes. -| `completeName` | `string` | The advertised complete local name. -| ` shortName` | `string` | The advertised shortened local name. -| `manufacturerSpecific` | `object` | An object containing the advertised manufacturer specific data. -| `flags` | `number` | The advertised flags value. -| `completeUUID16List` | `array` | The advertised complete 16-bit UUID list. -| `incompleteUUID16List` | `array` | The advertised incomplete 16-bit UUID list. +| `buffer` | `object` | 生のアドバタイズデータバイトを含む `ArrayBuffer`。 | +| `completeName` | `string` | アドバタイズされた完全なローカル名。 | +| `shortName` | `string` | アドバタイズされた短縮されたローカル名。 | +| `manufacturerSpecific` | `object` | アドバタイズされたメーカー固有のデータを含むオブジェクト。 | +| `flags` | `number` | アドバタイズされたフラグの値。 | +| `completeUUID16List` | `array` | アドバタイズされた完全な16ビットUUIDリスト。 | +| `incompleteUUID16List` | `array` | アドバタイズされた不完全な16ビットUUIDリスト。 | -### Functions +### 関数 #### `findIndex(type [,index])` -Use the `findIndex` function to find the index of a specific advertisement data type in the raw advertisement data bytes. +`findIndex` 関数を使用して、生のアドバタイズデータバイト内の特定のアドバタイズデータタイプのインデックスを見つけます。 -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `type` | `number` | The `GAP.ADType` to search for. | -| `index` | `number` | The optional starting index to search from. Defaults to 0. | +| `type` | `number` | 検索する `GAP.ADType`。 | +| `index` | `number` | 検索を開始するオプションの開始インデックス。デフォルトは0。 | -### Examples +### 例 -To identify an advertised device with the complete name "Zip": +完全な名前が "Zip" のアドバタイズデバイスを識別するには: ```javascript onDiscovered(device) { @@ -889,7 +891,7 @@ onDiscovered(device) { } ``` -To identify a [Blue Maestro Environment Monitor](https://www.bluemaestro.com/product/tempo-environment-monitor/) and read the temperature from the manufacturer specific data: +[Blue Maestro Environment Monitor](https://www.bluemaestro.com/product/tempo-environment-monitor/)を識別し、メーカー固有データから温度を読み取るには: ```javascript onDiscovered(device) { @@ -907,7 +909,7 @@ onDiscovered(device) { } ``` -To search for the "TX Power Level" advertisement data type in the scan response data: +スキャン応答データ内の「TX Power Level」アドバタイズデータタイプを検索するには: ```javascript onDiscovered(device) { @@ -922,23 +924,23 @@ onDiscovered(device) { ``` -## Class Bytes +## Bytesクラス -The private `Bytes` class extends `ArrayBuffer`. Applications typically use the provided `uuid` and `address` tagged templates to create a `Bytes` instance from hex strings. +プライベートな`Bytes`クラスは`ArrayBuffer`を拡張します。アプリケーションは通常、提供された`uuid`および`address`タグ付きテンプレートを使用して、16進文字列から`Bytes`インスタンスを作成します。 -#### Constructor Description +#### コンストラクタの説明 #### `Bytes(bytes [,littleEndian])` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `bytes` | `object` or `string` | The ArrayBuffer `bytes` to set. The bytes can be a String or ArrayBuffer. | -| `littleEndian` | `boolean` | When set `true` the contents of the ArrayBuffer are stored in reverse order. Default is `false`.| -### Functions +| `bytes` | `object` または `string` | 設定するArrayBufferの`bytes`。バイトは文字列またはArrayBufferで指定できます。 | +| `littleEndian` | `boolean` | `true`に設定すると、ArrayBufferの内容が逆順に格納されます。デフォルトは`false`です。| +### 関数 #### `address`\``string`` -The `address` tagged template is used to convert a Bluetooth address expressed as a hex string to a `Bytes` instance. +`address` タグ付きテンプレートは、16進文字列で表現されたBluetoothアドレスを `Bytes` インスタンスに変換するために使用されます。 ```javascript import {address} from "btutils"; @@ -948,7 +950,7 @@ const DEVICE_ADDRESS = address`66:55:44:33:22:11`; #### `uuid`\``string`` -The `uuid` tagged template is used to convert a Bluetooth UUID expressed as a hex string to a `Bytes` instance. +`uuid` タグ付きテンプレートは、16進文字列で表現されたBluetooth UUIDを `Bytes` インスタンスに変換するために使用されます。 ```javascript import {uuid} from "btutils"; @@ -959,11 +961,11 @@ const CHARACTERISTIC_RX_UUID = uuid`6E400002-B5A3-F393-E0A9-E50E24DCCA9E`; #### `equals(buffer)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `buffer` | `object` | The `Bytes` instance to compare. | +| `buffer` | `object` | 比較する `Bytes` インスタンス。 | -The `equals` function returns `true` if the instance ArrayBuffer data equals the data contained in `buffer`. +`equals` 関数は、インスタンスのArrayBufferデータが `buffer` に含まれるデータと等しい場合に `true` を返します。 ```javascript import {uuid} from "btutils"; @@ -978,7 +980,7 @@ onServices(services) { #### `toString()` -The `toString` helper function returns a printable hex string of the `Bytes` contents. The string is formatted in big endian order with separators. +`toString` ヘルパー関数は、`Bytes` の内容を印刷可能な16進文字列として返します。文字列はビッグエンディアン順でセパレータ付きでフォーマットされます。 ```javascript onDiscovered(device) { @@ -992,15 +994,15 @@ onServices(services) { ``` -## BLE Server -A BLE server/peripheral can connect to one BLE client and typically performs the following steps to send notifications to a BLE client: +## BLE サーバー +BLEサーバー/ペリフェラルは、1つのBLEクライアントに接続でき、通常、BLEクライアントに通知を送信するために次の手順を実行します。 -1. Start advertising so that clients can discover the peripheral -2. Establish a connection with a client -3. Accept characteristic value change notification request(s) -4. Notify characteristic value changes. +1. クライアントがペリフェラルを発見できるようにアドバタイズを開始する +2. クライアントとの接続を確立する +3. キャラクタリスティックの値変更通知要求を受け入れる +4. キャラクタリスティックの値の変更を通知する -The following abbreviated code from the [heart-rate-server](../../../examples/network/ble/heart-rate-server) example app shows a typical server flow: +以下の[heart-rate-server](../../../examples/network/ble/heart-rate-server)サンプルアプリからの省略されたコードは、典型的なサーバーフローを示しています: ```javascript onReady() { @@ -1032,12 +1034,12 @@ startMeasurements(characteristic) { } ``` -GATT services are automatically deployed by the BLE server when launched. A BLE server is fundamentally asynchronous and results are always delivered to the `BLEServer` class callback methods, e.g. `onReady`, `onConnected`, etc. above. The following sections describe the `BLEServer` class, properties, and callbacks. +GATTサービスは、BLEサーバーが起動されると自動的に展開されます。BLEサーバーは基本的に非同期であり、結果は常に`BLEServer`クラスのコールバックメソッド(例:上記の`onReady`、`onConnected`など)に配信されます。以下のセクションでは、`BLEServer`クラス、プロパティ、およびコールバックについて説明します。 -## Class BLEServer +## BLEServerクラス -The `BLEServer` class provides access to the BLE server features. +`BLEServer`クラスは、BLEサーバーの機能にアクセスするためのものです。 ```javascript import BLEServer from "bleserver"; @@ -1045,16 +1047,16 @@ import BLEServer from "bleserver"; ### `constructor([dictionary])` -The `BLEServer` constructor takes a single argument, an optional dictionary of initialization parameters. +`BLEServer`コンストラクタは、初期化パラメータのオプションの辞書を1つの引数として受け取ります。 -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `deployServices` | `boolean` | Optional property to deploy [GATT Services](#gattservices). Default is `true`. Set to `false` to not deploy GATT services. +| `deployServices` | `boolean` | [GATT Services](#gattservices)をデプロイするためのオプションプロパティ。デフォルトは`true`です。GATTサービスをデプロイしない場合は`false`に設定します。 -### Functions +### 関数 #### `onReady()` -Applications must wait for the `onReady` callback before calling other `BLEServer` functions: +アプリケーションは、他の`BLEServer`関数を呼び出す前に`onReady`コールバックを待つ必要があります。 ```javascript class Server extends BLEServer { @@ -1068,7 +1070,7 @@ let server = new BLEServer; *** #### `deviceName` -The `deviceName` property accessor function is used to set/get the Bluetooth peripheral device name. +`deviceName`プロパティアクセサ関数は、Bluetoothペリフェラルデバイスの名前を設定/取得するために使用されます。 ```javascript class Advertiser extends BLEServer { @@ -1083,7 +1085,7 @@ let advertiser = new BLEServer; *** #### `localAddress` -The read-only `localAddress` property accessor function returns the Bluetooth peripheral's local address as a [Bytes](#classbytes) object. +読み取り専用の`localAddress`プロパティアクセサ関数は、Bluetoothペリフェラルのローカルアドレスを[Bytes](#classbytes)オブジェクトとして返します。 ```javascript class Advertiser extends BLEServer { @@ -1097,16 +1099,16 @@ class Advertiser extends BLEServer { #### `securityParameters` -BLE servers can optionally request link-layer security to protect data transferred between devices. The `securityParameters` property accessor function is used to configure the device security requirements and I/O capabilities. +BLEサーバーは、デバイス間で転送されるデータを保護するためにリンク層のセキュリティをオプションで要求できます。`securityParameters`プロパティアクセサ関数は、デバイスのセキュリティ要件とI/O機能を設定するために使用されます。 -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `encryption` | `boolean` | Optional property to enable encryption. Default is `true` -| `bonding` | `boolean` | Optional property to enable bonding. Default is `false` -| `mitm` | `boolean` | Optional property to enable man-in-the-middle (MITM) protection. Default is `false` -| `ioCapability` | `object` | Optional `IOCapability` instance to configure the device I/O capabilities. Default is `IOCapability.NoInputNoOutput`. See the section [Class SM](#classsm) for more information. +| `encryption` | `boolean` | 暗号化を有効にするためのオプションプロパティ。デフォルトは `true` | +| `bonding` | `boolean` | ボンディングを有効にするためのオプションプロパティ。デフォルトは `false` | +| `mitm` | `boolean` | 中間者攻撃 (MITM) 保護を有効にするためのオプションプロパティ。デフォルトは `false` | +| `ioCapability` | `object` | デバイスのI/O機能を設定するためのオプションの `IOCapability` インスタンス。デフォルトは `IOCapability.NoInputNoOutput`。詳細は [Class SM](#classsm) のセクションを参照してください。 -To request MITM protection with encryption for a display-only device. The device will display a passkey when requested: +暗号化を伴うMITM保護をディスプレイのみのデバイスで要求するには。デバイスは要求されたときにパスキーを表示します: ```javascript import {IOCapability} from "sm"; @@ -1116,7 +1118,7 @@ onReady() { } ``` -To request MITM protection with encryption and bonding for a device with both a display and keyboard. The device will request a passkey to be entered and encryption keys will be saved: +ディスプレイとキーボードの両方を備えたデバイスで、暗号化とボンディングを伴うMITM保護を要求するには。デバイスはパスキーの入力を要求し、暗号化キーが保存されます: ```javascript import {IOCapability} from "sm"; @@ -1130,60 +1132,60 @@ onReady() { #### `startAdvertising(params)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `params` | `object` | Object containing advertisement properties. +| `params` | `object` | アドバタイズプロパティを含むオブジェクト。 -The `params` object contains the following properties: +`params` オブジェクトには以下のプロパティが含まれています: -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `advertisingData` | `object` | Object containing advertisement data properties. -| `connectable` | `boolean` | Optional property to specify connectable mode. Set to `true` to specify unidirected connectable mode; `false` to specify non-connectable mode. Defaults to `true`. -| `discoverable` | `boolean` | Optional property to specify discoverable mode. Set to `true` to use the general discovery procedure; `false` to specify non-discoverable. Defaults to `true`. -| `fast` | `boolean` | Optional property to specify the GAP advertisement interval. Set to `true` to specify TGAP(adv\_fast\_interval1); `false` to specify TGAP(adv\_slow\_interval). Defaults to `true`. -| `filterPolicy` | `number` | Optional property to apply a filter policy. Defaults to `GAP.AdvFilterPolicy.NONE` (no filtering). Refer to the [BLE whitelisting](#blewhitelisting) section for details. -| `notify` | `boolean` | Optional property to notify application after each advertising data packet sent. Defaults to `false`. -| `scanResponseData` | `object` | Optional object containing scan response data properties. +| `advertisingData` | `object` | アドバタイズデータプロパティを含むオブジェクト。 | +| `connectable` | `boolean` | 接続可能モードを指定するためのオプションプロパティ。`true` に設定すると一方向接続可能モードを指定し、`false` に設定すると非接続可能モードを指定します。デフォルトは `true`。 | +| `discoverable` | `boolean` | 発見可能モードを指定するためのオプションプロパティ。`true` に設定すると一般的な発見手順を使用し、`false` に設定すると非発見可能を指定します。デフォルトは `true`。 | +| `fast` | `boolean` | GAP アドバタイズ間隔を指定するためのオプションプロパティ。`true` に設定すると TGAP(adv\_fast\_interval1) を指定し、`false` に設定すると TGAP(adv\_slow\_interval) を指定します。デフォルトは `true`。 | +| `filterPolicy` | `number` | フィルターポリシーを適用するためのオプションプロパティ。デフォルトは `GAP.AdvFilterPolicy.NONE` (フィルタリングなし)。詳細は [BLE ホワイトリスト](#blewhitelisting) セクションを参照してください。 | +| `notify` | `boolean` | 各アドバタイズデータパケット送信後にアプリケーションに通知するためのオプションプロパティ。デフォルトは `false`。 | +| `scanResponseData` | `object` | スキャン応答データプロパティを含むオプションオブジェクト。 | -> Note: The `notify` property is only implemented for nRF52 devices. +> 注: `notify` プロパティは nRF52 デバイスでのみ実装されています。 -The `filterPolicy` property can be one of the following: +`filterPolicy` プロパティは以下のいずれかです: -| Name | Description | +| 名前 | 説明 | | --- | :--- | -| `GAP.AdvFilterPolicy.NONE` | No filtering. -| `GAP.AdvFilterPolicy.WHITELIST_SCANS` | Process all connection requests but only scans from devices in the whitelist. -| `GAP.AdvFilterPolicy.WHITELIST_CONNECTIONS` | Process all scan requests but only connection requests from devices in the whitelist. -| `GAP.AdvFilterPolicy.WHITELIST_SCANS_CONNECTIONS` | Ignore all scan and connection requests unless peer device is in the whitelist. - -The `startAdvertising` function starts broadcasting advertisement and scan response packets. The function is also used to configure discoverable and connectable modes. - -The `advertisingData` and `scanResponseData` contain one or more properties corresponding to the [Bluetooth Advertisement Data Types](https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile): - -| Property | Type | Description | -| --- | --- | :--- | -| `incompleteUUID16List` | `array` | Array of UUID objects corresponding to *Incomplete List of 16 bit Service UUIDs*. -| `completeUUID16List` | `array ` | Array of UUID objects corresponding to *Complete List of 16 bit Service UUIDs*. -| `incompleteUUID128List` | `array` | Array of UUID objects corresponding to *Incomplete List of 128 bit Service UUIDs*. -| `completeUUID128List` | `array` | Array of UUID objects corresponding to *Complete List of 128 bit Service UUIDs*. -| `shortName` | `string` | String corresponding to the *Shortened Local Name*. -| `completeName` | `string` | String corresponding to the *Complete Local Name*. -| `manufacturerSpecific` | `object` | Object corresponding to the *Manufacturer Specific Data*. The `identifier` property is a number corresponding to the *Company Identifier Code*. The `data` property is a `Uint8Array` of numbers corresponding to additional manufacturer specific data. -| `txPowerLevel` | `number` | Number corresponding to the *TX Power Level*. -| `connectionInterval` | `object` | Object corresponding to the *Slave Connection Interval Range*. The `intervalMin` property is a number corresponding to the minimum connection interval value. The `intervalMax` property is a number corresponding to the maximum connection interval value. -| `solicitationUUID16List` | `array` | Array of UUID objects corresponding to the *List of 16 bit Service Solicitation UUIDs*. -| `solicitationUUID128List ` | `array` | Array of UUID objects corresponding to the *List of 128 bit Service Solicitation UUIDs*. -| `serviceDataUUID16` | `object` | Object corresponding to the *Service Data - 16 bit UUID*. The `uuid` property is an object corresponding to the 16-bit Service UUID. The `data` property is an array of numbers corresponding to additional service data. -| `serviceDataUUID128` | `object` | Object corresponding to the *Service Data - 128 bit UUID*. The `uuid` property is an object corresponding to the 128-bit Service UUID. The `data` property is an array of numbers corresponding to additional service data. -| `appearance` | `number` | Number corresponding to the *Appearance*. -| `publicAddress` | `object` | Address object corresponding to the *Public Target Address*. -| `randomAddress` | `object` | Address object corresponding to the *Random Target Address*. -| `advertisingInterval` | `number` | Number corresponding to the *Advertising Interval*. -| `role` | `number` | Number corresponding to the *LE Role*. -| `uri` | `string` | String corresponding to the *Uniform Resource Identifier*. - -To advertise a [Health Thermometer Sensor](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.health_thermometer.xml) BLE-only connectable device with the complete local name "Thermometer" and one service with UUID 0x1809: +| `GAP.AdvFilterPolicy.NONE` | フィルタリングなし。 +| `GAP.AdvFilterPolicy.WHITELIST_SCANS` | すべての接続要求を処理しますが、ホワイトリストにあるデバイスからのスキャンのみを処理します。 +| `GAP.AdvFilterPolicy.WHITELIST_CONNECTIONS` | すべてのスキャン要求を処理しますが、ホワイトリストにあるデバイスからの接続要求のみを処理します。 +| `GAP.AdvFilterPolicy.WHITELIST_SCANS_CONNECTIONS` | ピアデバイスがホワイトリストにない限り、すべてのスキャンおよび接続要求を無視します。 + +`startAdvertising` 関数は、アドバタイズおよびスキャン応答パケットのブロードキャストを開始します。この関数は、発見可能モードおよび接続可能モードを設定するためにも使用されます。 + +`advertisingData` および `scanResponseData` は、[Bluetooth Advertisement Data Types](https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile) に対応する1つ以上のプロパティを含みます: + +| プロパティ | 型 | 説明 | +| --- | --- | :--- | +| `incompleteUUID16List` | `array` | *不完全な16ビットサービスUUIDのリスト*に対応するUUIDオブジェクトの配列。 +| `completeUUID16List` | `array ` | *完全な16ビットサービスUUIDのリスト*に対応するUUIDオブジェクトの配列。 +| `incompleteUUID128List` | `array` | *不完全な128ビットサービスUUIDのリスト*に対応するUUIDオブジェクトの配列。 +| `completeUUID128List` | `array` | *完全な128ビットサービスUUIDのリスト*に対応するUUIDオブジェクトの配列。 +| `shortName` | `string` | *短縮ローカル名*に対応する文字列。 +| `completeName` | `string` | *完全なローカル名*に対応する文字列。 +| `manufacturerSpecific` | `object` | *メーカー固有データ*に対応するオブジェクト。`identifier` プロパティは *会社識別子コード* に対応する数値です。`data` プロパティは追加のメーカー固有データに対応する `Uint8Array` の数値です。 +| `txPowerLevel` | `number` | *TXパワーレベル*に対応する数値。 +| `connectionInterval` | `object` | *スレーブ接続間隔範囲*に対応するオブジェクト。`intervalMin` プロパティは最小接続間隔値に対応する数値です。`intervalMax` プロパティは最大接続間隔値に対応する数値です。 +| `solicitationUUID16List` | `array` | *16ビットサービス勧誘UUIDのリスト*に対応するUUIDオブジェクトの配列。 +| `solicitationUUID128List ` | `array` | *128ビットサービス勧誘UUIDのリスト*に対応するUUIDオブジェクトの配列。 +| `serviceDataUUID16` | `object` | *サービスデータ - 16ビットUUID*に対応するオブジェクト。`uuid` プロパティは16ビットサービスUUIDに対応するオブジェクトです。`data` プロパティは追加のサービスデータに対応する数値の配列です。 +| `serviceDataUUID128` | `object` | *サービスデータ - 128ビットUUID*に対応するオブジェクト。`uuid` プロパティは128ビットサービスUUIDに対応するオブジェクトです。`data` プロパティは追加のサービスデータに対応する数値の配列です。 +| `appearance` | `number` | *外観*に対応する数値。 +| `publicAddress` | `object` | *パブリックターゲットアドレス*に対応するアドレスオブジェクト。 +| `randomAddress` | `object` | *ランダムターゲットアドレス*に対応するアドレスオブジェクト。 +| `advertisingInterval` | `number` | *アドバタイズ間隔*に対応する数値。 +| `role` | `number` | *LEロール*に対応する数値。 +| `uri` | `string` | *統一リソース識別子*に対応する文字列。 + +[Health Thermometer Sensor](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.health_thermometer.xml) BLE専用接続可能デバイスを、完全なローカル名「Thermometer」とUUID 0x1809の1つのサービスでアドバタイズするには: ```javascript import {uuid} from "btutils"; @@ -1193,7 +1195,7 @@ this.startAdvertising({ }); ``` -To advertise a [Heart Rate Sensor](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.heart_rate.xml) BLE-only connectable device with the complete local name "Moddable HRS" and two services with UUIDs 0x180D and 0x180F: +[Heart Rate Sensor](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.heart_rate.xml) BLE専用接続可能デバイスを、完全なローカル名「Moddable HRS」とUUID 0x180Dおよび0x180Fの2つのサービスでアドバタイズするには: ```javascript import {uuid} from "btutils"; @@ -1203,7 +1205,7 @@ this.startAdvertising({ }); ``` -To advertise a BLE-only non-connectable and limited discoverable device with the complete local name "Moddable HRS" and the short name "Moddable" and random target address 00:11:22:33:44:55 provided in the scan response: +BLE専用非接続可能かつ限定的に発見可能なデバイスを、完全なローカル名「Moddable HRS」、短縮名「Moddable」、およびスキャン応答で提供されるランダムターゲットアドレス00:11:22:33:44:55でアドバタイズするには: ```javascript import {address} from "btutils"; @@ -1215,7 +1217,7 @@ this.startAdvertising({ }); ``` -To receive a notification callback after each advertising data packet sent: +各アドバタイズデータパケット送信後に通知コールバックを受け取るには: ```javascript onReady() { @@ -1232,7 +1234,7 @@ onAdvertisementSent() { *** #### `stopAdvertising()` -Call the `stopAdvertising` function to stop broadcasting Bluetooth advertisements. +`stopAdvertising` 関数を呼び出して、Bluetoothアドバタイズの送信を停止します。 ```javascript import {uuid} from "btutils"; @@ -1248,14 +1250,14 @@ onConnected(device) { ``` #### `notifyValue(characteristic, value)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `characteristic` | `object` | The `characteristic` object to notify. | -| `value` | `varies` | The `characteristic` notification value. The value is automatically converted from the `type` defined in the service JSON. | +| `characteristic` | `object` | 通知する `characteristic` オブジェクト。 | +| `value` | `varies` | `characteristic` の通知値。値はサービス JSON で定義された `type` から自動的に変換されます。 | -Call the `notifyValue` function to send a characteristic value change notification to the connected client. +`notifyValue` 関数を呼び出して、接続されたクライアントにcharacteristic値の変更通知を送信します。 -To notify a characteristic with the string "hello" every 250 ms: +250 msごとに文字列 "hello" をcharacteristicに通知するには: ```javascript onCharacteristicNotifyEnabled(characteristic) { @@ -1272,39 +1274,39 @@ startNotifications(characteristic) { #### `onAdvertisementSent()` -The `onAdvertisementSent` callback function is called after each advertising data packet sent, when a server enables advertisement notifications from the `startAdvertising()` function. +`onAdvertisementSent` コールバック関数は、`startAdvertising()` 関数からアドバタイズ通知が有効になっているサーバーで、各アドバタイズデータパケット送信後に呼び出されます。 -> Note: The `onAdvertisementSent` callback is only implemented for nRF52 devices. +> 注: `onAdvertisementSent` コールバックは nRF52 デバイスでのみ実装されています。 *** #### `onCharacteristicNotifyEnabled(characteristic)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `characteristic` | `object` | The `characteristic` object with notifications enabled. +| `characteristic` | `object` | 通知が有効になった `characteristic` オブジェクト。 -The `onCharacteristicNotifyEnabled` callback function is called when a client enables notifications on the `characteristic`. +`onCharacteristicNotifyEnabled` コールバック関数は、クライアントが `characteristic` の通知を有効にしたときに呼び出されます。 *** #### `onCharacteristicWritten(characteristic, value)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `characteristic` | `object` | The `characteristic` object written. -| `value` | `varies` | The value written. The value is automatically converted to the `type` defined in the service JSON. +| `characteristic` | `object` | 書き込まれた `characteristic` オブジェクト。 +| `value` | `varies` | 書き込まれた値。値はサービスJSONで定義された `type` に自動的に変換されます。 -The `characteristic` object contains the following properties: +`characteristic` オブジェクトには以下のプロパティがあります: -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `uuid` | `object` | Instance of [Bytes](#classbytes) class containing Characteristic UUID. -| `name` | `string` | Characteristic name defined in the service JSON. -| `type` | `string` | Characteristic type defined in the service JSON. -| `handle` | `number` | Characteristic handle. +| `uuid` | `object` | Characteristic UUIDを含む [Bytes](#classbytes) クラスのインスタンス。 +| `name` | `string` | サービスJSONで定義されたCharacteristic名。 +| `type` | `string` | サービスJSONで定義されたCharacteristicタイプ。 +| `handle` | `number` | Characteristicハンドル。 -The `onCharacteristicWritten` callback is called when a client writes a service characteristic value on demand. The `BLEServer` application is responsible for handling the write request. +`onCharacteristicWritten` コールバックは、クライアントがサービスのキャラクタリスティックの値を書き込む際に呼び出されます。`BLEServer` アプリケーションは、書き込み要求を処理する責任があります。 -The following abbreviated example from the [wifi-connection-server](../../../examples/network/ble/wifi-connection-server) example shows how characteristic write requests are handled. The `SSID` and `password` characteristics are strings and the `control` characteristic is a numeric value. When the BLE client writes the value 1 to the `control` characteristic, the app closes the client connection and initiates a WiFi connection: +以下の [wifi-connection-server](../../../examples/network/ble/wifi-connection-server) 例からの省略された例は、キャラクタリスティックの書き込み要求がどのように処理されるかを示しています。`SSID` と `password` のキャラクタリスティックは文字列であり、`control` のキャラクタリスティックは数値です。BLEクライアントが `control` キャラクタリスティックに値1を書き込むと、アプリはクライアント接続を閉じ、WiFi接続を開始します。 ```javascript onCharacteristicWritten(characteristic, value) { @@ -1324,22 +1326,22 @@ onCharacteristicWritten(characteristic, value) { *** #### `onCharacteristicRead(characteristic)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `characteristic ` | `object` | The characteristic object being read. +| `characteristic ` | `object` | 読み取られているキャラクタリスティックオブジェクト。 -The `characteristic` object contains the following properties: +`characteristic` オブジェクトには以下のプロパティが含まれています。 -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `uuid` | `string` | Instance of [Bytes](#classbytes) class containing Characteristic UUID. -| `name` | `string` | Characteristic name defined in the service JSON. -| `type` | `string` | Characteristic type defined in the service JSON. -| `handle` | `number` | Characteristic handle. +| `uuid` | `string` | キャラクタリスティック UUID を含む [Bytes](#classbytes) クラスのインスタンス。 +| `name` | `string` | サービス JSON で定義されたキャラクタリスティック名。 +| `type` | `string` | サービス JSON で定義されたキャラクタリスティックタイプ。 +| `handle` | `number` | キャラクタリスティックハンドル。 -The `onCharacteristicRead` callback is called when a client reads a service characteristic value on demand. The `BLEServer` application is responsible for handling the read request. +`onCharacteristicRead` コールバックは、クライアントがサービスのキャラクタリスティックの値を要求に応じて読み取るときに呼び出されます。`BLEServer` アプリケーションは、読み取り要求の処理を担当します。 -To respond to a read request corresponding to a numeric "status" characteristic: +数値の "status" キャラクタリスティックに対応する読み取り要求に応答するには、次のようにします。 ```javascript onReady() { @@ -1353,7 +1355,7 @@ onCharacteristicRead(characteristic) { *** #### `disconnect()` -Use the `disconnect` function to terminate the BLE client connection. +`disconnect` 関数を使用して、BLEクライアント接続を終了します。 ```javascript import {address} from "btutils"; @@ -1374,25 +1376,25 @@ onDisconnected(device) { *** #### `onConnected(device)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `device` | `object` | A `device` object. See the section [Class Client](#classclient) for more information. | +| `device` | `object` | `device` オブジェクト。詳細は [Class Client](#classclient) セクションを参照してください。 | -The `onConnected` callback function is called when a client connects to the `BLEServer`. +`onConnected` コールバック関数は、クライアントが `BLEServer` に接続したときに呼び出されます。 *** #### `onDisconnected(device)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `device` | `object` | A `device` object. See the section [Class Client](#classclient) for more information. | +| `device` | `object` | `device` オブジェクト。詳細は [Class Client](#classclient) セクションを参照してください。 | -The `onDisconnected` callback function is called when the client connection is closed. +`onDisconnected` コールバック関数は、クライアント接続が閉じられたときに呼び出されます。 *** #### `close()` -Use the `close` function to terminate any BLE client connection and release all BLE resources. +`close` 関数を使用して、BLEクライアント接続を終了し、すべてのBLEリソースを解放します。 ```javascript onDisconnected(device) { @@ -1402,30 +1404,30 @@ onDisconnected(device) { *** -## GATT Services -GATT services are defined by JSON files located in a BLE server or client project's `bleservices` directory. The JSON files are optional for BLE clients. Each JSON file defines a single service with one or more characteristics. The JSON is automatically converted to platform-specific native code by the Moddable `mcconfig` command line tool and the compiled object code is linked to the app. +## GATT サービス +GATTサービスは、BLEサーバーまたはクライアントプロジェクトの `bleservices` ディレクトリにあるJSONファイルによって定義されます。JSONファイルはBLEクライアントにとってオプションです。各JSONファイルは、1つ以上のキャラクタリスティックを持つ単一のサービスを定義します。JSONはModdableの `mcconfig` コマンドラインツールによってプラットフォーム固有のネイティブコードに自動的に変換され、コンパイルされたオブジェクトコードはアプリにリンクされます。 -The JSON file for a service consists of an object with a single `service` property. The `service` property is an object that includes the following top-level properties: +サービス用のJSONファイルは、単一の `service` プロパティを持つオブジェクトで構成されています。`service` プロパティは、以下のトップレベルプロパティを含むオブジェクトです: -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `uuid` | `string` | Service UUID. -| `characteristics` | `object` | An object with details about the service characteristic(s). Each key corresponds to a characteristic name. +| `uuid` | `string` | サービス UUID。 +| `characteristics` | `object` | サービスキャラクタリスティックに関する詳細を持つオブジェクト。各キーはキャラクタリスティック名に対応します。 -Each item in the `characteristics` object contains the following properties. Note that only the `uuid` and `type` properties are required for BLE client applications that include GATT services JSON files: +`characteristics` オブジェクトの各項目には、以下のプロパティが含まれています。GATTサービスJSONファイルを含むBLEクライアントアプリケーションでは、`uuid` と `type` プロパティのみが必須であることに注意してください。 -| Property | Type | Description | Required by BLE client | +| プロパティ | 型 | 説明 | BLE クライアントで必須 | | --- | --- | --- | :--- | -| `uuid` | `string` | Characteristic UUID. | Y -| `maxBytes` | `number` | Maximum number of bytes required to store the characteristic value. -| `type` | `string` | Optional JavaScript data value type. Supported types include `Array`, `ArrayBuffer`, `String`, `Uint8`, `Uint8Array`, `Int8Array`, `Int16Array`, `Uint16`, `Uint16Array`, and `Uint32`. If the `type` property is not present, the data value type defaults to `ArrayBuffer`. The `BLEServer` and `BLEClient` classes automatically convert characteristic values delivered in buffers by the underlying BLE implementation to the requested `type`. | Y -| `permissions` | `string` | Characteristic permissions. Supported permissions include `read`, `readEncrypted`, `write`, and `writeEncrypted`. Multiple permissions can be specified by comma-separating permission strings, but only one of read/readEncrypted and write/writeEncrypted can be specified for each characteristic. -| `properties` | `string` | Characteristic properties. Supported properties include `read`, `write`, `writeNoResponse`, `notify`, `indicate` and `extended`. Multiple properties can be specified by comma-separating property strings. -| `value` | `array`, `string`, or `number` | Optional characteristic value. The `BLEServer` class automatically converts the value specified here to the type specified by the `type` property. +| `uuid` | `string` | キャラクタリスティック UUID。 | Y +| `maxBytes` | `number` | キャラクタリスティックの値を格納するために必要な最大バイト数。 +| `type` | `string` | オプションの JavaScript データ値の型。サポートされている型には `Array`、`ArrayBuffer`、`String`、`Uint8`、`Uint8Array`、`Int8Array`、`Int16Array`、`Uint16`、`Uint16Array`、および `Uint32` が含まれます。`type` プロパティが存在しない場合、データ値の型はデフォルトで `ArrayBuffer` になります。`BLEServer` および `BLEClient` クラスは、基盤となる BLE 実装によってバッファで提供されるキャラクタリスティックの値を要求された `type` に自動的に変換します。 | Y +| `permissions` | `string` | キャラクタリスティックの権限。サポートされている権限には `read`、`readEncrypted`、`write`、および `writeEncrypted` が含まれます。複数の権限はカンマで区切って指定できますが、各キャラクタリスティックに対して read/readEncrypted と write/writeEncrypted のいずれか一方のみを指定できます。 +| `properties` | `string` | キャラクタリスティックのプロパティ。サポートされているプロパティには `read`、`write`、`writeNoResponse`、`notify`、`indicate`、および `extended` が含まれます。複数のプロパティはカンマで区切って指定できます。 +| `value` | `array`, `string`, または `number` | オプションのキャラクタリスティックの値。`BLEServer` クラスは、ここで指定された値を `type` プロパティで指定された型に自動的に変換します。 -Characteristics that include a `value` property are considered static. The `BLEServer` class automatically responds to read requests for static characteristic values, further reducing the script code required to host a GATT service. +`value` プロパティを含むキャラクタリスティックは静的と見なされます。`BLEServer` クラスは、静的キャラクタリスティックの値の読み取り要求に自動的に応答し、GATTサービスをホストするために必要なスクリプトコードをさらに削減します。 -The following is an example of JSON corresponding to a Bluetooth [Battery Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.battery_service.xml): +以下は、Bluetooth [Battery Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.battery_service.xml) に対応するJSONの例です: { "service": { @@ -1443,36 +1445,35 @@ The following is an example of JSON corresponding to a Bluetooth [Battery Servic } } -The service is defined as follows: +サービスは次のように定義されます: -* The service UUID is 0x180F -* The service contains a single characteristic named "battery" - * The characteristic UUID is 0x2A19 - * The characteristic represents an unsigned 8-bit value - * The characteristic value is 85 and clients only have permission to read the characteristic +* サービスUUIDは0x180Fです +* サービスには「battery」という名前の単一のキャラクタリスティックが含まれています + * キャラクタリスティックUUIDは0x2A19です + * キャラクタリスティックは符号なし8ビット値を表します + * キャラクタリスティックの値は85で、クライアントはキャラクタリスティックを読み取る権限のみを持ちます -## BLE Security - -BLE clients and servers use the `securityParameters` property accessor to optionally request link-layer security to protect data transferred between devices. Passkey pairing requires both devices to exchange and confirm the code before establishing a connection. Once the pairing process is complete, the connection and data transferred is encrypted. The BLE Security Manager (SM) defines the methods and protocols for pairing and key distribution. +## BLE セキュリティ +BLEクライアントとサーバーは、`securityParameters`プロパティアクセサを使用して、デバイス間で転送されるデータを保護するためにリンク層のセキュリティをオプションで要求します。パスキーのペアリングでは、接続を確立する前に両方のデバイスがコードを交換して確認する必要があります。ペアリングプロセスが完了すると、接続と転送されるデータは暗号化されます。BLEセキュリティマネージャー(SM)は、ペアリングとキー配布のための方法とプロトコルを定義します。 -## Class SM +## SMクラス -The `SM` class provides objects used to configure BLE client and server security requirements and device capabilities. The `SM` class is available to both `BLEClient` and `BLEServer` classes. The security callback functions defined here are hosted by the `BLEClient` and `BLEServer` classes. +`SM`クラスは、BLEクライアントとサーバーのセキュリティ要件とデバイスの機能を設定するために使用されるオブジェクトを提供します。`SM`クラスは、`BLEClient`クラスと`BLEServer`クラスの両方で利用可能です。ここで定義されているセキュリティコールバック関数は、`BLEClient`クラスと`BLEServer`クラスによってホストされます。 -The `IOCapability` object contains the following properties: +`IOCapability`オブジェクトには、次のプロパティが含まれています: -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `NoInputNoOutput` | `number` | Device has no input or output capabilities -| `DisplayOnly` | `number` | Device has only output capability -| `KeyboardOnly` | `number` | Device has only input capability -| `KeyboardDisplay` | `number` | Device has input and output capabilities -| `DisplayYesNo` | `number` | Device has output capability and button feedback for a Yes or No response +| `NoInputNoOutput` | `number` | デバイスには入力または出力機能がありません +| `DisplayOnly` | `number` | デバイスには出力機能のみがあります +| `KeyboardOnly` | `number` | デバイスには入力機能のみがあります +| `KeyboardDisplay` | `number` | デバイスには入力および出力機能があります +| `DisplayYesNo` | `number` | デバイスには出力機能と、YesまたはNoの応答のためのボタンフィードバックがあります -To request MITM protection with encryption on a keyboard device: +キーボードデバイスで暗号化によるMITM保護を要求するには: ```javascript import {IOCapability} from "sm"; @@ -1482,18 +1483,18 @@ onReady() { } ``` -### Functions +### 関数 #### `deleteBonding(address, addressType)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `address` | `object` | `ArrayBuffer` containing peer device Bluetooth address -| `addressType` | `number` | Peer device Bluetooth address type. Refer to `GAP.AddressType` for supported address types. +| `address` | `object` | ピアデバイスのBluetoothアドレスを含む`ArrayBuffer` | +| `addressType` | `number` | ピアデバイスのBluetoothアドレスタイプ。サポートされているアドレスタイプについては`GAP.AddressType`を参照してください。 | -Call the `deleteBonding` function to delete stored bonding information for the peer device with the provided `address` and `addressType`. The `onBondingDeleted` callback is called once the bond has been deleted. The `onBondingDeleted` callback is supported by both the `BLEClient` and `BLEServer` classes. +`deleteBonding`関数を呼び出して、指定された`address`と`addressType`を持つピアデバイスの保存されたボンディング情報を削除します。ボンドが削除されると、`onBondingDeleted`コールバックが呼び出されます。`onBondingDeleted`コールバックは、`BLEClient`クラスと`BLEServer`クラスの両方でサポートされています。 -To delete bonding information after disconnecting from the peer device: +ピアデバイスから切断した後にボンディング情報を削除するには: ```javascript onDisconnected(device) { @@ -1508,7 +1509,7 @@ onBondingDeleted(params) { #### `deleteAllBondings()` -Use the `deleteAllBondings` function to delete all bonding information and encryption keys from persistent storage: +`deleteAllBondings`関数を使用して、永続ストレージからすべてのボンディング情報と暗号化キーを削除します。 ```javascript onReady() { @@ -1520,12 +1521,12 @@ onReady() { #### `passkeyInput(address, value)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `address` | `object` | `ArrayBuffer` containing peer device Bluetooth address -| `value` | `number` | passkey value input +| `address` | `object` | ピアデバイスのBluetoothアドレスを含む`ArrayBuffer` +| `value` | `number` | 入力されたパスキーの値 -Call the `passkeyInput` function from the `onPasskeyInput` callback function to provide an input passkey value: +`onPasskeyInput`コールバック関数から`passkeyInput`関数を呼び出して、入力パスキーの値を提供します: ```javascript onPasskeyInput(params) { @@ -1538,12 +1539,12 @@ onPasskeyInput(params) { #### `passkeyReply(address, result)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `address` | `object` | `ArrayBuffer` containing peer device Bluetooth address -| `result` | `boolean` | Set `true` to confirm passkey value, `false` otherwise +| `address` | `object` | ピアデバイスのBluetoothアドレスを含む`ArrayBuffer` +| `result` | `boolean` | パスキーの値を確認するには`true`を設定し、そうでない場合は`false`を設定 -Call the `passkeyReply` function from the `onPasskeyConfirm` callback function to confirm the passkey displayed by the peer device: +`onPasskeyConfirm`コールバック関数から`passkeyReply`関数を呼び出して、ピアデバイスによって表示されたパスキーを確認します: ```javascript onPasskeyConfirm(params) { @@ -1556,11 +1557,11 @@ onPasskeyConfirm(params) { #### `onSecurityParameters(params)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `params` | `object` | Device security properties applied. +| `params` | `object` | 適用されたデバイスのセキュリティプロパティ。 -The `onSecurityParameters` callback is called after the device security requirements and I/O capabilities have been set. +`onSecurityParameters` コールバックは、デバイスのセキュリティ要件とI/O機能が設定された後に呼び出されます。 ```javascript import {IOCapability} from "sm"; @@ -1577,18 +1578,17 @@ onSecurityParameters() { #### `onAuthenticated(params)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `params` | `object` | Properties associated with the authentication procedure. +| `params` | `object` | 認証手続きに関連するプロパティ。 -The `params` object contains the following properties: +`params` オブジェクトには次のプロパティが含まれています: -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `bonded` | `boolean` | Set `true` if the device has bonded with the peer. +| `bonded` | `boolean` | デバイスがピアとボンディングしている場合は `true` に設定。 - -The `onAuthenticated` callback is called when an authentication procedure successfully completes, i.e. after successful device pairing or bonding. The `onAuthenticated` callback is supported by the `BLEClient` and `BLEServer` classes. +`onAuthenticated` コールバックは、認証手続きが正常に完了したとき、つまりデバイスのペアリングまたはボンディングが成功した後に呼び出されます。`onAuthenticated` コールバックは、`BLEClient` および `BLEServer` クラスでサポートされています。 ```javascript onAuthenticated(params) { @@ -1600,18 +1600,18 @@ onAuthenticated(params) { #### `onPasskeyConfirm(params)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `params` | `object` | Properties associated with the passkey confirmation. +| `params` | `object` | パスキー確認に関連するプロパティ。 -The `params` object contains the following properties: +`params` オブジェクトには以下のプロパティが含まれています: -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `address` | `object` | `ArrayBuffer` containing peer device Bluetooth address -| `passkey` | `number` | The passkey to confirm +| `address` | `object` | ピアデバイスのBluetoothアドレスを含む`ArrayBuffer` +| `passkey` | `number` | 確認するパスキー -The `onPasskeyConfirm` callback is called when the user needs to confirm a passkey value displayed on a peer device. The callback calls `passkeyReply` passing `true` or `false` to confirm the passkey value. +`onPasskeyConfirm` コールバックは、ユーザーがピアデバイスに表示されたパスキー値を確認する必要があるときに呼び出されます。コールバックは `passkeyReply` を呼び出し、パスキー値を確認するために `true` または `false` を渡します。 ```javascript onPasskeyConfirm(params) { @@ -1625,18 +1625,18 @@ onPasskeyConfirm(params) { #### `onPasskeyDisplay(params)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `params` | `object` | Properties associated with the passkey display. +| `params` | `object` | パスキー表示に関連するプロパティ。 -The `params` object contains the following properties: +`params` オブジェクトには以下のプロパティが含まれています: -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `address` | `object` | `ArrayBuffer` containing peer device Bluetooth address -| `passkey` | `number` | The passkey to display +| `address` | `object` | ピアデバイスのBluetoothアドレスを含む`ArrayBuffer` +| `passkey` | `number` | 表示するパスキー -The `onPasskeyDisplay` callback is called when the device needs to display a passkey. +`onPasskeyDisplay` コールバックは、デバイスがパスキーを表示する必要があるときに呼び出されます。 ```javascript onPasskeyDisplay(params) { @@ -1649,17 +1649,17 @@ onPasskeyDisplay(params) { #### `onPasskeyInput(params)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `params` | `object` | Properties associated with the passkey input. +| `params` | `object` | パスキー入力に関連するプロパティ。 -The `params` object contains the following properties: +`params` オブジェクトには次のプロパティが含まれています: -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `address` | `object` | `ArrayBuffer` containing peer device Bluetooth address +| `address` | `object` | ピアデバイスのBluetoothアドレスを含む `ArrayBuffer` -The `onPasskeyInput` callback is called when the device needs to input the passkey displayed by the peer device. The `inputPasskey` function is called to return the input passkey value. +`onPasskeyInput` コールバックは、デバイスがピアデバイスに表示されたパスキーを入力する必要があるときに呼び出されます。`inputPasskey` 関数は入力されたパスキー値を返すために呼び出されます。 ```javascript onPasskeyInput(params) { @@ -1673,17 +1673,17 @@ onPasskeyInput(params) { #### `onPasskeyRequested(params)` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `params` | `object` | Properties associated with the passkey to request. +| `params` | `object` | 要求するパスキーに関連するプロパティ。 -The `params` object contains the following properties: +`params` オブジェクトには次のプロパティが含まれています: -| Property | Type | Description | +| プロパティ | 型 | 説明 | | --- | --- | :--- | -| `address` | `object` | `ArrayBuffer` containing peer device Bluetooth address +| `address` | `object` | ピアデバイスのBluetoothアドレスを含む `ArrayBuffer` -The `onPasskeyRequested` callback is called when the device needs to request a passkey entry. The callback returns a numeric passkey value between 0 and 999,999. +`onPasskeyRequested` コールバックは、デバイスがパスキー入力を要求する必要があるときに呼び出されます。コールバックは0から999,999の間の数値のパスキー値を返します。 ```javascript onPasskeyRequested(params) { @@ -1692,38 +1692,38 @@ onPasskeyRequested(params) { return passkey; } ``` -> **Note:** Passkey values are integers, but must always include six digits. The host application is responsible for padding with leading zeros for display. +> **注:** パスキーの値は整数ですが、常に6桁を含める必要があります。ホストアプリケーションは、表示のために先頭にゼロを追加する責任があります。 -## BLE Whitelisting +## BLEホワイトリスティング -Whitelisting provides filtering of peer devices by Bluetooth address. A BLE client can use the whitelist to only receive peripheral scan responses and hence subsequent connections to devices in the whitelist. A BLE peripheral can use the whitelist to filter BLE client scans and connections. Whitelist filtering provides enhanced security by limiting communication to known and trusted BLE devices. +ホワイトリスティングは、Bluetoothアドレスによるピアデバイスのフィルタリングを提供します。BLEクライアントはホワイトリストを使用して、ホワイトリスト内のデバイスへの周辺機器スキャン応答とその後の接続のみを受信できます。BLE周辺機器はホワイトリストを使用して、BLEクライアントのスキャンと接続をフィルタリングできます。ホワイトリストフィルタリングは、既知の信頼できるBLEデバイスとの通信に限定することで、セキュリティを強化します。 -There is one BLE whitelist used by both the BLE client and server. The maximum number of whitelist entries allowed is platform-specific. +BLEクライアントとサーバーの両方で使用されるBLEホワイトリストは1つです。許可されるホワイトリストエントリの最大数は、プラットフォームに依存します。 -> **Note:** Whitelisting is not currently supported on the Blue Gecko platform. +> **注:** ホワイトリスティングは現在、Blue Geckoプラットフォームではサポートされていません。 -## Class GAPWhitelist +## GAPWhitelistクラス -The `GAPWhitelist` class provides functions for manipulating the BLE whitelist. +`GAPWhitelist` クラスは、BLEホワイトリストを操作するための関数を提供します。 ```javascript import GAPWhitelist from "gapwhitelist"; ``` -### Functions +### 関数 #### `add(address [,addressType])` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `address` | `string` or `object` | The peer address to whitelist. -| `addressType` | `number` | Optional peer address type. Defaults to `GAP.AddressType.PUBLIC`. +| `address` | `string` または `object` | ホワイトリストに追加するピアアドレス。 | +| `addressType` | `number` | オプションのピアアドレスタイプ。デフォルトは `GAP.AddressType.PUBLIC`。 | -Use the `add` function to add a peer device to the whitelist. +`add` 関数を使用して、ピアデバイスをホワイトリストに追加します。 -To add a Bluetooth address to the whitelist and receive only scan responses from devices in the whitelist: +Bluetoothアドレスをホワイトリストに追加し、ホワイトリスト内のデバイスからのみスキャン応答を受け取るには: ```javascript onReady() { @@ -1732,7 +1732,7 @@ onReady() { } ``` -To add a Bluetooth address to the whitelist and limit scan requests and connections to devices in the whitelist using a filter policy: +Bluetoothアドレスをホワイトリストに追加し、フィルターポリシーを使用してスキャン要求と接続をホワイトリスト内のデバイスに制限するには: ```javascript onReady() { @@ -1753,42 +1753,43 @@ onDisconnected() { #### `remove(address [,addressType])` -| Argument | Type | Description | +| 引数 | 型 | 説明 | | --- | --- | :--- | -| `address` | `string` or `object` | The peer address to whitelist. -| `addressType` | `number` | Optional peer address type. Defaults to `GAP.AddressType.PUBLIC`. +| `address` | `string` または `object` | ホワイトリストから削除するピアアドレス。 | +| `addressType` | `number` | オプションのピアアドレスタイプ。デフォルトは `GAP.AddressType.PUBLIC`。 | -Use the `remove` function to remove a peer device from the whitelist. +`remove` 関数を使用して、ピアデバイスをホワイトリストから削除します。 #### `clear()` -Use the `clear` function to remove all peer devices from the whitelist. +`clear` 関数を使用して、ホワイトリストからすべてのピアデバイスを削除します。 -## BLE Apps on ESP32 Platform -The `mcconfig` command line tool **automatically** configures the ESP-IDF [sdkconfig.defaults](https://github.com/Moddable-OpenSource/moddable/blob/public/build/devices/esp32/xsProj-esp32/sdkconfig.defaults) BLE options required by the host app. The ESP-IDF supports both the Apache [NimBLE](http://mynewt.apache.org/latest/network/index.html#) Bluetooth LE [5.1-certified](https://launchstudio.bluetooth.com/ListingDetails/97856) open-source host and the dual-mode [Bluedroid](https://www.espressif.com/sites/default/files/documentation/esp32_bluetooth_architecture_en.pdf) stack. NimBLE provides [several benefits](https://blog.moddable.com/blog/moddable-sdk-improvements-for-esp32-projects/) over Bluedroid, including smaller Flash/RAM footprint, fewer buffer copies, and faster builds. NimBLE is enabled by default by the Moddable SDK in ESP32 builds. +## ESP32プラットフォームでのBLEアプリ +`mcconfig` コマンドラインツールは、ホストアプリに必要なESP-IDFの[sdkconfig.defaults](https://github.com/Moddable-OpenSource/moddable/blob/public/build/devices/esp32/xsProj-esp32/sdkconfig.defaults) BLEオプションを**自動的に**設定します。ESP-IDFは、Apache [NimBLE](http://mynewt.apache.org/latest/network/index.html#) Bluetooth LE [5.1認証済み](https://launchstudio.bluetooth.com/ListingDetails/97856) オープンソースホストとデュアルモードの[Bluedroid](https://www.espressif.com/sites/default/files/documentation/esp32_bluetooth_architecture_en.pdf) スタックの両方をサポートしています。NimBLEは、Bluedroidに比べて、フラッシュ/RAMのフットプリントが小さい、バッファコピーが少ない、ビルドが速いなどの[いくつかの利点](https://blog.moddable.com/blog/moddable-sdk-improvements-for-esp32-projects/)を提供します。NimBLEは、ESP32ビルドでModdable SDKによってデフォルトで有効化されています。 ->**Note:** BLE options can be further customized by the host app, if necessary, by providing a pathname to a directory containing custom sdkconfig defaults entries in the application manifest. Refer to the [manifest](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/manifest.md) documentation for details. For example, the `CONFIG_BT_NIMBLE_MAX_CONNECTIONS` value can be increased to support more than one BLE client connection. This value should match the `max_connections` value in the application manifest. +>**注:** BLEオプションは、必要に応じてホストアプリによってさらにカスタマイズできます。これは、アプリケーションマニフェスト内でカスタムsdkconfigデフォルトエントリを含むディレクトリへのパス名を提供することによって行います。詳細については、[マニフェスト](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/tools/manifest.md)のドキュメントを参照してください。例えば、`CONFIG_BT_NIMBLE_MAX_CONNECTIONS`の値を増やして、複数のBLEクライアント接続をサポートすることができます。この値はアプリケーションマニフェストの`max_connections`値と一致する必要があります。 -To build BLE apps using the legacy Bluedroid implementation, set the `ESP32_BLUEDROID` build environment variable to `1`. This environment variable can be set on the `mcconfig` command line for convenience: +レガシーBluedroid実装を使用してBLEアプリをビルドするには、`ESP32_BLUEDROID`ビルド環境変数を`1`に設定します。この環境変数は、利便性のために`mcconfig`コマンドラインで設定できます: cd $MODDABLE/examples/network/ble/scanner ESP32_BLUEDROID=1 mcconfig -d -m -p esp32 -## BLE Apps on Blue Gecko Platform -Building and deploying BLE apps on Blue Gecko follow the same workflow outlined in our [Gecko developer documentation](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/devices/gecko/GeckoBuild.md). For BLE apps, we recommend starting from the `soc-ibeacon` Simplicity Studio example project. +## Blue GeckoプラットフォームでのBLEアプリ +Blue GeckoでのBLEアプリのビルドとデプロイは、[Gecko開発者ドキュメント](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/devices/gecko/GeckoBuild.md)で説明されているワークフローに従います。BLEアプリの場合、`soc-ibeacon` Simplicity Studioのサンプルプロジェクトから始めることをお勧めします。 -The [make.blue.mk](../../../build/devices/gecko/targets/blue/make.blue.mk) makefile includes variables that define the Gecko target platform, kit and part. The makefile is configured by default to build apps for the Blue Gecko [EFR32BG13P632F512GM48](https://www.silabs.com/products/wireless/bluetooth/blue-gecko-bluetooth-low-energy-socs/device.efr32bg13p632f512gm48) Bluetooth low energy chip mounted on the [BRD4104A](https://www.silabs.com/documents/login/reference-manuals/brd4104a-rm.pdf) 2.4 GHz 10 dBm Radio Board. To configure the build for a different Blue Gecko target, change the makefile `GECKO_BOARD`, `GECKO_PART`, `HWKIT` and `HWINC` variables accordingly. +[make.blue.mk](../../../build/devices/gecko/targets/blue/make.blue.mk) makefileには、Geckoターゲットプラットフォーム、キット、およびパートを定義する変数が含まれています。デフォルトでは、このmakefileは、[BRD4104A](https://www.silabs.com/documents/login/reference-manuals/brd4104a-rm.pdf) 2.4 GHz 10 dBmラジオボードに搭載されたBlue Gecko [EFR32BG13P632F512GM48](https://www.silabs.com/products/wireless/bluetooth/blue-gecko-bluetooth-low-energy-socs/device.efr32bg13p632f512gm48) Bluetooth低エネルギーチップ用のアプリをビルドするように設定されています。別のBlue Geckoターゲット用にビルドを設定するには、makefileの `GECKO_BOARD`、`GECKO_PART`、`HWKIT`、および `HWINC` 変数を適切に変更してください。 -To build the [scanner](../../../examples/network/ble/scanner) BLE app `xs_gecko.a` archive for Blue Gecko: +Blue Gecko用の [scanner](../../../examples/network/ble/scanner) BLEアプリ `xs_gecko.a` アーカイブをビルドするには、以下のコマンドを実行します。 cd $MODDABLE/examples/network/ble/scanner mcconfig -d -m -p gecko/blue -After building the BLE archive, the archive is linked to the native app hosted in Simplicity Studio. The `main()` native code function for a basic BLE client/server app can be reduced to the following: +BLEアーカイブをビルドした後、そのアーカイブはSimplicity Studioにホストされているネイティブアプリにリンクされます。基本的なBLEクライアント/サーバーアプリの `main()` ネイティブコード関数は、次のように簡略化できます。 +```c void main(void) { initMcu(); @@ -1801,48 +1802,49 @@ After building the BLE archive, the archive is linked to the native app hosted i xs_loop(); } } +``` -BLE apps require additional stack and heap. We've been able to run the Moddable BLE example apps using the following values: +BLEアプリケーションは追加のスタックとヒープを必要とします。以下の値を使用して、Moddable BLEのサンプルアプリケーションを実行することができました: __STACK_SIZE=0x2000 __HEAP_SIZE=0xA000 -Simplicity Studio includes a **BLE GATT Configurator** to define BLE services. Moddable apps define BLE services in JSON files and hence don't use the `gatt_db.c` and `gatt_db.h` files generated by the configurator tool. These two files must be removed from the Simplicity Studio project. +Simplicity Studioには、BLEサービスを定義するための**BLE GATT Configurator**が含まれています。ModdableアプリケーションはJSONファイルでBLEサービスを定義するため、コンフィギュレータツールによって生成される`gatt_db.c`と`gatt_db.h`ファイルを使用しません。これらの2つのファイルはSimplicity Studioプロジェクトから削除する必要があります。 -## BLE Example Apps -The Moddable SDK includes many BLE client and server example apps to build from. We recommend starting from an example app, since the apps demonstrate how to implement common use cases: +## BLEサンプルアプリケーション +Moddable SDKには、多くのBLEクライアントおよびサーバーのサンプルアプリケーションが含まれており、それを基に構築することができます。一般的な使用例を実装する方法を示しているため、サンプルアプリケーションから始めることをお勧めします: -### Client Apps +### クライアントアプリケーション -| Name | Description | +| 名前 | 説明 | | :---: | :--- | -| [colorific](../../../examples/network/ble/colorific) | Randomly changes the color of a BLE bulb every 100 ms. -| [discovery](../../../examples/network/ble/discovery) | Demonstrates how to discover a specific GATT service and characteristic. -| [heart-rate-client](../../../examples/network/ble/heart-rate-client) | Demonstrates how to implement a [Heart Rate Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.heart_rate.xml) client. -| [hid-keyboard](../../../examples/network/ble/hid-keyboard) | Demonstrates how to connect to a BLE keyboard that implements the HID over GATT profile. -| [hid-mouse](../../../examples/network/ble/hid-mouse) | Demonstrates how to connect to a BLE mouse that implements the HID over GATT profile. -| [ios-media-sync](../../../examples/network/ble/ios-media-sync) | [Commodetto](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/commodetto/commodetto.md) app that demonstrates how to implement an [Apple Media Service](https://developer.apple.com/library/archive/documentation/CoreBluetooth/Reference/AppleMediaService_Reference/Specification/Specification.html#//apple_ref/doc/uid/TP40014716-CH1-SW48) client. -| [ios-time-sync](../../../examples/network/ble/ios-time-sync) | Demonstrates how to set the device clock by connecting to the iPhone [Current Time Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.current_time.xml). -| [powermate](../../../examples/network/ble/powermate) | Receives button spin and press notifications from the [Griffin BLE Multimedia Control Knob](https://griffintechnology.com/us/powermate-bluetooth). -| [scanner](../../../examples/network/ble/scanner) | Scans for and displays peripheral advertised names. -| [scanner-whitelist](../../../examples/network/ble/scanner-whitelist) | Scans for and displays whitelisted peripheral advertised name. -| [security-client](../../../examples/network/ble/security-client) | Demonstrates how to implement a secure health thermometer BLE client using SMP. The `security-client` can connect to the [security-server](../../../examples/network/ble/security-server) app. -| [sensortag](../../../examples/network/ble/sensortag) | Receives sensor notifications from the [TI CC2541 SensorTag](http://www.ti.com/tool/CC2541DK-SENSOR#technicaldocuments) on-board sensors. -| [tempo](../../../examples/network/ble/tempo) | Reads temperature, humidity and barometric pressure from a [Blue Maestro Environment Monitor](https://www.bluemaestro.com/product/tempo-environment-monitor/) beacon. -| [uart-client](../../../examples/network/ble/uart-client) | Shows how implement a Nordic UART Service client. The `uart-client` can connect to the [uart-server](../../../examples/network/ble/uart-server) app. - -### Server Apps - -| Name | Description | +| [colorific](../../../examples/network/ble/colorific) | BLE電球の色を100ミリ秒ごとにランダムに変更します。 +| [discovery](../../../examples/network/ble/discovery) | 特定のGATTサービスとキャラクタリスティックを発見する方法を示します。 +| [heart-rate-client](../../../examples/network/ble/heart-rate-client) | [心拍数サービス](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.heart_rate.xml)クライアントを実装する方法を示します。 +| [hid-keyboard](../../../examples/network/ble/hid-keyboard) | HID over GATTプロファイルを実装するBLEキーボードに接続する方法を示します。 +| [hid-mouse](../../../examples/network/ble/hid-mouse) | HID over GATTプロファイルを実装するBLEマウスに接続する方法を示します。 +| [ios-media-sync](../../../examples/network/ble/ios-media-sync) | [Apple Media Service](https://developer.apple.com/library/archive/documentation/CoreBluetooth/Reference/AppleMediaService_Reference/Specification/Specification.html#//apple_ref/doc/uid/TP40014716-CH1-SW48)クライアントを実装する方法を示す[Commodetto](https://github.com/Moddable-OpenSource/moddable/blob/public/documentation/commodetto/commodetto.md)アプリ。 +| [ios-time-sync](../../../examples/network/ble/ios-time-sync) | iPhoneの[現在時刻サービス](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.current_time.xml)に接続してデバイスの時計を設定する方法を示します。 +| [powermate](../../../examples/network/ble/powermate) | [Griffin BLEマルチメディアコントロールノブ](https://griffintechnology.com/us/powermate-bluetooth)からボタンの回転と押下通知を受信します。 +| [scanner](../../../examples/network/ble/scanner) | 周辺機器のアドバタイズ名をスキャンして表示します。 +| [scanner-whitelist](../../../examples/network/ble/scanner-whitelist) | ホワイトリストに登録された周辺機器のアドバタイズ名をスキャンして表示します。 +| [security-client](../../../examples/network/ble/security-client) | SMPを使用してセキュアな健康温度計BLEクライアントを実装する方法を示します。`security-client`は[security-server](../../../examples/network/ble/security-server)アプリに接続できます。 +| [sensortag](../../../examples/network/ble/sensortag) | [TI CC2541 SensorTag](http://www.ti.com/tool/CC2541DK-SENSOR#technicaldocuments)のオンボードセンサーからセンサー通知を受信します。 +| [tempo](../../../examples/network/ble/tempo) | [Blue Maestro環境モニター](https://www.bluemaestro.com/product/tempo-environment-monitor/)ビーコンから温度、湿度、気圧を読み取ります。 +| [uart-client](../../../examples/network/ble/uart-client) | Nordic UARTサービスクライアントを実装する方法を示します。`uart-client`は[uart-server](../../../examples/network/ble/uart-server)アプリに接続できます。 + +### サーバーアプリケーション + +| 名前 | 説明 | | :---: | :--- | -| [advertiser](../../../examples/network/ble/advertiser) | Broadcasts advertisements until a BLE client connects. -| [advertiser-notify](../../../examples/network/ble/advertiser-whitelist) | Demonstrates how to configure advertiser to receive notification callbacks for each advertising data packet sent. -| [advertiser-whitelist](../../../examples/network/ble/advertiser-whitelist) | Broadcasts advertisements until the whitelisted BLE client connects. -| [health-thermometer-server](../../../examples/network/ble/health-thermometer-server) | Implements the Bluetooth [Health Thermometer Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.health_thermometer.xml). -| [health-thermometer-server-gui](../../../examples/network/ble/health-thermometer-server-gui) | [Piu](../../../documentation/piu/piu.md) app for ESP32 that implements the Bluetooth [Health Thermometer Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.health_thermometer.xml). -| [heart-rate-server](../../../examples/network/ble/heart-rate-server) | Implements the Bluetooth [Heart Rate Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.heart_rate.xml). -| [security-server](../../../examples/network/ble/security-server) | Demonstrates how to implement a secure health thermometer BLE server using SMP. The `security-server` can connect to the [security-client](../../../examples/network/ble/security-client) app. -| [uri-beacon](../../../examples/network/ble/uri-beacon) | Implements a [UriBeacon](https://github.com/google/uribeacon/tree/uribeacon-final/specification) compatible with Google's [Physical Web](https://github.com/google/physical-web) discovery service. -| [wifi-connection-server](../../../examples/network/ble/wifi-connection-server) | Deploys a BLE WiFi connection service on ESP32. The connection service allows BLE clients to connect the BLE device to a WiFi access point, by writing the SSID and password characteristics. -| [uart-server](../../../examples/network/ble/uart-server) | Shows how implement a Nordic UART Service server. The `uart-server` can connect to the [uart-client](../../../examples/network/ble/uart-client) app. +| [advertiser](../../../examples/network/ble/advertiser) | BLEクライアントが接続するまでアドバタイズをブロードキャストします。 +| [advertiser-notify](../../../examples/network/ble/advertiser-whitelist) | 送信された各アドバタイズデータパケットに対して通知コールバックを受け取るようにアドバタイズ主を設定する方法を示します。 +| [advertiser-whitelist](../../../examples/network/ble/advertiser-whitelist) | ホワイトリストに登録されたBLEクライアントが接続するまでアドバタイズをブロードキャストします。 +| [health-thermometer-server](../../../examples/network/ble/health-thermometer-server) | Bluetooth [Health Thermometer Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.health_thermometer.xml) を実装します。 +| [health-thermometer-server-gui](../../../examples/network/ble/health-thermometer-server-gui) | ESP32用の[Piu](../../../documentation/piu/piu.md)アプリで、Bluetooth [Health Thermometer Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.health_thermometer.xml) を実装します。 +| [heart-rate-server](../../../examples/network/ble/heart-rate-server) | Bluetooth [Heart Rate Service](https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Services/org.bluetooth.service.heart_rate.xml) を実装します。 +| [security-server](../../../examples/network/ble/security-server) | SMPを使用してセキュアな健康温度計BLEサーバーを実装する方法を示します。`security-server`は[security-client](../../../examples/network/ble/security-client)アプリに接続できます。 +| [uri-beacon](../../../examples/network/ble/uri-beacon) | Google's [Physical Web](https://github.com/google/physical-web) 発見サービスと互換性のある[UriBeacon](https://github.com/google/uribeacon/tree/uribeacon-final/specification)を実装します。 +| [wifi-connection-server](../../../examples/network/ble/wifi-connection-server) | ESP32上でBLE WiFi接続サービスを展開します。この接続サービスにより、BLEクライアントはSSIDとパスワードのキャラクタリスティックを書き込むことでBLEデバイスをWiFiアクセスポイントに接続できます。 +| [uart-server](../../../examples/network/ble/uart-server) | Nordic UART Serviceサーバーを実装する方法を示します。`uart-server`は[uart-client](../../../examples/network/ble/uart-client)アプリに接続できます。