This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2530: Implementing ZCL SE Callback for CC2530

Part Number: CC2530
Other Parts Discussed in Thread: Z-STACK

Hi Guys,t

I´m trying to implementing the ZCL SE METERING, the last changes in my On/off device over the Z-Stack Home 1.2.2a.44539 before port it to Zstack 3.0.2 supported by CC2530.

I used in my device 3 endpoints, onde specific to working with  ZCL_SE_METERING_SERVER and another two to working with ZCL_CLUSTER_ID_GEN_BASIC and other mandatory clusters. as i describe below:

EndPoint 1 ZCL_CLUSTER_ID_GEN_BASIC, ZCL_CLUSTER_ID_GEN_IDENTIFY and ZCL_CLUSTER_ID_GEN_ON_OFF 

EndPoint 2  ZCL_CLUSTER_ID_GEN_BASIC, ZCL_CLUSTER_ID_GEN_IDENTIFY and ZCL_CLUSTER_ID_GEN_ON_OFF and ZCL_SE_METERING_SERVER

EndPoint 3 ZCL_CLUSTER_ID_GEN_BASIC, ZCL_CLUSTER_ID_GEN_IDENTIFY and ZCL_CLUSTER_ID_GEN_ON_OFF 

I included the ZCL_se.c and ZCL_se.h on my application MyApp.c and MyApp_data.c

I dindt have success to implement the call back for ZCL Read Attributes Mesage - 0x00 (Client to Server) to my device answer those attributes: 

Current Summation Delivered (0x0000)

Instanteneous Demand (0x0400)

Unit of measure (0x0300)

I have used the Texas Reference desing (TIREX) to implement the ZCL SE Callback:https://dev.ti.com/tirex/explore/node?node=AHbBZxMuyaeDZaCvHJ42MQ__t1zoukP__LATEST

I have observed on breackpoint that My Callback is not reached.

Someone can help me?

My Callback code:

void zclAZh0006SE_Init( byte task_id )
{
  zclAZh0006SE1_TaskID = task_id;


  // Set destination address to indirect
 // zclAZh0006_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
 // zclAZh0006_DstAddr.endPoint = 0;
 // zclAZh0006_DstAddr.addr.shortAddr = 0;
 
  /**********************************************************************************************************
 * 											UART Init  -  by ASA
 **********************************************************************************************************/  
	// Set UART Definitions:
	//uartMapPort(1,0);
	initUart0(uart0RxCb);
	
 /**********************************************************************************************************
 * ZCL Addressing Mode  -  by ASA
 efeito através das mensagens originadas a partir deste dispositivo
 **********************************************************************************************************/  
   zclAZh0006_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
   zclAZh0006_DstAddr.addr.shortAddr = 0; // Short Address sent to gateway
   zclAZh0006_DstAddr.endPoint=1; // DST Endpoint sent to Gateway

  // This app is part of the Home Automation Profile
  zclHA_Init(&zclAZh0006SE1_SimpleDesc);

   // Register the ZCL SE Cluster Library callback functions according zcl_se.c
#ifdef ZCL_SE_METERING_SERVER
  zclSE_RegisterCmdCallbacks( AZh0006_ENDPOINT2, &zclAZh0006_SECmdCallbacks );
#endif

  // Register the application's attribute list 
  zcl_registerAttrList( AZh0006_ENDPOINT2,zclAZh0006_NumAttributesSE1, zclAZh0006_AttrsSE1 );

  // Register the Application to receive the unprocessed Foundation command/response messages
  zcl_registerForMsg( zclAZh0006SE1_TaskID );

#ifdef ZCL_DISCOVER
  // Register the application's command list
  zcl_registerCmdList( AZh0006_ENDPOINT2, zclCmdsArraySize, zclAZh0006_Cmds );
#endif

  // Register for all key events - This app will handle all key events
  RegisterForKeys( zclAZh0006SE1_TaskID );

  // Register for a test endpoint
  afRegister( &AZh0006_TestEp2 );

#ifdef ZCL_EZMODE
  // Register EZ-Mode
  zcl_RegisterEZMode( &zclAZh0006_RegisterEZModeDataSE );

  // Register with the ZDO to receive Match Descriptor Responses
  ZDO_RegisterForZDOMsg(task_id, Match_Desc_rsp);
  
  //Register with the ZDO to receive Permit to Join Request
  ZDO_RegisterForZDOMsg(task_id, Mgmt_Permit_Join_req);
  
  //Register with the ZDO to receive Leave Req
  ZDO_RegisterForZDOMsg(task_id, Mgmt_Leave_req);
#endif

#ifdef ZCL_DIAGNOSTIC
  // Register the application's callback function to read/write attribute data.
  // This is only required when the attribute data format is unknown to ZCL.
  zcl_registerReadWriteCB( AZh0006_ENDPOINT2, zclDiagnostic_ReadWriteAttrCB, NULL );

  if ( zclDiagnostic_InitStats() == ZSuccess )
  {
    // Here the user could start the timer to save Diagnostics to NV
  }
#endif

#ifdef ZGP_AUTO_TT
  zgpTranslationTable_RegisterEP ( &zclAZh0006SE1_SimpleDesc );
#endif
}


/*********************************************************************
 * ZCL SE Profile Callback table for EP2
 */ // Client-to-Server Callbacks
 
 static const zclSE_MeteringServerCBs_t zclAZh0006_MeteringServerCBs =
{
  zclAZh0006_MeteringGetProfileCB,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL
};

