nRF Stop scanning coded phy beacon

Hello,

Currently using nrf connect sdk version 3.0.0 and nRF5340,
After some random time my device stop scanning coded phy beacon, it not coming in scan callback,
I attached my configuration related to scanning,

Thanks and regards,
Saurabh.

#define CONFIG_BT_LE_SCAN_TYPE  BT_LE_SCAN_TYPE_PASSIVE         /**< Scan type (BT_LE_SCAN_TYPE_ACTIVE or BT_LE_SCAN_TYPE_PASSIVE). */
#define CONFIG_BT_LE_SCAN_OPT  BT_LE_SCAN_OPT_CODED  /**< Bit-field of scanning options. */
#define CONFIG_BT_GAP_SCAN_INTERVAL BT_GAP_SCAN_FAST_INTERVAL_MIN   /**< Scan interval (N * 0.625 ms). */
#define CONFIG_BT_GAP_SCAN_WINDOW   BT_GAP_SCAN_FAST_WINDOW   /**< Scan Window (N * 0.625 ms). */

static struct bt_le_scan_param scan_param = {
    .type = CONFIG_BT_LE_SCAN_TYPE,
    .options = CONFIG_BT_LE_SCAN_OPT,
    .interval = CONFIG_BT_GAP_SCAN_INTERVAL,
    .window = CONFIG_BT_GAP_SCAN_WINDOW,
    .interval_coded = CONFIG_BT_GAP_SCAN_INTERVAL,
    .window_coded = CONFIG_BT_GAP_SCAN_WINDOW,
    .timeout = 30000, /** Scan stop after 5 minutes. 10.9 is (Maximum) */
};

struct bt_le_scan_cb scan_cb_struct = {
    .recv = ble_scan_cb,
    .timeout = ble_scan_timeout_cb,
};

static void ble_scan_timeout_cb(void)
{
    LOG_INF("scan stop timeout restart bluetooth scanning");\
    k_work_submit(&start_scan_work);
    // ble_start_scanning();
}

// Register callback function
err = bt_le_scan_cb_register(&scan_cb_struct);

// Start scanning
err = bt_le_scan_start(&scan_param, NULL);

