Is there any way to change/set custom advertising and connection intervals wtih using CAF BLE Advertising module

Hello Everyone,

I was wondering if there is any easy "ready configuration" way to directly set BLE advertising and connection interval with adding some config to the prj.conf or Kconfig file. Here some of the configurations I'm using for my BLE peripheral device and its currently consuming too much power than I expected because even default slow interval is also to fast for my case.

# ============= Bluetooth Configuration =============
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DEVICE_NAME_MAX=32
CONFIG_BT_DEVICE_NAME_GATT_WRITABLE=n

# BLE Security
CONFIG_BT_SMP=y
CONFIG_BT_SETTINGS=y
CONFIG_BT_PRIVACY=n

# ============= Common Application Framework (CAF) =============
CONFIG_CAF=y

# CAF BLE State Module
CONFIG_CAF_BLE_STATE=y
CONFIG_CAF_BLE_STATE_SECURITY_REQ=n
CONFIG_CAF_BLE_STATE_MAX_LOCAL_ID_BONDS=1
CONFIG_CAF_BLE_COMMON_EVENTS=y

# CAF BLE Advertising Module
CONFIG_CAF_BLE_ADV=y
CONFIG_CAF_BLE_ADV_DIRECT_ADV=n
CONFIG_CAF_BLE_ADV_FAST_ADV=y
CONFIG_CAF_BLE_ADV_FAST_ADV_TIMEOUT=30


I'm aiming to set it to the "max_interval = min_interval = 1000ms" for advertising and "min_interval = 75ms to max_interval = 150ms" for the connection interval. I'm currently using Zephyr RTOS and Nordic SDK NCS version 2.9.0

Thanks for your help in advance.

Best regards,
Semih.

Parents
  • Hi Semih, 
    Could you try using 

    CONFIG_CAF_BLE_ADV_FAST_INT_MIN
    CONFIG_CAF_BLE_ADV_FAST_INT_MAX
    CONFIG_CAF_BLE_ADV_SLOW_INT_MIN
    CONFIG_CAF_BLE_ADV_SLOW_INT_MAX
    For example if you want 1000ms adverting, you can try setting
    CONFIG_CAF_BLE_ADV_SLOW_INT_MIN=0x640 
    CONFIG_CAF_BLE_ADV_SLOW_INT_MAX=0x640
    The unit here is N * 0.625 ms

    Regarding connection interval, it's dictated by the central. The peripheral can request connection parameter update to request a change but I don't think it's covered by CAF. Please refer to other samples (for example throughput) in the SDK for that. 
  • Hi Hung,

    Thank you so much, It worked for me!

    I also found Kconfig definition from the link below and I am sharing this information because I think it may be important.

    "Minimum Advertising Interval shall be less than or equal to the Maximum Advertising Interval. The Minimum Advertising Interval and Maximum Advertising Interval should not be the same value (as stated in Bluetooth Core Spec 5.2, section 7.8.5) " 

    https://docs.nordicsemi.com/bundle/ncs-1.9.2-dev1/page/kconfig/CONFIG_CAF_BLE_ADV_SLOW_INT_MAX.html 

    Additionally, I managed to adjust the connection range using the following:

    CONFIG_BT_PERIPHERAL_PREF_MIN_INT=75
    CONFIG_BT_PERIPHERAL_PREF_MAX_INT=150
    CONFIG_BT_PERIPHERAL_PREF_LATENCY=0
    CONFIG_BT_PERIPHERAL_PREF_TIMEOUT=400

    Thanks for your support!

Reply Children
Related