<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>adding an &amp;quot;array&amp;quot; attribute</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/78833/adding-an-array-attribute</link><description>Hello! I add an attribute array (0x48) for the user cluster. Having problems using the &amp;quot;array&amp;quot; attribute: 
 1. If you select the data type of 16 or 32 bits, then an alignment is added in the transmission, since the frame structure is: 8 bits for the type</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Dec 2021 10:51:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/78833/adding-an-array-attribute" /><item><title>RE: adding an "array" attribute</title><link>https://devzone.nordicsemi.com/thread/343603?ContentTypeID=1</link><pubDate>Wed, 15 Dec 2021 10:51:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6071ae50-9159-44bd-81a4-d788313da280</guid><dc:creator>Litvinus</dc:creator><description>&lt;div class="D5aOJc vJwDU"&gt;
&lt;div class="D5aOJc vJwDU"&gt;
&lt;div class="D5aOJc vJwDU"&gt;&lt;/div&gt;
&lt;div class="hlJJmd"&gt;
&lt;div class="Bmcqed"&gt;
&lt;div&gt;nRF5_SDK_for_Thread_and_Zigbee_v4.1.0&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="cEWAef"&gt;
&lt;div class="cEWAef"&gt;I can send the whole project to the mail or by a personal message.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="hlJJmd"&gt;
&lt;div class="D5aOJc Hapztf"&gt;&lt;/div&gt;
&lt;div class="Bmcqed"&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="cEWAef"&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Array_5F00_Attr.rar"&gt;devzone.nordicsemi.com/.../Array_5F00_Attr.rar&lt;/a&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adding an "array" attribute</title><link>https://devzone.nordicsemi.com/thread/343580?ContentTypeID=1</link><pubDate>Wed, 15 Dec 2021 10:00:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c8bbaa6-7ee4-4db5-b32e-f6a14b2408ce</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Nice to hear you found a workaround and have not been stucked without a reply. Again I am sorry I didn&amp;#39;t came back to you earlier. &lt;/p&gt;
[quote user="Litvinus"]It seems like the &lt;span&gt;&amp;quot;sum of lengths of content&amp;quot;&lt;/span&gt; field is not used by the stack, the whole array is sent all the time.[/quote]
&lt;p&gt;If you have project files you can share to reproduce this it would be helpful for us as we can then verify if this is a bug or not more easily and then report it to our SDK team internally. &lt;br /&gt;&lt;br /&gt;BTW which nRF5 SDK version are you using? &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adding an "array" attribute</title><link>https://devzone.nordicsemi.com/thread/343570?ContentTypeID=1</link><pubDate>Wed, 15 Dec 2021 09:27:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a17e35b3-cd47-42da-8246-e940fec95312</guid><dc:creator>Litvinus</dc:creator><description>&lt;p&gt;hi and thanks.&lt;/p&gt;
&lt;p&gt;No more, now I am packing data into an array and transmitting it as a string. An array also works, but the entire array that was defined during initialization (CUSTOM_NUMBER_OF_ARRAY_ELEMENTS) is transmitted. And the value specified in the request (it may be less) is ignored and is still transmitted more as it was specified during initialization. The data still comes through, of course.&amp;nbsp;It seems like the &lt;span&gt;&amp;quot;sum of lengths of content&amp;quot;&lt;/span&gt; field is not used by the stack, the whole array is sent all the time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adding an "array" attribute</title><link>https://devzone.nordicsemi.com/thread/343558?ContentTypeID=1</link><pubDate>Wed, 15 Dec 2021 08:48:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93cfd6db-c8f8-41fc-a1e7-8336c7dabb38</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am sorry for the late reply. I was not able to reproduce your issue. Are you still struggling with this? Could you send your whole project folder so I can test this at my end?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adding an "array" attribute</title><link>https://devzone.nordicsemi.com/thread/326783?ContentTypeID=1</link><pubDate>Thu, 26 Aug 2021 12:23:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4bd8d02-3723-41d1-8d5c-9529eb5ca50b</guid><dc:creator>Litvinus</dc:creator><description>&lt;p&gt;pay attention &amp;quot;helloz&amp;quot; is in the next attribute &amp;quot;string&amp;quot;, but it is passed along with the array, as if the length of the array is being ignored (last picture)&lt;/p&gt;
&lt;p&gt;m_dev_ctx.custom_attr.ArrayAttrData.Data_Array[0]=0x1122;&lt;br /&gt; m_dev_ctx.custom_attr.ArrayAttrData.Data_Array[1]=0x3344;&lt;br /&gt; m_dev_ctx.custom_attr.ArrayAttrData.Data_Array[2]=0x5566;&lt;br /&gt; m_dev_ctx.custom_attr.ArrayAttrData.Data_Array[3]=0x7788;&lt;br /&gt; m_dev_ctx.custom_attr.ArrayAttrData.Element_Type=CUSTOM_ARRAY_DATA_TYPE;&lt;br /&gt; m_dev_ctx.custom_attr.ArrayAttrData.Number_Of_Elements_1=CUSTOM_NUMBER_OF_ARRAY_ELEMENTS*2+1;&lt;br /&gt; m_dev_ctx.custom_attr.StringAttrData[0]=5;&lt;br /&gt; m_dev_ctx.custom_attr.StringAttrData[1]=&amp;#39;h&amp;#39;;&lt;br /&gt;m_dev_ctx.custom_attr.StringAttrData[2]=&amp;#39;e&amp;#39;;&lt;br /&gt;m_dev_ctx.custom_attr.StringAttrData[3]=&amp;#39;l&amp;#39;;&lt;br /&gt;m_dev_ctx.custom_attr.StringAttrData[4]=&amp;#39;l&amp;#39;;&lt;br /&gt;m_dev_ctx.custom_attr.StringAttrData[5]=&amp;#39;o&amp;#39;;&lt;br /&gt;m_dev_ctx.custom_attr.StringAttrData[6]=&amp;#39;z&amp;#39;;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adding an "array" attribute</title><link>https://devzone.nordicsemi.com/thread/326780?ContentTypeID=1</link><pubDate>Thu, 26 Aug 2021 12:15:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc16db2b-2d36-4e3f-804c-976525110200</guid><dc:creator>Litvinus</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Thanks for the answer. Zero element with 16-bit type, but one more bit is added for alignment, apparently this is done by the linker.&lt;br /&gt;now I&amp;#39;m making a custom attribute (I wanted an analog one right away, but more data needs to be transferred). There is an array and a string:&lt;br /&gt;ZB_ZCL_ATTR_TYPE_ARRAY,&lt;br /&gt;ZB_ZCL_ATTR_TYPE_CHAR_STRING.&lt;br /&gt;0x80 is the attribute number, during initialization I specify the correct ZB_ZCL_ATTR_TYPE_ARRAY = 0x48:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DATA_ARRAY_ID(data_ptr)                 \
{                                                                                  \
    ZB_ZCL_ATTR_DATA_ARRAY_ID,                                                     \
    ZB_ZCL_ATTR_TYPE_ARRAY,                                                        \
    ZB_ZCL_ATTR_ACCESS_READ_ONLY,                                                  \
    (zb_voidp_t) data_ptr                                                          \
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;When requesting an array, the first element of the array (16-bit), which contains the length, is ignored, and all the time 32 bits of data are transmitted, including zero (16-bit, with the number of array elements).&lt;/p&gt;
&lt;p&gt;for example, I exposed 13 elements to see the extra data in the package:&lt;/p&gt;
&lt;p&gt;#define&amp;nbsp; &amp;nbsp;CUSTOM_NUMBER_OF_ARRAY_ELEMENTS&amp;nbsp; &amp;nbsp; &amp;nbsp;6 //(&lt;span&gt;CUSTOM_NUMBER_OF_ARRAY_ELEMENTS&lt;/span&gt;*2+1)&lt;/p&gt;
&lt;p&gt;Array data type:&lt;/p&gt;
&lt;p&gt;#define&amp;nbsp; &amp;nbsp;CUSTOM_ARRAY_DATA_TYPE&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ZB_ZCL_ATTR_TYPE_U8&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
#ifndef ZB_ZCL_CUSTOM_SIGNAL_H__
#define ZB_ZCL_CUSTOM_SIGNAL_H__

#include &amp;quot;zcl/zb_zcl_common.h&amp;quot;

/* Cluster  */
#define   CUSTOM_ANALOG_STRING_SIZE           64
#define   CUSTOM_NUMBER_OF_ARRAY_ELEMENTS     6
#define   CUSTOM_ARRAY_DATA_TYPE              ZB_ZCL_ATTR_TYPE_U8

typedef struct  struct_array_attr_data
{   
    zb_uint8_t  Element_Type;    
    zb_uint8_t  Number_Of_Elements_1;
    zb_uint8_t  Number_Of_Elements_2;  
    zb_uint8_t  For_Allign;
    zb_int16_t  Data_Array[CUSTOM_NUMBER_OF_ARRAY_ELEMENTS];
} array_attr_data_t;


typedef struct
{
    array_attr_data_t   ArrayAttrData;
    zb_char_t           StringAttrData[CUSTOM_ANALOG_STRING_SIZE];
} zb_zcl_custom_attrs_t;


enum zb_zcl_custom_attr_e
{
    ZB_ZCL_ATTR_DATA_ARRAY_ID    = 0x0080,
    ZB_ZCL_ATTR_DATA_STRING_ID   = 0x0081,
};

/**@brief MeasuredValue attribute unknown value. */
#define ZB_ZCL_ATTR_CUSTOM_DATA_VALUE_UNKNOWN              ((zb_int16_t)0x8000)


/**@brief MinMeasuredValue attribute invalid value. */
#define ZB_ZCL_ATTR_CUSTOM_DATA_VALUE_INVALID              ((zb_int16_t)0x8000)

/**@brief Default value for Value attribute. */
#define ZB_ZCL_CUSTOM_DATA_DEFAULT_VALUE                   ((zb_int16_t)0x0)


#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DATA_ARRAY_ID(data_ptr)                 \
{                                                                                  \
    ZB_ZCL_ATTR_DATA_ARRAY_ID,                                                     \
    ZB_ZCL_ATTR_TYPE_ARRAY,                                                        \
    ZB_ZCL_ATTR_ACCESS_READ_ONLY,                                                  \
    (zb_voidp_t) data_ptr                                                          \
}

#define ZB_SET_ATTR_DESCR_WITH_ZB_ZCL_ATTR_DATA_STRING_ID(data_ptr)                \
{                                                                                  \
    ZB_ZCL_ATTR_DATA_STRING_ID,                                                    \
    ZB_ZCL_ATTR_TYPE_CHAR_STRING,                                                  \
    ZB_ZCL_ATTR_ACCESS_READ_ONLY,                                                  \
    (zb_voidp_t) data_ptr                                                          \
}

/**@brief Declares attribute list for the cluster on the server side.

 */
#define ZB_ZCL_DECLARE_ANALOG_ATTRIB_LIST(attr_list,                   \
    array, string)                                                     \
  ZB_ZCL_START_DECLARE_ATTRIB_LIST(attr_list)                          \
  ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DATA_ARRAY_ID, (array))             \
  ZB_ZCL_SET_ATTR_DESC(ZB_ZCL_ATTR_DATA_STRING_ID, (string))           \
  ZB_ZCL_FINISH_DECLARE_ATTRIB_LIST

