微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI Zigbee设计交流 > 急求ZSTACK3.0 如何在程序中控制设备状态切换为路由或终端设备,求全部步骤

急求ZSTACK3.0 如何在程序中控制设备状态切换为路由或终端设备,求全部步骤

时间:10-02 整理:3721RD 点击:

如题:

我在宏定义添加了BUILD_ALL_DEVICES , link中添加了AllDevice-Pro.lib

 设置设备类型zgDeviceLogicalType = ZG_DEVICETYPE_ENDDEVICE;

之后调用入网语句bdb_StartCommissioning

还需要设置什么吗?

Hi,

  1. Index: Projects/zstack/HomeAutomation/SampleLight/Source/zcl_samplelight.c
    ===================================================================
    --- Projects/zstack/HomeAutomation/SampleLight/Source/zcl_samplelight.c (revision 973)
    +++ Projects/zstack/HomeAutomation/SampleLight/Source/zcl_samplelight.c (working copy)
    @@ -71,6 +71,8 @@
    #include "ZDObject.h"
    #include "MT_SYS.h"

    +#include "ZGlobals.h"
    +
    #include "zcl.h"
    #include "zcl_general.h"
    #include "zcl_ha.h"
    @@ -209,6 +211,8 @@
    static uint8 zclSampleLight_ProcessInDiscAttrsExtRspCmd( zclIncomingMsg_t *pInMsg );
    #endif

    +static void configureDevType(uint8 devType);
    +
    /*********************************************************************
    * STATUS STRINGS
    */
    @@ -321,6 +325,14 @@
    #endif // LCD_SUPPORTED
    }

    +static void configureDevType(uint8 devType)
    +{
    + uint8 startOpt = ZCD_NV_STARTUP_OPTION;
    + osal_nv_write(ZCD_STARTOPT_DEFAULT_NETWORK_STATE, 0, 1, &startOpt);
    + osal_nv_write(ZCD_NV_LOGICAL_TYPE, 0, 1, &devType);
    + ZDOInitDevice(0);
    +}
    +
    /*********************************************************************
    * @fn zclSample_event_loop
    *
    @@ -526,6 +538,25 @@
    {
    giLightScreenMode = giLightScreenMode ? LIGHT_MAINMODE : LIGHT_HELPMODE;
    }
    +
    + if ( shift && ( keys & HAL_KEY_SW_1 ) )
    + {
    + //Shift up start as Coord
    + configureDevType(ZG_DEVICETYPE_COORDINATOR);
    + }
    +
    + if ( shift && ( keys & HAL_KEY_SW_2 ) )
    + {
    + //Shift right start as Router
    + configureDevType(ZG_DEVICETYPE_ROUTER);
    + }
    +
    + if ( shift && ( keys & HAL_KEY_SW_3 ) )
    + {
    + //Shift down start as EndDevice
    + configureDevType(ZG_DEVICETYPE_ENDDEVICE);
    + }
    +

    // update the display, including the light
    zclSampleLight_LcdDisplayUpdate();
    Index: Projects/zstack/Tools/CC2530DB/f8wAllDevice.cfg
    ===================================================================
    --- Projects/zstack/Tools/CC2530DB/f8wAllDevice.cfg (revision 0)
    +++ Projects/zstack/Tools/CC2530DB/f8wAllDevice.cfg (revision 0)
    @@ -0,0 +1,22 @@
    +/*
    + * f8wAllDevice.cfg
    + *
    + * Compiler command-line options used to define a TI Z-Stack
    + * with support for all device types.
    + *
    + */
    +
    +/* Common To All Applications */
    +-DCPU32MHZ // CC2530s Run at 32MHz
    +-DROOT=__near_func // MAC/ZMAC code in NEAR
    +
    +/* MAC Settings */
    +-DMAC_CFG_APP_PENDING_QUEUE=TRUE
    +-DMAC_CFG_TX_DATA_MAX=5
    +-DMAC_CFG_TX_MAX=8
    +-DMAC_CFG_RX_MAX=5
    +
    +/* Device Settings */
    +-DZSTACK_DEVICE_BUILD="(DEVICE_BUILD_COORDINATOR | DEVICE_BUILD_ROUTER | DEVICE_BUILD_ENDDEVICE)"
    +-DRTR_NWK
    +

BR,

Alvin Chen

Hi ,Alvin Chen

   First thank you for your support,

   but I followed the configuration and called it, but I couldn't access the network

    -----

    I called the "configureDevType" function directly, but I couldn't access the network

   

帖子别沉啊, 我在论坛上看到关于这个问题的帖子都是很散的。我希望能够让这个问题在这个帖子结束!

各位大神,请指点~~~~

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top