mesh nodes: concurrent advertising and scanning

We are developing a project where we have a BLE Mesh netrwork where each node is implementing generic ON OFF client and server, a specific vendor model (derived from the Nordic's Chat example), and DFU target.

After some hard work, everything is working as expected using the latest nRFConnect SDK (2.5.0).

Next phase in our project is to be able to do "observing"  and "beaconing" while not disturbing the mesh stack.

We know that we have to be careful and not to use these functions heavily to avoid disturbing the mesh stack itself, anyway we lack any code example to start with.

I discovered by browsing around and with some trial and error that after node initialization, I can register a callback for every adv packet received using:

bt_le_scan_cb_register(&scan_callbacks);

This way implementing the scan_callbacks we are "observing", and it apparently works! BUT: is this the correct approach inside a Mesh node project?

Then, to try something regarding the beaconing function I tried:

	err = bt_le_adv_start(BT_LE_ADV_NCONN_IDENTITY, ad, ARRAY_SIZE(ad),
			      sd, ARRAY_SIZE(sd));
	if (err) {
		printk("Advertising failed to start (err %d)\n", err);
		return;
	}

But it does not work returning "Advertising failed to start (err -12)"

Please do note that we know the mesh node is already advertising with a "normal" ble peripheral message (before being provisioned) and also is advertisig using "mesh Beacon", but what we need is the ability to add a different beacon packet, it will have a specific payload related to our application.

Can you provide a complete reference example of a BLE Mesh node that give the developer to run a custom becaon and a custom observer?

I found some mention to such an application inside the obsolete nRF5.0.0 Mesh documentation here but it is of no help.

Related