descriptor - Access a descriptor on Bluetooth Low Energy peripheral device - MATLAB (original) (raw)
Main Content
Access a descriptor on Bluetooth Low Energy peripheral device
Description
A descriptor
object represents a descriptor of a Bluetooth® Low Energy peripheral device. If read or write are supported in the object[Attributes](matlabshared.blelib.descriptor.html#mw%5Ffc98a0e2-dc38-4a64-8df6-7c555b885bc9)
property, you can read data using read or write data using write.
Creation
Syntax
Description
`d` = descriptor([c](#mw%5F690cf29e-7f26-44db-868f-e28fb43b3c50),[descriptorName](#mw%5F016b0303-cc56-435f-9020-74361c2fc6d0))
creates an object that represents the descriptor specified by its name. IdentifydescriptorName
by viewing the Descriptors
property of the characteristic object c
.
`d` = descriptor([c](#mw%5F690cf29e-7f26-44db-868f-e28fb43b3c50),[descriptorUUID](#mw%5F15809157-d266-4e6f-b850-2ab7056c1089))
creates an object that represents the descriptor specified by its UUID. IdentifydescriptorUUID
by viewing the Descriptors
property of the characteristic object c
.
Input Arguments
Characteristic of Bluetooth Low Energy peripheral device, specified as a characteristic object.
Descriptor name, specified as a character vector or string scalar. IdentifydescriptorName
in the Descriptors
table of the characteristic object. The DescriptorName
column lists the valid values.
Example: d = descriptor(c,"Client Characteristic Configuration")
creates an object that represents the "Client Characteristic Configuration
" descriptor on the characteristicc
.
Data Types: char
| string
Descriptor UUID, specified as a character vector or string scalar. IdentifydescriptorUUID
in the Descriptors
table of the characteristic object. The DescriptorUUID
column lists the valid values.
Example: d = descriptor(c,"2902")
creates an object that represents the descriptor with UUID "2902
" on the characteristicc
.
Data Types: char
| string
Properties
This property is read-only.
Descriptor name, returned as a string scalar.
Data Types: string
This property is read-only.
Descriptor UUID, returned as a string scalar. This value is specific to each descriptor.
Data Types: string
This property is read-only.
Descriptor attributes that describe the read and write permissions, returned as a string array. Possible values follow.
Value | Description |
---|---|
"Read" | Descriptor is readable using read |
"Write" | Descriptor is writable using write |
Data Types: string
Object Functions
read | Read characteristic or descriptor data on a Bluetooth Low Energy peripheral device |
---|---|
write | Write data to a characteristic or descriptor on a Bluetooth Low Energy peripheral device |
Examples
Create a connection to a nearby Bluetooth Low Energy peripheral device.
b = ble with properties:
Name: "Thingy"
Address: "F2DF635320F6"
Connected: 1
Services: [9×2 table]
Characteristics: [38×5 table]
Show services and characteristics
Create a characteristic object that represents the "Temperature"
characteristic.
c = characteristic(b,"Weather Station Service","Temperature")
c = Characteristic with properties:
Name: "Temperature"
UUID: "EF680201-9B35-4933-9B10-52FFA9740042"
Attributes: "Notify"
Descriptors: [1x3 table]
DataAvailableFcn: []
Show descriptors
List the descriptors for the characteristic.
ans=1×3 table DescriptorName DescriptorUUID Attributes _____________________________________ ______________ ____________
"Client Characteristic Configuration" "2902" {1×2 string}
Create a descriptor object that represents "Client Characteristic Configuration"
.
d = descriptor(c,"Client Characteristic Configuration")
d = Descriptor with properties:
Name: "Client Characteristic Configuration"
UUID: "2902"
Attributes: ["Read" "Write"]
Alternatively, you can use the UUID instead of the name to create the object.
d = Descriptor with properties:
Name: "Client Characteristic Configuration"
UUID: "2902"
Attributes: ["Read" "Write"]
This object represents the "Client Characteristic Configuration"
descriptor. Since it has both Read
and Write
attributes, you can use read or write.
Version History
Introduced in R2019b