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 receive message in the example simple_peer_to_peer

Other Parts Discussed in Thread: SIMPLICITI

Hello:

I am trying to use the example simple_peer_to_peer to send an array defined in LinkTo.c    

Here is the code i set in the linkTo()  :     uint8_t test[2]={0x38,0x25};

                                                                        SMPL_Send(sLinkID1, test, sizeof(test));  

The i defined an arrary in LinkListen,c  to receive the message.

Here is the code i set in the LinkFrom.c:  ( uint8_t     recmsg[2], len;

                                                                               SMPL_Receive(sLinkID2,recmsg, &len)  ;)--set by myself

However when i debug,i can not find the message in the array recmsg adding to watch.

Can anyone tell me whether i have received  the message? if i have received, where can i find message?

  • If you take the original Simple_Peer_To_Peer project you can look at the received message if you look in the sRxCallback function. You can setup your receive buffer there and replace the msg in the SMPL_Receive function.

     LinkTo:

    while (1)
    {
        SPIN_ABOUT_A_SECOND; /* manages FHSS implicitly */
        if (delay > 0x00)
        {
            SPIN_ABOUT_A_SECOND; /* manages FHSS implicitly */
        }
        if (delay > 0x01)
        {
            SPIN_ABOUT_A_SECOND; /* manages FHSS implicitly */
        }
        if (delay > 0x02)
        {
            SPIN_ABOUT_A_SECOND; /* manages FHSS implicitly */
        }
    
        /* delay longer and longer -- then start over */
        delay = (delay+1) & 0x03;
        /* put the sequence ID in the message */
        //msg[1] = ++sTxTid;
        //SMPL_Send(sLinkID1, msg, sizeof(msg));
        {    
            uint8_t test[2]={0x38,0x25};
            SMPL_Send(sLinkID1, test, sizeof(test));  
        }
    }
    

    LinkListen:

    static uint8_t sRxCallback(linkID_t port)
    {
        uint8_t msg[2], len, tid;
        uint8_t recmsg[2];
      
        /* is the callback for the link ID we want to handle? */
        if (port == sLinkID2)
        {
            /* yes. go get the frame. we know this call will succeed. */
            if ((SMPL_SUCCESS == SMPL_Receive(sLinkID2, recmsg, &len)) && len)
            {
                *msg = *recmsg;
                   .
                   .
    

     

  • Hi Siri:

    Thank you for your answer!It is really nice of you to help me.

    If i want to send a large array such as 1000 bytes, should i divide this array into some small arrays the size of which is smaller than mrfi_MAX_PAYLOAD_SIZE manually?

    Can you give me some advice?
  • Hi

    If you want to send for example 1000 bytes you need to break the data into smaller packets limited to the MAX_PAYLOAD_SIZE. Unfortunately we do not have any code examples to show you.

    Siri

  • Hi

    I have broken the data into smaller packet.

    But sometimes it is instable. Then I changed options SMPL_TXOPTION_NONE in SMPL_SendOpt() to SMPL_TXOPTION_ACKREQ. Then i find that it can not send the packet successfully. What else should i modify if i want to choose the TX option as SMPL_TXOPTION_ACKREQ?

    Can you give me some advice how to make sure the packet will be received by the device?
  • Hi

    When you use this option you request acknowledgement from peer. What are the status message the function return? The status could be one of the following:

    • SMPL_SUCCESS
    • SMPL_BAD_PARAM
    • SMPL_NOMEM
    • SMPL_TX_CCA_FAIL CCA
    • SMPL_NO_ACK

    Have you written your code so that the receiver will send an Ack. back to the sender?

    When debugging you can have a counter variable in your code, incrementing by one every time a packet is received with CRC OK. This way you can check this variable when you debug to see how many packets you have received.

    Siri

  • Hi

    I find i did not enable application autoacknowledge support in smpl_nwk_config.dat.

    Now i want to implement the low power character of simpliciTI.

    Can you tell me how simpliciTI reflect the character?
  • Hi

    Not sure I understand your question. The End Devices can be put in SLEEP when they are not active. Power management of the MCU must be accomplished at the application level using native MCU resources.

    Siri

  • Hi

    Can i understand as follows?After connected, the End Devices will get into SLEEP status. If a packect is received, the device will be awakened and invoke the call back function sRxCallback()to handle the received packet. And then the End Device get into the SLEEP status again until the next packet.
  • Hi

    The End Devices will not get into SLEEP unless the application tells them to go into SLEEP. When they are in SLEEP mode, they will not be able to receive anything. To be able to receive, the radio must be in RX state.

    A typical user case is an end device which is in SLEEP until something happens (external interrupt from a sensor). Then the MCU wakes up from sleep and wakes up the radio. The radio will then enter TX to transmit a message.

    If you want an end device to receive something, you must wake it up at regular intervals to sniff for data. The data transmitted must then be longer than the sleep interval of the ED. You can either send a very long preamble or repeat the transmitted packet several times.

    BR

    Siri

  • Note:

    In the Simple Peer to Peer example, the ED does not enter SLEEP