characteristic
説明
characteristic
オブジェクトは、Bluetooth® Low Energy 周辺デバイスの特性を表します。オブジェクトの Attributes
プロパティで読み取りまたは書き込みがサポートされている場合は、read
を使用して特性の値を読み取るか、write
を使用して特性の値を書き込むことができます。特性が記述子をもつ場合は、descriptor
を使用して記述子にアクセスすることもできます。
作成
構文
説明
は、サービス名と特性名を使用して、周辺デバイス c
= characteristic(b
,serviceName
,characteristicName
)b
の特性を表すオブジェクトを作成します。serviceName
と characteristicName
は、ble
オブジェクト b
の Characteristics
プロパティを表示することによって特定します。
は、特性の UUID とサービスの UUID を使用して、特性のオブジェクトを作成します。c
= characteristic(b
,serviceUUID
,characteristicUUID
)serviceUUID
と characteristicUUID
は、ble
オブジェクト b
の Characteristics
プロパティを表示することによって特定します。
入力引数
b
— Bluetooth Low Energy 周辺デバイスの接続
ble
オブジェクト
Bluetooth Low Energy 周辺デバイスの接続。ble
オブジェクトとして指定します。
serviceName
— サービス名
文字ベクトル | string スカラー
特性のサービス名。文字ベクトルまたは string スカラーとして指定します。serviceName
は、周辺デバイスを表す ble
オブジェクトの Characteristics
テーブルで特定します。ServiceName
列に有効な値がリストされます。
標準のサービスの完全なリストおよびそれらの解釈方法については、Bluetooth SIG Web サイトを参照してください。Characteristics
テーブル内のカスタム サービスにはすべて "Custom"
という名前が付いており、UUID の値によって区別されています。サービス名が "Custom"
である場合は、サービスの UUID を使用してアクセスしてください。
例: c = characteristic(b,"Current Time Service","Current Time")
は、"Current Time Service"
の "Current Time"
特性を表すオブジェクトを作成します。
データ型: char
| string
characteristicName
— 特性名
文字ベクトル | string スカラー
特性名。文字ベクトルまたは string スカラーとして指定します。characteristicName
は、周辺デバイスを表す ble
オブジェクトの Characteristics
テーブルで特定します。CharacteristicName
列に有効な値がリストされます。
標準の特性の完全なリストおよびそれらの解釈方法については、Bluetooth SIG Web サイトを参照してください。Characteristics
テーブル内のカスタム特性にはすべて "Custom"
という名前が付いており、UUID の値によって区別されています。特性名が "Custom"
である場合は、特性の UUID を使用してアクセスしてください。
例: c = characteristic(b,"Current Time Service","Current Time")
は、"Current Time Service"
の "Current Time"
特性を表すオブジェクトを作成します。
データ型: char
| string
serviceUUID
— サービスの UUID
文字ベクトル | string スカラー
特性のサービスの UUID。文字ベクトルまたは string スカラーとして指定します。serviceUUID
は、周辺デバイスを表す ble
オブジェクトの Characteristics
テーブルで特定します。ServiceUUID
列に有効な値がリストされます。
標準のサービスの完全なリストおよびそれらの解釈方法については、Bluetooth SIG Web サイトを参照してください。サービス名が "Custom"
である場合は、サービスの UUID を使用してアクセスしてください。
例: c = characteristic(b,"1805","2A2B")
は、UUID "1805
" をもつサービスの、UUID "2A2B
" をもつ特性を表すオブジェクトを作成します。
データ型: char
| string
characteristicUUID
— 特性の UUID
文字ベクトル | string スカラー
特性の UUID。文字ベクトルまたはスカラー string として指定します。characteristicUUID
は、周辺デバイスを表す ble
オブジェクトの Characteristics
テーブルで特定します。有効な値は、CharacteristicUUID
列にリストされている値です。
標準の特性の完全なリストおよびそれらの解釈方法については、Bluetooth SIG Web サイトを参照してください。特性名が "Custom"
である場合は、特性の UUID を使用してアクセスしてください。
例: c = characteristic(b,"1805","2A2B")
は、UUID "1805
" をもつサービスの、UUID "2A2B
" をもつ特性を表すオブジェクトを作成します。
データ型: char
| string
プロパティ
Name
— 特性名
string スカラー
この プロパティ は読み取り専用です。
特性名。string スカラーとして返されます。
データ型: string
UUID
— 特性の UUID
string スカラー
この プロパティ は読み取り専用です。
特性の UUID。string スカラーとして返されます。この値は各特性に固有です。
データ型: string
Attributes
— 特性の属性
string 配列
この プロパティ は読み取り専用です。
特性の属性。string 配列として返されます。このプロパティの値は、関数 read
、write
、subscribe
、および unsubscribe
の動作を決定します。取り得る値は以下のとおりです。
値 | 説明 |
---|---|
"Read" | 特性は読み取り可能 |
"Write" | 特性は書き込み可能 |
"WriteWithoutResponse" | 特性は応答なしのパケットで書き込み可能 |
"AuthenticatedSignedWrites" | 特性は署名付きの書き込みをサポート |
"Notify" | 特性は通知をサポート |
"Indicate" | 特性は表示をサポート |
"Broadcast" | 特性はアドバタイズ パケットを伴うブロードキャストをサポート |
"ExtendedProperties" | 特性は追加の属性をもつ ExtendedProperties 記述子を含む |
"NotifyEncryptionRequired" (macOS のみ) | 特性は信頼できるデバイスからの通知のみをサポート |
"IndicateEncryptionRequired" (macOS のみ) | 特性は信頼できるデバイスからの表示のみをサポート |
データ型: string
DataAvailableFcn
— データ利用可能関数
関数ハンドル
データ利用可能関数。関数ハンドルとして返されます。このプロパティは、関数ハンドルを割り当てるまでは空の配列です。このプロパティを、通知や表示をサポートする特性に使用します。
このプロパティにコールバックを割り当てる方法を示す例は、コールバック関数を使用した Bluetooth Low Energy 周辺デバイスからの特性データの読み取りを参照してください。
例:
特性からデータを読み取って表示し、ハンドルを作成し、ハンドルをこのプロパティに割り当てる関数 displayHeartRate
を作成します。
c.DataAvailableFcn = @displayHeartRate;
unsubscribe
を使用します。
データ型: function_handle
Descriptors
— 特性の記述子
table
特性の記述子。table として返されます。table にリストされている特定の記述子にアクセスするには、descriptor
を使用してオブジェクトを作成します。この table には以下の列があります。
列 | 説明 |
---|---|
DescriptorName | 記述子の名前 (string として返される) |
DescriptorUUID | 記述子の UUID (string として返される) |
Attributes | 記述子の読み取りまたは書き込み権限 (cell 配列として返される) |
データ型: table
オブジェクト関数
read | Bluetooth Low Energy 周辺デバイス上で特性または記述子のデータを読み取る |
write | Bluetooth Low Energy 周辺デバイス上の特性または記述子にデータを書き込む |
subscribe | 特性の通知または特性の表示のサブスクライブ |
unsubscribe | 特性の通知および特性の表示のサブスクライブ解除 |
descriptor | Bluetooth Low Energy 周辺デバイス上の記述子へのアクセス |
例
Bluetooth Low Energy 周辺デバイス上の特性へのアクセス
近くにある Bluetooth Low Energy 周辺デバイスに接続します。
b = ble("DemoDev")
b = ble with properties: Name: "DemoDev" Address: "FF548EA5658F" Connected: 1 Services: [5×2 table] Characteristics: [10×5 table] Show services and characteristics
このデバイス上にある利用可能な特性をリストします。
b.Characteristics
ans=10×5 table
ServiceName ServiceUUID CharacteristicName CharacteristicUUID Attributes
___________________ ______________________________________ ____________________________________________ ______________________________________ ______________
"Generic Access" "1800" "Device Name" "2A00" {1×2 string }
"Generic Access" "1800" "Appearance" "2A01" {["Read" ]}
"Generic Access" "1800" "Peripheral Preferred Connection Parameters" "2A04" {["Read" ]}
"Generic Access" "1800" "Central Address Resolution" "2AA6" {["Read" ]}
"Generic Attribute" "1801" "Service Changed" "2A05" {["Indicate"]}
"Heart Rate" "180D" "Heart Rate Measurement" "2A37" {["Notify" ]}
"Heart Rate" "180D" "Body Sensor Location" "2A38" {["Read" ]}
"Battery Service" "180F" "Battery Level" "2A19" {["Read" ]}
"Custom" "03B80E5A-EDE8-4B33-A751-6CE34EC4C700" "Custom" "7772E5DB-3868-4112-A1A9-F2669D106BF3" {1×6 string }
"Custom" "03B80E5A-EDE8-4B33-A751-6CE34EC4C700" "Custom" "7772E5DC-3868-4112-A1A9-F2669D106BF3" {1×3 string }
このリストには、すべての特性と、それぞれのサービスが表示されます。一部のサービスには複数の特性があります。リストには、各特性の属性も表示されます。
"Battery Level"
特性を表す characteristic オブジェクトを作成します。
c = characteristic(b,"Battery Service","Battery Level")
c = Characteristic with properties: Name: "Battery Level" UUID: "2A19" Attributes: "Read" Descriptors: []
あるいは、名前の代わりに UUID を使用してオブジェクトを作成することもできます。
c = characteristic(b,"180F","2A19")
c = Characteristic with properties: Name: "Battery Level" UUID: "2A19" Attributes: "Read" Descriptors: []
このオブジェクトは "Battery Level"
特性を表します。これには Read
属性があるため、read
を使用して特性の値を取得できます。
バージョン履歴
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)