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.

Samplelight LED1 blinking with HOLD_AUTO_START

Other Parts Discussed in Thread: CC2530EM, Z-STACK

Z-Stack Home 1.2.0, I'm trying samplelight with HOLD_AUTO_START enable. With no changes, run it on CC2530EM+SmartRF05 v1.8.1. The LED1 keeps blinking.

If I disable: xHOLD_AUTO_START, the samplelight working but auto connect to sampleswitch when it start.

I need it to be manually press button to enable the joining between samplelight and sampleswitch.

Then I made changes on ZDO:ZDApp.c and disable all LED4 such as //HalLedBlink ( HAL_LED_4, 0, 50, 500 );

with HOLD_AUTO_START enable in compile option, LED1 is not blink when start. But when start to join between samplelight and sampleswitch, the LED began to blink again. Status on LCD (LIGHT ON/OFF) is correctly appear. How to make the LED1 on/off accordingly when LIGHT ON/OFF? It keep blinking if HOLD_AUTO_START enable.

This is the compile option.

FEATURE_GREEN_POWER
SECURE=1
TC_LINKKEY_JOIN
NV_INIT
NV_RESTORE
xPOWER_SAVING
xNWK_AUTO_POLL
HOLD_AUTO_START
ZTOOL_P1
MT_TASK
MT_APP_FUNC
MT_SYS_FUNC
MT_ZDO_FUNC
LCD_SUPPORTED=DEBUG
ZCL_READ
ZCL_WRITE
ZCL_REPORT
ZCL_EZMODE
ZCL_BASIC
ZCL_IDENTIFY
ZCL_ON_OFF
ZCL_SCENES
ZCL_GROUPS
xZCL_LEVEL_CTRL

  • The HA Sample Apps use EZMode commissioning, this is triggered by HAL_KEY_SW_2 (right joystick push). EZMode is a mechanism in the ZigBee standard for Network Steering, Finding and Binding. 

    If you undefine HOLD_AUTO_START the device will not wait for EZMode and will join the network automatically. However it is not the network steering (or joining) part of EZMode that is causing the LED's to blink. The LED Blinks as part of the Finding and Binding process. EZMode uses Identify as part of this finding and binding process, the EZMode target (Light) will enter identify mode, the EZMode initiator (Switch) will then broadcast an IdentifyQuery  command to find the EZMode targets. It will then send any devices that respond a Match Descriptor Request to find which Clusters match and add those devices to its binding table. The Switch can then send commands to the Lights it found during EZMode commissioning by using address:

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

    So the LED blink you are seeing is the Light Identifying (in zclSampleLight_IdentifyCB -> zclSampleLight_ProcessIdentifyTimeChange -> HalLedBlink), as required by the Spec (when in Identify mode the device needs to visibly identify in some way), as part of the EZMode process. To remove this you would need to remove EZMode. The Switch would then need to use another method to address the switch, you could use just the Match Desc Request/Response to do this.

    Regards, TC.

  • Instead of blinking on LED1, I want to change it to LED2. How to do that? I cannot find any code that redirect the blinking part to LED1 that I can change. Please advice. Thanks.

  • You can swap LED1 and  LED2 in hal_board_cfg.h

  • This is the code in hal_board_cfg.h that maps LED_4 to LED_1:

      #define HAL_TURN_OFF_LED1()       st( LED1_SBIT = LED1_POLARITY (0); )
      #define HAL_TURN_OFF_LED2()       st( LED2_SBIT = LED2_POLARITY (0); )
      #define HAL_TURN_OFF_LED3()       st( LED3_SBIT = LED3_POLARITY (0); )
      #define HAL_TURN_OFF_LED4()       HAL_TURN_OFF_LED1()
    
      #define HAL_TURN_ON_LED1()        st( LED1_SBIT = LED1_POLARITY (1); )
      #define HAL_TURN_ON_LED2()        st( LED2_SBIT = LED2_POLARITY (1); )
      #define HAL_TURN_ON_LED3()        st( LED3_SBIT = LED3_POLARITY (1); )
      #define HAL_TURN_ON_LED4()        HAL_TURN_ON_LED1()
    
      #define HAL_TOGGLE_LED1()         st( if (LED1_SBIT) { LED1_SBIT = 0; } else { LED1_SBIT = 1;} )
      #define HAL_TOGGLE_LED2()         st( if (LED2_SBIT) { LED2_SBIT = 0; } else { LED2_SBIT = 1;} )
      #define HAL_TOGGLE_LED3()         st( if (LED3_SBIT) { LED3_SBIT = 0; } else { LED3_SBIT = 1;} )
      #define HAL_TOGGLE_LED4()         HAL_TOGGLE_LED1()
    
      #define HAL_STATE_LED1()          (LED1_POLARITY (LED1_SBIT))
      #define HAL_STATE_LED2()          (LED2_POLARITY (LED2_SBIT))
      #define HAL_STATE_LED3()          (LED3_POLARITY (LED3_SBIT))
      #define HAL_STATE_LED4()          HAL_STATE_LED1()
    

    On the SmartRF05 LED4 is shared with the "Shift" (S1) button, so in SW HAL_LED_4 is mapped to HAL_LED_1.

    This is the code in zcl_sampleLight.c that blinks LED_4 when in identify mode:

    static void zclSampleLight_ProcessIdentifyTimeChange( void )
    {
      if ( zclSampleLight_IdentifyTime > 0 )
      {
        osal_start_timerEx( zclSampleLight_TaskID, SAMPLELIGHT_IDENTIFY_TIMEOUT_EVT, 1000 );
        HalLedBlink ( HAL_LED_4, 0xFF, HAL_LED_DEFAULT_DUTY_CYCLE, HAL_LED_DEFAULT_FLASH_TIME );
      }
      else
      {
    #ifdef ZCL_EZMODE
        if ( zclSampleLight_IdentifyCommissionState & EZMODE_COMMISSION_OPERATIONAL )
        {
          HalLedSet ( HAL_LED_4, HAL_LED_MODE_ON );
        }
        else
        {
          HalLedSet ( HAL_LED_4, HAL_LED_MODE_OFF );
        }
    #endif
    
        osal_stop_timerEx( zclSampleLight_TaskID, SAMPLELIGHT_IDENTIFY_TIMEOUT_EVT );
      }
    }

    To make LED2 blink during identify replace HAL_LED_4 in zclSampleLight_ProcessIdentifyTimeChange with HAL_LED2, or replace:

      #define HAL_TURN_OFF_LED4()       HAL_TURN_OFF_LED1()
    ...
      #define HAL_TURN_ON_LED4()        HAL_TURN_ON_LED1()
    ...
      #define HAL_TOGGLE_LED4()         HAL_TOGGLE_LED1()
    ...
      #define HAL_STATE_LED4()          HAL_STATE_LED1()

    with:

      #define HAL_TURN_OFF_LED4()       HAL_TURN_OFF_LED2()
    ...
      #define HAL_TURN_ON_LED4()        HAL_TURN_ON_LED2()
    ...
      #define HAL_TOGGLE_LED4()         HAL_TOGGLE_LED2()
    ...
      #define HAL_STATE_LED4()          HAL_STATE_LED2()

    in hal_board_cfg.h

    Regards, TC.

  • Thanks a lot TC. Finally it work :)