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.

CC2540: Limited Discoverable mode taking longer than 30 seconds

Part Number: CC2540

Tool/software:

I recently updated my BLE stack to 1.5.2. Since doing so, my advertisement is taking longer than 30.72 seconds when the Limited Discoverable flag is set as the DEFAULT_DISCOVERABLE_MODE. By setting the param, TGAP_LIM_ADV_TIMEOUT to 30, my device only advertises for 30 seconds. However, I didn't need to set this variable before the upgrade. Is there a reason the flag isn't working as expected?

  • Hi,

    Thank you for reaching out. To confirm, you are seeing the expected behavior after changing the TIMEOUT value?

    Best Regards,

    Jan

  • Yes, once I set this value, I see the expected behavior. However, I never needed to set this value before and was getting the expected 30 second advertisement. The GAP_ADTYPE_FLAGS_LIMITED should make sure we advertise for 30 seconds despite the value of the timeout. Or at least that was the case for other BLE stacks.

  • Hi,

    Got it. My apologies, I misinterpreted the original issue. Can you share the code snippet that shows how you are setting the flag?

    Best Regards,

    Jan

  • No worries! I defined it as limited discovery and then used that flag in my advertData.
     

    #define DEFAULT_DISCOVERABLE_MODE             GAP_ADTYPE_FLAGS_LIMITED
    
    ...
    
    static uint8 advertData[] = 
    { 
      // Flags; this sets the device to use limited discoverable
      // mode (advertises for 30 seconds at a time) instead of general
      // discoverable mode (advertises indefinitely)
      0x02,   // length of this data
      GAP_ADTYPE_FLAGS,
      DEFAULT_DISCOVERABLE_MODE | GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED,
    ....
    }

  • Hi,

    The code looks okay to me. How long is the advertising data? In earlier SDKs, there was an issue where if the advert length was 31 bytes, then the advertising would not cease. This was fixed in one of the 1.4 releases but would be helpful to check if changing the length has an impact.

    Best Regards,

    Jan

  • Change of limited discoverable length

    Hi,

    Without the TGAP_LIM_ADV_TIMEOUT param set, it was advertising for about 3 minutes. Based on the link above, it seems there is a mismatch in what the limited discovery value is (GAP_ADTYPE_FLAGS_LIMITED). Where should I look to find the correct value? 

  • Hi,

    Based on the gap.h file:

    /**
     * @defgroup GAP_PARAMETER_ID_DEFINES GAP Parameter IDs
     * Used in place of gapParamIDs_t.
     * @{
     */
    // Timers
    #define TGAP_GEN_DISC_ADV_MIN          0  //!< Minimum time to remain advertising, when in Discoverable mode (mSec).  Setting this parameter to 0 turns off the timeout (default).
    #define TGAP_LIM_ADV_TIMEOUT           1  //!< Maximum time to remain advertising, when in Limited Discoverable mode. In seconds (default 180 seconds)
    #define TGAP_GEN_DISC_SCAN             2  //!< Minimum time to perform scanning, when performing General Discovery proc (mSec)
    #define TGAP_LIM_DISC_SCAN             3  //!< Minimum time to perform scanning, when performing Limited Discovery proc (mSec)
    #define TGAP_CONN_EST_ADV_TIMEOUT      4  //!< Advertising timeout, when performing Connection Establishment proc (mSec)
    #define TGAP_CONN_PARAM_TIMEOUT        5  //!< Link Layer connection parameter update notification timer, connection parameter update proc (mSec)
    

    Can you try calling the following API to set it to 30 seconds?

    VOID GAP_SetParamValue( TGAP_LIM_ADV_TIMEOUT, 30);
    Best Regards,
    Jan
  • Hello,

    Yes, using that type of call works for the time fame I am looking for. However, I just want to clarify that the comment made in simpleBLEPeripheral.c may be misleading since it will actually advertise for 180 seconds rather than the 30.72, correct?

    // Limited discoverable mode advertises for 30.72s, and then stops
    // General discoverable mode advertises indefinitely
    
    #if defined ( CC2540_MINIDK )
    #define DEFAULT_DISCOVERABLE_MODE             GAP_ADTYPE_FLAGS_LIMITED
    #else
    #define DEFAULT_DISCOVERABLE_MODE             GAP_ADTYPE_FLAGS_GENERAL
    #endif  // defined ( CC2540_MINIDK )
    // Minimum connection interval (units of 1.25ms, 80=100ms) if automatic parameter update request is enabled

  • Hi,

    Understood. Glad you are able to work around this! Yes, it seems the comment is misleading and I truly apologize for any inconvenience this may have caused.

    Best Regards,

    Jan

  • Thank you for clarifying and for all your assistance!