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.

Make a ZigBee device discoverable

Other Parts Discussed in Thread: Z-STACK, CC2530, CC2538

Hello,
I have a question about how to make a ZigBee device discoverable by any hub using IAR embedded workbench 8051 or some other software. For example: I have a ZigBee dev board programmed with IAR 8051 that is just powered, and then my Smartthings hub will see it as a device and that's all. How would I accomplish such a task by programming? I've already tried the default Z-Stack Home 1.2.2 samples, so I'm wondering if there is any cold I need to change in the example SampleLight. Help is much obliged!

If nobody is able to figure this out, then are there any TI products that can do such a thing as making itself discoverable by any commercially available smart hubs. If so, could you please tell me the link and the source code for it doing so? Thanks.

  • Jack,

    I have moved this thread to the appropriate forum. They will be able to give you better information.

    Thanks,
    Mark
  • As I know, SmartThings hub runs Zigbee HA profile so Z-Stack Home SampleLight should be able to join SmartThings hub without problem.
  • Ok. So what c file or other file in the SampleLight program exactly makes the ZigBee module send out a signal to be discovered by smart hubs such as Smartthings?
  • It's ZDApp.c
  • Would any ZigBee CC2530 dev device by able to run the SampleLight program and connect to Smartthings or just the TI ZigBee products?
  • Don't understand your question well. Can you elaborate?
  • So I have CC2530(TI chip) ZigBee module bought from China and not TI and there is also the CC2530 dev kit from www.ti.com/.../cc2530dk. Will the module from China work as well as the one from TI since both use the same chips?

  • Yes, it should work too. However, Z-Stack Home examples are dedicated for CC2530DK. If you want to run on other CC2530 module, you would have to revise it.
  • What is the difference between CC2530 and CC2530DK? My chips says CC2530F256 to be exact. Also what file would I open in SampleLight to edit and revise to work with my board?

  • CC2530 is the name of Soc. CC2530DK means CC2530 development kit which uses CC2530 on it. CC2530F256 means it has 256k bytes flash.
  • What file would I open in SampleLight to edit and revise to work with my CC2530 board?
  • Basically, I think you have to revise hal_key.c and LED in hal_board_cfg.c
  • What kinds of things would I change? Should I be changing certain variables? Which ones?
  • You should change IO pins used by your CC2530 module.
  • Would the CC2530 ZigBee Light Link Development Kit from www.ti.com/.../cc2530zdk-zll be able to run the program as the RouterZLight device type configuration and connect to Smartthings without any modification to the SampleLight program?
  • Yes, there is a RouterZlight configuration in Z-Stack Home SampleLight project which can run on CC2530ZDK-ZLL. I think it should be able to join SmartThings hub. However, I don't have SmartThings hub to verify it.

  • Which file(s) make a difference between a RouterZlight, EndDeviceEB, RouterEB, and a CoordinatorEB? Also I didn't really get what you meant by changing the IO pins on my CC2530 module. Can you elaborate on that more please?

  • 1. RouterZlight are for CC2530ZDK-ZLL and make it as Zigbee router.
    2. EndDeviceEB, RouterEB, and CoordinatorEB are for CC2530DK. EndDeviceEB would make CC2530DK run as Zigbee end device. RouterEB would make CC2530DK run as Zigbee router. CoordinatorEB would make CC2530DK run as Zigbee coordinator.
  • 1) What I meant was which files specific these specific configurations such as that ZDApp.c makes the CC2530 module send out a signal. Could you explain which files the configurations would be in please?

    2) Also I didn't really get what you meant by changing the IO pins on my CC2530 module. Can you elaborate on that more please?

  • 1. It use API NLME_NetworkDiscoveryRequest() in ZDO_StartDevice() of ZDAp.p.c to send out join/rejoin signal.
    2. Can you tell me which IO pins you would use as buttons and LEDs on your CC2530 module?
  • I know for sure that my LED ports in the program are P1_0 for LED1, P1_1 for LED2, and P1_4 for LED3. P0_1 is BUTTON1. I'm not sure what the 2nd button is though. Besides why are the buttons on the CC2530 module important if the lights on the board are being controlled from a smartphone?

  • In SampleLight, it use right button to do EZ-mode or end device binding. If you don't need it, you don't have to modify hal_key.c.
  • Where do I modify the button variables in hal_key.c? Also I saw this in hal_board_cfg.h:

    /* 1 - Green */
    #define LED1_BV           BV(0)
    #define LED1_SBIT         P1_0
    #define LED1_DDR          P1DIR
    #define LED1_POLARITY     ACTIVE_HIGH

    #if defined (HAL_BOARD_CC2530EB_REV17)
      /* 2 - Red */
      #define LED2_BV           BV(1)
      #define LED2_SBIT         P1_1
      #define LED2_DDR          P1DIR
      #define LED2_POLARITY     ACTIVE_HIGH

      /* 3 - Yellow */
      #define LED3_BV           BV(4)
      #define LED3_SBIT         P1_4
      #define LED3_DDR          P1DIR
      #define LED3_POLARITY     ACTIVE_HIGH
    #endif

    So I believe this means my led ports are the same as the default SampleLight program.

  • Your LED pins are the same to settings in hal_board_cfg.h so you don't have to revise it. For button, you can refer to SW_6 which uses P0.1 as GPI in hal_key.c and revise it accordingly.
  • Ok. Thanks. How many buttons are used in this program? I only have 2, so is this enough to do all the important things?
  • SampleLight uses four buttons but I think you only need two, SW_1 and SW_2.
  • I've changed the button configuration from "#defineHAL_KEY_SW_6_PORT P0" to "#define HAL_KEY_SW_6_PORT P0_1". Is this what I should be doing to get the button configured with my board?
  • SW_6 in hal_key.c already use P0.1 by default. If you want to use P0.1 as button, it is already there.
  • 1) So in that case the button port in the program matches the one on my CC2530 board correct?

    2) Also I changed -DDEFAULT_CHANLIST=0x00000800  // 11 - 0x0B to -DDEFAULT_CHANLIST=MAX_CHANNELS_24GHZ as described in the forum post, https://community.smartthings.com/t/program-cc2530-for-smartthings/53727/15 in the f8wConfig.cfg. This way it would send out a signal in all channels. Is this what I should be doing?

  • Does your CC2530 board use P0.1 as button?
  • My board uses P0_1 as a button. Is there a difference?
  • As I replied, you can use SW_6 directly since it uses P0.1 as well.
  • I've been reading the Z-Stack Home Sample Application User's Guide and here's an excerpt of it about Sample Applications (my question is below it):

    1.0 Building the Sample Applications
    All Sample applications configured as end devices/routers are compiled with option “HOLD_AUTO_START” and do not join the network automatically. Devices join the network when EZMODE is initiated. The process of building a sample application is the same for any application. The only differences are whether the device is a coordinator, router, or end device, and which ZCL clusters to include.

    1.1 CC2530/CC2538 This step-by-step process will use the SampleLight application as an example.
     Make sure all development software tools have been installed  Consult section 2.2 to Power up the board.  If Windows prompts to install a device driver, don’t let it connect to Windows Update. Instead, let Windows try to find the required driver automatically. If that fails, browse to: C:\Program Files\IAR Systems\<Embedded Workbench>\<arm\8051>\drivers\Texas Instruments to locate the necessary files.  Select IAR project workspace (*.eww), and open it with IAR. Select ZigBee device type configuration from the Workspace pull-down menu. Refer to section 2.4 to help identify device type for each sample application. For instance, SampleLight is associated with a ZC (select CoordinatorEB from the Workspace pull-down menu).

    1.2 Each sample application requires different set of clusters. By default, required application clusters are enabled in IAR project options. To enable specific clusters, consult f8wZCL.cfg file and enable it in IAR compiler options (Figure 14)
    -------------------------------------------------------------

    My Questions:
    1) (1.0) Is EZMODE on when I press button 1 on my board or is there something else I need to do?

    2) (1.1) Why does the sample tell me to select CoordinatorEB and what does it mean by SampleLight associates with ZC?

    3) (1.2) I looked through f8wZCL.cfg and everything looks commented out. What clusters am I supposed to change? I don't see any clusters in the first place.
  • 1. You need to press right button to trigger EZ-mode. That's all.
    2. It means if you want do make SampleLight to work as Zigbee coordinator, you have to select CoordinatorEB from the Workspace pull-down menu.
    3. If you are looking for clusters used by SampleLight, you should check zcl_samplelight_data.c
  • For number 1, do you mean BTN 1 when you say right button in order to initiate EZ-mode?
  • Please check static zclSampleLight_HandleKeys() in zcl_sampleLight.c. It's SW_2 (mapped to right button on CC2530DK) to trigger EZ-mode.

    static void zclSampleLight_HandleKeys( byte shift, byte keys )
    {
    ...
      if ( keys & HAL_KEY_SW_2 )
      {
    #if (defined HAL_BOARD_ZLIGHT)

        zclSampleLight_BasicResetCB();

    #else

        giLightScreenMode = LIGHT_MAINMODE;

    #ifdef ZCL_EZMODE
        {
          // Invoke EZ-Mode
          zclEZMode_InvokeData_t ezModeData;

          // Invoke EZ-Mode
          ezModeData.endpoint = SAMPLELIGHT_ENDPOINT; // endpoint on which to invoke EZ-Mode
          if ( (zclSampleLight_NwkState == DEV_ZB_COORD) ||
              (zclSampleLight_NwkState == DEV_ROUTER)   ||
                (zclSampleLight_NwkState == DEV_END_DEVICE) )
    ....

  • I changed "if ( keys & HAL_KEY_SW_2 )" to "if ( keys & HAL_KEY_SW_6 )" since SW_6 a.k.a. P0_1 is the only button that is already configured with my board.

    On an earlier post, you mentioned that I only needed two buttons which were SW_1 and SW_2. Can you specify what those 2 important buttons do exactly?

  • One is SW_2 which you already know it is to trigger EZ-mode. Another is SW_1 which is to toggle light.
  • Since I used SW_6 for EZ-mode instead of SW_2, what was the purpose of SW_6 by default? Also what were the other buttons supposed to do?
  • SW_6 is not used in SampleLight. SW_3 is for sending network status. SW_4 is for toggling permit join.
  • Which file and where would I change the default pin of each button SW? Would it be in hal_key.c or hal_key.h? The reason for this is so I can change SW_1 to P0_0 and SW_2 to P0_1.
  • You have to do it in hal_key.c. SW_1 and SW_2 are implemented by ADC reading so you have to copy code from SW_6 and revise accordingly.
  • I don't see SW_1 nor SW_2 mentioned in hal_key.c. "Can you rephrase and explain how to change SW_1 to P0_0 and SW_2 to P0_1? Which function do I need to write this code in?"
  • Just copy everything about SW_6 and change it to SW_1. Then, you have to change register settings to P0.0 to make it work.
  • "Then, you have to change register settings to P0.0 to make it work."
    1) Where do I do that and what is register settings?

    #define HAL_KEY_SW_1 0x01  // Joystick up
    #define HAL_KEY_SW_2 0x02  // Joystick right
    #define HAL_KEY_SW_5 0x04  // Joystick center
    #define HAL_KEY_SW_4 0x08  // Joystick left
    #define HAL_KEY_SW_3 0x10  // Joystick down

    #define HAL_KEY_SW_6 0x20  // Button S1 if available
    #define HAL_KEY_SW_7 0x40  // Button S2 if available

    2) Do I have to swap these variables in hal_key.h?

  • I mean you should make a copy of the following lines. Then, change them to SW_2 and related register settings.

    /* SW_6 is at P0.1 */
    #define HAL_KEY_SW_6_PORT P0
    #define HAL_KEY_SW_6_BIT BV(1)
    #define HAL_KEY_SW_6_SEL P0SEL
    #define HAL_KEY_SW_6_DIR P0DIR

    /* edge interrupt */
    #define HAL_KEY_SW_6_EDGEBIT BV(0)
    #define HAL_KEY_SW_6_EDGE HAL_KEY_FALLING_EDGE


    /* SW_6 interrupts */
    #define HAL_KEY_SW_6_IEN IEN1 /* CPU interrupt mask register */
    #define HAL_KEY_SW_6_IENBIT BV(5) /* Mask bit for all of Port_0 */
    #define HAL_KEY_SW_6_ICTL P0IEN /* Port Interrupt Control register */
    #define HAL_KEY_SW_6_ICTLBIT BV(1) /* P0IEN - P0.1 enable/disable bit */
    #define HAL_KEY_SW_6_PXIFG P0IFG /* Interrupt flag at source */
  • Is this the correct thing I should be doing for SW_2-(EZ-mode) at pin P0_1? I'm not sure how to change the code to the register settings of pin P0_0??

    /* SW_2 is at P0_1 */
    #define HAL_KEY_SW_2_PORT P0_1
    #define HAL_KEY_SW_2_BIT BV(1)
    #define HAL_KEY_SW_2_SEL P0SEL
    #define HAL_KEY_SW_2_DIR P0DIR

    /* edge interrupt */
    #define HAL_KEY_SW_2_EDGEBIT BV(0)
    #define HAL_KEY_SW_2_EDGE HAL_KEY_FALLING_EDGE


    /* SW_2 interrupts */
    #define HAL_KEY_SW_2_IEN IEN1 /* CPU interrupt mask register */
    #define HAL_KEY_SW_2_IENBIT BV(5) /* Mask bit for all of Port_0 */
    #define HAL_KEY_SW_2_ICTL P0IEN /* Port Interrupt Control register */
    #define HAL_KEY_SW_2_ICTLBIT BV(1) /* P0IEN - P0_1 enable/disable bit */
    #define HAL_KEY_SW_2_PXIFG P0IFG /* Interrupt flag at source */
  • Yes, it's correct for SW_2. For using P0.0 as SW_1, you have to make another copy to SW_1. Then, change "#define HAL_KEY_SW_2_BIT BV(1)" to "#define HAL_KEY_SW_1_BIT BV(0)" and "#define HAL_KEY_SW_2_ICTLBIT BV(1) " to "#define HAL_KEY_SW_1_ICTLBIT BV(0) "
  • You would have to read CC2530 user guide ( www.ti.com/.../swru191f.pdf ) to know more about details of those registers.
  • Do I also need to change these values in hal_key.h in addition to the post above?

    #define HAL_KEY_SW_1 0x01 // Joystick up
    #define HAL_KEY_SW_2 0x02 // Joystick right
    #define HAL_KEY_SW_5 0x04 // Joystick center
    #define HAL_KEY_SW_4 0x08 // Joystick left
    #define HAL_KEY_SW_3 0x10 // Joystick down

    #define HAL_KEY_SW_6 0x20 // Button S1 if available
    #define HAL_KEY_SW_7 0x40 // Button S2 if available