This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Zigbee reporting not work while using multiple endpoints

Hello,

I just started to understand Zigbee and I had some problem. I created 3 endpoints. In one of them (endpoint counter_ep) I need a attribute reporting. A reporting works well only if this endpoint is the last in the list of macro parameters ZBOSS_DECLARE_DEVICE_CTX_3_EP or the only one in the macro ZBOSS_DECLARE_DEVICE_CTX_1_EP, otherwise reports will be unstable (for example, only 1 out of 10 reports will be received). Please tell me what could be the problem. I already found a similar problem on your forum, but the question has been deleted.

Thanks in advance.

I am using nrf52840 chip, SDK 4.0.0, router.
Coordinator: nrf52840, SDK 4.0.0, CLI example.

Examples:
counter_ep - endpoint with report.

Works:

ZBOSS_DECLARE_DEVICE_CTX_3_EP (counter_ctx, duty_ep, leds_ep, counter_ep);

or
ZBOSS_DECLARE_DEVICE_CTX_1_EP (counter_ctx, counter_ep);

Does not work:

ZBOSS_DECLARE_DEVICE_CTX_3_EP (counter_ctx, counter_ep, duty_ep, leds_ep);

or
ZBOSS_DECLARE_DEVICE_CTX_3_EP (counter_ctx, duty_ep counter_ep, leds_ep);

or
ZBOSS_DECLARE_DEVICE_CTX_2_EP (counter_ctx, counter_ep, leds_ep);

or
ZBOSS_DECLARE_DEVICE_CTX_2_EP (counter_ctx, counter_ep, duty_ep);

