Friday, January 22, 2016

How to clone an existing Z-Stack coordinator.

The following steps are used for cloning an existing Z-Stack coordinator.

1. Enable Compiler option MT_SYS_KEY_MANAGEMENT on coordinator.

2. Use MT command to read out the following NV items from coordinator that you want to clone.

  • ZCD_NV_EXTADDR(0x0001)
  • ZCD_NV_BOOTCOUNTER(0x0002) – optional, If Diagnostics feature is necessary (new for HA spec.1.2)
  • ZCD_NV_NIB(0x0021)
  • ZCD_NV_EXTENDED_PAN_ID(0x002D)
  • ZCD_NV_NWK_ACTIVE_KEY_INFO(0x003A)
  • ZCD_NV_NWK_ALTERN_KEY_INFO(0x003B)
  • ZCD_NV_APS_USE_EXT_PANID(0x0047)
  • ZCD_NV_PRECFGKEY(0x0062)
  • ZCD_NV_TCLK_TABLE_START(0x0101)

3. Turn off old coordinator.

4. Flash the same coordinator binary to the new coordinator.

5. Using MT command to write NV items data that are read out in step 2.

6. Restart new coordinator to work.


Tuesday, January 19, 2016

How to use SensorTag CC2650STK with CC-DEVPACK-DEBUGGER as ZNP and connect to Z-Stack ZTool.

The following steps show you how to use SensorTag CC2650STK with CC-DEVPACK-DEBUGGER as ZNP and connect to Z-Stack ZTool.

1. Revise the following code in Board.h (C:\ti\tirtos_simplelink_2_11_01_09\packages\ti\boards\SRF06EB\CC2650EM_7ID)

#define Board_UART_RX IOID_2 /* RF1.7 */
#define Board_UART_TX IOID_3 /* RF1.9 */

to

#define Board_UART_RX IOID_28 /* RF1.7 */
#define Board_UART_TX IOID_29 /* RF1.9 */

2. Rebuild CC2650 ZNP example and download it to CC2650STK.
3. Disconnect CC2650STK from CC-DEVPACK-DEBUGGER and connect it to restart.
4. Find COM port of XDS110 Class Application/User UART.



5. Open ZTool and select COM port of XDS110 Class Application/User UART. Remember to select Flow to None.



6. You should see CC2650STK ZNP is connected with ZTool.


Monday, January 4, 2016

Set the Logical Device type to Coordinator and router dynamically using Z-Stack on CC2538DK

Apply the following steps to SampleLight coordinator project and I can set the Logical Device type to Coordinator and router at run time.

1. Add "uint8 dev_type=0;" as global variable in ZDApp.c.

2. Add the red part in ZDAppDetermineDeviceType.

void ZDAppDetermineDeviceType( void )
{
  if (dev_type==0)
    zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;
  else if(dev_type==1)
    zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;

  
  if ( zgDeviceLogicalType ==ZG_DEVICETYPE_COORDINATOR )
  {
    devStartMode = MODE_HARD;     // Start as a coordinator
    ZDO_Config_Node_Descriptor.LogicalType = NODETYPE_COORDINATOR;
  }
  else
  ...

3. Revise the red part in ZDAppCheckForHoldKey.

void ZDAppCheckForHoldKey( void )
{
#if (defined HAL_KEY) && (HAL_KEY == TRUE)

  // Get Keypad directly to see if a HOLD is needed
  zdappHoldKeys = HalKeyRead();

  // Hold down the SW_BYPASS_START key (see OnBoard.h)
  // while booting to avoid starting up the device.
  if ( zdappHoldKeys == SW_BYPASS_START )
  {
    // Change the device state to HOLD on start up
    //devState = DEV_HOLD;
    dev_type=1;

  }
#endif // HAL_KEY
}
4. Revise the red part in ZGlobals.h

extern uint8 dev_type;
 
/*********************************************************************
 * MACROS
 */
#if defined( BUILD_ALL_DEVICES ) && !defined( ZSTACK_DEVICE_BUILD )
  #define ZSTACK_DEVICE_BUILD  (DEVICE_BUILD_COORDINATOR | DEVICE_BUILD_ROUTER | DEVICE_BUILD_ENDDEVICE)
#endif

// Setup to work with the existing (old) compile flags
#if 0
#if !defined ( ZSTACK_DEVICE_BUILD )
  #if defined ( ZDO_COORDINATOR )
    #define ZSTACK_DEVICE_BUILD  (DEVICE_BUILD_COORDINATOR)
  #elif defined ( RTR_NWK )
    #define ZSTACK_DEVICE_BUILD  (DEVICE_BUILD_ROUTER)
  #else
    #define ZSTACK_DEVICE_BUILD  (DEVICE_BUILD_ENDDEVICE)
  #endif
#endif
#else
#define ZSTACK_DEVICE_BUILD  (dev_type+1)
#endif

5. Compile the code and download it to CC2538DK. If I turn on CC2538DK without pressing any button, it will become ZC. If I turn on CC2538DK with UP key pressed, it will become ZR.

How to run TI Z-Stack Linux Home Gateway on BeagleBone Black with CC2530DK.

The following steps show you how to run TI Z-Stack Linux Home Gateway on BeagleBone Black with CC2530DK.

1. Add ENABLE_MT_SYS_RESET_SHUTDOWN to compile options of ZNP CC2530-ProdHex project and set znpCfg1 = ZNP_CFG1_UART in InitBoard().

2. Build it to get CC2530ZNP-Prod.hex under \Projects\zstack\ZNP\CC253x\dev and download it to CC2530DK using Flash Programmer.

3. Connect the following pins between CC2530DK UART (P0.2 as RX and P0.3 as TX) and BeagleBone Black UART4.

       CC2530DK UART RX P0.2 (P18 Pin9)   <-------> BBB UART4 TX (P9 Pin13)
       CC2530DK UART TX P0.3 (P18 Pin11) <-------> BBB UART4 RX (P9 Pin11)
       CC2530DK GND (P18 Pin20)                 <-------> BBB DGND (P9 Pin1)




4. Change devPath="/dev/ttyACM0" to devPath="/dev/ttyO4" in NPI_Gateway.cfg

5. Revise the followings in zigbeeHAgw.

    "ZBEE_SERIAL_PORT=ttyACM0" to "ZBEE_SERIAL_PORT=ttyO4"

    "../tools/gw_soc_fw_version_query.bin /dev/ttyACM0" to "../tools/gw_soc_fw_version_query.bin /dev/ttyO4"

6. Comment out the folllowing lines in in zigbeeHAgw.

    "../tools/bbb_usbreset.bin"
    "echo -n  " sleeping $hw_reset_sleep seconds after reset... ""
    "sleep $hw_reset_sleep"

7. Add the following line to /media/BEAGLEBONE/uEnv.txt to enable UART4 on BBB.

    optargs=quiet drm.debug=7 capemgr.enable_partno=BB-UART4

8. Restart BBB and make sure ttyO4 shows under /dev

9. run ./zigbeeHAgw bbb on current terminal and ./start_application on another to test TI Z-Stack Linux Home Gateway.