Skip to content

Commit

Permalink
Update Bridged Device Basic Information cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
pjzander-signify committed Nov 22, 2021
1 parent 7c18e5c commit 2e73af0
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 57 deletions.
12 changes: 6 additions & 6 deletions examples/bridge-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ using namespace ::chip::Platform;

static DeviceCallbacks AppCallback;

static const int kUserLabelSize = 32;
static const int kNodeLabelSize = 32;
// Current ZCL implementation of Struct uses a max-size array of 254 bytes
static const int kDescriptorAttributeArraySize = 254;
static const int kFixedLabelAttributeArraySize = 254;
Expand Down Expand Up @@ -87,7 +87,7 @@ DECLARE_DYNAMIC_ATTRIBUTE(ZCL_DEVICE_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttrib

// Declare Bridged Device Basic information cluster attributes
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(bridgedDeviceBasicAttrs)
DECLARE_DYNAMIC_ATTRIBUTE(ZCL_USER_LABEL_ATTRIBUTE_ID, CHAR_STRING, kUserLabelSize, 0), /* UserLabel */
DECLARE_DYNAMIC_ATTRIBUTE(ZCL_NODE_LABEL_ATTRIBUTE_ID, CHAR_STRING, kNodeLabelSize, 0), /* NodeLabel */
DECLARE_DYNAMIC_ATTRIBUTE(ZCL_REACHABLE_ATTRIBUTE_ID, BOOLEAN, 1, 0), /* Reachable */
DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();

Expand Down Expand Up @@ -195,7 +195,7 @@ EmberAfStatus HandleReadBridgedDeviceBasicAttribute(Device * dev, chip::Attribut
{
*buffer = dev->IsReachable() ? 1 : 0;
}
else if ((attributeId == ZCL_USER_LABEL_ATTRIBUTE_ID) && (maxReadLength == 32))
else if ((attributeId == ZCL_NODE_LABEL_ATTRIBUTE_ID) && (maxReadLength == 32))
{
ToZclCharString(buffer, dev->GetName(), static_cast<uint8_t>(maxReadLength - 1));
}
Expand Down Expand Up @@ -323,10 +323,10 @@ void HandleDeviceStatusChanged(Device * dev, Device::Changed_t itemChangedMask)

if (itemChangedMask & Device::kChanged_Name)
{
uint8_t zclName[kUserLabelSize];
ToZclCharString(zclName, dev->GetName(), kUserLabelSize - 1);
uint8_t zclName[kNodeLabelSize];
ToZclCharString(zclName, dev->GetName(), kNodeLabelSize - 1);
MatterReportingAttributeChangeCallback(dev->GetEndpointId(), ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_ID,
ZCL_USER_LABEL_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, 0, ZCL_CHAR_STRING_ATTRIBUTE_TYPE,
ZCL_NODE_LABEL_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, 0, ZCL_CHAR_STRING_ATTRIBUTE_TYPE,
zclName);
}
if (itemChangedMask & Device::kChanged_Location)
Expand Down
12 changes: 6 additions & 6 deletions examples/bridge-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ using namespace chip::Inet;
using namespace chip::Transport;
using namespace chip::DeviceLayer;

static const int kUserLabelSize = 32;
static const int kNodeLabelSize = 32;
// Current ZCL implementation of Struct uses a max-size array of 254 bytes
static const int kDescriptorAttributeArraySize = 254;
static const int kFixedLabelAttributeArraySize = 254;
Expand Down Expand Up @@ -107,7 +107,7 @@ DECLARE_DYNAMIC_ATTRIBUTE(ZCL_DEVICE_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttrib

// Declare Bridged Device Basic information cluster attributes
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(bridgedDeviceBasicAttrs)
DECLARE_DYNAMIC_ATTRIBUTE(ZCL_USER_LABEL_ATTRIBUTE_ID, CHAR_STRING, kUserLabelSize, 0), /* UserLabel */
DECLARE_DYNAMIC_ATTRIBUTE(ZCL_NODE_LABEL_ATTRIBUTE_ID, CHAR_STRING, kNodeLabelSize, 0), /* NodeLabel */
DECLARE_DYNAMIC_ATTRIBUTE(ZCL_REACHABLE_ATTRIBUTE_ID, BOOLEAN, 1, 0), /* Reachable */
DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();

Expand Down Expand Up @@ -151,7 +151,7 @@ DECLARE_DYNAMIC_ATTRIBUTE(ZCL_DEVICE_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttrib

// Declare Bridged Device Basic information cluster attributes
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(switchBridgedDeviceBasicAttrs)
DECLARE_DYNAMIC_ATTRIBUTE(ZCL_USER_LABEL_ATTRIBUTE_ID, CHAR_STRING, kUserLabelSize, 0), /* UserLabel */
DECLARE_DYNAMIC_ATTRIBUTE(ZCL_NODE_LABEL_ATTRIBUTE_ID, CHAR_STRING, kNodeLabelSize, 0), /* NodeLabel */
DECLARE_DYNAMIC_ATTRIBUTE(ZCL_REACHABLE_ATTRIBUTE_ID, BOOLEAN, 1, 0), /* Reachable */
DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();

Expand Down Expand Up @@ -267,11 +267,11 @@ void HandleDeviceStatusChanged(Device * dev, Device::Changed_t itemChangedMask)

if (itemChangedMask & Device::kChanged_Name)
{
uint8_t zclName[kUserLabelSize];
uint8_t zclName[kNodeLabelSize];
MutableByteSpan zclNameSpan(zclName);
MakeZclCharString(zclNameSpan, dev->GetName());
MatterReportingAttributeChangeCallback(dev->GetEndpointId(), ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_ID,
ZCL_USER_LABEL_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, 0, ZCL_CHAR_STRING_ATTRIBUTE_TYPE,
ZCL_NODE_LABEL_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, 0, ZCL_CHAR_STRING_ATTRIBUTE_TYPE,
zclNameSpan.data());
}

Expand Down Expand Up @@ -342,7 +342,7 @@ EmberAfStatus HandleReadBridgedDeviceBasicAttribute(Device * dev, chip::Attribut
{
*buffer = dev->IsReachable() ? 1 : 0;
}
else if ((attributeId == ZCL_USER_LABEL_ATTRIBUTE_ID) && (maxReadLength == 32))
else if ((attributeId == ZCL_NODE_LABEL_ATTRIBUTE_ID) && (maxReadLength == 32))
{
uint8_t bufferMemory[254];
MutableByteSpan zclString(bufferMemory);
Expand Down
33 changes: 17 additions & 16 deletions src/app/zap-templates/zcl/data-model/chip/bridged-device-basic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ limitations under the License.
<server tick="false" init="false">true</server>
<globalAttribute side="either" code="0xFFFD" value="1"/>

<attribute side="server" code="0x0001" define="VENDOR_NAME" type="CHAR_STRING" length="32" writable="false" default="" optional="true">VendorName</attribute>
<attribute side="server" code="0x0002" define="VENDOR_ID" type="INT16U" min="0x0000" max="0xFFFF" writable="false" optional="true">VendorID</attribute>
<attribute side="server" code="0x0003" define="PRODUCT_NAME" type="CHAR_STRING" length="32" writable="false" default="" optional="true">ProductName</attribute>
<attribute side="server" code="0x0005" define="USER_LABEL" type="CHAR_STRING" length="32" writable="true" default="" optional="true">UserLabel</attribute>
<attribute side="server" code="0x0007" define="HARDWARE_VERSION" type="INT16U" min="0x0000" max="0xFFFF" writable="false" default="0x00" optional="true">HardwareVersion</attribute>
<attribute side="server" code="0x0008" define="HARDWARE_VERSION_STRING" type="CHAR_STRING" length="64" writable="false" default="" optional="true">HardwareVersionString</attribute>
<attribute side="server" code="0x0009" define="SOFTWARE_VERSION" type="INT32U" min="0x0000" max="0xFFFF" writable="false" default="0x00" optional="true">SoftwareVersion</attribute>
<attribute side="server" code="0x000A" define="SOFTWARE_VERSION_STRING" type="CHAR_STRING" length="64" writable="false" default="" optional="true">SoftwareVersionString</attribute>
<attribute side="server" code="0x000B" define="MANUFACTURING_DATE" type="CHAR_STRING" length="16" writable="false" default="" optional="true">ManufacturingDate</attribute>
<!-- TODO The actual length is not defined in the spec. But the current implementation expect a length -->
<attribute side="server" code="0x000C" define="PART_NUMBER" type="CHAR_STRING" length="254" writable="false" optional="true">PartNumber</attribute>
<!-- TODO The spec says the length is 256 ASCII characters. But the current implementation does not support values bigger than 254 -->
<attribute side="server" code="0x000D" define="PRODUCT_URL" type="CHAR_STRING" length="254" writable="false" optional="true">ProductURL</attribute>
<attribute side="server" code="0x000E" define="PRODUCT_LABEL" type="CHAR_STRING" length="64" writable="false" default="" optional="true">ProductLabel</attribute>
<attribute side="server" code="0x000F" define="SERIAL_NUMBER" type="CHAR_STRING" length="32" writable="false" default="" optional="true">SerialNumber</attribute>
<attribute side="server" code="0x0011" define="REACHABLE" type="BOOLEAN" min="0x00" max="0x01" writable="false" default="0x00" optional="false">Reachable</attribute>
<attribute side="server" code="1" define="VENDOR_NAME" type="char_string" length="32" optional="true">VendorName</attribute>
<attribute side="server" code="2" define="VENDOR_ID" type="int16u" optional="true">VendorID</attribute>
<attribute side="server" code="3" define="PRODUCT_NAME" type="char_string" length="32" optional="true">ProductName</attribute>
<attribute side="server" code="5" define="NODE_LABEL" type="char_string" length="32" default="" writable="true" optional="true">NodeLabel</attribute>
<attribute side="server" code="7" define="HARDWARE_VERSION" type="int16u" default="0" optional="true">HardwareVersion</attribute>
<attribute side="server" code="8" define="HARDWARE_VERSION_STRING" type="char_string" minLength="1" length="64" optional="true">HardwareVersionString</attribute>
<attribute side="server" code="9" define="SOFTWARE_VERSION" type="int32u" default="0" optional="true">SoftwareVersion</attribute>
<attribute side="server" code="10" define="SOFTWARE_VERSION_STRING" type="char_string" minLength="1" length="64" optional="true">SoftwareVersionString</attribute>
<attribute side="server" code="11" define="MANUFACTURING_DATE" type="char_string" minLength="8" length="16" optional="true">ManufacturingDate</attribute>
<attribute side="server" code="12" define="PART_NUMBER" type="char_string" length="32" optional="true">PartNumber</attribute>
<attribute side="server" code="13" define="PRODUCT_URL" type="long_char_string" length="256" optional="true">ProductURL</attribute>
<attribute side="server" code="14" define="PRODUCT_LABEL" type="char_string" length="64" optional="true">ProductLabel</attribute>
<attribute side="server" code="15" define="SERIAL_NUMBER" type="char_string" length="32" optional="true">SerialNumber</attribute>
<attribute side="server" code="17" define="REACHABLE" type="boolean" default="1" >Reachable</attribute>
<attribute side="server" code="18" define="UNIQUE_ID" type="char_string" length="32" optional="true">UniqueID</attribute>

<command source="server" code="0x00" name="StartUp" optional="true">
<description>The StartUp event SHALL be emitted by a Node as soon as reasonable after completing a boot or reboot process.</description>
</command>
Expand All @@ -54,5 +54,6 @@ limitations under the License.
<command source="server" code="0x03" name="ReachableChanged" optional="false">
<description>The Leave event SHOULD be emitted by a Node when the Reachable attribute changes.</description>
</command>

</cluster>
</configurator>
18 changes: 17 additions & 1 deletion src/controller/python/chip/clusters/Objects.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2e73af0

Please sign in to comment.