/**@brief Function initialising the server side of Cluster. */
zb_void_t zb_zcl_custom_signal_init_server(void);
/**@brief Function initialising the client side of Cluster. */
zb_void_t zb_zcl_custom_signal_init_client(void);

/**@brief Defines needed for the stack to initialise the cluster correctly. */
#define ZB_ZCL_CLUSTER_ID_CUSTOM_ATTR_SERVER_ROLE_INIT zb_zcl_custom_signal_init_server
#define ZB_ZCL_CLUSTER_ID_CUSTOM_ATTR_CLIENT_ROLE_INIT zb_zcl_custom_signal_init_client

#endif /* ZB_ZCL_CUSTOM_SIGNAL_H__ */
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;there are 6 16-bit elements plus 1 alignment octet equals 13 elements in an array of 8-bit elements:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;m_dev_ctx.custom_attr.ArrayAttrData.Data_Array[0]=0x1122;&lt;br /&gt; m_dev_ctx.custom_attr.ArrayAttrData.Data_Array[1]=0x3344;&lt;br /&gt; m_dev_ctx.custom_attr.ArrayAttrData.Data_Array[2]=0x5566;&lt;br /&gt; m_dev_ctx.custom_attr.ArrayAttrData.Data_Array[3]=0x7788;&lt;br /&gt; m_dev_ctx.custom_attr.ArrayAttrData.Element_Type=CUSTOM_ARRAY_DATA_TYPE;&lt;br /&gt; m_dev_ctx.custom_attr.ArrayAttrData.Number_Of_Elements_1=CUSTOM_NUMBER_OF_ARRAY_ELEMENTS*2+1;&lt;/p&gt;
&lt;p&gt;In the parser, element 0 is an alignment octet (looks like a linker):&lt;/p&gt;
&lt;p&gt;&lt;img style="font-family:inherit;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x1080/__key/communityserver-discussions-components-files/4/Screenshot-2021_2D00_08_2D00_26-14.43.24.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x1080/__key/communityserver-discussions-components-files/4/Screenshot-2021_2D00_08_2D00_26-14.43.34.png" /&gt;&lt;/p&gt;
&lt;p&gt;Basically, I created an array of 15 16-bit elements + an alignment octet, then everything is transmitted exactly without extra or missing bytes.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: adding an "array" attribute</title><link>https://devzone.nordicsemi.com/thread/326700?ContentTypeID=1</link><pubDate>Thu, 26 Aug 2021 10:03:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab77b128-5d2c-43fe-8511-a539b190f3e7</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Are you implementing a custom cluster or are you trying to implement the &amp;quot;Analog Value&amp;quot; cluster from the ZCL specification?&lt;/p&gt;
&lt;p&gt;According to the ZCL specification the lenght (in octets) for the Array attribute type (0x48) shoud be 2 octets + the sum of lengths of contents.&lt;br /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1629968204182v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;From the specification &amp;quot;The zeroth element is readable, always has type 16 bit unsigned integer, and holds the number of elements contained in the array&amp;quot;.&lt;/p&gt;
[quote user=""]2. For some reason, 32 bytes are always transferred, regardless of the size of the specified array. Is this hardcoded or is it possible to specify the size?[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It looks like you are sending your own data type, since you have the struct &amp;#39;analog_data_t&amp;#39; for attribute 0x0080, and I guess this is why you are having trouble. This is not encouraged by the Zigbee specification, see section 2.6.2 Data types in the ZCL specification.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>