NCS2.0.x periodic_adv, PHY CODED lost data

Hello,

nRF5340, NCS2.0.2, vscode.

\v2.0.2\zephyr\samples\bluetooth\periodic_adv

when TX and RX work on PHY_1M,  two side work well.

but when TX side set  BT_LE_ADV_OPT_CODED and RX side set BT_LE_SCAN_OPT_CODED,  RX side frequent data loss. 

the frist data byte for Serial number (like 0 1 2 3 4....),

interval 100ms  bt_le_per_adv_set_data(), RX side will loss some Serial number data.

how config it?

TX side demo code as follow,

RX code is default project periodic_sync (only set  bt_le_scan_start()BT_LE_SCAN_OPT_CODED, and printk recv data)

#include <bluetooth/bluetooth.h>
#if defined (NRF5340_XXAA_APPLICATION)
  #define CLOCK_FEATURE_HFCLK_DIVIDE_PRESENT
  #include "nrfx_clock.h"
#endif
#include <devicetree.h>
#include <device.h>
#include <drivers/gpio.h>
#include <hal/nrf_gpio.h>
#include <hal/nrf_gpiote.h>
#include <nrfx_gpiote.h>
#include <sys/reboot.h>

void main(void)
{
	uint8_t mfg_data[25] = {0, 'a','b','c','d','e','f','g'};
	const struct bt_data ad[] = {
		BT_DATA(BT_DATA_MANUFACTURER_DATA, mfg_data, sizeof(mfg_data)),
	};

	struct bt_le_ext_adv *adv=NULL;
	#if defined (NRF5340_XXAA_APPLICATION)
	nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1);//128MHz
	#endif

		#define BT_LE_EXT_ADV_NCONN_NAME_USER  \
	   			BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CODED | \
						BT_LE_ADV_OPT_USE_NAME, \
						BT_GAP_ADV_FAST_INT_MIN_1, \
						BT_GAP_ADV_FAST_INT_MAX_1, \
						NULL)
	// Create a non-connectable non-scannable unDIRECTED advertising set
	int err = bt_le_ext_adv_create(BT_LE_EXT_ADV_NCONN_NAME_USER, NULL, &adv);
	if (err) {
		printk("Failed to create advertising set (err %d)\n", err);
		return;
	}

        #define BT_LE_PER_ADV_P   BT_LE_PER_ADV_PARAM(BT_GAP_PER_ADV_FAST_INT_MIN_1, \
						BT_GAP_PER_ADV_FAST_INT_MIN_1, \
						0)
	// Set periodic advertising parameters   
	err = bt_le_per_adv_set_param(adv, BT_LE_PER_ADV_P);
	if (err) {
		printk("Failed to set advertising parameters (err %d)\n", err);
		return;
	}

	// Enable Periodic Advertising
	err = bt_le_per_adv_start(adv);
	if (err) {
		printk("Failed to enable advertising (err %d)\n", err);
		return;
	}

	printk("Start Extended Advertising...");
	err = bt_le_ext_adv_start(adv, BT_LE_EXT_ADV_START_DEFAULT);
	if (err) {
		printk("Failed to start extended advertising (err %d)\n", err);
		return;
	}
	printk("done.\n");

	while (true) 
	{	
		k_msleep(100);

		mfg_data[0]++;// The first byte acts as a sequence number, increment it for every data update
		err = bt_le_per_adv_set_data(adv, ad, ARRAY_SIZE(ad));
		if (err) {
			printk("Failed (err %d)\n", err);
			break;
		}
	}

}

   

Best regards

Parents Reply
  • Hi,

    Haven't you read the code so far?

    What kind of interval is it that you set to 20 ms or 100 ms and how do you do it in the code?

      

    How far apart are your boards during testing with and without coded phy?

    Distance: 10 cm   Always

        

    When do you start seeing packet loss, in which circumstances and at what distance?

    It appeared at the beginning and has been appearing all the time. The distance is 10cm Always

       

    Can you test it yourself

Children
Related