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.

LAUNCHXL-CC2640R2: Send data packets between broadcaster and observer

Part Number: LAUNCHXL-CC2640R2

Hello everyone,

I have two CC2640R2 launchpads. I am using one as a broadcaster and one as observer. I am able to form a non-connected advertisement between the two (on channels 37, 38 and 39)and also send advertising data.

Now, I would like to send data packets from broadcaster to observer. But in the simpleLink academy, it says that we can send data only after we form a connection between the two devices(Central and peripheral). But I am using a non-connectable advertisement, so there is no connection between the two(broadcaster and observer). How should I send data packets now? I am really confused and frustrated. Please do provide me some guidance.

Best Regards

Yasar

  • Hi Yasar,

    yasar Mohammed said:
    I am able to form a non-connected advertisement between the two (on channels 37, 38 and 39)and also send advertising data

    You do not form anything. The broadcaster sends data to "everyone" and the observer is scanning "everything"... so it's more of a convenience that you have the one way direction. You can send data from broadcaster to observer although it will consume more energy than a connection and it will not be secure, nor robust since the observer cannot acknowledge.

    These devices need to operate in peripheral and central mode instead and form a connection for data to be transferred (in a secure and bidirectional matter). it's simply how Bluetooth low energy is defined.

  • Hi Joakim,

    Thank you for the reply. I know what you mean but it is the requirement of my project to have a broadcaster and observer since I will be using more devices as observers. I realised that I don' t need to use data channels. I only need to use advertisement channels to send data with diff Tx power and time intervals. It is clear now. Thank you once again

  • Hey,

    No problem, let us know if there is anything else we can aid with. Good luck with your project!

  • Hi Joakim,

    Thank you, However I need to send 100 packets of data between the broadcaster and observer. But the default max. length of data is 31 bytes on adv.channel. Do you know how can I achieve this solution?

    Best Regards

    Yasar

  • Hi Yasar,

    You would have to fragment the data (split it up) although the problem is that there is no way for the broadcaster to know if and when an advertising packet is successfully received (thus move on to next portion).

    It sounds more like you need a connection.

  • Hello  Lindh,

    Thank you for the reply. I need to first send it only on one channel. What if I made a loop that sends 31 bytes of data 100 times. Do you think that will work?

    Best Regards

    Yasar

  • Hi Joakim,

    Do you maybe know some tutorials how to fragment data ? or can you give a brief overview on how to do it? 

    Best Regards

    Yasar

  • Hi Yasar,

    By fragment, I am referring to splitting up the data, which can be done by simple c operations. 

  • Hi Joakim,

    Thank you for the quick reply, really appreciate it. So, I was working on logic. I have 31 bytes = 31*8 = 248 bits = 248/100 = 2.48 bits. so, I should divide each packet to 2.48 bits?

    If that's correct. Can you please help with the code. I am fairly new to this. Just an example code would help me understand.

    Best Regards

    Yasar

  • Hi Yasar,

    I do not understand. You said send 31 Bytes in 100 packets. Does that mean you have 3100 Bytes to send in total?

    Maybe it's easier if you just let me know how much data you need to send, and the periodicy.

  • Hi Joakim,

    I need to send 100 data packets on one advertising channel(ex. 37) But since the limit is 31 bytes. How do I do it? 

    I don't know what periodicity is. But the adv. interval is 200 ms.

    Best Regards

    Yasar

  • Yasar,

    You still haven't responded to my question. You keep saying 100 packet, but my question is how large is each packet in bytes? Obviously, if the packet size is 31 Bytes, you are all good. If it's less, no fragmentation needed. If larger, then you need to fragment it... although not by bits but bytes.

  • Hello Joakim,

    I am sorry, I didn't understand the question. What I mean is, It doesn't matter how large the packet should be. 31 Bytes should be enough. Does this mean that I should send 31 Bytes of data (an array) 100 times?


    Right now I am using this for loop to send 1 packet of 10 bits data.


    My code:

     uint8_t i = 0;
                  bStatus_t status = 0;

                  static uint8_t advData = 0;

                  advertData[i++] = 0x02;   // length of this data
                  advertData[i++] = GAP_ADTYPE_FLAGS;
                  advertData[i++] = DEFAULT_DISCOVERABLE_MODE | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED;

                  //Setup up custom user data initially


                  advertData[i++] = ADV_MAX_LEN; // length of this data
                  advertData[i++] = GAP_ADTYPE_MANUFACTURER_SPECIFIC; // length of this data



    for(i = 0; i < 10; i++)
                                {
                                  advertData[i] = advData++;
                                }
                  status = GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(advertData), advertData);

    What changes I should make to meet my requirements?



    Best regards
    Yasar

  • Hi,

    That's 10 Bytes of data (not bits) although the concept should work.

  • Hello Joakim,

    Thank you for your reply. Yes, 10 Bytes. Now, How can I send it 100 times? I formed another loop but it doesn't seem to work. Can you please  suggest some code example?

    Best Regards

    Yasar

  • Hi Yasar,

    You will need to create a timer that you start whenever the advertising data is updated (and started). Once the timer runs out, you will ned to stop advertisement, update the advertising data to the next set of bytes... and so on.

    Since you have absolutely no idea if the data is received on the other end, I strongly recommend you consider using connections instead. Until then, this little adventure is something you will need to manage on your own. Good luck!