TI E2E Community (Beta)
Welcome to the TI E2E (Engineer-to-Engineer) Community! We invite you to freely and openly interact with your peer Engineers, TI Engineers, and other experts in order to ask questions, share knowledge, explore ideas, and help solve problems.
More Search Options

Bidirectional communication with sCB-function

rated by 0 users
Not Answered This post has 0 verified answers | 4 Replies | 2 Followers

Top 150 Contributor
45 Posts
Community Member
driesione posted on 11 Mar 2009 10:47 AM

Hi folks,

i'am using the eZ430-RF2500. I'am also using the demo-sensor application and i'am willing
to implement a bidirectional communication between ED and AP.

The application should run normally until the AP gets an interrupt on his UART. Therefore i putted
the smpl_send-function in the UART-interrupt vector. For the linkID in that function i used the variable
sLid[1]. I already want to ask if this is correct?I believe this is the linkID from the ED or is this not?

Afterwards, i want to catch the packet on my ED. Herefore, i need to have also a callbackfunction. In the callback-
function i'am going  to implement a semofoor. In the main-function, i will check on this semafoor. If it's set, i will
go throug the if-statement. In the if-statement, i have to use the smpl_receive function to catch the packets from the AP.

My main question: wich linkID do i have to use in the smpl_receive function to let the ED know that the packet will
come from the AP?

I really don't understand those linkID's?  Any help would be high appreciated.

Best Regards

All Replies

Top 200 Contributor
37 Posts
Community Member

If you're using an AP, as you say, your ED code only needs two function calls to establish a link to the AP:

SMPL_Init(sCB);

which registers your callback function and issues a join request to the AP. Once your ED is joined with AP, you can attempt to link with the AP to set up a communication channel with it using the returned link ID.

SMPL_Link(&tAPLinkID);

You'll notice that in SMPL_Link(), you pass a link ID variable by reference. If your ED successfully links to the access point, the function will set the link ID to a valid value (most likely the integer 1). This will be the link ID that you use to communicate with the AP via the functions SMPL_Send and SMPL_Receive. You may think of the link ID as an identifier for the logical connection between the AP and ED.

It is important that the AP is listening for a link request when the ED attempts to link. After receiving a join request, your example code probably goes into an infinite loop making SMPL_LinkListen calls until it hears the link request from the ED. Upon hearing a link request, the AP will send a link reply to the ED, and the SMPL_Link function will give you a valid link ID for communicating with the AP.

If you haven't already, you may want to peruse the documentation that installs with TI's SimpliciTI installer swrc099b. Mine installed at C:\Texas Instruments\SimpliciTI-1.0.6\Documents. Here you should be able to find an SimpliciTI API reference, SimpliciTI's detailed specification, and a few other useful documents.

Top 150 Contributor
45 Posts
Community Member

Hi Grifcj,

thanks for replying! It contains good information but most of the things i already knew.
I already did a lot of reading in the simpliciTI-documents. But i'am still doubting about my linkID's.

I will show you what i have.
For the ED i use the two function that you said. They look like this:

linkID_t linkID1;

while (SMPL_NO_JOIN == SMPL_Init(sCB))
  {
    ...
  }

while (SMPL_SUCCESS != SMPL_Link(&linkID1))
  {
    ....
  }

SMPL_SUCCESS == SMPL_Send(linkID1, msg2, sizeof(msg2))

 

if (sPeerFrameSem)
    {
      uint8_t     msg[MAX_APP_PAYLOAD], len;

      // process all frames waiting
        if (SMPL_Receive(linkID1, msg, &len) == SMPL_SUCCESS)
        {
          ioctlRadioSiginfo_t sigInfo;
          sigInfo.lid = linkID1;
          SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SIGINFO, (void *)&sigInfo);
          buf = ~buf; // toggle commando
          BSP_TOGGLE_LED2();
          BSP_ENTER_CRITICAL_SECTION(intState);
          sPeerFrameSem--;
          BSP_EXIT_CRITICAL_SECTION(intState);
        }
    }

static uint8_t sCB(linkID_t linkid)
{
    if(linkid == linkID1)
    {
        sPeerFrameSem++;

    }
}

Now, i wonder if my "linkdID's" are correct filled in, in every function?
The sCB-function is just to set the semafoor. This semafoor is checked in the main-function
(the if-statement that i copied)
Sending to the AP with "linkID1" already works. Receive-function asks for the same linkID so i would think that i implemented every linkid owkey but i'am still not sure?

Kind Regards

Top 200 Contributor
37 Posts
Community Member

driesione:

while (SMPL_NO_JOIN == SMPL_Init(sCB))
  {
    ...
  }

I might suggest looping until SMPL_SUCCESS rather than just checking for SMPL_NO_JOIN. SMPL_Init can fail for a number of reasons, and I don't think you'd want to let the code pass unless it was successful.

driesione:

SMPL_SUCCESS == SMPL_Send(linkID1, msg2, sizeof(msg2))

I'll assume this is meant to be in an if-statement. Your useage of the link ID looks correct to me.

driesione:

          ioctlRadioSiginfo_t sigInfo;
          sigInfo.lid = linkID1;
          SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SIGINFO, (void *)&sigInfo);

I've never used this particular function or object, but it looks quite correct. Doesn't it work?

driesione:

static uint8_t sCB(linkID_t linkid)
{
    if(linkid == linkID1)
    {
        sPeerFrameSem++;

    }
}

Again, this seems right. The linkid variable in the callback function will be set to whatever link ID the incoming message is associated with. Since you only have one link ID, i.e. linkID1, this is the one you check for.

You didn't mention any problems, so I assume everything is working correctly? Certainly, if you were misusing your link IDs, you wouldn't be able to reliably communicate between the AP and ED.

Top 150 Contributor
45 Posts
Community Member

Hey Grifcj,

thanks for replying! Your tip about the SMPL_SUCCES except SMPL_NO_JOIN was a good one.

For the rest it effectively works. I was just afraid and wanted to be sure. I didn't test anything yet.

Kind Regards

Page 1 of 1 (5 items) |

ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". TI AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY TI. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.