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.

CC2538: Can Change the device type at the RUN Time

Part Number: CC2538
Other Parts Discussed in Thread: Z-STACK

Hi,

Can I change the Zigbee device type at the run time in CC2538.

I mean ZED to ZR  and ZR to ZED change at the run time either stay with old factory settings in network or OK to on-board again.

If this is possible in Z-Stack3.0 please let me know, its great help.

Thank you

  • Hi,

    This is not possible with the Z-Stack HA sample applications, mainly because it doesn't really work in the context of a Zigbee network. In a Zigbee network, you would need to factory-new reset a device before "switching" it's device type, effectively making it a new network device, there is no way you could retain the old network configuration.

    The ZNP Z-Stack project does allow for run-time Zigbee logical device type selection, so I suppose you could use this project to design a node that can switch type, but again you would need to factory-new reset the node before you could change it's type.

  • Hi JasonB,
    You mean, the device type can change ZC/ZR/ZED, but before change type its mandatory to reset factory if it is in network (if device is not yet connected to any network no need) and change the device type, again on-board to network is it.
    If my understand is write, how can I change the device type after factory reset.
    Thank you
  • You can refer to sunmaysky.blogspot.tw/.../set-logical-device-type-to-coordinator.html which shows you how to switch between ZC and ZR in SOC mode. If you need this kind of capability, I would suggest you to use ZAP-ZNP architecture and you can switch to ZED, ZR, or ZC from ZAP when ZAP starts ZNP.
  • I am using IAR for CC2538, so in SOC can I do ZED and ZR.
    My need is devices will be always ZED, when my "ZC looks away from or Max device list of ZC exceeds" that time I want to make any one ZED has ZR.
    Our custom devices are under fabrication for development purpose. So, now we can't change the design

    thank you.
  • It seems that you want to do this dynamically and the answer is no.

  • Hi chen,
    I don't want dynamically,
    While start or restart defining any macros is also good. I am not expecting to change at run-time. any way changing the device type from ZED to ZR in CC2538 is fine. Or by making any changes using UART interface is also fine
    Thank you.
  • I tried to change role between ZC and ZR but not ZED. If you need to change between ZED and ZR, the possible way is to use ZNP or your have external flash to store two different FW, one is for ZED and another is for ZR. When you need to switch role, you can reload the FW from external flash to make it.
  • My device is ZED, I want to make it an ZR any way with the same image of application.
    So, in the link you shared "sunmaysky.blogspot.in/.../set-logical-device-type-to-coordinator.html
    they are trying between ZC to ZR wrt button press.
    As like I will keep store One master bit in Flash memory, if it is pointing to ZED_Val I will start as ZED else if it is pointing to ZR_Val I will start as ZR.
    Is it work out.
  • I think it's possible.
  • Hi Chen,
    I tried to make ZR and ZC as like in link you have shared "sunmaysky.blogspot.in/.../set-logical-device-type-to-coordinator.html

    But it always starting as ZC,

    to the "Coordinator project of Sample Light" in "Z-Stack1.2.2a" . Z-stack 3.0 project giving some undefinig errors for the defined functions so I did this.

    I tried to by restarting and /or switching on the board by pressing up-button always starting as ZC

    Thank you
  • I suggest you to debug why it always starts as coordinator.

  • What do you mean debug only?
  • Hi Chen,

    it seems working now, If I simply start or restart EZ-Mode is blinkig blue LED and Restart by pressing up-butoon is not blinking LED on EZ-Mode

    Please check the capture ans tell me.

    13.zip

    Thank you

  • What do you want me to check?
  • The same I trying in Z-Stack 3.0 project and I was getting the following errors:

    Error[Li005]: no definition for "bdb_setNodeJoinLinkKeyType" [referenced from APSMEDE_CB.o(EndDevice.a)]

    Error[Li005]: no definition for "bdb_tcLinkKeyExchangeAttempt" [referenced from E:\raghu\KIKO_PROJECTS\KIKO_POINT\Project\zstack\HomeAutomation\

    KikoPoint\CC2538\EndDevice - OTAClient - ImageA - withBootloader\Obj\bdb.o]

    Error[Li005]: no definition for "bdb_nwkDiscoveryAttempt" [referenced from E:\raghu\KIKO_PROJECTS\KIKO_POINT\Project\zstack\HomeAutomation\KikoPoint\

    CC2538\EndDevice - OTAClient - ImageA - withBootloader\Obj\ZDApp.o]

    Error[Li005]: no definition for "bdb_nwkAssocAttemt" [referenced from E:\raghu\KIKO_PROJECTS\KIKO_POINT\Project\zstack\HomeAutomation\KikoPoint\CC2538\

    EndDevice - OTAClient - ImageA - withBootloader\Obj\ZDApp.o]

    Error[Li005]: no definition for "AIB_MaxBindingTime" [referenced from E:\raghu\KIKO_PROJECTS\KIKO_POINT\Project\zstack\HomeAutomation\KikoPoint\CC2538\

    EndDevice - OTAClient - ImageA - withBootloader\Obj\ZDObject.o]

    Thank you

  • What do you mean the same you trying?
  • Did the same changes in as in link in Z-Stack 3.0 project. So, on build getting the above errors
  • I don't have experience to use Z-Stack 3.0 to do such test. You have to debug by yourself.
  • Hi Chen,

    Below change (red colored add on text) in "ZGlobals.h" only giving me these error. In linker adder "AllDevice.a" in place of "EndDevice.a" in "Otions --> Linker" also added "f8wRouter.cfg" in "Options --> C/C++ Compiler --> Extra Options" Please give some suggestions

    #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

     

    Errors:

    Error[Li005]: no definition for "bdb_setNodeJoinLinkKeyType" [referenced from APSMEDE_CB.o(AllDevice.a)]

    Error[Li005]: no definition for "bdb_tcLinkKeyExchangeAttempt" [referenced from E:\raghu\KIKO_PROJECTS\KIKO_POINT\Project\zstack\HomeAutomation\
    KikoPoint\CC2538\EndDevice - OTAClient - ImageA - withBootloader\Obj\bdb.o]

    Error[Li005]: no definition for "bdb_nwkDiscoveryAttempt" [referenced from E:\raghu\KIKO_PROJECTS\KIKO_POINT\Project\zstack\HomeAutomation\KikoPoint\
    CC2538\EndDevice - OTAClient - ImageA - withBootloader\Obj\ZDApp.o]

    Error[Li005]: no definition for "bdb_nwkAssocAttemt" [referenced from E:\raghu\KIKO_PROJECTS\KIKO_POINT\Project\zstack\HomeAutomation\KikoPoint\CC2538\
    EndDevice - OTAClient - ImageA - withBootloader\Obj\ZDApp.o]

     

    Thank you

  • Do you define ZG_BUILD_JOINING_TYPE in your project compile option?
  • Hi Chen,

    In "Z-Stack1.2.2a  SampleLight End Device" I tried to change from ZED to ZR by making your suggestions to other thread.

    But always from the finish of debug its enabling as ZR not starting as ZED

    Note: Green Colored text is added 

    Changes in  ZDApp.c

    uint8 dev_type=3;

    uint16 nv_dev_type=0x0401;

    //////////////////////////////////////////

    void ZDAppDetermineDeviceType( void )
    {

     uint8 dev_type_reset=3;

     osal_nv_item_init(0x0401, 1, NULL);

     osal_nv_read(0x0401, 0, 1, &dev_type);

     osal_nv_write(0x0401, 0, 1, &dev_type_reset);

     if (dev_type!=1)

       dev_type=3;

      if (dev_type==3)

       zgDeviceLogicalType = ZG_DEVICETYPE_ENDDEVICE;

     else if(dev_type==1)

       zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;

    /////////////////

    }

    Changes in  ZGlobal.h


    extern uint8 dev_type;

    #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

     

    Changes in  zcl_samplelight.c

    if ( keys & HAL_KEY_SW_3 )
    {
    #if 0
    NLME_SendNetworkStatus( zclSampleLight_DstAddr.addr.shortAddr,
    NLME_GetShortAddr(), NWKSTAT_NONTREE_LINK_FAILURE, FALSE );
    #else
    uint8 newdev_type=1;
    osal_nv_item_init(0x0401, 1, NULL);
    osal_nv_write(0x0401, 0, 1, &newdev_type);
    SystemReset();
    #endif

     

    Thank you

  • I told you I don't have experience changing role between ZR and ZED. You have to debug by yourself.
  • Yes I defined "ZG_BUILD_JOINING_TYPE" in "Options --> C/C++ Compiler --> Processor --> Defined Symbols"
  • Do you include bdb.c and bdb.h in your project?
  • Yes, you can see the attached bdb image

    Thank you

  • Can you post build error again?
  • Error[Li005]: no definition for "bdb_setNodeJoinLinkKeyType" [referenced from APSMEDE_CB.o(AllDevice.a)]

    Error[Li005]: no definition for "bdb_tcLinkKeyExchangeAttempt" [referenced from E:\raghu\KIKO_PROJECTS\KIKO_POINT\Project\zstack\HomeAutomation\
    KikoPoint\CC2538\EndDevice - OTAClient - ImageA - withBootloader\Obj\bdb.o]


    Error[Li005]: no definition for "bdb_nwkDiscoveryAttempt" [referenced from
    E:\raghu\KIKO_PROJECTS\KIKO_POINT\Project\zstack\HomeAutomation\KikoPoint\
    CC2538\EndDevice - OTAClient - ImageA - withBootloader\Obj\ZDApp.o]


    Error[Li005]: no definition for "bdb_nwkAssocAttemt" [referenced from
    E:\raghu\KIKO_PROJECTS\KIKO_POINT\Project\zstack\HomeAutomation\KikoPoint\CC2538\
    EndDevice - OTAClient - ImageA - withBootloader\Obj\ZDApp.o]

  • You can skip modification in ZGlobals.h to fix this error.
  • Hi Chen,
    I am facing one more problem all the Z-Stack Home1.2.2a ZED projects I mean Sample Switch and Sample Light are connecting as a ZR with my ZC.
    I tried by reinstalling Z-Stack Home 1.2.2a and debug the project Sample Switch End Device and Sample Light End Device with out changing anything but after connecting with my ZC the Ubiqua Showing it has Router

    please help to gt the ZED project in Z-Stack Home 1.2.2a
  • Try to reinstall a fresh new Z-Stack Home 1.2.2a to rebuild everything to test again.
  • Hi Chen,

    In the "Z-Stack3.0 , Sample Switch End Device OTA Client Image-A with BootLoader" project I made the configuration for both ZED and ZR.

    As like others you suggest, but the One thing making my application to start as Router always and is below one:

    Adding

    "-f $PROJ_DIR$\..\..\..\Tools\CC2538DB\f8wRouter.cfg"  to Options--> C/C++ Compiler --> Extra Options --> Command Line Options

    If I don't add this, I was getting  below error:

    Error[Li005]: no definition for "gLINK_STATUS_JITTER_MASK" [referenced from nwk_util.o(AllDevice.a)]

    I can avoid the above error by adding "E:\raghu\KIKO_PROJECTS\KIKO_POINT\Project\zstack\Libraries\CC2538\bin\EndDevice.a" instaed of "E:\raghu\KIKO_PROJECTS\KIKO_POINT\Project\zstack\Libraries\CC2538\bin\AllDevice.a"
    By making this my device will be always End Device.

    So, for all device configuration I need you help

    Please give me suggestion to override this

    Thank you

  • I have told you that I don’t have experience doing that so I cannot help.
  • Hi Chen,
    Finally I done with my need.
    Now my device can act as both ZED and ZR. I achieved this with "Z-Stack 3.0", "Sample Switch End Device OTA Client Image-A with Boot Loader"
    Thanks for your valuable support.