Difference between bt_scan_start and bt_le_scan_start?

I'm working with the observer example, and in trying to make modifications to it I have looked at a couple of other projects, both online and from another product under development here, and in those projects I see bt_scan_start and bt_scan_init, etc. This is consistent with what I see in online documentation, too - for example, on this page:

developer.nordicsemi.com/.../scan.html

However, in the observer example, I see it uses bt_le_scan_start, and other references that all start with "bt_le_"

It seems like these two are not interchangeable and I've spent some time spinning my wheels experimenting and trying to figure out what works and what doesn't, but I think it's better if I just ask:

What is the difference between the two, and what factors should be considered when deciding which is better to use? It seems like the former is better documented online - or maybe I'm just looking in the wrong places?

Scott

  • Hi Scott, 

    If you have a look at \nrf\subsys\bluetooth\scan.c you can see the source code of ble_scan_start()

    int bt_scan_start(enum bt_scan_type scan_type)
    {
    	switch (scan_type) {
    	case BT_SCAN_TYPE_SCAN_ACTIVE:
    		bt_scan.scan_param.type = BT_LE_SCAN_TYPE_ACTIVE;
    		break;
    
    	case BT_SCAN_TYPE_SCAN_PASSIVE:
    		bt_scan.scan_param.type = BT_LE_SCAN_TYPE_PASSIVE;
    		break;
    
    	default:
    		return -EINVAL;
    	}
    
    	/* Start the scanning. */
    	int err = bt_le_scan_start(&bt_scan.scan_param, NULL);
    
    	if (!err) {
    		LOG_DBG("Scanning");
    	}
    
    	return err;
    }

    The \nrf\subsys\bluetooth\scan.c  is just an Nordic's abstract layer on top of the base scan.c in Zephyr's host layer inside. \zephyr\subsys\bluetooth\host . This is provided to simplify the API you need to call to do BLE. 

    If you want you can use the bt_le_scan_start() directly and provide the scan parameters directly in the function. You can see that in Zephyr's sample they use the default bt_le API. 

    There is no difference regarding BLE functionality between the two, it's just more simple to use the ble_scan_start abstract layer. If you want more advanced feature, for example scan callback , then you would need to use the bt_le_scan_start(). 

Related