Parents
  • Hi Nikita

    The issue is still that you only receive one out of 10 packets, right? Can you please upload a sniffer log of your connection here and specify what configuration you're using, so our experts can have a look at it. If you don't want to share this with the community, I can set the case to private mode so that only yourself and Nordic engineers will be able to see it.

    Best regards,

    Simon

  • Hello Simon,

    I did as I wrote above and it finally worked for me. But before closing this thread, I want to find out if I'm doing it right or not. Unfortunately, I do not have a sniffer. But I can show my code:

    #include "zb_zcl_analog_input.h"
    #include "zb_zcl_multistate_value.h"
    #include "zb_zcl_binary_value.h"
    #include "zb_zcl_multistate_input.h"
    
    #define ZB_DEVICE_VER                        1
    
    /* COUNTER EndPoint */
    #define ZB_COUNTER_EP                        10                  /**< Device endpoint. */
    #define ZB_COUNTER_EP_REPORT_ATTR_COUNT      4                   /**< Number of attributes mandatory for reporting in cluster. */
    #define ZB_COUNTER_EP_IN_CLUSTER_NUM         4                   /**< Number of the input (server) clusters in the multisensor device. */
    #define ZB_COUNTER_EP_OUT_CLUSTER_NUM        0                   /**< Number of the output (client) clusters in the multisensor device. */
    
    /* DUTY EndPoint */
    #define ZB_DUTY_EP                           11                  /**< Device endpoint. */
    #define ZB_DUTY_EP_REPORT_ATTR_COUNT         2                   /**< Number of attributes mandatory for reporting in cluster. */
    #define ZB_DUTY_EP_IN_CLUSTER_NUM            3                   /**< Number of the input (server) clusters in the multisensor device. */
    #define ZB_DUTY_EP_OUT_CLUSTER_NUM           0                   /**< Number of the output (client) clusters in the multisensor device. */
    
    /* LEDS EndPoint */
    #define ZB_LEDS_EP                           12                  /**< Device endpoint. */
    #define ZB_LEDS_EP_REPORT_ATTR_COUNT         4                   /**< Number of attributes mandatory for reporting in cluster. */
    #define ZB_LEDS_EP_IN_CLUSTER_NUM            5                   /**< Number of the input (server) clusters in the multisensor device. */
    #define ZB_LEDS_EP_OUT_CLUSTER_NUM           0                   /**< Number of the output (client) clusters in the multisensor device. */
    #define ZB_LEDS_EP_LIGHT_CVC_ATTR_COUNT      1
    
    /* -------------------------------------------- COUNTER ENDPOINT DECLARE ---------------------------------------------------------- */
    
    /** @brief Declares cluster list for the COUNTER EndPoint.
     *
     *  @param cluster_list_name            Cluster list variable name.
     *  @param basic_attr_list              Attribute list for the Basic cluster.
     *  @param identify_attr_list           Attribute list for the Identify cluster.
     *  @param counter_attr_list            Attribute list for the Analog Input cluster.
     *  @param pulse_in_kwh_attr_list       Attribute list for the Multistate Value cluster.
     */
    #define ZB_DECLARE_COUNTER_CLUSTER_LIST(                            \
          cluster_list_name,                                            \
          basic_attr_list,                                              \
          identify_attr_list,                                           \
          counter_attr_list,                                            \
          pulse_in_kwh_attr_list)                                       \
          zb_zcl_cluster_desc_t cluster_list_name[] =                   \
          {                                                             \
            ZB_ZCL_CLUSTER_DESC(                                        \
              ZB_ZCL_CLUSTER_ID_IDENTIFY,                               \
              ZB_ZCL_ARRAY_SIZE(identify_attr_list, zb_zcl_attr_t),     \
              (identify_attr_list),                                     \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                               \
              ZB_ZCL_MANUF_CODE_INVALID                                 \
            ),                                                          \
            ZB_ZCL_CLUSTER_DESC(                                        \
              ZB_ZCL_CLUSTER_ID_BASIC,                                  \
              ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t),        \
              (basic_attr_list),                                        \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                               \
              ZB_ZCL_MANUF_CODE_INVALID                                 \
            ),                                                          \
            ZB_ZCL_CLUSTER_DESC(                                        \
              ZB_ZCL_CLUSTER_ID_ANALOG_INPUT,                           \
              ZB_ZCL_ARRAY_SIZE(counter_attr_list, zb_zcl_attr_t),      \
              (counter_attr_list),                                      \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                               \
              ZB_ZCL_MANUF_CODE_INVALID                                 \
            ),                                                          \
            ZB_ZCL_CLUSTER_DESC(                                        \
              ZB_ZCL_CLUSTER_ID_MULTI_VALUE,                            \
              ZB_ZCL_ARRAY_SIZE(pulse_in_kwh_attr_list, zb_zcl_attr_t), \
              (pulse_in_kwh_attr_list),                                 \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                               \
              ZB_ZCL_MANUF_CODE_INVALID                                 \
            )                                                           \
          }
    
    /** @brief Declares simple descriptor for the COUNTER EndPoint.
     *  
     *  @param ep_name          Endpoint variable name.
     *  @param ep_id            Endpoint ID.
     *  @param in_clust_num     Number of the supported input clusters.
     *  @param out_clust_num    Number of the supported output clusters.
     */
    #define ZB_DECLARE_COUNTER_DESC(ep_name, ep_id, in_clust_num, out_clust_num)  \
      ZB_DECLARE_SIMPLE_DESC(in_clust_num, out_clust_num);                        \
      ZB_AF_SIMPLE_DESC_TYPE(in_clust_num, out_clust_num) simple_desc_##ep_name = \
      {                                                                           \
        ep_id,                                                                    \
        ZB_AF_HA_PROFILE_ID,                                                      \
        ZB_HA_CONSUMPTION_AWARENESS_DEVICE_ID,                                    \
        ZB_DEVICE_VER,                                                            \
        0,                                                                        \
        in_clust_num,                                                             \
        out_clust_num,                                                            \
        {                                                                         \
          ZB_ZCL_CLUSTER_ID_BASIC,                                                \
          ZB_ZCL_CLUSTER_ID_IDENTIFY,                                             \
          ZB_ZCL_CLUSTER_ID_ANALOG_INPUT,                                         \
          ZB_ZCL_CLUSTER_ID_MULTI_VALUE,                                          \
        }                                                                         \
      }
    
    /** @brief Declares endpoint for the COUNTER EndPoint.
     *   
     *  @param ep_name          Endpoint variable name.
     *  @param ep_id            Endpoint ID.
     *  @param cluster_list     Endpoint cluster list.
     */
    #define ZB_DECLARE_COUNTER_EP(ep_name, ep_id, cluster_list)                           \
      ZB_DECLARE_COUNTER_DESC(ep_name,                                                    \
                              ep_id,                                                      \
                              ZB_COUNTER_EP_IN_CLUSTER_NUM,                               \
                              ZB_COUNTER_EP_OUT_CLUSTER_NUM);                             \
                                                                                          \
      ZBOSS_DEVICE_DECLARE_REPORTING_CTX(reporting_info## device_ctx_name,                \
                                         ZB_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT);                \
                                                                                          \
      ZB_AF_DECLARE_ENDPOINT_DESC(ep_name,                                                \
                                  ep_id,                                                  \
                                  ZB_AF_HA_PROFILE_ID,                                    \
                                  0,                                                      \
                                  NULL,                                                   \
                                  ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t), \
                                  cluster_list,                                           \
                                  (zb_af_simple_desc_1_1_t*)&simple_desc_##ep_name,       \
                                  ZB_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT,                        \
                                  reporting_info## device_ctx_name,                       \
                                  0,                                                      \
                                  NULL)
    
    
    /* -------------------------------------------- DUTY ENDPOINT DECLARE ---------------------------------------------------------- */
    
    /** @brief Declares cluster list for the DUTY EndPoint.
     *
     *  @param cluster_list_name            Cluster list variable name.
     *  @param basic_attr_list              Attribute list for the Basic cluster.
     *  @param identify_attr_list           Attribute list for the Identify cluster.
     *  @param time_live_in_hour_attr_list  Attribute list for the Multistate Input cluster.
     */
    #define ZB_DECLARE_DUTY_CLUSTER_LIST(                                     \
          cluster_list_name,                                                  \
          basic_attr_list,                                                    \
          identify_attr_list,                                                 \
          time_live_in_hour_attr_list)                                        \
          zb_zcl_cluster_desc_t cluster_list_name[] =                         \
          {                                                                   \
            ZB_ZCL_CLUSTER_DESC(                                              \
              ZB_ZCL_CLUSTER_ID_IDENTIFY,                                     \
              ZB_ZCL_ARRAY_SIZE(identify_attr_list, zb_zcl_attr_t),           \
              (identify_attr_list),                                           \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                                     \
              ZB_ZCL_MANUF_CODE_INVALID                                       \
            ),                                                                \
            ZB_ZCL_CLUSTER_DESC(                                              \
              ZB_ZCL_CLUSTER_ID_BASIC,                                        \
              ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t),              \
              (basic_attr_list),                                              \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                                     \
              ZB_ZCL_MANUF_CODE_INVALID                                       \
            ),                                                                \
            ZB_ZCL_CLUSTER_DESC(                                              \
              ZB_ZCL_CLUSTER_ID_MULTI_INPUT,                                  \
              ZB_ZCL_ARRAY_SIZE(time_live_in_hour_attr_list, zb_zcl_attr_t),  \
              (time_live_in_hour_attr_list),                                  \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                                     \
              ZB_ZCL_MANUF_CODE_INVALID                                       \
            )                                                                 \
          }
    
    /** @brief Declares simple descriptor for the DUTY EndPoint.
     *  
     *  @param ep_name          Endpoint variable name.
     *  @param ep_id            Endpoint ID.
     *  @param in_clust_num     Number of the supported input clusters.
     *  @param out_clust_num    Number of the supported output clusters.
     */
    #define ZB_DECLARE_DUTY_DESC(ep_name, ep_id, in_clust_num, out_clust_num)             \
      ZB_DECLARE_SIMPLE_DESC(in_clust_num, out_clust_num);                                \
      ZB_AF_SIMPLE_DESC_TYPE(in_clust_num, out_clust_num) simple_desc_##ep_name =         \
      {                                                                                   \
        ep_id,                                                                            \
        ZB_AF_HA_PROFILE_ID,                                                              \
        ZB_HA_CONFIGURATION_TOOL_DEVICE_ID ,                                              \
        ZB_DEVICE_VER,                                                                    \
        0,                                                                                \
        in_clust_num,                                                                     \
        out_clust_num,                                                                    \
        {                                                                                 \
          ZB_ZCL_CLUSTER_ID_BASIC,                                                        \
          ZB_ZCL_CLUSTER_ID_IDENTIFY,                                                     \
          ZB_ZCL_CLUSTER_ID_MULTI_INPUT,                                                  \
        }                                                                                 \
      }
    
    /** @brief Declares endpoint for the DUTY EndPoint.
     *   
     *  @param ep_name          Endpoint variable name.
     *  @param ep_id            Endpoint ID.
     *  @param cluster_list     Endpoint cluster list.
     */
    #define ZB_DECLARE_DUTY_EP(ep_name, ep_id, cluster_list)                              \
      ZB_DECLARE_DUTY_DESC(ep_name,                                                       \
                           ep_id,                                                         \
                           ZB_DUTY_EP_IN_CLUSTER_NUM,                                     \
                           ZB_DUTY_EP_OUT_CLUSTER_NUM);                                   \
                                                                                          \
      ZB_AF_DECLARE_ENDPOINT_DESC(ep_name,                                                \
                                  ep_id,                                                  \
                                  ZB_AF_HA_PROFILE_ID,                                    \
                                  0,                                                      \
                                  NULL,                                                   \
                                  ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t), \
                                  cluster_list,                                           \
                                  (zb_af_simple_desc_1_1_t*)&simple_desc_##ep_name,       \
                                  ZB_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT,                           \
                                  reporting_info## device_ctx_name,                       \
                                  0,                                                      \
                                  NULL)                                                   \
                                  
    
    /* -------------------------------------------- LEDS ENDPOINT DECLARE ---------------------------------------------------------- */
    
    /*!
      @brief Declare cluster list for Dimmable Light device
      @param cluster_list_name - cluster list variable name
      @param basic_attr_list - attribute list for Basic cluster
      @param identify_attr_list - attribute list for Identify cluster
      @param on_off_attr_list - attribute list for On/Off cluster
      @param level_control_attr_list - attribute list for Level Control cluster
     */
    #define ZB_DECLARE_LEDS_CLUSTER_LIST(                            \
      cluster_list_name,                                             \
      basic_attr_list,                                               \
      identify_attr_list,                                            \
      on_off_attr_list,                                              \
      level_control_attr_list,                                       \
      inversion_attr_list)                                           \
      zb_zcl_cluster_desc_t cluster_list_name[] =                    \
      {                                                              \
        ZB_ZCL_CLUSTER_DESC(                                         \
          ZB_ZCL_CLUSTER_ID_IDENTIFY,                                \
          ZB_ZCL_ARRAY_SIZE(identify_attr_list, zb_zcl_attr_t),      \
          (identify_attr_list),                                      \
          ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
          ZB_ZCL_MANUF_CODE_INVALID                                  \
        ),                                                           \
        ZB_ZCL_CLUSTER_DESC(                                         \
          ZB_ZCL_CLUSTER_ID_BASIC,                                   \
          ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t),         \
          (basic_attr_list),                                         \
          ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
          ZB_ZCL_MANUF_CODE_INVALID                                  \
        ),                                                           \
        ZB_ZCL_CLUSTER_DESC(                                         \
          ZB_ZCL_CLUSTER_ID_ON_OFF,                                  \
          ZB_ZCL_ARRAY_SIZE(on_off_attr_list, zb_zcl_attr_t),        \
          (on_off_attr_list),                                        \
          ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
          ZB_ZCL_MANUF_CODE_INVALID                                  \
        ),                                                           \
        ZB_ZCL_CLUSTER_DESC(                                         \
          ZB_ZCL_CLUSTER_ID_LEVEL_CONTROL,                           \
          ZB_ZCL_ARRAY_SIZE(level_control_attr_list, zb_zcl_attr_t), \
          (level_control_attr_list),                                 \
          ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
          ZB_ZCL_MANUF_CODE_INVALID                                  \
        ),                                                           \
        ZB_ZCL_CLUSTER_DESC(                                         \
          ZB_ZCL_CLUSTER_ID_BINARY_VALUE,                            \
          ZB_ZCL_ARRAY_SIZE(inversion_attr_list, zb_zcl_attr_t),     \
          (inversion_attr_list),                                     \
          ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
          ZB_ZCL_MANUF_CODE_INVALID                                  \
        )                                                            \
      }
    
    
    /*!
      @brief Declare simple descriptor for Dimmable Light device
      @param ep_name - endpoint variable name
      @param ep_id - endpoint ID
      @param in_clust_num - number of supported input clusters
      @param out_clust_num - number of supported output clusters
    */
    #define ZB_DECLARE_LEDS_SIMPLE_DESC(ep_name, ep_id, in_clust_num, out_clust_num) \
      ZB_DECLARE_SIMPLE_DESC(in_clust_num, out_clust_num);                           \
      ZB_AF_SIMPLE_DESC_TYPE(in_clust_num, out_clust_num) simple_desc_##ep_name =    \
      {                                                                              \
        ep_id,                                                                       \
        ZB_AF_HA_PROFILE_ID,                                                         \
        ZB_HA_DIMMABLE_LIGHT_DEVICE_ID,                                              \
        ZB_DEVICE_VER,                                                               \
        0,                                                                           \
        in_clust_num,                                                                \
        out_clust_num,                                                               \
        {                                                                            \
          ZB_ZCL_CLUSTER_ID_BASIC,                                                   \
          ZB_ZCL_CLUSTER_ID_IDENTIFY,                                                \
          ZB_ZCL_CLUSTER_ID_ON_OFF,                                                  \
          ZB_ZCL_CLUSTER_ID_LEVEL_CONTROL,                                           \
          ZB_ZCL_CLUSTER_ID_BINARY_VALUE                                             \
        }                                                                            \
      }   
    
    /*!
      @brief Declare endpoint for Dimmable Light device
      @param ep_name - endpoint variable name
      @param ep_id - endpoint ID
      @param cluster_list - endpoint cluster list
     */
    #define ZB_DECLARE_LEDS_EP(ep_name, ep_id, cluster_list)                              \
      ZB_DECLARE_LEDS_SIMPLE_DESC(ep_name, ep_id,                                         \
                                  ZB_LEDS_EP_IN_CLUSTER_NUM,                              \
                                  ZB_LEDS_EP_OUT_CLUSTER_NUM);                            \
                                                                                          \
      ZBOSS_DEVICE_DECLARE_LEVEL_CONTROL_CTX(cvc_alarm_info## ep_name,                    \
                                             ZB_LEDS_EP_LIGHT_CVC_ATTR_COUNT);            \
                                                                                          \
      ZB_AF_DECLARE_ENDPOINT_DESC(ep_name,                                                \
                                  ep_id,                                                  \
                                  ZB_AF_HA_PROFILE_ID,                                    \
                                  0,                                                      \
                                  NULL,                                                   \
                                  ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t), \
                                  cluster_list,                                           \
                                  (zb_af_simple_desc_1_1_t*)&simple_desc_##ep_name,       \
                                  ZB_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT,                           \
                                  reporting_info## device_ctx_name,                       \
                                  ZB_LEDS_EP_LIGHT_CVC_ATTR_COUNT,                        \
                                  cvc_alarm_info## ep_name)
    

    ------------------------------

    I will remind you that I have 3 endpoints. Each has clusters with attribute reporting. But now I declare the context of reporting attributes only in ONE endpoint (and not in all three as before). The size of this context is the sum of the number of ALL attributes with reporting from ALL three endpoints (B_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT):

    ZBOSS_DEVICE_DECLARE_REPORTING_CTX(reporting_info## device_ctx_name,                \
                                         ZB_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT); \

    At two other endpoints, I only refer to this (already declared) attribute reporting context.

    ZB_AF_DECLARE_ENDPOINT_DESC(...                                 \
                                ...                                 \
                                ...                                 \
                                ...                                 \
                                ...                                 \
                                ...                                 \
                                ...                                 \
                                ...                                 \
                                ...                                 \
                                ZB_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT,                           \
                                reporting_info## device_ctx_name,   \
                                ...                                 \
                                ...)                                \
    ---------------------------------

    The question is still relevant: is it right to do one common context of attribute reporting for all endpoints? I ask this because it does not seem logical to me. I believed that for each endpoint there should be a personal context of attribute reporting. Or I'm wrong?

    What can you say about my decision in the code?

    Thanks in advance.

