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.

CCS/CC2652R: Add 4 light loads in one zr_light example

Part Number: CC2652R


Tool/software: Code Composer Studio

hi,

How can I add 4 light loads in one zr_light sample example?

Is it by adding 4 different endpoints for 4 light load? or Is it possible in one endpoint?

if have any procedure/guideline for adding 4 light loads in one device please let me know.

  • Yes, you should use four endpoint for four different loads. You can refer to zr_switc_ota example to know how to register another endpoint.
  • hi,
    Thanks for your reply,
    In zr_switch_ota example I have not understood how ota client endpoint added & register.

    In zr_light example ->
    add a duplicate of files for 2nd endpoint in Application like zcl_samplelight1_data.c, zcl_samplelight1.c and replace all
    SampleLight to SampleLight1,
    SAMPLELIGHT to SAMPLELIGHT1,
    sLight to sLight1

    open zcl_samplelight.h--> add below for samplelight1 end point
    #define SAMPLELIGHT1_ENDPOINT 9
    #define SAMPLELIGHT1_NUM_GRPS 2
    #define SAMPLELIGHT1_POLL_CONTROL_TIMEOUT_EVT 0x0001
    #define SAMPLELIGHT1_LEVEL_CTRL_EVT 0x0002
    extern bdbTLDeviceInfo_t tlSampleLight1_DeviceInfo;
    extern SimpleDescriptionFormat_t zclSampleLight1_SimpleDesc;
    extern CONST zclCommandRec_t zclSampleLight1_Cmds[];
    extern CONST zclAttrRec_t zclSampleLight1_Attrs[];
    extern CONST uint8 zclSampleLight1_NumAttributes;
    extern uint16 zclSampleLight1_IdentifyTime;
    extern uint8 zclSampleLight1_IdentifyCommissionState;
    extern uint8 zclSampleLight1_GroupsNameSupport;
    extern uint8 zclSampleLight1_ScenesSceneCount;
    extern uint8 zclSampleLight1_ScenesCurrentScene;
    extern uint16 zclSampleLight1_ScenesCurrentGroup;
    extern uint8 zclSampleLight1_ScenesSceneValid;
    extern CONST uint8 zclSampleLight1_ScenesNameSupport;
    extern uint8 zclSampleLight1_OnOff;
    extern uint8 zclSampleLight1_LevelCurrentLevel;
    extern uint16 zclSampleLight1_LevelRemainingTime;
    extern uint16 zclSampleLight1_LevelOnOffTransitionTime;
    extern uint8 zclSampleLight1_LevelOnLevel;
    extern uint16 zclSampleLight1_LevelOnTransitionTime;
    extern uint16 zclSampleLight1_LevelOffTransitionTime;
    extern uint8 zclSampleLight1_LevelDefaultMoveRate;
    extern void zclSampleLight1_task(NVINTF_nvFuncts_t *pfnNV);
    extern void zclSampleLight1_ResetAttributesToDefaultValues(void);

    in main.c add
    zclSampleLight1_task(&zstack_user0Cfg.nvFps); at end of function Void taskFxn(UArg a0, UArg a1)

    Is it the correct way?
    if yes then when I build the project it shows below error,
    Failed linktime optimization null: Failed linktime optimization
    gmake: *** [all] Error 2
    gmake[1]: *** [zr_light_cc26x2lp.out] Error 1
    symbol "zclSampleLight1_task" redeclared with incompatible type: null: symbol "zclSampleLight1_task" redeclared with incompatible type:

    please let me know where i am getting wrong.
  • hi,
    build successfully by changing #include "zcl_samplelight.h" to #include "../Application/zcl_samplelight.h"

    but when a device joins to Zigbee sensor to cloud Linux gateway it shows only one endpoint 8. Endpoint 9 not display.
    Is there something missing? Please help me to solve this issue.
  • I don’t see where you registered new endpoint.
  • hi,
    Can you tell me where I can register new endpoint in zr_light sample example?

    I also cross-checked new endpoint by doing below,
    zclSampleLight_task(&zstack_user0Cfg.nvFps);
    zclSampleLight1_task(&zstack_user0Cfg.nvFps);
    --> it shows endpoint 8 only.

    zclSampleLight1_task(&zstack_user0Cfg.nvFps);
    zclSampleLight_task(&zstack_user0Cfg.nvFps);
    --> it shows endpoint 9 only.

    if new endpoint 9 is not registered then why it displays.
  • I suppose you should call zclport_registerEndpoint to register new endpoint and call zclGeneral_RegisterCmdCallbacks to register zcl general cluster command callback functions.
  • hi,

    I already called both functions in zclSampleLight_Init function see below

    static void zclSampleLight1_Init( void )
    {

    // Set destination address to indirect
    zclSampleLight1_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
    zclSampleLight1_DstAddr.endPoint = 0;
    zclSampleLight1_DstAddr.addr.shortAddr = 0;

    //Register Endpoint
    zclSampleLight1EpDesc.endPoint = SAMPLELIGHT1_ENDPOINT;
    zclSampleLight1EpDesc.simpleDesc = &zclSampleLight1_SimpleDesc;
    zclport_registerEndpoint(zclSampleLight1_Entity, &zclSampleLight1EpDesc);

    #if defined (ENABLE_GREENPOWER_COMBO_BASIC)
    zclGp_RegisterCBForGPDCommand(&zclSampleLight1_GpSink_AppCallbacks);
    #endif


    // Register the ZCL General Cluster Library callback functions
    zclGeneral_RegisterCmdCallbacks( SAMPLELIGHT1_ENDPOINT, &zclSampleLight1_CmdCallbacks );

    // Register the application's attribute list and reset to default values
    zclSampleLight1_ResetAttributesToDefaultValues();
    zcl_registerAttrList( SAMPLELIGHT1_ENDPOINT, zclSampleLight1_NumAttributes, zclSampleLight1_Attrs );

    // Register the Application to receive the unprocessed Foundation command/response messages
    zclport_registerZclHandleExternal(zclSampleLight1_ProcessIncomingMsg);

    #if !defined (DISABLE_GREENPOWER_BASIC_PROXY) && (ZG_BUILD_RTR_TYPE)
    gp_endpointInit(zclSampleLight1_Entity);
    #endif

    //Write the bdb initialization parameters
    zclSampleLight1_initParameters();

    //Setup ZDO callbacks
    SetupZStackCallbacks();

    #if !defined (DISABLE_GREENPOWER_BASIC_PROXY) && (ZG_BUILD_RTR_TYPE)
    gp_endpointInit(zclSampleLight1_Entity);
    #endif

    #ifdef ZCL_LEVEL_CTRL
    zclSampleLight1_LevelLastLevel = zclSampleLight1_LevelCurrentLevel;
    #endif


    #ifdef ZCL_DISCOVER
    // Register the application's command list
    zcl_registerCmdList( SAMPLELIGHT1_ENDPOINT, zclCmdsArraySize, zclSampleLight1_Cmds );
    #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( SAMPLELIGHT1_ENDPOINT, zclDiagnostic_ReadWriteAttrCB, NULL );

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

    #ifdef PER_TEST
    UI_Init(zclSampleLight1_Entity, &events, sem, SAMPLEAPP_UI_AUTO_REFRESH_EVT, SAMPLEAPP_UI_INPUT_EVT, &zclSampleLight1_IdentifyTime, APP_TITLE, &PERTest_UiRefresh, PERTest_UiStatesMain,NULL);
    #else
    UI_Init(zclSampleLight1_Entity, &events, sem, SAMPLEAPP_UI_AUTO_REFRESH_EVT, SAMPLEAPP_UI_INPUT_EVT, &zclSampleLight1_IdentifyTime, APP_TITLE, &zclSampleLight1_UiRefresh, zclSampleLight1_UiStatesMain,NULL);
    #endif

    #if !defined (DISABLE_GREENPOWER_BASIC_PROXY) && (ZG_BUILD_RTR_TYPE)
    app_Green_Power_Init(zclSampleLight1_Entity, &events, sem, SAMPLEAPP_PROCESS_GP_DATA_SEND_EVT,
    SAMPLEAPP_PROCESS_GP_EXPIRE_DUPLICATE_EVT, SAMPLEAPP_PROCESS_GP_TEMP_MASTER_EVT);
    #endif

    #if defined ( BDB_TL_INITIATOR )
    touchLinkInitiatorApp_Init(zclSampleLight1_Entity);
    #elif defined ( BDB_TL_TARGET )
    touchLinkTargetApp_Init(zclSampleLight1_Entity);
    #endif

    UI_Refresh();

    #ifdef PER_TEST
    per_interface_init(sem, zclSampleLight1_Entity, SAMPLELIGHT1_ENDPOINT );
    #endif
    }



    I have used simplelink_cc26x2_sdk_2_30_00_34 zr_light sample example.
  • hi,
    in main.c

    /* Kick off application */
    zclSampleLight_task(&zstack_user0Cfg.nvFps);
    zclSampleLight1_task(&zstack_user0Cfg.nvFps);

    --> same structure pass to both tasks &zstack_user0Cfg.nvFps

    and

    void zclSampleLight1_task(NVINTF_nvFuncts_t *pfnNV)
    {
    // Save and register the function pointers to the NV drivers
    pfnZdlNV = pfnNV;
    zclport_registerNV(pfnZdlNV, ZCL_PORT_SCENE_TABLE_NV_ID);

    // Initialize application
    zclSampleLight1_initialization();

    // No return from task process
    zclSampleLight1_process_loop();
    }

    void zclSampleLight_task(NVINTF_nvFuncts_t *pfnNV)
    {
    // Save and register the function pointers to the NV drivers
    pfnZdlNV = pfnNV;
    zclport_registerNV(pfnZdlNV, ZCL_PORT_SCENE_TABLE_NV_ID);

    // Initialize application
    zclSampleLight_initialization();

    // No return from task process
    zclSampleLight_process_loop();
    }
    --> zclport_registerNV(pfnZdlNV, ZCL_PORT_SCENE_TABLE_NV_ID); are common in both task functions
    Is this will be affect to register second endpoint?
  • I suppose you should call zclport_registerEndpoint and zclGeneral_RegisterCmdCallbacks in the same zclSampleLight_Init to register second endpoint and ZCL General Cluster Library callback functions for second endpoint. No need to create another task.
  • hi,
    as per your suggestion, I have modified below function

    static void zclSampleLight_Init( void )
    {

    // Set destination address to indirect
    zclSampleLight_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
    zclSampleLight_DstAddr.endPoint = 0;
    zclSampleLight_DstAddr.addr.shortAddr = 0;
    zclSampleLight1_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
    zclSampleLight1_DstAddr.endPoint = 0;
    zclSampleLight1_DstAddr.addr.shortAddr = 0;

    //Register Endpoint 1
    zclSampleLightEpDesc.endPoint = SAMPLELIGHT_ENDPOINT;
    zclSampleLightEpDesc.simpleDesc = &zclSampleLight_SimpleDesc;
    zclport_registerEndpoint(zclSampleLight_Entity, &zclSampleLightEpDesc);
    zclSampleLight1EpDesc.endPoint = SAMPLELIGHT1_ENDPOINT;
    zclSampleLight1EpDesc.simpleDesc = &zclSampleLight1_SimpleDesc;
    zclport_registerEndpoint(zclSampleLight_Entity, &zclSampleLight1EpDesc);

    #if defined (ENABLE_GREENPOWER_COMBO_BASIC)
    zclGp_RegisterCBForGPDCommand(&zclSampleLight_GpSink_AppCallbacks);
    #endif


    // Register the ZCL General Cluster Library callback functions
    zclGeneral_RegisterCmdCallbacks( SAMPLELIGHT_ENDPOINT, &zclSampleLight_CmdCallbacks );
    zclGeneral_RegisterCmdCallbacks( SAMPLELIGHT1_ENDPOINT, &zclSampleLight1_CmdCallbacks );
    // Register the application's attribute list and reset to default values
    zclSampleLight_ResetAttributesToDefaultValues();
    zclSampleLight1_ResetAttributesToDefaultValues();
    zcl_registerAttrList( SAMPLELIGHT_ENDPOINT, zclSampleLight_NumAttributes, zclSampleLight_Attrs );
    zcl_registerAttrList( SAMPLELIGHT1_ENDPOINT, zclSampleLight1_NumAttributes, zclSampleLight1_Attrs );
    // Register the Application to receive the unprocessed Foundation command/response messages
    zclport_registerZclHandleExternal(zclSampleLight_ProcessIncomingMsg);

    #if !defined (DISABLE_GREENPOWER_BASIC_PROXY) && (ZG_BUILD_RTR_TYPE)
    gp_endpointInit(zclSampleLight_Entity);
    #endif

    //Write the bdb initialization parameters
    zclSampleLight_initParameters();

    //Setup ZDO callbacks
    SetupZStackCallbacks();

    #if !defined (DISABLE_GREENPOWER_BASIC_PROXY) && (ZG_BUILD_RTR_TYPE)
    gp_endpointInit(zclSampleLight_Entity);
    #endif

    #ifdef ZCL_LEVEL_CTRL
    zclSampleLight_LevelLastLevel = zclSampleLight_LevelCurrentLevel;
    zclSampleLight1_LevelLastLevel = zclSampleLight1_LevelCurrentLevel;
    #endif


    #ifdef ZCL_DISCOVER
    // Register the application's command list
    zcl_registerCmdList( SAMPLELIGHT_ENDPOINT, zclCmdsArraySize, zclSampleLight_Cmds );
    zcl_registerCmdList( SAMPLELIGHT1_ENDPOINT, zclCmdsArraySize1, zclSampleLight1_Cmds );
    #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( SAMPLELIGHT_ENDPOINT, zclDiagnostic_ReadWriteAttrCB, NULL );

    if ( zclDiagnostic_InitStats() == ZSuccess )
    {
    // Here the user could start the timer to save Diagnostics to NV
    }
    zcl_registerReadWriteCB( SAMPLELIGHT1_ENDPOINT, zclDiagnostic_ReadWriteAttrCB, NULL );
    if ( zclDiagnostic_InitStats() == ZSuccess )
    {
    // Here the user could start the timer to save Diagnostics to NV
    }
    #endif

    #ifdef PER_TEST
    UI_Init(zclSampleLight_Entity, &events, sem, SAMPLEAPP_UI_AUTO_REFRESH_EVT, SAMPLEAPP_UI_INPUT_EVT, &zclSampleLight_IdentifyTime, APP_TITLE, &PERTest_UiRefresh, PERTest_UiStatesMain,NULL);
    #else
    UI_Init(zclSampleLight_Entity, &events, sem, SAMPLEAPP_UI_AUTO_REFRESH_EVT, SAMPLEAPP_UI_INPUT_EVT, &zclSampleLight_IdentifyTime, APP_TITLE, &zclSampleLight_UiRefresh, zclSampleLight_UiStatesMain,NULL);
    #endif

    #if !defined (DISABLE_GREENPOWER_BASIC_PROXY) && (ZG_BUILD_RTR_TYPE)
    app_Green_Power_Init(zclSampleLight_Entity, &events, sem, SAMPLEAPP_PROCESS_GP_DATA_SEND_EVT,
    SAMPLEAPP_PROCESS_GP_EXPIRE_DUPLICATE_EVT, SAMPLEAPP_PROCESS_GP_TEMP_MASTER_EVT);
    #endif

    #if defined ( BDB_TL_INITIATOR )
    touchLinkInitiatorApp_Init(zclSampleLight_Entity);
    #elif defined ( BDB_TL_TARGET )
    touchLinkTargetApp_Init(zclSampleLight_Entity);
    #endif

    UI_Refresh();

    #ifdef PER_TEST
    per_interface_init(sem, zclSampleLight_Entity, SAMPLELIGHT_ENDPOINT );
    #endif
    }

    Remove zclSampleLight1_task(&zstack_user0Cfg.nvFps); from main function.
    Delete zcl_samplelight1.c file in application

    add necessary functions & variblale for endpoint2 in zcl_samplelight.c

    Now this will resolve my issue If anything not required or required to call in the above function then let me know.