Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

How to connect with direct advertising?

I am implementing a central device using the nRF Connect SDK. I want to connect to a peripheral device using direct advertising, but the central device does not seem to recognize the direct advertising. How can I connect to a device using direct advertising?

In the nRF SDK, when receiving direct advertising, there was an event called "White list report", but there is no corresponding callback in the nRF Connect SDK. The source code is as follows, and I have looked at various sample projects for central devices, but they all seem to be similar.

static void scan_init(void)
{
	int err;

	const struct bt_le_scan_param scan_param = {
		.interval = SCAN_INTERVAL,      // 100msec
		.interval_coded = 0,
		.options = BT_LE_SCAN_OPT_FILTER_ACCEPT_LIST | BT_LE_SCAN_OPT_FILTER_DUPLICATE,
		.timeout = 0,
		.type = BT_HCI_LE_SCAN_PASSIVE,
		.window = SCAN_WINDOW,          // 50msec
		.window_coded = 0,
	};

	struct bt_scan_init_param scan_init = {
		.connect_if_match = false,
		.conn_param = BT_LE_CONN_PARAM_DEFAULT,
		.scan_param = &scan_param,
	};

	bt_scan_init(&scan_init);
	bt_scan_cb_register(&scan_cb);

	err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_UUID, BT_UUID_BAS);
	if (err) {
		LOG_ERR("Scanning filters cannot be set (err %d)", err);
		return;
	}

	err = bt_scan_filter_enable(BT_SCAN_UUID_FILTER, false);
	if (err) {
		LOG_ERR("Filters cannot be turned on (err %d)", err);
	}
}

Parents Reply
  • I would like the Nordic member to respond this question if possible, unfortunately that is not possible. This is because you cannot create the private key to exchange for bonding.
    If you could do that, it would be easy to hack the system.
    I think the direct advertising is not suitable for your desired connection.
    I don't know what you use for the central device, but I recommend you would use connecting a peripheral as a HID device instead of directed advertising.

Children
Related