EmberZnet

※This article is based on EmberZnet SDK 6.7.5.0 and EFR32MG Series

概要 [edit]

扩展Cluster的两种场景: - 扩展标准Cluster上的属性或命令 - 创建全新的自定义Cluster

请注意,在这两种情况下,基于自定义Cluster的功能只能与具有这些自定义Cluster的产品进行交互操作,这意味着您的产品只能与您自己的产品进行交互操作。我们建议您仅在必须使用自定义Cluster时才使用。

根据 ZCL 规范的描述, 一部分Cluster ID是预留给厂商自行定义的:

Cluster ID描述
0x0000 – 0x7fff标准 Cluster
0xfc00 – 0xffff厂商自定义 cluster
其他值保留

Zibgee Clusters 在 EmberZnet SDK 中是以xml文件的形式来定义的. 这些xml文件可以在SDK下面的app\zcl 目录中找到。

例如:

C:\SiliconLabs\SimplicityStudio\v4\developer\sdks\gecko_sdk_suite\v2.7\app\zcl

你可以查看其中的xml文件内容来尝试去理解这些格式。

例如,general.xml 这个文件定义了一些通用类别的Cluster,比如Basic、Identify、Groups、Scenes、On/Off等等。

有关于Cluster和Attribute的信息在xxx_endpoint_config.h这个文件中

ZCL attribute [edit]

ZCL attribute types [edit]

// ZCL attribute types
enum {
  ZCL_NO_DATA_ATTRIBUTE_TYPE                        = 0x00, // No data
  ZCL_DATA8_ATTRIBUTE_TYPE                          = 0x08, // 8-bit data
  ZCL_DATA16_ATTRIBUTE_TYPE                         = 0x09, // 16-bit data
  ZCL_DATA24_ATTRIBUTE_TYPE                         = 0x0A, // 24-bit data
  ZCL_DATA32_ATTRIBUTE_TYPE                         = 0x0B, // 32-bit data
  ZCL_DATA40_ATTRIBUTE_TYPE                         = 0x0C, // 40-bit data
  ZCL_DATA48_ATTRIBUTE_TYPE                         = 0x0D, // 48-bit data
  ZCL_DATA56_ATTRIBUTE_TYPE                         = 0x0E, // 56-bit data
  ZCL_DATA64_ATTRIBUTE_TYPE                         = 0x0F, // 64-bit data
  ZCL_BOOLEAN_ATTRIBUTE_TYPE                        = 0x10, // Boolean
  ZCL_BITMAP8_ATTRIBUTE_TYPE                        = 0x18, // 8-bit bitmap
  ZCL_BITMAP16_ATTRIBUTE_TYPE                       = 0x19, // 16-bit bitmap
  ZCL_BITMAP24_ATTRIBUTE_TYPE                       = 0x1A, // 24-bit bitmap
  ZCL_BITMAP32_ATTRIBUTE_TYPE                       = 0x1B, // 32-bit bitmap
  ZCL_BITMAP40_ATTRIBUTE_TYPE                       = 0x1C, // 40-bit bitmap
  ZCL_BITMAP48_ATTRIBUTE_TYPE                       = 0x1D, // 48-bit bitmap
  ZCL_BITMAP56_ATTRIBUTE_TYPE                       = 0x1E, // 56-bit bitmap
  ZCL_BITMAP64_ATTRIBUTE_TYPE                       = 0x1F, // 64-bit bitmap
  ZCL_INT8U_ATTRIBUTE_TYPE                          = 0x20, // Unsigned 8-bit integer
  ZCL_INT16U_ATTRIBUTE_TYPE                         = 0x21, // Unsigned 16-bit integer
  ZCL_INT24U_ATTRIBUTE_TYPE                         = 0x22, // Unsigned 24-bit integer
  ZCL_INT32U_ATTRIBUTE_TYPE                         = 0x23, // Unsigned 32-bit integer
  ZCL_INT40U_ATTRIBUTE_TYPE                         = 0x24, // Unsigned 40-bit integer
  ZCL_INT48U_ATTRIBUTE_TYPE                         = 0x25, // Unsigned 48-bit integer
  ZCL_INT56U_ATTRIBUTE_TYPE                         = 0x26, // Unsigned 56-bit integer
  ZCL_INT64U_ATTRIBUTE_TYPE                         = 0x27, // Unsigned 64-bit integer
  ZCL_INT8S_ATTRIBUTE_TYPE                          = 0x28, // Signed 8-bit integer
  ZCL_INT16S_ATTRIBUTE_TYPE                         = 0x29, // Signed 16-bit integer
  ZCL_INT24S_ATTRIBUTE_TYPE                         = 0x2A, // Signed 24-bit integer
  ZCL_INT32S_ATTRIBUTE_TYPE                         = 0x2B, // Signed 32-bit integer
  ZCL_INT40S_ATTRIBUTE_TYPE                         = 0x2C, // Signed 40-bit integer
  ZCL_INT48S_ATTRIBUTE_TYPE                         = 0x2D, // Signed 48-bit integer
  ZCL_INT56S_ATTRIBUTE_TYPE                         = 0x2E, // Signed 56-bit integer
  ZCL_INT64S_ATTRIBUTE_TYPE                         = 0x2F, // Signed 64-bit integer
  ZCL_ENUM8_ATTRIBUTE_TYPE                          = 0x30, // 8-bit enumeration
  ZCL_ENUM16_ATTRIBUTE_TYPE                         = 0x31, // 16-bit enumeration
  ZCL_FLOAT_SEMI_ATTRIBUTE_TYPE                     = 0x38, // Semi-precision
  ZCL_FLOAT_SINGLE_ATTRIBUTE_TYPE                   = 0x39, // Single precision
  ZCL_FLOAT_DOUBLE_ATTRIBUTE_TYPE                   = 0x3A, // Double precision
  ZCL_OCTET_STRING_ATTRIBUTE_TYPE                   = 0x41, // Octet string
  ZCL_CHAR_STRING_ATTRIBUTE_TYPE                    = 0x42, // Character string
  ZCL_LONG_OCTET_STRING_ATTRIBUTE_TYPE              = 0x43, // Long octet string
  ZCL_LONG_CHAR_STRING_ATTRIBUTE_TYPE               = 0x44, // Long character string
  ZCL_ARRAY_ATTRIBUTE_TYPE                          = 0x48, // Array
  ZCL_STRUCT_ATTRIBUTE_TYPE                         = 0x4C, // Structure
  ZCL_SET_ATTRIBUTE_TYPE                            = 0x50, // Set
  ZCL_BAG_ATTRIBUTE_TYPE                            = 0x51, // Bag
  ZCL_TIME_OF_DAY_ATTRIBUTE_TYPE                    = 0xE0, // Time of day
  ZCL_DATE_ATTRIBUTE_TYPE                           = 0xE1, // Date
  ZCL_UTC_TIME_ATTRIBUTE_TYPE                       = 0xE2, // UTC Time
  ZCL_CLUSTER_ID_ATTRIBUTE_TYPE                     = 0xE8, // Cluster ID
  ZCL_ATTRIBUTE_ID_ATTRIBUTE_TYPE                   = 0xE9, // Attribute ID
  ZCL_BACNET_OID_ATTRIBUTE_TYPE                     = 0xEA, // BACnet OID
  ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE                   = 0xF0, // IEEE address
  ZCL_SECURITY_KEY_ATTRIBUTE_TYPE                   = 0xF1, // 128-bit security key
  ZCL_UNKNOWN_ATTRIBUTE_TYPE                        = 0xFF // Unknown

};
#endif // SILABS_EMBER_AF_ATTRIBUTE_TYPES

