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.

msp430 SimpliciTI AP_as_Data_Hub example sending/receiving message problems

Other Parts Discussed in Thread: SIMPLICITI, CC430F6137

Hello everyone,

I am using the SimpliciTI Ap as Data Hub example code to connect two cc430f6137 boards, one as End device and one as Acess Point. When  I run the code both boards work they way they are supposed to creating the link and toggling the leds just fine. 

Now I am trying to make the end device send a message to the acess point using the SMPL_Send and SMPL_Receive function already present and defined within the code. The 'msg' variable is defined as an 'unsigned char' vector both on the End Device code and the Acess Point, but when I input some random values to the 'msg variable on the End device code and run the whole system, connecting both boards and creating the link I am not able to see the same values being received by the acess point 'msg' variable. 

I am able to see the variable values by using the Watch expression and variables function of CCS.

I thought this example code was already set for sending the message between devices, do I have to add any kind of extra code to be able to perform this action?

Or is there anything specific that I might have to change to able to create this data between the two devices?

Any help will be highly appreciated,

Thanks a lot in advance,

Renan.

  • Renan,

    could you share part of your code showing how the transmission is done including variable definition,etc.?

    It would be also nice if you can show the capture of packet sniffer showing that the node is sending the wrong data.

    Thanks.

  • Hello again Leo,

    So the code creates the link connection between the end device and the acess point with the following code, this code also sends the message calling the 'SMPL_SendOpt' function. For the receiving code the function called is 'SMPL_Receive'. What I am trying to do is to give random values to the msg[ ] vector on the end device code and try to get those values on the msg[ ] variable over at the acess point. I though the code was already pre set to do this.

    The code for both devices is below:

    static void linkTo()
    {
    uint8_t msg[5];
    uint8_t button, misses, done;

    /* Keep trying to link... */
    while (SMPL_SUCCESS != SMPL_Link(&sLinkID1))
    {
    toggleLED(1);
    toggleLED(2);
    SPIN_ABOUT_A_SECOND;
    }

    /* Turn off LEDs. */
    if (BSP_LED2_IS_ON())
    {
    toggleLED(2);
    }
    if (BSP_LED1_IS_ON())
    {
    toggleLED(1);
    }

    /* sleep until button press... */
    SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0);

    while (1)
    {
    button = 0;
    /* Send a message when either button pressed */
    if (BSP_BUTTON1())
    {
    SPIN_ABOUT_A_QUARTER_SECOND; /* debounce... */
    /* Message to toggle LED 1. */
    button = 1;
    }
    else if (BSP_BUTTON2())
    {
    SPIN_ABOUT_A_QUARTER_SECOND; /* debounce... */
    /* Message to toggle LED 2. */
    button = 2;
    }
    if (button)
    {
    uint8_t noAck;
    smplStatus_t rc;

    /* get radio ready...awakens in idle state */
    SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);

    /* Set TID and designate which LED to toggle */
    msg[4]= 'b';
    msg[3] = 'a';
    msg[2] = '1';
    msg[1] = ++sTid;
    msg[0] = (button == 1) ? 1 : 2;
    done = 0;
    while (!done)
    {
    noAck = 0;

    /* Try sending message MISSES_IN_A_ROW times looking for ack */
    for (misses=0; misses < MISSES_IN_A_ROW; ++misses)
    {
    if (SMPL_SUCCESS == (rc=SMPL_SendOpt(sLinkID1, msg, sizeof(msg), SMPL_TXOPTION_ACKREQ)))
    {
    /* Message acked. We're done. Toggle LED 1 to indicate ack received. */
    toggleLED(1);
    break;
    }
    if (SMPL_NO_ACK == rc)
    {
    /* Count ack failures. Could also fail becuase of CCA and
    * we don't want to scan in this case.
    */
    noAck++;
    }
    }
    if (MISSES_IN_A_ROW == noAck)
    {
    /* Message not acked. Toggle LED 2. */
    toggleLED(2);
    #ifdef FREQUENCY_AGILITY
    /* Assume we're on the wrong channel so look for channel by
    * using the Ping to initiate a scan when it gets no reply. With
    * a successful ping try sending the message again. Otherwise,
    * for any error we get we will wait until the next button
    * press to try again.
    */
    if (SMPL_SUCCESS != SMPL_Ping(sLinkID1))
    {
    done = 1;
    }
    #else
    done = 1;
    #endif /* FREQUENCY_AGILITY */
    }
    else
    {
    /* Got the ack or we don't care. We're done. */
    done = 1;
    }
    }

    /* radio back to sleep */
    SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0);
    }
    }
    }

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

    As for receiving the message the code is this, which is actually inside the 'main()' of the acess point.


    while (1)
    {
    /* Wait for the Join semaphore to be set by the receipt of a Join frame from a
    * device that supports an End Device.
    *
    * An external method could be used as well. A button press could be connected
    * to an ISR and the ISR could set a semaphore that is checked by a function
    * call here, or a command shell running in support of a serial connection
    * could set a semaphore that is checked by a function call.
    */
    if (sJoinSem && (sNumCurrentPeers < NUM_CONNECTIONS))
    {
    /* listen for a new connection */
    while (1)
    {
    if (SMPL_SUCCESS == SMPL_LinkListen(&sLID[sNumCurrentPeers]))
    {
    break;
    }
    /* Implement fail-to-link policy here. otherwise, listen again. */
    }

    sNumCurrentPeers++;

    BSP_ENTER_CRITICAL_SECTION(intState);
    sJoinSem--;
    BSP_EXIT_CRITICAL_SECTION(intState);
    }

    /* Have we received a frame on one of the ED connections?
    * No critical section -- it doesn't really matter much if we miss a poll
    */
    if (sPeerFrameSem)
    {
    uint8_t msg[MAX_APP_PAYLOAD], len, i;

    /* process all frames waiting */
    for (i=0; i<sNumCurrentPeers; ++i)
    {
    if (SMPL_SUCCESS == SMPL_Receive(sLID[i], msg, &len))
    {
    processMessage(sLID[i], msg, len);

    BSP_ENTER_CRITICAL_SECTION(intState);
    sPeerFrameSem--;
    BSP_EXIT_CRITICAL_SECTION(intState);
    }
    }
    }
    if (BSP_BUTTON1())
    {
    SPIN_ABOUT_A_QUARTER_SECOND; /* debounce */
    changeChannel();
    }
    else
    {
    checkChangeChannel();
    }
    BSP_ENTER_CRITICAL_SECTION(intState);
    if (sBlinky)
    {
    if (++sBlinky >= 0xF)
    {
    sBlinky = 1;
    toggleLED(1);
    toggleLED(2);
    }
    }
    BSP_EXIT_CRITICAL_SECTION(intState);
    }

    }

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

    Sorry for the late response, I am still trying to get the capture of the packet sniffer, as soon as I have I will post is here as well.

    Thanks a lot,

    Renan.

  • Hello Leo,

    I have managed to get the Package Sniffer to work and captured the behaviour of the code above with it:

    So the connection is made but for the Access Point it appears that it is not receiving the 'msg' from the End Device.

    Shouldn't it be showing as 'Application Payload' for the access point, the values that I sent via the 'msg' of the End Device?

    Thanks a lot,

    Renan.