Parents
  • Hi,

    There is a known issue in the SoftDevice Controller where sometimes stopped generating advertising reprots when doing extended scanning (like scanning coded PHY). This is fixed in nRF Connect SDK 3.1.0, so i recommend updateing to that or later.

  • Below is the ipc_prj,conf

    CONFIG_HEAP_MEM_POOL_SIZE=8192
    CONFIG_MAIN_STACK_SIZE=512
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
    
    CONFIG_MBOX=y
    CONFIG_IPC_SERVICE=y
    
    CONFIG_BT=y
    CONFIG_BT_HCI_RAW=y
    CONFIG_BT_CTLR_ASSERT_HANDLER=y
    CONFIG_BT_EXT_ADV=y
    
    # Ensure BLE ECC key generation works
    CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
    CONFIG_BT_CTLR_LE_PING=y
    CONFIG_ENTROPY_GENERATOR=y
    CONFIG_ENTROPY_BT_HCI=y
    
    
    #CONFIG_BT_MAX_CONN=16
    
    # Enable and adjust the below value as necessary
    CONFIG_BT_BUF_EVT_RX_COUNT=32
    CONFIG_BT_BUF_EVT_RX_SIZE=255
    CONFIG_BT_BUF_ACL_RX_SIZE=255
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    CONFIG_BT_BUF_CMD_TX_SIZE=255
    
    CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT=4000000
    
    CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
    CONFIG_BT_BUF_ACL_RX_SIZE=502
    CONFIG_BT_BUF_ACL_TX_SIZE=502
    
    CONFIG_BT_MAX_CONN=2
    
    CONFIG_ASSERT=y
    
    CONFIG_IPC_RADIO_BT=y
    CONFIG_IPC_RADIO_BT_HCI_IPC=y
    
    #Added to fix BLE crash in coex enable cases.
    CONFIG_NRF_RPC=n
    CONFIG_NRF_RPC_CBOR=n
    


    Below is the mcuboot.conf

    # Enable logging for MCUboot
    CONFIG_LOG=y
    
    # Turn on a LED so we can see when Serial Recovery mode is active
    CONFIG_MCUBOOT_INDICATION_LED=n
    
    # Step 1.2 - Enable QSPI driver for MCUboot
    CONFIG_NORDIC_QSPI_NOR=y
    
    # Step 4.1 - Increase number of sectors
    # This is 512 for the nRF54L15 but can be smaller for other chips
    CONFIG_BOOT_MAX_IMG_SECTORS=512
    
    CONFIG_PM=n
    
    CONFIG_MAIN_STACK_SIZE=10240
    
    CONFIG_BOOT_SWAP_SAVE_ENCTLV=n
    CONFIG_BOOT_ENCRYPT_IMAGE=n
    
    CONFIG_BOOT_UPGRADE_ONLY=n
    CONFIG_BOOT_BOOTSTRAP=n
    
    ### mbedTLS has its own heap
    # CONFIG_HEAP_MEM_POOL_SIZE is not set
    
    ### We never want Zephyr's copy of tinycrypt.  If tinycrypt is needed,
    ### MCUboot has its own copy in tree.
    
    CONFIG_FLASH=y
    CONFIG_FPROTECT=y
    
    ### Various Zephyr boards enable features that we don't want.
    # CONFIG_BT is not set
    # CONFIG_I2C is not set
    
    CONFIG_LOG=y
    CONFIG_LOG_MODE_MINIMAL=y # former CONFIG_MODE_MINIMAL
    ### Ensure Zephyr logging changes don't use more resources
    CONFIG_LOG_DEFAULT_LEVEL=0
    ### Use info log level by default
    CONFIG_MCUBOOT_LOG_LEVEL_INF=y
    ### Decrease footprint by ~4 KB in comparison to CBPRINTF_COMPLETE=y
    CONFIG_CBPRINTF_NANO=y
    CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT=0
    ### Use the minimal C library to reduce flash usage
    CONFIG_MINIMAL_LIBC=y
    
    #core should be on a clean state when TF-M starts
    CONFIG_MCUBOOT_CLEANUP_ARM_CORE=n
    


    and below is the prj.conf

    CONFIG_GPIO=y
    
    # Enable mcumgr DFU in application
    CONFIG_MCUMGR=y
    
    # Enable MCUMGR management for both OS and Images
    CONFIG_MCUMGR_GRP_OS=y
    CONFIG_MCUMGR_GRP_IMG=y
    
    # Configure MCUMGR transport to UART
    # CONFIG_MCUMGR_TRANSPORT_UART=y
    CONFIG_MCUMGR_TRANSPORT_BT=y
    
    # Dependencies
    # Configure dependencies for CONFIG_MCUMGR  
    CONFIG_NET_BUF=y
    CONFIG_ZCBOR=y
    CONFIG_CRC=y
    
    # Configure dependencies for CONFIG_MCUMGR_GRP_IMG  
    CONFIG_FLASH=y
    CONFIG_IMG_MANAGER=y
    
    # Configure dependencies for CONFIG_IMG_MANAGER  
    CONFIG_STREAM_FLASH=y
    CONFIG_FLASH_MAP=y
    
    # Configure dependencies for CONFIG_MCUMGR_TRANSPORT_UART 
    CONFIG_BASE64=y
    
    # Step 1.1 - Enable QSPI driver for Application
    CONFIG_NORDIC_QSPI_NOR=y
    #
    CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    # CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME_DYNAMIC=y
    CONFIG_BT_SETTINGS=y
    CONFIG_BT_DEVICE_NAME_MAX=48
    # Step 2.2 - Enable FOTA over Bluetooth LE
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
    
    CONFIG_LOG=y
    
    CONFIG_SPI=y
    
    # CONFIG_MAIN_STACK_SIZE=4096
    
    CONFIG_LOG=y
    CONFIG_LOG_MODE_MINIMAL=y
    CONFIG_FPU=y
    CONFIG_CBPRINTF_FP_SUPPORT=y
    
    CONFIG_FILE_SYSTEM_MKFS=y
    CONFIG_FILE_SYSTEM=y
    CONFIG_FILE_SYSTEM_LITTLEFS=y
    
    CONFIG_BT_CENTRAL=y
    CONFIG_BT_SCAN=y
    CONFIG_BT_GATT_CLIENT=y
    CONFIG_BT_GATT_DM=y
    CONFIG_FS_LITTLEFS_NUM_FILES=10
    CONFIG_FS_LITTLEFS_NUM_DIRS=1
    CONFIG_FS_LITTLEFS_FMP_DEV=y
    
    CONFIG_FLASH_JESD216_API=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL=y
    CONFIG_PM_PARTITION_SIZE_LITTLEFS=0x70c000
    
    # CONFIG_UART_INTERRUPT_DRIVEN=y
    
    CONFIG_DK_LIBRARY=y
    
    CONFIG_BT_DEVICE_APPEARANCE=832
    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_MAX_PAIRED=1
    
    CONFIG_BT_SMP=y
    CONFIG_BT_EXT_ADV=y
    
    # Enable nRFx TWIS (I2C Slave)
    CONFIG_I2C=y
    CONFIG_I2C_TARGET=y
    # NCS 3.2.0 (nrfx 4.0) migration: per-instance CONFIG_NRFX_TWIS3 was consolidated into the
    # single CONFIG_NRFX_TWIS option; the concrete instance (TWIS3 / i2c3) is still selected via
    # the "nordic,nrf-twis" devicetree node (see boards/nrf5340dk_nrf5340_cpuapp.overlay).
    CONFIG_NRFX_TWIS=y
    CONFIG_I2C_NRFX=y
    
    CONFIG_NVS=y
    CONFIG_SETTINGS_NVS=y
    # CONFIG_BT_BUF_ACL_TX_COUNT=10
    # CONFIG_BT_BUF_ACL_RX_COUNT=10
    # CONFIG_BT_L2CAP_TX_BUF_COUNT=10
    CONFIG_BT_L2CAP_TX_MTU=247
    
    # ----------------------
    # Antenna Board selection
    # ----------------------
    # Gateway Antenna B10
    CONFIG_ANT_B10=y
    # Node Antenna B11
    CONFIG_ANT_B11=n
    
    # Set to y for gateway hardware version 3.1
    CONFIG_GATEWAY_HW_V2=n
    CONFIG_BT_DEVICE_NAME="Gateway"
    
    # ----------------------
    # General Configurations
    # ----------------------
    CONFIG_ASSERT=y
    CONFIG_HW_STACK_PROTECTION=y # Hardware stack protection to detect overflows earlier
    CONFIG_NEWLIB_LIBC=y # To make visible math.h
    
    
    # ----------------------
    # Debug Logger configuration
    # ----------------------
    
    # Enable this when tracking using python script.
    # CONFIG_LOG_OVERRIDE_LEVEL=1
    
    CONFIG_LOG=y                     # Enable Zephyr logging subsystem
    CONFIG_SERIAL=y                  # Enable serial driver
    CONFIG_CONSOLE=y                 # Enable console output
    
    # Enable this for UART logging, Disable the RTT
    CONFIG_UART_CONSOLE=y            # Disable UART console (we are using ACM)
    # CONFIG_STDOUT_CONSOLE=n          # Send the printf to console
    
    # CONFIG_FPU=y                     # Enable floating point unit
    # CONFIG_CBPRINTF_FP_SUPPORT=y     # Enable floating-point support for logging
    
    CONFIG_LOG_BUFFER_SIZE=8196
    # CONFIG_LOG_MODE_MINIMAL=y      # Disable Full log mode with timestamps and module inf
    CONFIG_LOG_MODE_DEFERRED=y       # Logs are processed in seperate thread from ring buffer.
    CONFIG_LOG_DEFAULT_LEVEL=2
    
    #
    # ------- Configuration For High Speed Logging --------->
    #
    
    # JLinkExe -if SWD -device nrf5340 -speed 8000 -autoconnect 1 --> Terminal 1
    # JLinkRTTClient --> Terminal 2
    
    # Use SEGGER RTT as backend
    # CONFIG_USE_SEGGER_RTT=y
    # CONFIG_LOG_BACKEND_RTT=y
    
    # High Speed Configurations
    # CONFIG_LOG_BACKEND_RTT_MODE_DROP=y
    # CONFIG_LOG_BACKEND_RTT_MODE_BLOCK=n
    # CONFIG_LOG_BACKEND_RTT_MODE_OVERWRITE=n
    
    # Target -> host buffer
    # CONFIG_SEGGER_RTT_BUFFER_SIZE_DOWN=8192
    # Host -> target buffer
    # CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=8192
    
    # Max log message size, Valid for Drop Mode
    # CONFIG_LOG_BACKEND_RTT_MESSAGE_SIZE=256
    
    # Logger up-buffer
    # CONFIG_LOG_BACKEND_RTT_BUFFER=1
    # CONFIG_LOG_BACKEND_RTT_BUFFER_SIZE=8192
    
    # Retry settings, Valid for Block Mode
    # CONFIG_LOG_BACKEND_RTT_RETRY_CNT=10
    # CONFIG_LOG_BACKEND_RTT_RETRY_DELAY_MS=10
    # Message formatting buffer
    # CONFIG_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE=512
    
    
    # -------------------------------
    # Ant-b1x configuration
    # ------------------------------
    CONFIG_UART_INTERRUPT_DRIVEN=y
    # NCS 3.2.0 (nrfx 4.0) migration: per-instance CONFIG_NRFX_UARTE1 was consolidated into the
    # single CONFIG_NRFX_UARTE option; the concrete instance (UARTE1) is still selected via the
    # uart1 devicetree node status = "okay" (see boards/*.overlay).
    CONFIG_NRFX_UARTE=y
    # CONFIG_TFM_LOG_LEVEL_SILENCE=y # CRITICAL : Disable TFM logs on UART1, Don't enable this.
    
    # ---- UART DMA configurations ------------
    CONFIG_UART_ASYNC_API=y # Enable for DMA
    CONFIG_UART_1_ASYNC=y # Enable DMA support for UART1
    CONFIG_UART_1_INTERRUPT_DRIVEN=n # Disable interrupt to use DMA
    CONFIG_RING_BUFFER=y
    
    CONFIG_HEAP_MEM_POOL_SIZE=35840
    
    # -------------------------------
    # STACK size configurations
    # -------------------------------
    CONFIG_MAIN_STACK_SIZE=8196
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
    
    CONFIG_MCUMGR_MGMT_NOTIFICATION_HOOKS=y
    CONFIG_MCUMGR_GRP_IMG_STATUS_HOOKS=y
    CONFIG_MCUMGR_GRP_IMG_UPLOAD_CHECK_HOOK=y
    
    CONFIG_WATCHDOG=y
    CONFIG_STREAM_FLASH=y
    CONFIG_STREAM_FLASH_ERASE=y
    CONFIG_DFU_TARGET=y
    CONFIG_DFU_TARGET_STREAM=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_DFU_TARGET_MODEM_DELTA=n
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    # -------------------------------
    # ANT-B10 firmware update (SMP/mcumgr serial client, module/smp_dfu.c)
    # -------------------------------
    # No new Kconfig options required: this feature relays/uploads the ANT-B10 image using a
    # self-contained base64/CRC16/CBOR implementation (does not use CONFIG_ZCBOR / CONFIG_BASE64,
    # which stay enabled above only for the existing BT MCUmgr DFU and Nordic self-update paths).
    # It reuses the already-enabled CONFIG_FILE_SYSTEM_LITTLEFS (image staging) and the existing
    # UART1/ANT-B10 driver config above (CONFIG_NRFX_UARTE, CONFIG_UART_ASYNC_API, etc.).
    #
    # Standalone ANT-B10 DFU POC (module/antb10_dfu_poc.c, embedded-buffer test): disabled by
    # default. To enable, uncomment the line below and rebuild:
    #CONFIG_ANTB10_DFU_POC=y
    



    And using ncs version 3.3.0 and tool chain version 3.3.0 but still facing the same issue.

  • Hi,

    The issue I was refering to was fixed SDK 3.1.0, and the fix is part of 3.3.0. If you see this with 3.3.0 as well, it points to potentially another issue.

    Some quesions in order to understand more:

    • How long does it typically take before advertising reports stop?
    • Are there any factors you have seen that affect it?
    • Do you have logging in both the application core and network core? Can you share the logs?
    • What else happens when advertising reports stop? Could it be a problem with the network core? It could be interesting to see if eanbling the network core monitor makes a difference.
  • Thanks for your quick reply,
    I will try to answer your all the questions,

    Q. How long does it typically take before advertising reports stop?
    -> It took almost 5-6 hours, and coded phy data stop coming in scanning call back,

    Q. Are there any factors you have seen that affect it?
    -> As i mentioned earlier that we are restart bluetooth scanning every 5 minutes and our scanning options is same ".options = CONFIG_BT_LE_SCAN_OPT" but still not receiving any data.

    Q. Do you have logging in both the application core and network core? Can you share the logs?
    -> Currently we are building with board target nrf5340dk/nrf5340/cpuapp and we don't have any network core log, but in application core we added the logs when bluetooth data received with 

    info->primary_phy as below
    case BT_GAP_LE_PHY_CODED:
    case BT_GAP_LE_PHY_CODED_S2:
    case BT_GAP_LE_PHY_CODED_S8:
    LOG_WRN("Received Coded Phy tag:%d", info->primary_phy);

    but not getting this log as well

    Q. What else happens when advertising reports stop? Could it be a problem with the network core? It could be interesting to see if eanbling the network core monitor makes a difference.
    -> Let me enable this configuration for more details,

    one more thing i want to share that we are scanning for bluetooth beacon and we are not connecting with that just scanning data, even they are advertising we not able to receive it on this callback.
