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.

How to implement SMPL_Init(), SMPL_link, unlink in an infinite loop?

Other Parts Discussed in Thread: SIMPLICITI

Hi everybody,

Now I have ez430-rf2500, simplicitTI 1.1.0 and CCE3.1. My project is save data to sd card, read data from sd card and transfer by rf to computer. As the data in sd card is too big, I save a sector data from sd card to MSP430 buffer and turn to rf block to send it, then turn bcak to read another sector from sd card. It ris a loop to switch between sd card and rf block. At this point, i meet a serious problem. When i try to excute SMPL_Link the secnod time, it always unsuccessful. I tried to use SMPL_Unlink fuction. As the connection table in AP is not cleared, relink works only few times. And I tried to use unjoin function mentioned in (http://e2e.ti.com/forums/t/7594.aspx?PageIndex=1), still fail.

Pls help me to solve this problem.

Thanks,

Sun Li

  • Hi,

    I am having a similar problem. I have a device A that connects to device B every time a button is pressed on device A. When device A and Device B have finished communicating they break the link using the SMPL_Unlink command. This all works fine but I have found that I can only connect device A to device B 3 times and the SMPL_Link fails on the 4th attempt. Have you found that the link always fails after a certain number of connections. 

    Dave

  • Hi,

    I found the solution to my problem which may be a possible solution to your problem. I did not include Extended API in the Device B software, (It was included in Device A software which is the code that calls SMPL_Unlink) so Device B was not acting on the Unlink command. Enabling Extended API in the Device B fixed the problem.

    Dave

  • Hi Dave,

    Thanks for your sharing. My links works only 7 times, also a fixed number.

    As you deiscribed, your device A should be ED and B should be AP. RIght? You mentioned enable the Extened API in AP. How to do that?

    Thanks,

    Sun Li

  • Hi.

    What is the returned status for the failing SMPL_Link()?
    Can you try to capture exactly what is happening on the AP side. Have not used CCE, but you should be able to set a breakpoint in the Mrfi_SyncPinRxIsr and then step through the code from there to see what the AP does with this link request.

    Regards,
    Kjetil

  • Hi Kjetil,

    Thanks very much for your reply. I changed the program. It seems work now, but i did not check the returned status of failing SMPL_Link(). Is there simple function in CCE that i can check this status directly? I always do it step byu step manually.

    I just write the following simple test program and did not put it in the whole program. I'd like to check with you whether the program is right or not. 

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    void

     

     

    main (void

    )

    {

     

     

    int i;

     

     

    int p = 0;

     

     

     

    for (i = 0;; i++)

    {

    BSP_Init();

     

     

     

    /* If an on-the-fly device address is generated it must be done before the

    * call to SMPL_Init(). If the address is set here the ROM value will not

    * be used. If SMPL_Init() runs before this IOCTL is used the IOCTL call

    * will not take effect. One shot only. The IOCTL call below is conformal.

    */

    #ifdef

     

     

    I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE

    {

    addr_t lAddr;

     

    createRandomAddress(&lAddr);

    SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);

    }

    #endif

     

     

    /* I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE */

     

     

     

    /* Keep trying to join (a side effect of successful initialization) until

    * successful. Toggle LEDS to indicate that joining has not occurred.

    */

     

     

     

    while

    (SMPL_SUCCESS != SMPL_Init(0))

    {

    toggleLED(1);

    toggleLED(2);

    SPIN_ABOUT_A_SECOND;

    }

     

     

     

    /* LEDs on solid to indicate successful join. */

     

     

    if

    (!BSP_LED2_IS_ON())

    {

    toggleLED(2);

    }

     

     

    if

    (!BSP_LED1_IS_ON())

    {

    toggleLED(1);

    }

     

     

    if

    (SMPL_SUCCESS != SMPL_Link(&sLinkID1))

    {

    p++;

    toggleLED(1);

    toggleLED(2);

    SPIN_ABOUT_A_SECOND;

    }

     

     

    SMPL_Unlink(i);

    SMPL_Ioctl(IOCTL_OBJ_CONNOBJ,IOCTL_ACT_DELETE,&sLinkID1);

     }

    }

    Thanks!

    Li Sun

  • Hi Sun Li,

    My device A and device b are both ED's. Sorry I should have mentioned this. To enable the extended API open the file smpl_nwk_config.dat and remove the x in the link -DxEXTENDED_API.

    Dave

  • Hi Dave,

    I've tried to use the function SMPL_Unlink, but it come out:  Error[e46]: Undefined external "SMPL_Unlink" referred in demo_ED ( C:\Users\minqian\Desktop\project\code\slac139b changed3\eZ430-RF2500 

  • Hi,

    Are you using the SimpliciTI library (i.e. the .lib file) in your project of are you using the full simpliciTI source. I'm using the full simpliciTI source because as far as I know, and I could be incorrect here, so please anyone correct if I am, the .lib file does not have extended API.

    To get Extended API using the full source take a look at the following project:

    C:\Texas Instruments\SimpliciTI-IAR-1.1.0\Projects\Examples\EXP461x\Simple_Peer_to_Peer\IAR

    You will need to copy most of this code into your project. Make sure you also copy the project settings aswell. You will need to change some of the bsp files to suit your hardware.

    Now, to include extended API open the file smpl_nwk_config.dat which is in the Configuration folder and on line 68 remove the x from -DxEXTENDED_API. This will enable extended API.

    Hope this helps,

    Dave

  • I am also triing to implement such kind of loop with "Init, Link, Unlink, Do something else with RF (!), Init, Link, Unlink...." with "AP as data hub" scenario on CC430. But I always receive a SMPL_TIMEOUT when calling SMPL_Unlink(sLinkID) on ED even just after successful link. Problem generally is not the timeout, but the fact that ED remains in the table of AP as linked device.

    It is not obvious from documentation if SMPL_Unlink may be called from ED or AP or both and whether it is necessary on AP to add some action in the code for Unlink to be successful. Does anybody succeeded with unlinking already?

    BTW: I had to modify the SMPL_Unlink call to set sInit_done=0 otherwise the subsequent Init would skip the setup of RF, effectively failing if you use RF for something else in between.

     

  • OK, the TIMEOUT is my fault - have to put sInit_done=0 after nwk_unlink...

  • Hi Sun Li, the problem with SMPL_link() is that if you have a CCA fail and the procedure returns the initialized connection is not released. If you only have 2 connections you will soon run out of connections. Add "nwk_freeConnection(pCInfo);" just before returning.

    In procedure "smplStatus_t nwk_link(linkID_t *lid)" change the section below and SMPL_link() will work fine.

    if (SMPL_SUCCESS != (rc=SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_WRITE, &ioctl_info.send)))
    {
    nwk_freeConnection(pCInfo); // Add to release connection if failed TX
    return rc;
    }