ble
説明
ble
オブジェクトは、コンピューターから Bluetooth® Low Energy 周辺デバイスへの接続を表します。blelist
を使用して、近くにある接続可能なデバイスを見つけます。
作成
説明
入力引数
name
— デバイス名
文字ベクトル | string スカラー
デバイス名。文字ベクトルまたは string スカラーとして指定します。blelist
によって返される情報を使用して、接続先の周辺デバイスの名前を特定します。デバイスに name
がない場合は、アドレスを使用して接続します。
例: b = ble("Tile")
は、"Tile
" という名前の周辺デバイスに接続します。
データ型: char
| string
address
— デバイス アドレス
文字ベクトル | string スカラー
デバイス アドレス。文字ベクトルまたは string スカラーとして指定します。blelist
によって返される情報を使用して、接続先の周辺デバイスのアドレスを特定します。デバイスに name
がない場合は、アドレスを使用して接続します。
例: b = ble("5A8769A09DA6")
は、Windows® コンピューター上で MAC アドレス "5A8769A09DA6
" をもつ周辺デバイスに接続します。
例: b = ble("121B0BAC-0DE7-4FB1-909A-EEA6877DBC5C")
は、macOS コンピューター上でランダムな OS 割り当てアドレス "121B0BAC-0DE7-4FB1-909A-EEA6877DBC5C
" をもつ周辺デバイスに接続します。
データ型: char
| string
プロパティ
Name
— 周辺デバイス名
string スカラー
この プロパティ は読み取り専用です。
周辺デバイス名。string スカラーとして返されます。
データ型: string
Address
— 周辺デバイス アドレス
string スカラー
この プロパティ は読み取り専用です。
周辺デバイス アドレス。string スカラーとして返されます。Windows では、この値はデバイスの 48 ビットの Bluetooth MAC アドレスです。macOS では、この値はランダムな 128 ビットの OS 割り当てアドレスです。
データ型: string
Connected
— 周辺デバイスの接続ステータス
true
または 1
| false
または 0
この プロパティ は読み取り専用です。
周辺デバイスの接続ステータス。数値もしくは logical の 1
(true
) または 0
(false
) として返されます。
データ型: logical
Services
— 周辺デバイスに含まれているサービス
table
この プロパティ は読み取り専用です。
周辺デバイスに含まれているサービス。table として返されます。table には次の列があります。
列 | 説明 |
---|---|
ServiceName | 周辺デバイスに含まれているサービスの名前。string として返されます。 |
ServiceUUID | 周辺デバイスに含まれているサービスの UUID。string として返されます。 |
標準のサービスおよびそれらの UUID の完全なリストは、Bluetooth SIG Web サイトを参照してください。すべてのカスタム サービスは "Custom
" という名前をもち、UUID 値で区別されます。
メモ
macOS では、"Generic Access
" サービスと "Generic Attributes
" サービスおよびそれらの特性は非表示になっています。Services
プロパティと Characteristics
プロパティには表示されません。
データ型: table
Characteristics
— 周辺デバイスに含まれている特性
table
この プロパティ は読み取り専用です。
周辺デバイスに含まれている特性。table として返されます。table にリストされている特定の特性にアクセスするには、characteristic
を使用してオブジェクトを作成します。この table には次の列があります。
列 | 説明 |
---|---|
ServiceName | 周辺デバイスに含まれているサービスの名前。string として返されます。 |
ServiceUUID | 周辺デバイスに含まれているサービスの UUID。string として返されます。 |
CharacteristicName | 周辺デバイスに含まれている特性の名前。string として返されます。 |
CharacteristicUUID | 周辺デバイスに含まれている特性の UUID。string として返されます。 |
Attributes | 特性に対してサポートされている操作。cell 配列として返されます。取り得る値については、Attributesプロパティを参照してください。 |
標準の特性の完全なリストおよびそれらの解釈方法については、Bluetooth SIG Web サイトを参照してください。すべてのカスタム特性は Characteristics
table 内で "Custom
" という名前をもち、UUID 値で区別されます。
メモ
macOS では、"Generic Access
" サービスと "Generic Attributes
" サービスおよびそれらの特性は非表示になっています。Services
プロパティと Characteristics
プロパティには表示されません。
データ型: table
オブジェクト関数
characteristic | Bluetooth Low Energy 周辺デバイスの特性にアクセス |
例
名前を使用した Bluetooth Low Energy 周辺デバイスへの接続
Bluetooth Low Energy 周辺デバイスを検索して接続を確立します。
blelist
を使用して、近くにある "Gear Fit2 (E16A)"
という名前の周辺デバイスをスキャンします。
blelist("Name","Gear Fit2 (E16A)")
ans=1×5 table
Index Name Address RSSI Advertisement
_____ __________________ ______________ ____ _____________
1 "Gear Fit2 (E16A)" "8498663EE16A" -61 [1×1 struct]
デバイスへの接続を作成します。
b = ble("Gear Fit2 (E16A)")
b = ble with properties: Name: "Gear Fit2 (E16A)" Address: "8498663EE16A" Connected: 1 Services: [2×2 table] Characteristics: [3×5 table] Show services and characteristics
Windows 上のアドレスを使用した Bluetooth Low Energy 周辺デバイスへの接続
Bluetooth Low Energy 周辺デバイスを検索して接続を確立します。
blelist
を使用して、近くにある "Gear Fit2 (E16A)"
という名前の周辺デバイスをスキャンします。
blelist("Name","Gear Fit2 (E16A)")
ans=1×5 table
Index Name Address RSSI Advertisement
_____ __________________ ______________ ____ _____________
1 "Gear Fit2 (E16A)" "8498663EE16A" -58 [1×1 struct]
"8498663EE16A"
というアドレスをもつデバイスへの接続を作成します。Windows® コンピューターでは、このアドレスは、周辺デバイスの 48 ビットの Bluetooth MAC アドレスを表します。
b = ble("8498663EE16A")
b = ble with properties: Name: "Gear Fit2 (E16A)" Address: "8498663EE16A" Connected: 1 Services: [2×2 table] Characteristics: [3×5 table] Show services and characteristics
macOS 上のアドレスを使用した Bluetooth Low Energy 周辺デバイスへの接続
Bluetooth Low Energy 周辺デバイスを検索して接続を確立します。
blelist
を使用して、近くにある "Gear Fit2 (E16A)"
という名前の周辺デバイスをスキャンします。
blelist("Name","Gear Fit2 (E16A)")
ans=1×5 table
Index Name Address RSSI Advertisement
_____ __________________ ______________________________________ ____ _____________
1 "Gear Fit2 (E16A)" "2F4AFADA-1F14-4BBD-A1F1-E7E64C0CF5BA" -49 [1×1 struct]
"2F4AFADA-1F14-4BBD-A1F1-E7E64C0CF5BA"
というアドレスをもつデバイスへの接続を作成します。macOS コンピューターでは、このアドレスは、周辺デバイスのランダムな 128 ビットの OS 割り当てアドレスを表します。
b = ble("2F4AFADA-1F14-4BBD-A1F1-E7E64C0CF5BA")
b = ble with properties: Name: "Gear Fit2 (E16A)" Address: "2F4AFADA-1F14-4BBD-A1F1-E7E64C0CF5BA" Connected: 1 Services: [] Characteristics: [] Show services and characteristics
バージョン履歴
R2019b で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)