No device found with bt_le_scan_start and observer

Dear,

I am using nRF5340 and I am trying to scan devices around me. With the example observer my device founds other devices around me, but when I use the same configuration and the same functions into my project the device doesn't find anything. The code is the same, exactly the same but I can't see anything.

The prj.conf is

#Peripherals
CONFIG_GPIO=y
CONFIG_SPI=y

CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

CONFIG_PRINTK=y


# Bootloader
CONFIG_BOOTLOADER_MCUBOOT=y

# Bluetooth configuration
CONFIG_BT=y
#CONFIG_BT_PERIPHERAL=y
#CONFIG_BT_DEVICE_NAME="Test"
#CONFIG_BT_DEBUG_LOG=y
#CONFIG_BT_CENTRAL=y
#CONFIG_BT_SCAN=y
CONFIG_BT_OBSERVER=y

# Other 
CONFIG_MAIN_STACK_SIZE=2048

CONFIG_LOG=y

And the code is:

#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/hci.h>


#if (APP_DEBUG_ON == 1)
#include <zephyr/sys/printk.h>
#endif

#define DEVICE_NAME CONFIG_BT_DEVICE_NAME
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)

static void deviceFound (const bt_addr_le_t *addr, 
                         int8_t rssi, 
                         uint8_t type,
                         struct net_buf_simple *buf)
{
    char dev[BT_ADDR_LE_STR_LEN];

    // if (type == BT_GAP_ADV_TYPE_ADV_SCAN_IND)
    // {
        bt_addr_le_to_str(addr, dev, sizeof(dev));
        printk("[DEVICE]: %s, AD evt type %u, AD data len %u, RSSI %i\n",dev, type, buf->len, rssi);
    // }


}

void Bluetooth_init (void)
{
    int err = 0;

    err = bt_enable(NULL);
    if (err) 
    {
#if (APP_DEBUG_ON == 1)
        printk("ERROR: Bluetooth init failed (err %d)\n", err);
#endif
        goto bluetooth_init_error;
    }

#if (APP_DEBUG_ON == 1)
    printk("BLUETOOTH0: Bluetooth initialized\n");
#endif

	struct bt_le_scan_param scanParam = 
    {
        .type       = BT_LE_SCAN_TYPE_PASSIVE,
        .options    = BT_LE_SCAN_OPT_FILTER_DUPLICATE,
        .interval   = BT_GAP_SCAN_FAST_INTERVAL,
        .window     = BT_GAP_SCAN_FAST_WINDOW,
    };

    err = bt_le_scan_start(&scanParam, deviceFound);
    if (err) 
    {
#if (APP_DEBUG_ON == 1)
        printk("ERROR: Scanning failed to start (err %d)\n", err);
#endif
        goto bluetooth_init_error;
    }
#if (APP_DEBUG_ON == 1)
    printk("BLUETOOTH0: Scanning successfully started\n");
#endif

bluetooth_init_error:
    if (err)
    {
        // TODO
    }
}

The output log is:

BLUETOOTH0: Bluetooth initialized
BLUETOOTH0: Scanning successfully started

Where is it the error? Haw can I debug this issue?

Thanks

Marco

Parents
  • Hi again Marco

    I mean in what path in your computer is your project located, for example the peripheral_UART and most other BLE sample projects are located in ...ncs\v2.1.2\nrf\samples\bluetooth\

    One of my colleagues pointed out what the issue likely is here. You might not have set up the network core correctly. Since the nRF5340 has two cores, and the network core will need to be flashed with the Bluetooth controller image. Information on how to do this is explained in the nRF5340 user guide, more specifically under "multi-image builds".

    Best regards,

    Simon

Reply
  • Hi again Marco

    I mean in what path in your computer is your project located, for example the peripheral_UART and most other BLE sample projects are located in ...ncs\v2.1.2\nrf\samples\bluetooth\

    One of my colleagues pointed out what the issue likely is here. You might not have set up the network core correctly. Since the nRF5340 has two cores, and the network core will need to be flashed with the Bluetooth controller image. Information on how to do this is explained in the nRF5340 user guide, more specifically under "multi-image builds".

    Best regards,

    Simon

Children
Related