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.

Problems with SampleApp

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

Hi, i am having some problems with SampleApp.

I am trying to restore the network, but here is some things that i observed:

In DemoEB project, Router is functioning as a coordinator. I don`t want that (tried to find the nwkCoordinatorCapable flag but ctrl+shift+f didn't find it)

And in RouterEB project, It doesn't even start.

Is there another difference in this two projects besides BUILD_ALL_DEVICES compile flag?

I am using NV_INIT and NV_RESTORE compile flags, and HOLD_AUTO_START too.

Thanks in advance, i am running out of ideas..

Daniel.

  • Hello Daniel,

    Have you looked at the "Z-Stack Sample Application For CC2530DB.pdf" to understand how to setup the Sample Application Demo Build - Jumper Settings.This is located at  C:\Texas Instruments\ZStack-CC2530-2.5.0\Documents\CC2530 after installing the Z-Stack. This document should help to answer your questions and provide you better understanding of the code.

    Regards,

    Suyash Jain

  • Hi, i may have badly explained my problem.

    I changed the code so that it would`t depend on jumpers, but on a define made previously.

    Without NV_INIT and NV_RESTORE it works perfectly.

    I put a printf function before and after ZDO_InitDevice(0) (Inside HOLD_AUTO_START block). And it tells me that before this function the device is a router, but after, it becomes a coordinator. And this is only with NV_INIT and NV_RESTORE. I am erasing flash every time i download the code by the way.

    When i use CorrdinatorEB and RouterEB without HOLD_AUTO_START, sometimes it works. But with the latter compiler flag it forces the device to be of a type that it shouldn`t be.

    On the opportunity of this topic, knowing how to leave and rejoin a network could help me debug this. But i am having difficulty to find how to do that. What function do i use?

    Thank you for your time.

    Daniel.

  • Hi Daniel,

     Yes you can change role without using the jumper. you can trigger it in the software itself. please find below the sample code

    #define MY_LOGICAL_ROLE_ITEM_ID         0x0408

     //write the value using serial port or toggle it using the key press

     

     if ( keys & HAL_KEY_SW_1 )//up
        {

                  NvFlg = 1//coordinator

                     (void)osal_nv_write(MY_LOGICAL_ROLE_ITEM_ID, 0, 1, &NvFlg);

    }

     if ( keys & HAL_KEY_SW_3 )
        {

               NvFlg = 2//Router

                     (void)osal_nv_write(MY_LOGICAL_ROLE_ITEM_ID, 0, 1, &NvFlg);

    }

    void GenericApp_Init( byte task_id )
    {

     (void)osal_nv_item_init(MY_LOGICAL_ROLE_ITEM_ID, 1, &NvFlg);
       (void)osal_nv_read(MY_LOGICAL_ROLE_ITEM_ID, 0, 1, &NvFlg);
        if(NvFlg)
        {
          #if defined ( BUILD_ALL_DEVICES )
              // The  target is setup to have BUILD_ALL_DEVICES and HOLD_AUTO_START
              //  we will start up a coordinator with 1 and Router with 2. Otherwise,
       

          if(NvFlg == 1)
                                zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;
         else if(NvFlg == 2)
                                zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER; //ZG_DEVICETYPE_ENDDEVICE
         #endif // BUILD_ALL_DEVICES
          #if defined ( HOLD_AUTO_START )
            // HOLD_AUTO_START is a compile option that will surpress ZDApp
            //  from starting the device and wait for the application to
            //  start the device.
            ZDOInitDevice(0);
          #endif  
        }

    }

    Hope it helps.

    Thanks and Regards

    Lakshman,PMP

     

  • Hi, i didn't understand your point. I was already doing this:

    #define BOARD1 //BOARD2  //Before downloading the code to the device i change this define).

    void SampleApp_Init( uint8 task_id )
    {

    *Here i do iniatilization of keys (interruptions). I don't use HAL_KEY.

    #if defined ( BUILD_ALL_DEVICES )
     #ifdef BOARD1
        zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;
    #endif
        //else
     #ifdef BOARD2
        zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;
    #endif

    #if defined ( HOLD_AUTO_START )

        if(zgDeviceLogicalType == ZG_DEVICETYPE_COORDINATOR)
        printf("Coord\n");
      if(zgDeviceLogicalType == ZG_DEVICETYPE_ROUTER)
        printf("Router\n");
     
      ZDOInitDevice(0);
     
      if(zgDeviceLogicalType == ZG_DEVICETYPE_COORDINATOR)
        printf("Coord\n");
      if(zgDeviceLogicalType == ZG_DEVICETYPE_ROUTER)
        printf("Router\n");
    #endif

    -----------------------------

    As you can see, i use printf to know the device type. And without NV it works perfectly, but when i try to use NV this printf function tells me that ZDOInitDevice changes the device type to coordinator every time.

  • Hi daniel,

     The above code you have mentioned suppose to work even with NV item.

    So for  #define BOARD1 ---> you are expecting the coord right ?

     I am using with NV it works perfectly as expected.May be i didnt understand your requirement.Can you please eloberate your requirement?

     

    Can you print the status as mentioned below with NV.

    printf ("zgDeviceLogicalType  %d ",zgDeviceLogicalType) ----> display it using the LCD or Serial Port  ( intial value of NV  before assigning)

    #if defined ( BUILD_ALL_DEVICES )
    #ifdef BOARD1
        zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;
    #endif
        //else
    #ifdef BOARD2
        zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;
    #endif

     

    Thanks and Regards

    Lakshman,PMP

     

     

     

     

     

  • This is the strange thing.

    With this printf, before ZDOInitDevice(0), it prints ZG_DEVICETYPE_ROUTER.. but right after the function, it prints ZG_DEVICETYPE_COORDINATOR.

    There is something inside the function, inside NV_RESTORE define that is changing the device type.

    When i use other projects (CoordinatorEB and RouterEB) it works fine.

  • New information. I forced "zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;" in different locations inside ZDOInitDevice(0).

    Awkwardly, the problem wasn't inside NV_RESTORE define.

    The root of the problem lies in this line:

    zgInitItems( FALSE );

    But then, i don't know what is really the problem, but at least i could make it work.

    And again, i am erasing the flash when i download the code.

    Thank you for your time, and if you know what was happening please let me know.

    Daniel.