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.

Compiler/CC2640R2F: What is the proper way to disable/re-enable SCAN_RSP for a connectable advertising ?

Part Number: CC2640R2F


Tool/software: TI C/C++ Compiler

I am using SDK 4.10, ble5 stack but legacy LE advertising, peripheral mode. (simple (ble5) peripheral)

According to my understanding, active-scan-response is required for connectable advertising with the legacy LE advertising.

I tried to disable it virtually by giving the GAP_ADV_DATA_TYPE_SCAN_RSP size 0, so the peripheral was still connectable even without an active scan response.

That seemed working.

However, when I tried to enable it by loading another content, the stack crashed. What is the proper way to disable and re-enable it?

My intention is to save power by not let the central scan it unless it is needed. By giving size 0, does that really help with power saving?

Here is the sample... It works fine when "not-disable" to "disable", but it crashes when it goes back from "disable" to "not-disable"!

  // disable the advertising and release the buffer
  bStatus_t status = GapAdv_prepareLoadByHandle(advHandleSet1, GAP_ADV_FREE_OPTION_SCAN_RESP_DATA);
  
  // reload with the newly created active scan response data
  uint8_t *tmpScanRspData = ICall_malloc(sizeof(scanRspData));
  
  uint32_t useSize;
  if(disable)
  {
    useSize = 0;
  }
  else
  {
    useSize = sizeof(scanRspData);
  }
  
  memcpy(tmpScanRspData, scanRspData, sizeof(scanRspData));
  status = GapAdv_loadByHandle(advHandleSet1, GAP_ADV_DATA_TYPE_SCAN_RSP,
                               useSize, tmpScanRspData);

Samson

  • Hi Samson,

    Can you be a bit more specific on which line of code is crashing?

    For the rest, I am not sure your solution is the more power-optimized. Including by having 0 bytes in the scan response, the device will still turn on the radio and transmit a few data during each scan request.
    I imagine that using a non-connectable-non-scannable advertisement when you don't want to answer a scan request would be a better choice.

    Kind regards,

  • I guess there is no way to turn off the Active Scan RSP totally. (If there is, please do let me know.) 

    I used two advertisement handles, one with the Active Scan RSP and one without. That way works. However, the sniffer showed there was still Active Scan RSP sent out from the peripheral without the Active Scan RSP, just there was NO DATA. Anyway, this might still save a little bit of power since the PDU is still shorter, I guess.

    Samson 

  • Thanks, Clement,

    Since I need the peripheral to be connected, I guess I have to tolerate the existence of the "empty" Active Scan RSP. 

    Samson