Reply
  • Thanks for your quick reply,
    I will try to answer your all the questions,

    Q. How long does it typically take before advertising reports stop?
    -> It took almost 5-6 hours, and coded phy data stop coming in scanning call back,

    Q. Are there any factors you have seen that affect it?
    -> As i mentioned earlier that we are restart bluetooth scanning every 5 minutes and our scanning options is same ".options = CONFIG_BT_LE_SCAN_OPT" but still not receiving any data.

    Q. Do you have logging in both the application core and network core? Can you share the logs?
    -> Currently we are building with board target nrf5340dk/nrf5340/cpuapp and we don't have any network core log, but in application core we added the logs when bluetooth data received with 

    info->primary_phy as below
    case BT_GAP_LE_PHY_CODED:
    case BT_GAP_LE_PHY_CODED_S2:
    case BT_GAP_LE_PHY_CODED_S8:
    LOG_WRN("Received Coded Phy tag:%d", info->primary_phy);

    but not getting this log as well

    Q. What else happens when advertising reports stop? Could it be a problem with the network core? It could be interesting to see if eanbling the network core monitor makes a difference.
    -> Let me enable this configuration for more details,

    one more thing i want to share that we are scanning for bluetooth beacon and we are not connecting with that just scanning data, even they are advertising we not able to receive it on this callback.
Children
No Data
Related