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.

CCS/LAUNCHXL-CC2640R2: Dynamic Adjust Advertising Data for Simple Broadcaster

Part Number: LAUNCHXL-CC2640R2
Other Parts Discussed in Thread: CC2640

Tool/software: Code Composer Studio

Hi,

As title, I want to broadcast some data within counter, so any packet will have different data.
Example i based on : simplelink_cc2640r2_sdk_2_20_00_49\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_broadcaster.

I changing advertData in function SimpleBroadcaster_processAdvEvent 's case GAP_EVT_ADV_END
The result is packet will changed, but over some number of times, it will stop changing.

Any suggestion you can give me to solve my problem?

Best regard,
Lee

  • Can you post code snippet?

    Under what circumstances the counter stops changing?
    Is the device still advertising at the time?
  • Here my code, pls take a look.

    static bool SimpleBroadcaster_processAdvEvent(sbGapAdvEventData_t *pEventData)
    {
      bool safeToDealloc = TRUE;
    
      switch (pEventData->event)
      {
        case GAP_EVT_ADV_START_AFTER_ENABLE:
          Display_printf(dispHandle, 2, 0, "Advertising");
          Display_printf(dispHandle, 3, 0, "Channel 37");
          Display_printf(dispHandle, 4, 0, "primPhy: 1 mbps");
          Display_printf(dispHandle, 5, 0, "secPhy: 1 mbps");
          Display_printf(dispHandle, 6, 0, "Interval : %d (%dms)", INTERVAL, (INTERVAL*625/1000));
          break;
    
        case GAP_EVT_INSUFFICIENT_MEMORY:
          safeToDealloc = FALSE;
          break;
    
    #ifdef COUNTER
        case GAP_EVT_ADV_END:
            count = count + 1;
            count = count % 0x1000000;   //count range : 0 - 0xFFFFFF
            advertData[7] = count / 0x10000;
            advertData[8] = (count / 0x100) % 0x100;
            advertData[9] = count % 0x100;
            Display_printf(dispHandle, 8, 0, "count : %d", count);
            Display_printf(dispHandle, 9, 0, "advertData : %x %x %x", advertData[7], advertData[8], advertData[9]);
            break;
    #endif
    
        default:
          // Do nothing.
          break;
      }
    
      return(safeToDealloc);
    }

    And here is my result. Every times reset will let Broadcaster count from 0 to 977, and then stop counting, but still broadcasting.

  • Hi,

    I was able to reproduce what you are seeing. We are trying to figure out what's going on now, will keep you posted once we identify the root cause.
  • Hi,

    Thx for your reply. Actually i had fix the problem. Here is how i done.

    1. After a few testing, i guess the problem was produced by memory of CC2640 become full.
    2. So i compared the code with 1067.simple_peripheral.c from other forum.
        And i find a line of code at before return in function SimplePeripheral_processAdvEvent. Code : ICall_free(pEventData->pBuf);
    3. After i add it to my code, it fix the problem.

    I think the example (ble5stack/simple_broadcaster) in simplelink_cc2640r2_sdk_2_20_00_49 was miss this code.
    You may add the code in next version SDK.

    Tq for reply my issue.

  • Hi, I doubled check the call, the implementation of how the event is cleared is different between those two projects. What you need to do is to add " safeToDealloc = TRUE; " into your original code. But doing it the same way as simple_peripheral is also ok. Just make sure that you don't double free the msg.