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.

Changing broadcast data after a hardware interrupt on CC2650

Hi, I'm using the smartrf06 board with cc2650EM-7ID package and trying to make a custom Broadcaster project. I'm also using ble stack v2.1.1 SimpleBLEBroadcaster with IAR for my application.

Firstly, my broadcaster sets the necessary configurations for negative edge pin wake up in the init function and goes to shutdown. After it wakes up with a negative edge, it starts broadcasting a data. Until now my application works perfectly. The next step is to trigger an interrupt if a negative edge is captured and change the broadcasting data. I was able to implement the callback of the hardware interrupt with the following code and also added HCI_EXT_AdvEventNoticeCmd function to update data in taskFxn function.

    g_pinHandle = PIN_open(&g_pinState, alertIO);
    
    PIN_registerIntCb(g_pinHandle, alertHwiFxn);
    
    PIN_setConfig(g_pinHandle, PIN_BM_IRQ, Board_KEY_UP | PIN_IRQ_NEGEDGE);
    
    HCI_EXT_AdvEventNoticeCmd(selfEntity, ALERT_EVENT);
    
    // Start the Device
    VOID GAPRole_StartDevice(&simpleBLEBroadcaster_BroadcasterCBs);

I've tested this and the hardware interrupt works fine triggering the following event that I defined before:

#define ALERT_EVENT                           0x0010

static void alertHwiFxn(PIN_Handle hPin, PIN_Id pinId)
{
  g_events.hdr.event |= ALERT_EVENT;
  
  Semaphore_post(sem);
}

Lastly I'm checking if the event is triggered inside taskFxn for loop with the following code:

    if(g_events.hdr.event & ALERT_EVENT)
    {
      // Clear event
      g_events.hdr.event &= ~ALERT_EVENT;
      
      g_status = GAPRole_SetParameter(GAPROLE_ADVERT_DATA, sizeof(alertData), alertData);
      
      if(g_status == SUCCESS){
        GPIOPinToggle(1<<IOID_25);
      }
    }

I can see that the LED toggles every time I press the button but the broadcasting data doesn't change. I've read similar questions on the forum but couldn't find a solution that updates the data. Can someone tell me what am I doing wrong or missing here.

Thank you for your help.

  • Hello Ogulcan,

    What is the result of g_status when you update the data? That would be a good first step to try.

    Best wishes
  • Hi JXS, thank you for your answer.

    I put the if statement before toggling the led just to be sure that g_status is success after calling the function. So when I push the button event is triggered and the LED toggles every time I press it but the advertising data still doesn't change.

    All the best

  • Hi again, I looked through the stack few more times to be sure that I'm doing everything right. In the end I discovered a missing code inside broadcaster.c where GAPRole_SetParameter function is defined. When advertising data is updated the stack doesn't actually update the data. It only does it when scan response data is updated as well. Here is the code that I found missing:

        case GAPROLE_ADVERT_DATA:
          if (len <= B_MAX_ADV_LEN)
          {
            VOID memset(gapRole_AdvertData, 0, B_MAX_ADV_LEN);
            VOID memcpy(gapRole_AdvertData, pValue, len);
            gapRole_AdvertDataLen = len;
          }
          else
          {
            ret = bleInvalidRange;
          }
          break;
    
        case GAPROLE_SCAN_RSP_DATA:
          if (len <= B_MAX_ADV_LEN)
          {
            VOID memset(gapRole_ScanRspData, 0, B_MAX_ADV_LEN);
            VOID memcpy(gapRole_ScanRspData, pValue, len);
            gapRole_ScanRspDataLen = len;
            
            // Update the advertising data
            ret = GAP_UpdateAdvertisingData(selfEntity,
                                  TRUE, gapRole_AdvertDataLen, gapRole_AdvertData);
          }
          else
          {
            ret = bleInvalidRange;
          }
          break;

    As you can see advertising data is not updated even though the parameter is passed to an array. So I added the same code at GAPROLE_SCAN_RSP_DATA to GAPROLE_ADVERT_DATA as well. Now the application works and updates the advertising data if the button is pressed with the following code:

        case GAPROLE_ADVERT_DATA:
          if (len <= B_MAX_ADV_LEN)
          {
            VOID memset(gapRole_AdvertData, 0, B_MAX_ADV_LEN);
            VOID memcpy(gapRole_AdvertData, pValue, len);
            gapRole_AdvertDataLen = len;
            
                    // Update the advertising data
            ret = GAP_UpdateAdvertisingData(selfEntity,
                                  TRUE, gapRole_AdvertDataLen, gapRole_AdvertData);
          }
          else
          {
            ret = bleInvalidRange;
          }
          break;

    I think this should be mentioned somewhere in the software developer guide or the stack should be changed as I did to update when only advertising data is changed as well.

    All the best

  • Hello Ogulcan,

    I apologize for the confusion here. Yes, this is the issue and I have confirmed that it has been addressed in our next SDK.

    Best wishes