static zclSE_AppCallbacks_t zclAZh0006_SECmdCallbacks =
{
  NULL,               					// zclSE_DRLC_ServerCBs_t
  NULL,               					// zclSE_DRLC_ClientCBs_t
  &zclAZh0006_MeteringServerCBs,        // zclSE_MeteringServerCBs_t
  NULL,               					// zclSE_MeteringClientCBs_t
  NULL,               					// zclSE_PriceServerCBs_t
  NULL,               					// zclSE_PriceClientCBs_t
  NULL,               					// zclSE_MessagingServerCBs_t
  NULL,               					// zclSE_MessagingClientCBs_t
  NULL,               					// zclSE_TunnelingServerCBs_t
  NULL,               					// zclSE_TunnelingClientCBs_t
  NULL,               					// zclSE_PrepaymentServerCBs_t
  NULL,               					// zclSE_PrepaymentClientCBs_t
  NULL,               					// zclSE_EnergyMgmtServerCBs_t
  NULL,               					// zclSE_EnergyMgmtClientCBs_t
  NULL,               					// zclSE_CalendarServerCBs_t
  NULL,               					// zclSE_CalendarClientCBs_t
  NULL,               					// zclSE_DeviceMgmtServerCBs_t
  NULL,               					// zclSE_DeviceMgmtClientCBs_t
  NULL,               					// zclSE_EventsServerCBs_t
  NULL,               					// zclSE_EventsClientCBs_t
  NULL,               					// zclSE_MDUPairingServerCBs_t
  NULL                					// zclSE_MDUPairingClientCBs_t
};


static void zclAZh0006_MeteringGetProfileCB( zclIncoming_t *pInMsg,zclSE_MeteringGetProfile_t *pCmd )
{ 
	switch ( pInMsg->hdr.commandID )
	{

    case COMMAND_SE_METERING_GET_PROFILE:
     //zclAZh0006_ProcessInReadRspCmd( pInMsg );
     break;
  }

  if ( pInMsg->attrCmd )
    osal_mem_free( pInMsg->attrCmd );
}

BR,

