Main Content

descriptor

访问低功耗 Bluetooth 外围设备上的描述符

自 R2019b 起

说明

descriptor 对象表示低功耗 Bluetooth® 外围设备的描述符。如果对象的 Attributes 属性支持读取或写入,您可以使用 read 读取数据或使用 write 写入数据。

创建对象

描述

示例

d = descriptor(c,descriptorName) 创建对象,该对象表示由其名称指定的描述符。通过查看 characteristic 对象 cDescriptors 属性,确定 descriptorName

示例

d = descriptor(c,descriptorUUID) 创建对象,该对象表示由其 UUID 指定的描述符。通过查看 characteristic 对象 cDescriptors 属性,确定 descriptorUUID

输入参量

全部展开

低功耗 Bluetooth 外围设备的特征,指定为 characteristic 对象。

描述符名称,指定为字符向量或字符串标量。在 characteristic 对象的 Descriptors 表中确定 descriptorNameDescriptorName 列中列出了有效值。

示例: d = descriptor(c,"Client Characteristic Configuration") 创建一个对象,该对象表示 c 特征上的“Client Characteristic Configuration”描述符。

数据类型: char | string

描述符 UUID,指定为字符向量或字符串标量。在 characteristic 对象的 Descriptors 表中确定 descriptorUUIDDescriptorUUID 列中列出了有效值。

示例: d = descriptor(c,"2902") 创建一个对象,该对象表示 c 特征上具有 UUID“2902”的描述符。

数据类型: char | string

属性

全部展开

此 属性 为只读。

描述符名称,以字符串标量形式返回。

数据类型: string

此 属性 为只读。

描述符 UUID,以字符串标量形式返回。该值对每个描述符唯一。

数据类型: string

此 属性 为只读。

描述读写权限的描述符属性,以字符串数组形式返回。可能的值如下。

描述
"Read"可使用 read 读取描述符
"Write"可使用 write 写入描述符

数据类型: string

对象函数

read读取低功耗 Bluetooth 外围设备上的特征或描述符数据
write将数据写入低功耗 Bluetooth 外围设备的特征或描述符

示例

全部折叠

创建与附近低功耗蓝牙外围设备的连接。

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

创建一个表示 "Temperature" 特征的特征对象。

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

列出特征的描述符。

c.Descriptors
ans=1×3 table
               DescriptorName                DescriptorUUID     Attributes 
    _____________________________________    ______________    ____________

    "Client Characteristic Configuration"        "2902"        {1×2 string}

创建表示“Client Characteristic Configuration"”的描述符对象。

d = descriptor(c,"Client Characteristic Configuration")
d = 
  Descriptor with properties:

          Name: "Client Characteristic Configuration"
          UUID: "2902"
    Attributes: ["Read"    "Write"]

您也可以使用 UUID(而不是名称)来创建此对象。

d = descriptor(c,"2902")
d = 
  Descriptor with properties:

          Name: "Client Characteristic Configuration"
          UUID: "2902"
    Attributes: ["Read"    "Write"]

此对象表示 "Client Characteristic Configuration" 描述符。由于该对象同时具有 ReadWrite 属性,您可以使用 readwrite

版本历史记录

在 R2019b 中推出