Main Content

descriptor

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 property, you can read data using read or write data using write.

Creation

Description

d = descriptor(c,descriptorName) creates an object that represents the descriptor specified by its name. Identify descriptorName by viewing the Descriptors property of the characteristic object c.

example

d = descriptor(c,descriptorUUID) creates an object that represents the descriptor specified by its UUID. Identify descriptorUUID by viewing the Descriptors property of the characteristic object c.

example

Input Arguments

expand all

Characteristic of Bluetooth Low Energy peripheral device, specified as a characteristic object.

Descriptor name, specified as a character vector or string scalar. Identify descriptorName 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 characteristic c.

Data Types: char | string

Descriptor UUID, specified as a character vector or string scalar. Identify descriptorUUID 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 characteristic c.

Data Types: char | string

Properties

expand all

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.

ValueDescription
"Read"Descriptor is readable using read
"Write"Descriptor is writable using write

Data Types: string

Object Functions

readRead characteristic or descriptor data on a Bluetooth Low Energy peripheral device
writeWrite data to a characteristic or descriptor on a Bluetooth Low Energy peripheral device

Examples

collapse all

Create a connection to a nearby Bluetooth Low Energy peripheral device.

b = ble("Thingy")
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.

c.Descriptors
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(c,"2902")
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