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.

Problem using HAL_KEY_SW_6

Other Parts Discussed in Thread: Z-STACK

Hi,

I'm making a lighting app (HA) with a coordinator (as Dimmable SW) and  a router (as Dimmable Light ), using  the HA examples (Sample Light and Sample Switch) for the Z-Stack. For this, I implemented the level control cluster, using the on/off cluster and the ZCL specification (attributes/commands) as reference.

My problem is that the coordinator sends the on/off command without problems but never sends the level control command that i want.

This line is never executed and i don't know why:

if ( keys & HAL_KEY_SW_6){

 // Using Level Control
 #ifdef ZCL_LEVEL_CTRL

 zclGeneral_SendLevelControlStep( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, 0x00, 0x80, 0xFFFF, false, 0 );

 #endif // ZCL_LEVEL_CTRL

}

Thanks.

  • HAL_KEY_SW_6 is used as the 'shift' modifier to the other keys and as a way to wake from PM. The IAR optimizes out the key handler, so do this so you can hit a break point in the function and study the parameters passed to it:

    #pragma optimize=none  //ggg
    static void GenericApp_HandleKeys( uint8 shift, uint8 keys )

    Run through two examples - press the joystick up (HAL_KEY_SW_1), then press + hold the Button 1 while pressing the joystick up.

  • Thank you a lot for your reply, now I can hit a breakpoint in the HandleKeys function.

    I didn't say that I'm using a custom board (without Joystick) but there is not a problem because I changed HAL_KEY  libraries and the  Z-stack examples run without problems.

    My problem is with the Level Control Cluster. As you said me, with a breakpoint I can see that the system doesn't excute this line (the key interrupt runs OK):

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

    #ifdef ZCL_LEVEL_CTRL //System doesn't execute the next line

     zclGeneral_SendLevelControlStep( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, 0x00, 0x80, 0xFFFF, false, 0 );

     #endif // ZCL_LEVEL_CTRL

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

    -Do I need to define ZCL_LEVEL_CTRL? 

    -I use binding with the devices.

    Thanks for all.

  • Of course you do

    #ifdef ZCL_LEVEL_CTRL

    is equivalent to

    #if defined ZCL_LEVEL_CTRL

    which is like the C-code statement

    if (ZCL_LEVEL_CTRL)

    If you started with an HA sample app, your project will already be including f8wZCL.cfg in the 'Tools' folder of the IDE, so open the file and look for your word:


    /* ZCL Level Control enables the following commands:
     *   1) Move to Level
     *   2) Move
     *   3) Step
     *   4) Stop
     */
    //-DZCL_LEVEL_CTRL

    So you see that by default, it is not defined.

     

  • Thank you for your help. It was so useful for me.

    Manuel Menchaca.

  • Today I'm doing all you said but I had a new problem...

    // Using Level Control
    #ifdef ZCL_LEVEL_CTRL
    zclGeneral_SendLevelControlStep( SAMPLESW_ENDPOINT, &zclSampleSw_DstAddr, 0x00, 0x80, 0xFFFF, false, 0 );
    #endif

    I receive this message when I try to compile the code...

    Error[e46]: Undefined external "zclGeneral_SendLevelControlStepRequest" referred in zcl_samplesw ( C:\Texas Instruments\ZStack-MSP2618-2.5.0\Projects\zstack\HomeAutomation\SampleSwitch\CC2520DB\Coordinator\Obj\

    What can I do?

  • I solved the problem adding this line in he C/C++ Compile:

    $PROJ_DIR$\..\..\..\..\..\Components\stack\zcl

    That's all!