自定义 ZCL clusters [edit]

将自定义的 xml 文件放入项目文件夹,然后转向 Zigbee Stack 标签,在底部有一个 Custom ZCL additions 的区域。单击按钮"Add",然后选择 xml 文件将其添加到项目中。

Emberznet_stackzcladditions.png

XML文件的格式

<configurator>
  <domain name="Test" />

  <cluster manufacturerCode="0x1002">
    <name>Hello World</name>
    <domain>Ember</domain>
    <description>This cluster provides an example of how the Application 
      Framework can be extended to include manufacturer specific clusters.
      </description>
    <!-- Cluster Id must be within the mfg spec range 0xfc00 - 0xffff -->
    <code>0xFC10</code> 
    <define>SAMPLE_MFG_SPECIFIC_HELLOWORLD_CLUSTER</define>
    <client init="false" tick="false">true</client>
    <server init="false" tick="false">true</server>
    <attribute side="server" code="0x0000" define="ATTRIBUTE_ONE" 
      type="CHAR_STRING"  min="0x00"   max="0xFF"   writable="true"  
      default="" optional="true">ember sample attribute</attribute>
    <command source="client" code="0x00" 
      name="CommandOne" 
      optional="true">
      <description>
        A sample manufacturer specific command within the sample manufacturer specific
        cluster.
      </description>
      <arg name="argOne" type="CHAR_STRING" />
    </command>
  </cluster>

</configurator>

参考:

https://zhuanlan.zhihu.com/p/339586860

API [edit]

工程目录下/zcl-framework-core/attribute-table.c 文件里面提供了一些API
EmberAfStatus emberAfReadAttribute(uint8_t endpoint,
                                   EmberAfClusterId cluster,
                                   EmberAfAttributeId attributeID,
                                   uint8_t mask,
                                   uint8_t *dataPtr,
                                   uint8_t readLength,
                                   EmberAfAttributeType *dataType);

&ref(): File not found: "ZigBee.png" at page "++EmberZnet++Cluster";


Comment:



(画像の文字列を入力して下さい)

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS