This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to enable LE_CODED in NCS1.8.0 periodic_adv ?

Hello,

NCS1.8.0 Windows10 X64,

periodic_adv had set BT_LE_ADV_OPT_CODED   and   BT_GAP_ADV_FAST_INT_MIN_2 /* 100 ms   */

periodic_sync scan info "Prim: LE 1M, Secn: LE Coded, Interval: 0x03c0 (1200 ms)"

question:

1. why it still  Prim: LE 1M?

2. why the Interval is 1200ms?

thanks 

Best regards,

yuyou

  • Hi

    Can you upload the serial log in its entirety so we can see where this information comes from. If it's from a connection parameter update, it might be that one of the devices in the connection does not support Coded PHY for example. Just to make sure, what device are you testing this project on, and what device are you using to scan (and possibly connect to)? 

    To see how the application should be configured to use the Coded PHY, you can check out the Bluetooth: Peripheral Heart Rate Monitor with Coded PHY sample in the nRFConnect SDK. I was not able to spot anything obvious missing, but you might have missed some configuration so it's worth taking a look at our sample I think.

    Best regards,

    Simon

  • Hello,Simonr

    thanks for your reply,

    i using two 52840DK, serial  log as follow:

    [DEVICE]: 2D:F2:98:1B:DB:1E (random), AD evt type 5, Tx Pwr: 0, RSSI -20 PerAdv C:0 S:0 D:0 SR:0 E:1 Prim: LE 1M, Secn: LE Coded, Interval: 0x03c0 (1200 ms), SID: 0
    Found periodic advertising.
    Creating Periodic Advertising Sync...success.
    Waiting for periodic sync...
    PER_ADV_SYNC[0]: [DEVICE]: 2D:F2:98:1B:DB:1E (random) synced, Interval 0x03c0 (1200 ms), PHY LE Coded
    PER_ADV_SYNC[0]: [DEVICE]: 2D:F2:98:1B:DB:1E (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000001000000000000
    Periodic sync established.
    Stop blinking LED.
    Waiting for periodic sync lost...
    PER_ADV_SYNC[0]: [DEVICE]: 2D:F2:98:1B:DB:1E (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000002000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 2D:F2:98:1B:DB:1E (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000003000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 2D:F2:98:1B:DB:1E (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000004000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 2D:F2:98:1B:DB:1E (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000005000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 2D:F2:98:1B:DB:1E (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000007000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 2D:F2:98:1B:DB:1E (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000008000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 2D:F2:98:1B:DB:1E (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000009000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 2D:F2:98:1B:DB:1E (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff00000a000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 2D:F2:98:1B:DB:1E (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff00000b000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 2D:F2:98:1B:DB:1E (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff00000d000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 2D:F2:98:1B:DB:1E (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff00000e000000000000
    

    Best regards,

    yuyou

  • Hi

    What is your bt_le_per_adv_set_param() function setting the periodic advertising parameters as?

    Best regards,

    Simon

  • Hello,

    thanks for your reply.

    i'v know why the Interval is 1200ms.

    Prim: LE 1M, Secn: LE Coded, Interval: 0x0018 (30 ms),

    but  it still  Prim: LE 1M.    codes as follow:

    /*
     * Copyright (c) 2020 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <bluetooth/bluetooth.h>
    #include "common/log.h"
    
    static uint8_t mfg_data[9] = { 0xff, 0xff, 0x00 };
    static struct bt_le_ext_adv_cb cb;//call back
    
    static const struct bt_data ad[] = {
    	BT_DATA(BT_DATA_MANUFACTURER_DATA, mfg_data, 9 ),
    };
    
    void sent(struct bt_le_ext_adv *adv, struct bt_le_ext_adv_sent_info *info)
    {
            printk("Sent Data...");
            mfg_data[2]++;
            int err = bt_le_per_adv_set_data(adv, ad, ARRAY_SIZE(ad));
            if (err) {
                  printk("Failed (err %d)\n", err);
                  return;
            }
    }
    
    void main(void)
    {
    	struct bt_le_ext_adv *adv;
        cb.sent=sent;//call back
    	int err;
    
    	printk("Starting Periodic Advertising Demo\n");
    
    	/* Initialize the Bluetooth Subsystem */
    	err = bt_enable(NULL);
    	if (err) {
    		printk("Bluetooth init failed (err %d)\n", err);
    		return;
    	}
     
            /** Non-connectable extended advertising with @ref BT_LE_ADV_OPT_USE_NAME BT_LE_ADV_OPT_CODED */
           #define BT_LE_EXT_ADV_NCONN_NAME_CODED  BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | \
    						 BT_LE_ADV_OPT_USE_NAME | BT_LE_ADV_OPT_USE_TX_POWER | \
                                                     BT_LE_ADV_OPT_CODED, \
    						 BT_GAP_ADV_FAST_INT_MIN_2, \
    						 BT_GAP_ADV_FAST_INT_MAX_2, \
    						 0)   //Peer address, set to NULL for undirected advertising
    	/* Create a non-connectable non-scannable unDIRECTED advertising set */
    	err = bt_le_ext_adv_create(BT_LE_EXT_ADV_NCONN_NAME_CODED, &cb, &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, \
    						  BT_LE_PER_ADV_OPT_NONE)
    	/* Set periodic advertising parameters */
    	err = bt_le_per_adv_set_param(adv, BT_LE_PER_ADV_P);
    	if (err) {
    		printk("Failed to set periodic advertising parameters"
    		       " (err %d)\n", err);
    		return;
    	}
    
    	/* Enable Periodic Advertising */
    	err = bt_le_per_adv_start(adv);
    	if (err) {
    		printk("Failed to enable periodic advertising (err %d)\n", err);
    		return;
    	}
    
    	/* 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;
    	}
    
        for(int i=0;i<sizeof(mfg_data);i++){mfg_data[i]=0;}
    	while (true) {
    		k_sleep(K_SECONDS(1));
    
    		mfg_data[2]++;
    
    		printk("Set Periodic Advertising Data...");
    		err = bt_le_per_adv_set_data(adv, ad, ARRAY_SIZE(ad));
    		if (err) {
    			printk("Failed (err %d)\n", err);
    			return;
    		}
    		printk("done.\n");
    	}
    }
    

    Best regards,

    yuyou

  • Hi

    You also need to add the CONFIG_BT_CTLR_PHY_CODED=y to add Coded PHY support in prj.conf. You can also add CONFIG_BT_USER_PHY_UPDATE=y here although I don't think it's necessary.

    Best regards,

    Simon

Related