Reply
  • Hello Simon,

    I did as I wrote above and it finally worked for me. But before closing this thread, I want to find out if I'm doing it right or not. Unfortunately, I do not have a sniffer. But I can show my code:

    #include "zb_zcl_analog_input.h"
    #include "zb_zcl_multistate_value.h"
    #include "zb_zcl_binary_value.h"
    #include "zb_zcl_multistate_input.h"
    
    #define ZB_DEVICE_VER                        1
    
    /* COUNTER EndPoint */
    #define ZB_COUNTER_EP                        10                  /**< Device endpoint. */
    #define ZB_COUNTER_EP_REPORT_ATTR_COUNT      4                   /**< Number of attributes mandatory for reporting in cluster. */
    #define ZB_COUNTER_EP_IN_CLUSTER_NUM         4                   /**< Number of the input (server) clusters in the multisensor device. */
    #define ZB_COUNTER_EP_OUT_CLUSTER_NUM        0                   /**< Number of the output (client) clusters in the multisensor device. */
    
    /* DUTY EndPoint */
    #define ZB_DUTY_EP                           11                  /**< Device endpoint. */
    #define ZB_DUTY_EP_REPORT_ATTR_COUNT         2                   /**< Number of attributes mandatory for reporting in cluster. */
    #define ZB_DUTY_EP_IN_CLUSTER_NUM            3                   /**< Number of the input (server) clusters in the multisensor device. */
    #define ZB_DUTY_EP_OUT_CLUSTER_NUM           0                   /**< Number of the output (client) clusters in the multisensor device. */
    
    /* LEDS EndPoint */
    #define ZB_LEDS_EP                           12                  /**< Device endpoint. */
    #define ZB_LEDS_EP_REPORT_ATTR_COUNT         4                   /**< Number of attributes mandatory for reporting in cluster. */
    #define ZB_LEDS_EP_IN_CLUSTER_NUM            5                   /**< Number of the input (server) clusters in the multisensor device. */
    #define ZB_LEDS_EP_OUT_CLUSTER_NUM           0                   /**< Number of the output (client) clusters in the multisensor device. */
    #define ZB_LEDS_EP_LIGHT_CVC_ATTR_COUNT      1
    
    /* -------------------------------------------- COUNTER ENDPOINT DECLARE ---------------------------------------------------------- */
    
    /** @brief Declares cluster list for the COUNTER EndPoint.
     *
     *  @param cluster_list_name            Cluster list variable name.
     *  @param basic_attr_list              Attribute list for the Basic cluster.
     *  @param identify_attr_list           Attribute list for the Identify cluster.
     *  @param counter_attr_list            Attribute list for the Analog Input cluster.
     *  @param pulse_in_kwh_attr_list       Attribute list for the Multistate Value cluster.
     */
    #define ZB_DECLARE_COUNTER_CLUSTER_LIST(                            \
          cluster_list_name,                                            \
          basic_attr_list,                                              \
          identify_attr_list,                                           \
          counter_attr_list,                                            \
          pulse_in_kwh_attr_list)                                       \
          zb_zcl_cluster_desc_t cluster_list_name[] =                   \
          {                                                             \
            ZB_ZCL_CLUSTER_DESC(                                        \
              ZB_ZCL_CLUSTER_ID_IDENTIFY,                               \
              ZB_ZCL_ARRAY_SIZE(identify_attr_list, zb_zcl_attr_t),     \
              (identify_attr_list),                                     \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                               \
              ZB_ZCL_MANUF_CODE_INVALID                                 \
            ),                                                          \
            ZB_ZCL_CLUSTER_DESC(                                        \
              ZB_ZCL_CLUSTER_ID_BASIC,                                  \
              ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t),        \
              (basic_attr_list),                                        \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                               \
              ZB_ZCL_MANUF_CODE_INVALID                                 \
            ),                                                          \
            ZB_ZCL_CLUSTER_DESC(                                        \
              ZB_ZCL_CLUSTER_ID_ANALOG_INPUT,                           \
              ZB_ZCL_ARRAY_SIZE(counter_attr_list, zb_zcl_attr_t),      \
              (counter_attr_list),                                      \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                               \
              ZB_ZCL_MANUF_CODE_INVALID                                 \
            ),                                                          \
            ZB_ZCL_CLUSTER_DESC(                                        \
              ZB_ZCL_CLUSTER_ID_MULTI_VALUE,                            \
              ZB_ZCL_ARRAY_SIZE(pulse_in_kwh_attr_list, zb_zcl_attr_t), \
              (pulse_in_kwh_attr_list),                                 \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                               \
              ZB_ZCL_MANUF_CODE_INVALID                                 \
            )                                                           \
          }
    
    /** @brief Declares simple descriptor for the COUNTER EndPoint.
     *  
     *  @param ep_name          Endpoint variable name.
     *  @param ep_id            Endpoint ID.
     *  @param in_clust_num     Number of the supported input clusters.
     *  @param out_clust_num    Number of the supported output clusters.
     */
    #define ZB_DECLARE_COUNTER_DESC(ep_name, ep_id, in_clust_num, out_clust_num)  \
      ZB_DECLARE_SIMPLE_DESC(in_clust_num, out_clust_num);                        \
      ZB_AF_SIMPLE_DESC_TYPE(in_clust_num, out_clust_num) simple_desc_##ep_name = \
      {                                                                           \
        ep_id,                                                                    \
        ZB_AF_HA_PROFILE_ID,                                                      \
        ZB_HA_CONSUMPTION_AWARENESS_DEVICE_ID,                                    \
        ZB_DEVICE_VER,                                                            \
        0,                                                                        \
        in_clust_num,                                                             \
        out_clust_num,                                                            \
        {                                                                         \
          ZB_ZCL_CLUSTER_ID_BASIC,                                                \
          ZB_ZCL_CLUSTER_ID_IDENTIFY,                                             \
          ZB_ZCL_CLUSTER_ID_ANALOG_INPUT,                                         \
          ZB_ZCL_CLUSTER_ID_MULTI_VALUE,                                          \
        }                                                                         \
      }
    
    /** @brief Declares endpoint for the COUNTER EndPoint.
     *   
     *  @param ep_name          Endpoint variable name.
     *  @param ep_id            Endpoint ID.
     *  @param cluster_list     Endpoint cluster list.
     */
    #define ZB_DECLARE_COUNTER_EP(ep_name, ep_id, cluster_list)                           \
      ZB_DECLARE_COUNTER_DESC(ep_name,                                                    \
                              ep_id,                                                      \
                              ZB_COUNTER_EP_IN_CLUSTER_NUM,                               \
                              ZB_COUNTER_EP_OUT_CLUSTER_NUM);                             \
                                                                                          \
      ZBOSS_DEVICE_DECLARE_REPORTING_CTX(reporting_info## device_ctx_name,                \
                                         ZB_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT);                \
                                                                                          \
      ZB_AF_DECLARE_ENDPOINT_DESC(ep_name,                                                \
                                  ep_id,                                                  \
                                  ZB_AF_HA_PROFILE_ID,                                    \
                                  0,                                                      \
                                  NULL,                                                   \
                                  ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t), \
                                  cluster_list,                                           \
                                  (zb_af_simple_desc_1_1_t*)&simple_desc_##ep_name,       \
                                  ZB_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT,                        \
                                  reporting_info## device_ctx_name,                       \
                                  0,                                                      \
                                  NULL)
    
    
    /* -------------------------------------------- DUTY ENDPOINT DECLARE ---------------------------------------------------------- */
    
    /** @brief Declares cluster list for the DUTY EndPoint.
     *
     *  @param cluster_list_name            Cluster list variable name.
     *  @param basic_attr_list              Attribute list for the Basic cluster.
     *  @param identify_attr_list           Attribute list for the Identify cluster.
     *  @param time_live_in_hour_attr_list  Attribute list for the Multistate Input cluster.
     */
    #define ZB_DECLARE_DUTY_CLUSTER_LIST(                                     \
          cluster_list_name,                                                  \
          basic_attr_list,                                                    \
          identify_attr_list,                                                 \
          time_live_in_hour_attr_list)                                        \
          zb_zcl_cluster_desc_t cluster_list_name[] =                         \
          {                                                                   \
            ZB_ZCL_CLUSTER_DESC(                                              \
              ZB_ZCL_CLUSTER_ID_IDENTIFY,                                     \
              ZB_ZCL_ARRAY_SIZE(identify_attr_list, zb_zcl_attr_t),           \
              (identify_attr_list),                                           \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                                     \
              ZB_ZCL_MANUF_CODE_INVALID                                       \
            ),                                                                \
            ZB_ZCL_CLUSTER_DESC(                                              \
              ZB_ZCL_CLUSTER_ID_BASIC,                                        \
              ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t),              \
              (basic_attr_list),                                              \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                                     \
              ZB_ZCL_MANUF_CODE_INVALID                                       \
            ),                                                                \
            ZB_ZCL_CLUSTER_DESC(                                              \
              ZB_ZCL_CLUSTER_ID_MULTI_INPUT,                                  \
              ZB_ZCL_ARRAY_SIZE(time_live_in_hour_attr_list, zb_zcl_attr_t),  \
              (time_live_in_hour_attr_list),                                  \
              ZB_ZCL_CLUSTER_SERVER_ROLE,                                     \
              ZB_ZCL_MANUF_CODE_INVALID                                       \
            )                                                                 \
          }
    
    /** @brief Declares simple descriptor for the DUTY EndPoint.
     *  
     *  @param ep_name          Endpoint variable name.
     *  @param ep_id            Endpoint ID.
     *  @param in_clust_num     Number of the supported input clusters.
     *  @param out_clust_num    Number of the supported output clusters.
     */
    #define ZB_DECLARE_DUTY_DESC(ep_name, ep_id, in_clust_num, out_clust_num)             \
      ZB_DECLARE_SIMPLE_DESC(in_clust_num, out_clust_num);                                \
      ZB_AF_SIMPLE_DESC_TYPE(in_clust_num, out_clust_num) simple_desc_##ep_name =         \
      {                                                                                   \
        ep_id,                                                                            \
        ZB_AF_HA_PROFILE_ID,                                                              \
        ZB_HA_CONFIGURATION_TOOL_DEVICE_ID ,                                              \
        ZB_DEVICE_VER,                                                                    \
        0,                                                                                \
        in_clust_num,                                                                     \
        out_clust_num,                                                                    \
        {                                                                                 \
          ZB_ZCL_CLUSTER_ID_BASIC,                                                        \
          ZB_ZCL_CLUSTER_ID_IDENTIFY,                                                     \
          ZB_ZCL_CLUSTER_ID_MULTI_INPUT,                                                  \
        }                                                                                 \
      }
    
    /** @brief Declares endpoint for the DUTY EndPoint.
     *   
     *  @param ep_name          Endpoint variable name.
     *  @param ep_id            Endpoint ID.
     *  @param cluster_list     Endpoint cluster list.
     */
    #define ZB_DECLARE_DUTY_EP(ep_name, ep_id, cluster_list)                              \
      ZB_DECLARE_DUTY_DESC(ep_name,                                                       \
                           ep_id,                                                         \
                           ZB_DUTY_EP_IN_CLUSTER_NUM,                                     \
                           ZB_DUTY_EP_OUT_CLUSTER_NUM);                                   \
                                                                                          \
      ZB_AF_DECLARE_ENDPOINT_DESC(ep_name,                                                \
                                  ep_id,                                                  \
                                  ZB_AF_HA_PROFILE_ID,                                    \
                                  0,                                                      \
                                  NULL,                                                   \
                                  ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t), \
                                  cluster_list,                                           \
                                  (zb_af_simple_desc_1_1_t*)&simple_desc_##ep_name,       \
                                  ZB_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT,                           \
                                  reporting_info## device_ctx_name,                       \
                                  0,                                                      \
                                  NULL)                                                   \
                                  
    
    /* -------------------------------------------- LEDS ENDPOINT DECLARE ---------------------------------------------------------- */
    
    /*!
      @brief Declare cluster list for Dimmable Light device
      @param cluster_list_name - cluster list variable name
      @param basic_attr_list - attribute list for Basic cluster
      @param identify_attr_list - attribute list for Identify cluster
      @param on_off_attr_list - attribute list for On/Off cluster
      @param level_control_attr_list - attribute list for Level Control cluster
     */
    #define ZB_DECLARE_LEDS_CLUSTER_LIST(                            \
      cluster_list_name,                                             \
      basic_attr_list,                                               \
      identify_attr_list,                                            \
      on_off_attr_list,                                              \
      level_control_attr_list,                                       \
      inversion_attr_list)                                           \
      zb_zcl_cluster_desc_t cluster_list_name[] =                    \
      {                                                              \
        ZB_ZCL_CLUSTER_DESC(                                         \
          ZB_ZCL_CLUSTER_ID_IDENTIFY,                                \
          ZB_ZCL_ARRAY_SIZE(identify_attr_list, zb_zcl_attr_t),      \
          (identify_attr_list),                                      \
          ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
          ZB_ZCL_MANUF_CODE_INVALID                                  \
        ),                                                           \
        ZB_ZCL_CLUSTER_DESC(                                         \
          ZB_ZCL_CLUSTER_ID_BASIC,                                   \
          ZB_ZCL_ARRAY_SIZE(basic_attr_list, zb_zcl_attr_t),         \
          (basic_attr_list),                                         \
          ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
          ZB_ZCL_MANUF_CODE_INVALID                                  \
        ),                                                           \
        ZB_ZCL_CLUSTER_DESC(                                         \
          ZB_ZCL_CLUSTER_ID_ON_OFF,                                  \
          ZB_ZCL_ARRAY_SIZE(on_off_attr_list, zb_zcl_attr_t),        \
          (on_off_attr_list),                                        \
          ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
          ZB_ZCL_MANUF_CODE_INVALID                                  \
        ),                                                           \
        ZB_ZCL_CLUSTER_DESC(                                         \
          ZB_ZCL_CLUSTER_ID_LEVEL_CONTROL,                           \
          ZB_ZCL_ARRAY_SIZE(level_control_attr_list, zb_zcl_attr_t), \
          (level_control_attr_list),                                 \
          ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
          ZB_ZCL_MANUF_CODE_INVALID                                  \
        ),                                                           \
        ZB_ZCL_CLUSTER_DESC(                                         \
          ZB_ZCL_CLUSTER_ID_BINARY_VALUE,                            \
          ZB_ZCL_ARRAY_SIZE(inversion_attr_list, zb_zcl_attr_t),     \
          (inversion_attr_list),                                     \
          ZB_ZCL_CLUSTER_SERVER_ROLE,                                \
          ZB_ZCL_MANUF_CODE_INVALID                                  \
        )                                                            \
      }
    
    
    /*!
      @brief Declare simple descriptor for Dimmable Light device
      @param ep_name - endpoint variable name
      @param ep_id - endpoint ID
      @param in_clust_num - number of supported input clusters
      @param out_clust_num - number of supported output clusters
    */
    #define ZB_DECLARE_LEDS_SIMPLE_DESC(ep_name, ep_id, in_clust_num, out_clust_num) \
      ZB_DECLARE_SIMPLE_DESC(in_clust_num, out_clust_num);                           \
      ZB_AF_SIMPLE_DESC_TYPE(in_clust_num, out_clust_num) simple_desc_##ep_name =    \
      {                                                                              \
        ep_id,                                                                       \
        ZB_AF_HA_PROFILE_ID,                                                         \
        ZB_HA_DIMMABLE_LIGHT_DEVICE_ID,                                              \
        ZB_DEVICE_VER,                                                               \
        0,                                                                           \
        in_clust_num,                                                                \
        out_clust_num,                                                               \
        {                                                                            \
          ZB_ZCL_CLUSTER_ID_BASIC,                                                   \
          ZB_ZCL_CLUSTER_ID_IDENTIFY,                                                \
          ZB_ZCL_CLUSTER_ID_ON_OFF,                                                  \
          ZB_ZCL_CLUSTER_ID_LEVEL_CONTROL,                                           \
          ZB_ZCL_CLUSTER_ID_BINARY_VALUE                                             \
        }                                                                            \
      }   
    
    /*!
      @brief Declare endpoint for Dimmable Light device
      @param ep_name - endpoint variable name
      @param ep_id - endpoint ID
      @param cluster_list - endpoint cluster list
     */
    #define ZB_DECLARE_LEDS_EP(ep_name, ep_id, cluster_list)                              \
      ZB_DECLARE_LEDS_SIMPLE_DESC(ep_name, ep_id,                                         \
                                  ZB_LEDS_EP_IN_CLUSTER_NUM,                              \
                                  ZB_LEDS_EP_OUT_CLUSTER_NUM);                            \
                                                                                          \
      ZBOSS_DEVICE_DECLARE_LEVEL_CONTROL_CTX(cvc_alarm_info## ep_name,                    \
                                             ZB_LEDS_EP_LIGHT_CVC_ATTR_COUNT);            \
                                                                                          \
      ZB_AF_DECLARE_ENDPOINT_DESC(ep_name,                                                \
                                  ep_id,                                                  \
                                  ZB_AF_HA_PROFILE_ID,                                    \
                                  0,                                                      \
                                  NULL,                                                   \
                                  ZB_ZCL_ARRAY_SIZE(cluster_list, zb_zcl_cluster_desc_t), \
                                  cluster_list,                                           \
                                  (zb_af_simple_desc_1_1_t*)&simple_desc_##ep_name,       \
                                  ZB_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT,                           \
                                  reporting_info## device_ctx_name,                       \
                                  ZB_LEDS_EP_LIGHT_CVC_ATTR_COUNT,                        \
                                  cvc_alarm_info## ep_name)
    

    ------------------------------

    I will remind you that I have 3 endpoints. Each has clusters with attribute reporting. But now I declare the context of reporting attributes only in ONE endpoint (and not in all three as before). The size of this context is the sum of the number of ALL attributes with reporting from ALL three endpoints (B_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT):

    ZBOSS_DEVICE_DECLARE_REPORTING_CTX(reporting_info## device_ctx_name,                \
                                         ZB_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT); \

    At two other endpoints, I only refer to this (already declared) attribute reporting context.

    ZB_AF_DECLARE_ENDPOINT_DESC(...                                 \
                                ...                                 \
                                ...                                 \
                                ...                                 \
                                ...                                 \
                                ...                                 \
                                ...                                 \
                                ...                                 \
                                ...                                 \
                                ZB_COUNTER_EP_REPORT_ATTR_COUNT + ZB_DUTY_EP_REPORT_ATTR_COUNT + ZB_LEDS_EP_REPORT_ATTR_COUNT,                           \
                                reporting_info## device_ctx_name,   \
                                ...                                 \
                                ...)                                \
    ---------------------------------

    The question is still relevant: is it right to do one common context of attribute reporting for all endpoints? I ask this because it does not seem logical to me. I believed that for each endpoint there should be a personal context of attribute reporting. Or I'm wrong?

    What can you say about my decision in the code?

    Thanks in advance.

Children
No Data
Related