Alex

  • Hi Alex,

    How do you configure AZh0006_ENDPOINT2 inside MyApp_data.c?  Does zclSE_RegisterCmdCallbacks return a success status?  Are you able to debug the project to follow zclSE_HdlIncoming -> zclSE_HdlSpecificCmd -> zclSE_HdlSpecificServerCmd -> zclSE_MeteringHdlServerCmd?  Are you able to capture the Get Profile ZCL SE command from the client device in a sniffer log?

    Regards,
    Ryan

  • Hi Ryan, thanks a lot for your kicky reply.

    I have some problem in IAR EWB to set up the breakpoint in the ZCL_SE Callback, for example, in the zclAZh0006_MeteringGetProfileCB inside the zclAZh0006_MeteringServerCBs. I observing that the behaviour is not the same as the two Callbacks (on/off), that is working well.

    I´ll describe bellow all those configuration and mesages over the air.

    1. ..."you configure AZh0006_ENDPOINT2 inside MyApp_data.c?"

    My AZh0006_Endpoint 2  configuration:

    /*********************************************************************
     * EndPoint 2 - Metering Device
     */
    #ifdef ZCL_SE_METERING_SERVER
    
    #define AZh0006_ENDPOINT2	2 		// EndPoint 2 - EP2 - Metering Cluster
    
    #endif // ZCL_SE_METERING_SERVER
    
    /*********************************************************************

    Additional information about Metering Device Attributes over EP2

    /*********************************************************************
     * EndPoint 2 - EP2 SE Cluster Attributes
     attributes:
    			0x0000 - ATTRID_SE_METERING_CURR_SUMM_DLVD
    			0x0006 - ATTRID_SE_METERING_PWR_FACTOR
    			0x0200 - ATTRID_SE_METERING_STATUS
    			0x0300 - ATTRID_SE_METERING_UOM - Unit of measurement
    			0x0301 - ATTRID_SE_METERING_MULT
    			0x0302 - ATTRID_SE_METERING_DIV
    			0x0303 - ATTRID_SE_METERING_SUMM_FMTG - Summation formatting
    			0x0304 - ATTRID_SE_METERING_DMD_FMTG  - Demanding formatting
    			0x0306 - ATTRID_SE_METERING_DEVICE_TYPE
    			0x0400 - ATTRID_SE_METERING_INST_DMD
    			
     */
     
     /******************************************************************************
     *
     *  *************************** Metering Device Attributes *********************
     *
     ******************************************************************************/
    CONST zclAttrRec_t zclAZh0006_AttrsSE1[] =
    {
    
    
    #ifdef ZCL_IDENTIFY
      // *** Identify Cluster Attribute ***
      {
        ZCL_CLUSTER_ID_GEN_IDENTIFY,
        { // Attribute record
          ATTRID_IDENTIFY_TIME,
          ZCL_DATATYPE_UINT16,
          (ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE),
          (void *)&zclAZh0006_IdentifyTime
        }
      },
     #ifdef ZCL_EZMODE
      // *** Identify Cluster Attribute ***
      {
        ZCL_CLUSTER_ID_GEN_IDENTIFY,
        { // Attribute record
          ATTRID_IDENTIFY_COMMISSION_STATE,
          ZCL_DATATYPE_UINT8,
          (ACCESS_CONTROL_READ),
          (void *)&zclAZh0006_IdentifyCommissionState
        }
      },
     #endif // ZCL_EZMODE 
    #endif
    
    // *** Smart Energy Metering Server Cluster Attributes ***
    #ifdef ZCL_SE_METERING_SERVER
      {
       ZCL_CLUSTER_ID_SE_METERING,				// Cluster IDs - defined in the foundation (ie. zcl.h) - Smart Energy (SE) Clusters
        { // Attribute record
          ATTRID_SE_METERING_CURR_SUMM_DLVD,	// Attribute ID - Found in Cluster Library header (ie. zcl_se.h)
          ZCL_DATATYPE_UINT48,					// Data Type - found in zcl.h
          ACCESS_CONTROL_READ,					// Variable access control - found in zcl.h
          (void *)&zclAZh0006_CurrentSummationDelivered // Pointer to attribute variable
        }
      },
      {
       ZCL_CLUSTER_ID_SE_METERING,
        { // Attribute record
          ATTRID_SE_METERING_PWR_FACTOR,
    	  ZCL_DATATYPE_UINT8,
          ACCESS_CONTROL_READ,
          (void *)&zclAZh0006_Power_Factor
        }
      },
      {
       ZCL_CLUSTER_ID_SE_METERING,
        { // Attribute record
          ATTRID_SE_METERING_STATUS,
          ZCL_DATATYPE_BITMAP8,
          ACCESS_CONTROL_READ,
          (void *)&zclAZh0006_Metering_Status
        }
      },
      {
       ZCL_CLUSTER_ID_SE_METERING,
        { // Attribute record
          ATTRID_SE_METERING_UOM,
          ZCL_DATATYPE_ENUM8,
          ACCESS_CONTROL_READ,
          (void *)&zclAZh0006_UnitofMeasure
        }
      },
      {
       ZCL_CLUSTER_ID_SE_METERING,
        { // Attribute record
          ATTRID_SE_METERING_MULT,
    	  ZCL_DATATYPE_UINT24,
          ACCESS_CONTROL_READ,
          (void *)&zclAZh0006_MeasureMult
        }
      },
      {
       ZCL_CLUSTER_ID_SE_METERING,
        { // Attribute record
          ATTRID_SE_METERING_DIV,
    	  ZCL_DATATYPE_UINT24,
          ACCESS_CONTROL_READ,
          (void *)&zclAZh0006_MeasureDiv
        }
      },
      {
       ZCL_CLUSTER_ID_SE_METERING,
        { // Attribute record
          ATTRID_SE_METERING_SUMM_FMTG,
          ZCL_DATATYPE_BITMAP8,
          ACCESS_CONTROL_READ,
          (void *)&zclAZh0006_Summation_Formatting
        }
      },
      {
       ZCL_CLUSTER_ID_SE_METERING,
        { // Attribute record
          ATTRID_SE_METERING_DMD_FMTG,
    	  ZCL_DATATYPE_BITMAP8,
          ACCESS_CONTROL_READ,
          (void *)&zclAZh0006_Demand_Formatting
        }
      },
      {
       ZCL_CLUSTER_ID_SE_METERING,
        { // Attribute record
          ATTRID_SE_METERING_DEVICE_TYPE,
          ZCL_DATATYPE_BITMAP8,
          ACCESS_CONTROL_READ,
          (void *)&zclAZh0006_Metering_DeviceType
        }
      },
      {
       ZCL_CLUSTER_ID_SE_METERING,
        { // Attribute record
          ATTRID_SE_METERING_INST_DMD,
    	  ZCL_DATATYPE_UINT24,
          ACCESS_CONTROL_READ,
          (void *)&zclAZh0006_Instantaneous_Demand
        }
      },
    #endif 
      // *** On/Off Cluster Attributes ***
      {
        ZCL_CLUSTER_ID_GEN_ON_OFF,
        { // Attribute record
          ATTRID_ON_OFF,
          ZCL_DATATYPE_BOOLEAN,
          ACCESS_CONTROL_READ,
          (void *)&zclAZh0006_OnOffC1
        }
      }
    
    #ifdef ZCL_LEVEL_CTRL
      , {
        ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL,
        { // Attribute record
          ATTRID_LEVEL_CURRENT_LEVEL,
          ZCL_DATATYPE_UINT8,
          ACCESS_CONTROL_READ,
          (void *)&zclAZh0006_LevelCurrentLevel
        }
      },
      {
        ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL,
        { // Attribute record
          ATTRID_LEVEL_REMAINING_TIME,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          (void *)&zclAZh0006_LevelRemainingTime
        }
      },
      {
        ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL,
        { // Attribute record
          ATTRID_LEVEL_ON_OFF_TRANSITION_TIME,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE,
          (void *)&zclAZh0006_LevelOnOffTransitionTime
        }
      },
      {
        ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL,
        { // Attribute record
          ATTRID_LEVEL_ON_LEVEL,
          ZCL_DATATYPE_UINT8,
          ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE,
          (void *)&zclAZh0006_LevelOnLevel
        }
      },
      {
        ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL,
        { // Attribute record
          ATTRID_LEVEL_ON_TRANSITION_TIME,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE,
          (void *)&zclAZh0006_LevelOnTransitionTime
        }
      },
      {
        ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL,
        { // Attribute record
          ATTRID_LEVEL_OFF_TRANSITION_TIME,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE,
          (void *)&zclAZh0006_LevelOffTransitionTime
        }
      },
      {
        ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL,
        { // Attribute record
          ATTRID_LEVEL_DEFAULT_MOVE_RATE,
          ZCL_DATATYPE_UINT8,
          ACCESS_CONTROL_READ | ACCESS_CONTROL_WRITE,
          (void *)&zclAZh0006_LevelDefaultMoveRate
        }
      }
    #endif
     #ifdef ZCL_DIAGNOSTIC
      , {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_NUMBER_OF_RESETS,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_PERSISTENT_MEMORY_WRITES,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_MAC_RX_BCAST,
          ZCL_DATATYPE_UINT32,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_MAC_TX_BCAST,
          ZCL_DATATYPE_UINT32,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_MAC_RX_UCAST,
          ZCL_DATATYPE_UINT32,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_MAC_TX_UCAST,
          ZCL_DATATYPE_UINT32,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_MAC_TX_UCAST_RETRY,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_MAC_TX_UCAST_FAIL,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_APS_RX_BCAST,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_APS_TX_BCAST,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_APS_RX_UCAST,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_APS_TX_UCAST_SUCCESS,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_APS_TX_UCAST_RETRY,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_APS_TX_UCAST_FAIL,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_ROUTE_DISC_INITIATED,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_NEIGHBOR_ADDED,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_NEIGHBOR_REMOVED,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_NEIGHBOR_STALE,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_JOIN_INDICATION,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_CHILD_MOVED,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_NWK_FC_FAILURE,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_APS_FC_FAILURE,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_APS_UNAUTHORIZED_KEY,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_NWK_DECRYPT_FAILURES,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_APS_DECRYPT_FAILURES,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_PACKET_BUFFER_ALLOCATE_FAILURES,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_RELAYED_UCAST,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_PHY_TO_MAC_QUEUE_LIMIT_REACHED,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_PACKET_VALIDATE_DROP_COUNT,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_AVERAGE_MAC_RETRY_PER_APS_MESSAGE_SENT,
          ZCL_DATATYPE_UINT16,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_LAST_MESSAGE_LQI,
          ZCL_DATATYPE_UINT8,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
      {
        ZCL_CLUSTER_ID_HA_DIAGNOSTIC,
        {  // Attribute record
          ATTRID_DIAGNOSTIC_LAST_MESSAGE_RSSI,
          ZCL_DATATYPE_INT8,
          ACCESS_CONTROL_READ,
          NULL // Use application's callback to Read this attribute
        }
      },
    #endif // ZCL_DIAGNOSTIC
    
     
    };
    /*********************************************************************
     * EndPoint 1 NumAttributes
     */
    uint8 CONST zclAZh0006_NumAttributesC1 = ( sizeof(zclAZh0006_AttrsC1) / sizeof(zclAZh0006_AttrsC1[0]) );
    
    /*********************************************************************
     * EndPoint 2 NumAttributes
     */
    uint8 CONST zclAZh0006_NumAttributesC2 = ( sizeof(zclAZh0006_AttrsC2) / sizeof(zclAZh0006_AttrsC2[0]) );
    
    /*********************************************************************
     * EndPoint 3 NumAttributes
     */
    uint8 CONST zclAZh0006_NumAttributesSE1 = ( sizeof(zclAZh0006_AttrsSE1) / sizeof(zclAZh0006_AttrsSE1[0]) );
    
    

    2. ..." Does zclSE_RegisterCmdCallbacks return a success status"..

    I got it via Wireshark sniffer over ZDO Simples Desc Response and ZCL mesages:

    3. .."Are you able to debug the project to follow zclSE_HdlIncoming -> zclSE_HdlSpecificCmd -> zclSE_HdlSpecificServerCmd -> zclSE_MeteringHdlServerCmd? "

    I have problem to debug it, i tried to start and the IAR EWB is not starting over the ZCL_SE code. Since If I change the compiler > optmization to reduce the optmization level to low, I got errors when I try to compiler my project. It just started to happen, in my App, when included the additionals lines in my code to improve the ZCL_SE callback procedures. If I comment out the function zclAZh0006_MeteringGetProfileCB the error doesn´t happen!

    "-Z(CODE)ZIGNV_ADDRESS_SPACE=_ZIGNV_ADDRESS_SPACE_START-_ZIGNV_ADDRESS_SPACE_END", where at the moment of placement the available

    4 - I trying to get  the ZCL Read Attributes Mesage - 0x00 to processing those attributes Current Summation Delivered (0x0000),  Instanteneous Demand (0x0400) and Unit of measure (0x0300). Maybe I´m trying to capture it using the ZCL type structure wrong. I didnt find inside the zlc_se.c structure type that matches exacly the ZCL SE Metering Parameters (0x0000, 0x0400 and 0x0300).

    I have no idea how to fix it.

    BR,

    Alex

  • Thank you for the additional information.  Can you provide your in/out cluster lists and simple descriptor code as well?  Concerning the Simple Descriptor Response, I recommend using a different endpoint for OTA and adding basic to the out cluster list.  Are you sure that metering is required as an output cluster?  I would also expect the application device ID for a Smart Plug to be 0x0051.  Can you try listing the attributes sequentially (i.e. ZCL_CLUSTER_ID_GEN_ON_OFF, ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, ZCL_CLUSTER_ID_SE_METERING, and ZCL_CLUSTER_ID_HA_DIAGNOSTIC)?

    Does commenting out the code in zclAZh0006_MeteringGetProfileCB resolve the build issue?  Or considered using Zigbee 3.0 or a standalone project (i.e. only Metering endpoint) to further isolate the issue?  

    ATTRID_SE_METERING_CURR_SUMM_DLVD, ATTRID_SE_METERING_UOM, and ATTRID_SE_METERING_INST_DMD are defined in zcl_se.h but not used in zcl_se.c so you would need to modify this ZCL layer for your own purposes.

    Regards,
    Ryan

  • Ryan, as you asked me.

    1. ..." Can you provide your in/out cluster lists and simple descriptor code as well?..."

    here is my cluster list and simple descritpt for each one EP.

    /*********************************************************************
     * EndPoint 1 NumAttributes
     */
    uint8 CONST zclAZh0006_NumAttributesC1 = ( sizeof(zclAZh0006_AttrsC1) / sizeof(zclAZh0006_AttrsC1[0]) );
    
    /*********************************************************************
     * EndPoint 2 NumAttributes
     */
    uint8 CONST zclAZh0006_NumAttributesC2 = ( sizeof(zclAZh0006_AttrsC2) / sizeof(zclAZh0006_AttrsC2[0]) );
    
    /*********************************************************************
     * EndPoint 3 NumAttributes
     */
    uint8 CONST zclAZh0006_NumAttributesSE1 = ( sizeof(zclAZh0006_AttrsSE1) / sizeof(zclAZh0006_AttrsSE1[0]) );
    
    
    /*********************************************************************
     * SIMPLE DESCRIPTOR FOR CIRCUIT1 - EP1 and EP3
     */
    // This is the Cluster ID List and should be filled with Application
    // specific cluster IDs.
    const cId_t zclAZh0006_InClusterList[] =
    {
       ZCL_CLUSTER_ID_GEN_BASIC,  		 	//0x0000
       ZCL_CLUSTER_ID_GEN_IDENTIFY, 		//0x0003
       ZCL_CLUSTER_ID_GEN_GROUPS,   		//0x0004
       ZCL_CLUSTER_ID_GEN_SCENES,		 	//0x0005
       ZCL_CLUSTER_ID_GEN_ON_OFF,  			//0x0006
    #ifdef ZCL_LEVEL_CTRL
       ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL		//0x0008
    #endif
    };
    // work-around for compiler bug... IAR can't calculate size of array with #if options.
    #ifdef ZCL_LEVEL_CTRL
     #define ZCLAZh0006_MAX_INCLUSTERS   6
    #else
     #define ZCLAZh0006_MAX_INCLUSTERS   5
    #endif
    
    const cId_t zclAZh0006_OutClusterList[] =
    {
      ZCL_CLUSTER_ID_OTA				//0x00019
    
    };
    #define ZCLAZh0006_MAX_OUTCLUSTERS  (sizeof(zclAZh0006_OutClusterList) / sizeof(zclAZh0006_OutClusterList[0]))
    
    
    /*********************************************************************
     * SIMPLE DESCRIPTOR FOR METERING DEVICE - EP2
     */
    // This is the Cluster ID List and should be filled with Application
    // specific cluster IDs.
    const cId_t zclAZh0006_InClusterListSE1[] =
    {  
       ZCL_CLUSTER_ID_GEN_BASIC,  		 	//0x0000
       ZCL_CLUSTER_ID_GEN_IDENTIFY, 		//0x0003
       ZCL_CLUSTER_ID_GEN_GROUPS,   		//0x0004
       ZCL_CLUSTER_ID_GEN_SCENES,		 	//0x0005
       ZCL_CLUSTER_ID_GEN_ON_OFF,  			//0x0006
       ZCL_CLUSTER_ID_SE_METERING,		 	//0x0702
    #ifdef ZCL_LEVEL_CTRL
       ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL
    #endif
    };
    // work-around for compiler bug... IAR can't calculate size of array with #if options.
    #ifdef ZCL_LEVEL_CTRL
     #define ZCLAZh0006_MAX_INCLUSTERSSE1   7
    #else
     #define ZCLAZh0006_MAX_INCLUSTERSSE1   6
    #endif
    
    const cId_t zclAZh0006_OutClusterListSE1[] =
    {
      ZCL_CLUSTER_ID_OTA,					//0x0019
      ZCL_CLUSTER_ID_SE_METERING
      
    };
    #define ZCLAZh0006_MAX_OUTCLUSTERSSE1  (sizeof(zclAZh0006_OutClusterListSE1) / sizeof(zclAZh0006_OutClusterListSE1[0]))
    
    
    /*********************************************************************
     * EndPoint 1 SimpleDescription Format Circuito FOR EP 1 and 3
     */
    
    SimpleDescriptionFormat_t	zclAZh0006C1_SimpleDesc	=
    {
      AZh0006_ENDPOINT1,                  		//  int Endpoint circuit 1;
      ZCL_HA_PROFILE_ID,                     	//  uint16 AppProfId  as 0x0104 - Home Automation
    #ifdef ZCL_LEVEL_CTRL
      ZCL_HA_DEVICEID_DIMMABLE_LIGHT,        	//  uint16 AppDeviceId as 0x0101 in Lighting Device IDs - zcl_ha.h, visto na mensagem Simple Description Response
    #else 
      ZCL_HA_DEVICEID_ON_OFF_LIGHT,          	//  uint16 AppDeviceId as 0x0100 in Lighting Device IDs - zcl_ha.h, visto na mensagem Simple Description Response
    #endif
      AZh0006_DEVICE_VERSION,            		//  int   AppDevVer:4;
      AZh0006_FLAGS,                     		//  int   AppFlags:0;
      ZCLAZh0006_MAX_INCLUSTERS,         		//  byte  AppNumInClusters;
      (cId_t *)zclAZh0006_InClusterList, 		//  byte *pAppInClusterList;
      ZCLAZh0006_MAX_OUTCLUSTERS,        		//  byte  AppNumInClusters;
      (cId_t *)zclAZh0006_OutClusterList 		//  byte *pAppInClusterList;
    };
    
    /*********************************************************************
     * EndPoint 3  SimpleDescription Format for FOR EP 1 and 3
     */
    
    SimpleDescriptionFormat_t zclAZh0006C2_SimpleDesc =
    {
      AZh0006_ENDPOINT3,                  		//  int Endpoint circuit 2;
      ZCL_HA_PROFILE_ID,                     	//  uint16 AppProfId as 0x0104 - Home Automation
    #ifdef ZCL_LEVEL_CTRL
      ZCL_HA_DEVICEID_DIMMABLE_LIGHT,        	//  uint16 AppDeviceId as 0x0101 in Lighting Device IDs - zcl_ha.h, visto na mensagem Simple Description Response
    #else 
      ZCL_HA_DEVICEID_ON_OFF_LIGHT,          	//  uint16 AppDeviceId as 0x0100 in Lighting Device IDs - zcl_ha.h, visto na mensagem Simple Description Response
    #endif
      AZh0006_DEVICE_VERSION,            		//  int   AppDevVer:4;
      AZh0006_FLAGS,                     		//  int   AppFlags:0;
      ZCLAZh0006_MAX_INCLUSTERS,         		//  byte  AppNumInClusters;
      (cId_t *)zclAZh0006_InClusterList, 		//  byte *pAppInClusterList;
      ZCLAZh0006_MAX_OUTCLUSTERS,        		//  byte  AppNumOutClusters;
      (cId_t *)zclAZh0006_OutClusterList 		//  byte *pAppInClusterList;
    };
    
    /*********************************************************************
     * EndPoint 2 SimpleDescription for SE - Metering Device EP 2
     */
    
    SimpleDescriptionFormat_t	zclAZh0006SE1_SimpleDesc	=
    {
      AZh0006_ENDPOINT2,                 		//  int Endpoint Metering Device
      ZCL_HA_PROFILE_ID,                 		//  uint16 AppProfId  as 0x0104 - Home Automation
      //ZCL_HA_DEVICEID_SMART_PLUG,        		//  uint16 AppDeviceId (APP id 0x51) or DeviceID de acordo com a zcl_ha.h, visto na mensagem Simple Description Response
      //ZCL_HA_DEVICEID_ON_OFF_OUTPUT,			//  uint16 AppDeviceId (APP id 0x0002) or DeviceID de acordo com a zcl_ha.h, visto na mensagem Simple Description Response. 
      ZCL_SE_DEVICEID_METERING,					//  uint16 AppDeviceId (APP id 0x0501) or DeviceID de acordo com a zcl_se.h,visto na mensagem Simple Description Response
      AZh0006_DEVICE_VERSION,            		//  int   AppDevVer:4;
      AZh0006_FLAGS,                     		//  int   AppFlags:0;
      ZCLAZh0006_MAX_INCLUSTERSSE1,         	//  byte  AppNumInClusters;
      (cId_t *)zclAZh0006_InClusterListSE1, 	//  byte *pAppInClusterList;
      ZCLAZh0006_MAX_OUTCLUSTERSSE1,        	//  byte  AppNumInClusters;
      (cId_t *)zclAZh0006_OutClusterListSE1 	//  byte *pAppOutClusterList;
    };
    

    2. " ... I recommend using a different endpoint for OTA and adding basic to the out cluster list..."

    I´ll do the changes and will share with you soon!

    3. "... Are you sure that metering is required as an output cluster? ..."

    I´m not have sure, I´ll take out it and will share you soon!

    4. " I would also expect the application device ID for a Smart Plug to be 0x0051"

    I totaly agree with you, I have used it in the last test, I´ll change the app ID to 0x0051 definectely!

    5; "...Can you try listing the attributes sequentially (i.e. ZCL_CLUSTER_ID_GEN_ON_OFF, ZCL_CLUSTER_ID_GEN_LEVEL_CONTROL, ZCL_CLUSTER_ID_SE_METERING, and ZCL_CLUSTER_ID_HA_DIAGNOSTIC)? ..."

    ´ll do the changes and will share with you soon!

    6.. "ATTRID_SE_METERING_CURR_SUMM_DLVD, ATTRID_SE_METERING_UOM, and ATTRID_SE_METERING_INST_DMD are defined in zcl_se.h but not used in zcl_se.c so you would need to modify this ZCL layer for your own purposes..."

    I´ll working on it, and let you know soon!

    Thanks a lot Ryan for your assistance!

    BR,

    Alex

  • HI Ryan,

    I got success to implement almost all changes you adivise me, I´m trying to parser ZCL Read Attributes Request and the ZCL SE attributes (item 6) 

    ATTRID_SE_METERING_CURR_SUMM_DLVD, ATTRID_SE_METERING_UOM, and ATTRID_SE_METERING_INST_DMD.

    I have use zclAZh0006_OnOffCB as a reference to write on ZCL_se.C and ZCL_se.h and Myapp.c, maybe is not the best way to do it and I have several doubts on how to do it. Do you have a post or Texas aplication notes to share it with me?

    BR,

    Alex

  • Hi Alex,

    I am not aware of any posts or TI Application Notes involving the Secure Metering ZCL with Z-Stack HA 1.2.2a.  Nevertheless, it should follow the basic procedure implemented for the general/HA ZCL.

    Regards,
    Ryan

  • Thanks Ryan, I have mapping all those parameters that envolve ZCL basic procedures on zcl_general.c, zcl_general.h and zcl.h.

    I´ll keep maintaing this post open to share my progress here. Are you agree with me?

    BR,

    Alex

  • Hi Alex,

    I recommend that you debug zclSE_RegisterCmdCallbacks and ensure that it executes zcl_registerPlugin in the same manner as zclGeneral_RegisterCmdCallbacks, but for zclSE_HdlIncoming instead of zclGeneral_HdlIncoming.  You also have the OTA examples (and thus endpoint registrations and callbacks) that can be referenced.

    Regards,
    Ryan

  • Hi Ryan,

    I got a few progress here:

    1, Included ZCL SE Cluster register over EP2,

    2. ZclSE_Hdlincoming procedure,  I added ZCL plugin cluster ID as  ZCL_CLUSTER_ID_SE_METERING

    After it I have observe my device anwser ZCL Reading attribute as default (sucessfuly), before it without changes 1 and 2, a observed unrecognized attribute in the ZCL read attribute esponse message.

    But I observed that the Message ZCL attribute message continued to be handled on ZCL.C in the "zclProcessInReadCmd" function, cause by non-existed CB procedure on zclSE_AppCallbacks_t type. I have used one existent for handling ZCL_CLUSTER_ID_SE_METERING but non prepered to handling ZCL Read Attribute Message with SE attributes. I undertanding that i need to create an proceure type (_t) to parsing it and need to include it on zclSE_AppCallbacks_t.

    Please, could you help me how to prepare/parser it for onde ot those SE parameters above?

    My zclSE_AppCallbacks_t:

    *********************************************************************
     * ZCL SE Profile Callback table for EP2 */
    
    
    static zclSE_AppCallbacks_t zclAZh0006_CmdCallbacksSE =
    {
      NULL,       
      NULL,       
      NULL,     
      NULL,    
      NULL,        
      NULL,     
      NULL,   
      NULL,   
      NULL,   
      NULL,   
      NULL,  
      NULL,  
      NULL, 
      //const zclSE_EnergyMgmtClientCBs_t  *pEnergyMgmtClientCBs;
      NULL,
      NULL,    
      NULL,    
      NULL,  
      NULL,  
      NULL,     
      NULL,       
      NULL,   
      NULL,   
    };
    

    My APP SE INIT with RegisterCalback and Application attributes Parameters list

    void zclAZh0006SE_Init( byte task_id )
    {
      zclAZh0006SE1_TaskID = task_id;
    
    
      // Set destination address to indirect
     // zclAZh0006_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
     // zclAZh0006_DstAddr.endPoint = 0;
     // zclAZh0006_DstAddr.addr.shortAddr = 0;
     
      /**********************************************************************************************************
     * 											UART Init  -  by ASA
     **********************************************************************************************************/  
    	// Set UART Definitions:
    	//uartMapPort(1,0);
    	initUart0(uart0RxCb);
    	
     /**********************************************************************************************************
     * ZCL Addressing Mode  -  by ASA
     efeito através das mensagens originadas a partir deste dispositivo
     **********************************************************************************************************/  
       zclAZh0006_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
       zclAZh0006_DstAddr.addr.shortAddr = 0; // Short Address sent to gateway
       zclAZh0006_DstAddr.endPoint=1; // DST Endpoint sent to Gateway
    
      // This app is part of the Home Automation Profile
      zclHA_Init(&zclAZh0006SE1_SimpleDesc);
    
       // Register the ZCL SE Cluster Library callback functions according zcl_se.c
    #ifdef ZCL_SE_METERING_SERVER
      zclSE_RegisterCmdCallbacks( AZh0006_ENDPOINT2, &zclAZh0006_CmdCallbacksSE ); //using the same callback as circuit 2
    #endif
    
      // Register the application's attribute list 
      zcl_registerAttrList( AZh0006_ENDPOINT2,zclAZh0006_NumAttributesSE1, zclAZh0006_AttrsSE1 );
    
      // Register the Application to receive the unprocessed Foundation command/response messages
      zcl_registerForMsg( zclAZh0006SE1_TaskID );
    
    #ifdef ZCL_DISCOVER
      // Register the application's command list
      zcl_registerCmdList( AZh0006_ENDPOINT2, zclCmdsArraySize, zclAZh0006_Cmds );
    #endif
    
      // Register for all key events - This app will handle all key events
      RegisterForKeys( zclAZh0006SE1_TaskID );
    
      // Register for a test endpoint
      afRegister( &AZh0006_TestEp2 );
    
    #ifdef ZCL_EZMODE
      // Register EZ-Mode
      zcl_RegisterEZMode( &zclAZh0006_RegisterEZModeDataSE );
    
      // Register with the ZDO to receive Match Descriptor Responses
      ZDO_RegisterForZDOMsg(task_id, Match_Desc_rsp);
      
      //Register with the ZDO to receive Permit to Join Request
      ZDO_RegisterForZDOMsg(task_id, Mgmt_Permit_Join_req);
      
      //Register with the ZDO to receive Leave Req
      ZDO_RegisterForZDOMsg(task_id, Mgmt_Leave_req);
    #endif
    
    #ifdef ZCL_DIAGNOSTIC
      // Register the application's callback function to read/write attribute data.
      // This is only required when the attribute data format is unknown to ZCL.
      zcl_registerReadWriteCB( AZh0006_ENDPOINT2, zclDiagnostic_ReadWriteAttrCB, NULL );
    
      if ( zclDiagnostic_InitStats() == ZSuccess )
      {
        // Here the user could start the timer to save Diagnostics to NV
      }
    #endif
    
    #ifdef ZGP_AUTO_TT
      zgpTranslationTable_RegisterEP ( &zclAZh0006SE1_SimpleDesc );
    #endif
    }
    

    my ZCL_SE.C changes:

    /**************************************************************************************************
     * @fn      zclSE_HdlIncoming
     *
     * @brief   Callback from ZCL to process incoming Commands specific
     *          to this cluster library or Profile commands for attributes
     *          that aren't in the attribute list
     *
     * @param   pInMsg - incoming message to process
     *
     * @return  ZStatus_t
     */
    static ZStatus_t zclSE_HdlIncoming( zclIncoming_t *pInMsg )
    {
      ZStatus_t status = ZCL_STATUS_SUCCESS;
    
    #if defined ( INTER_PAN )
      if ( StubAPS_InterPan( pInMsg->msg->srcAddr.panId, pInMsg->msg->srcAddr.endPoint ) &&
           !( pInMsg->msg->clusterId == ZCL_CLUSTER_ID_SE_METERING ||							//ZCL_CLUSTER_ID_SE_PRICE original value by ASA
              pInMsg->msg->clusterId == ZCL_CLUSTER_ID_SE_MESSAGING )                       )
      {
        return status; // Cluster not supported thru Inter-PAN
      }
    #endif
      if ( zcl_ClusterCmd( pInMsg->hdr.fc.type ) )
      {
        // Check for manufacturer specific command
        if ( pInMsg->hdr.fc.manuSpecific == 0 )
        {
          status = zclSE_HdlSpecificCmdHook( pInMsg );
        }
        else
        {
          // Manufacturer specific command not handled
          status = ZCL_STATUS_FAILURE;
        }
      }
      else
      {
        //Handle all the normal (Read, Write...) commands -- should never get here
        status = ZCL_STATUS_FAILURE;
      }
    
      return status;
    }
    

  • You should not need to change zclSE_HdlIncoming as I do not believe you are using InterPan messages.  Can you provide a sniffer log in which you explain which commands you think should be entering a callback?  As your setup implies a metering server, I would expect that ZCL_SE_METERING_SERVER is defined and zclSE_MeteringHdlServerCmd should be processed for an incoming client-to-server metering command.  There are several unique commands which can be supported, which is why secondary structs are used inside zclSE_MeteringServerCBs_t.  However, basic Read Attribute Commands are still handled by the ZCL foundation layer (*_ProcessIncomingMsg -> *_ProcessInReadRspCmd) inside the zcl_[application].c file.

    Regards,
    Ryan

  • Ryan, thanks you for your support! I´ll explain below your questions:

    1. "You should not need to change zclSE_HdlIncoming as I do not believe you are using InterPan messages"

    I totaly agree with you, i change it to default parameters!

    2. "Can you provide a sniffer log in which you explain which commands you think should be entering a callback"

    Would you see attached my wireshark log.

    You can see in this log the message #290 - ZCL Read attribute from gateway to my device with those Attributes that I need to processing in my device:

    Attribute: Current Summation Delivered (0x0000)

    Attribute: Instantaneous Demand (0x0400)

    Attribute: Unit of Measure (0x0300)

    Attribute: Multiplier (0x0301)

    Attribute: Divisor (0x0302)

    Note: My Metering Server Device have: EP =2 and short add 0x9ca6

    I need to include in my Callback the treatment for those attributes above got from ZCL Read Attributes and Send ZCL Read attributes response with correspondent values storage in my device to Gateway. 

    It´s possible to deviate the ZCL Read Attribute to do the treatment of LOAD Attributes in my ZCL_[Appilication].c file?

    3. I would expect that ZCL_SE_METERING_SERVER is defined and zclSE_MeteringHdlServerCmd should be processed for an incoming client-to-server metering command

    My breakpoints was not hit in the zclSE_MeteringHdlServerCmd, I only see it as I told you in ZCL.C in the "zclProcessInReadCmd.

    The breackpoint above was not reach when my device received the message #290, ZCL Read attributes.

    4. There are several unique commands which can be supported, which is why secondary structs are used inside zclSE_MeteringServerCBs_t.

    I understanding that I need to inclue a new structures on zclSE_MeteringServerCBs_t  to provide the specific call back for each one ot five attributes I need to processing in my device and send it to gateway. But the Gateway uses basic ZCL attributes, according ZCL.C, via ZCL Read Attributes message and I not have one specific CMD as we can see on zclSE_MeteringServerCBs (COMMAND_SE_METERING_GET_PROFILE, COMMAND_SE_METERING_REQ_MIRROR_RSP and etc) .

    I have no idea how to include, or if it is necessary, to processing the LOAD CONTROL EVENTS (INSTANTANEOUS DEMAND, CURRENT SUMMATION DELIVERED and etc).

    I would like to do the treatment of LOAD Control Atrributes on my ZCL_[Appilication].c!

    5. However, basic Read Attribute Commands are still handled by the ZCL foundation layer (*_ProcessIncomingMsg -> *_ProcessInReadRspCmd) inside the zcl_[application].c file

    Sorry, I forgot to explain it before, I have included breakpoints on ProcessInReadRspCmd in my ZCL_[Appilication].c file and never I dont see being achieved when the Message ZCL Read attribute (msg #290 in my attached log) was arrived. I reproduce it iagain to try to find the message #290.  But i didnt succed As you see below and in the log.

    The breackpoint above was not reach when my device received the message #290, ZCL Read attributes.

    BR

    Alex

    rayanLOG20210911.zip

     

  • Hi Ryan,

    I worked in the wrong way. As you told me before the ZCL Read Attributes works with "However, basic Read Attribute Commands are still handled by the ZCL foundation layer Its no necessary to implement Calback as I tried before!!!

    I just created an external variable linked in the ZCL SE Attribute in the application's attribute list and updated that variable, according to the sensor data sent to my device via UART, in the ZCL_[Application] .c file. I will describe it in the part of my code below:

    1. SE Cluster ID and their respective Attribute CSMD.

    // *** Smart Energy Metering Server Cluster Attributes ***
    #ifdef ZCL_SE_METERING_SERVER
      ,{
       ZCL_CLUSTER_ID_SE_METERING,				// Cluster IDs - defined in the foundation (ie. zcl.h) - Smart Energy (SE) Clusters
        { // Attribute record
          ATTRID_SE_METERING_CURR_SUMM_DLVD,	// Attribute ID - Found in Cluster Library header (ie. zcl_se.h)
          ZCL_DATATYPE_UINT48,					// Data Type - found in zcl.h
          ACCESS_CONTROL_READ,					// Variable access control - found in zcl.h
          (void *)&zclAZh0006_CurrentSummationDelivered // Pointer to attribute variable
        }
      },

    2. SE Default Value variables. 

    // in the zc_myapp_data.c
    
     * EndPoint 2 - EP2 - Metering Cluster
     */
     #ifdef ZCL_SE_METERING_SERVER
    uint24 zclAZh0006_MeasureMult = DEFAULT_METERING_MULT_VALUE;
    uint24 zclAZh0006_MeasureDiv  = DEFAULT_METERING_DIV_VALUE;
    uint32 zclAZh0006_CurrentSummationDelivered = DEFAULT_CURR_SUMM_DLVD_VALUE;
    #endif //ZCL_SE_METERING_SERVER
    
    // in the zc_myapp.h
    
    // to persist external - ZCL_SE_METERING_SERVER - Metering Measurement Cluster 
    extern uint32 zclAZh0006_CurrentSummationDelivered;
    
    #ifdef ZCL_SE_METERING_SERVER
    // *** Smart Energy Metering Server Cluster Attributes -default value ***
    #define DEFAULT_CURR_SUMM_DLVD_VALUE   0;
    #define DEFAULT_INSTANTANEOUS_DEMAND   0
    #define DEFAULT_METERING_STATUS        0
    #define DEFAULT_UOM_VALUE              0
    #define DEFAULT_SUMM_FMTG_VALUE        0
    #define DEFAULT_METERING_DEVICE_TYPE   0
    #define DEFAULT_METERING_MULT_VALUE	   0x000001 // new one ASA - 24-bits unsigned integer - dec.      1
    #define DEFAULT_METERING_DIV_VALUE	   0x0186A0 // new one ASA - 24-bits unsigned integer - dec. 100000
    #endif // ZCL_SE_METERING_SERVER

    3. My device responding with te ZCL Read Attribute Response: Current Summation Delivered (0x0000) 

    Ryan, thanks a lot for your assistance!!!

    BR,

    Alex