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

Parents Reply Children
  • Hello,

    i add bt_le_ext_adv_set_data at line 74,

    but the periodic_sync  log show the same;

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

      

    periodic_adv source code and serial log,

    /*
     * 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 ),
    };
    static const struct bt_data sd[] = {
    	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...");
    }
    void connected(struct bt_le_ext_adv *adv, struct bt_le_ext_adv_connected_info *info)
    {
          printk("connected...");
    }
    void scanned(struct bt_le_ext_adv *adv, struct bt_le_ext_adv_scanned_info *info)
    {
          printk("scanned...");
    }
    
    void main(void)
    {
    	struct bt_le_ext_adv *adv;
            cb.sent=sent;//call back
            cb.connected=connected;//call back
            cb.scanned=scanned;//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_1, \
    						 BT_GAP_ADV_FAST_INT_MAX_1, \
    						 NULL)   //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_USE_TX_POWER)
    	/* Set periodic advertising parameters */
    	err = bt_le_per_adv_set_param(adv,BT_LE_PER_ADV_DEFAULT);
    	if (err) {
    		printk("Failed to set periodic advertising parameters"
    		       " (err %d)\n", err);
    		return;
    	}
            err = bt_le_ext_adv_set_data(adv,ad, ARRAY_SIZE(ad),sd, ARRAY_SIZE(sd) );
    
    	/* 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");
    	}
    }
    

     *** Booting Zephyr OS build v2.7.0-ncs1  ***
    Starting Periodic Advertising Demo
    [00:00:00.262,756] <inf> bt_hci_coreSet Periodic Advertising Data...done.
    : HW Platform: Nordic Semiconductor (0x0002)
    [00:00:00.262,756] <inf> bt_hci_core: HW Variant: nRF52x (0x0002)
    [00:00:00.262,786] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 2.7 Build 0
    [00:00:00.263,366] <inf> bt_hci_core: Identity: F7:42:24:3A:91:18 (random)
    [00:00:00.263,366] <inf> bt_hci_core: HCI: version 5.3 (0x0c) revision 0x0000, manufacturer 0x05f1
    [00:00:00.263,366] <inf> bt_hci_core: LMP: version 5.3 (0x0c) subver 0xffff
    Set Periodic Advertising Data...done.
    Set Periodic Advertising Data...done.
    Set Periodic Advertising Data...done.
    Set Periodic Advertising Data...done.
    Set Periodic Advertising Data...done.

      

    periodic_sync  serial log

    [DEVICE]: 0D:7E:90:95:48:AB (random), AD evt type 5, Tx Pwr: 0, RSSI -25 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]: 0D:7E:90:95:48:AB (random) synced, Interval 0x03c0 (1200 ms), PHY LE Coded
    PER_ADV_SYNC[0]: [DEVICE]: 0D:7E:90:95:48:AB (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]: 0D:7E:90:95:48:AB (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000002000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 0D:7E:90:95:48:AB (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000003000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 0D:7E:90:95:48:AB (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000005000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 0D:7E:90:95:48:AB (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000007000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 0D:7E:90:95:48:AB (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000008000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 0D:7E:90:95:48:AB (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff000009000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 0D:7E:90:95:48:AB (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff00000a000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 0D:7E:90:95:48:AB (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff00000b000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 0D:7E:90:95:48:AB (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff00000d000000000000
    PER_ADV_SYNC[0]: [DEVICE]: 0D:7E:90:95:48:AB (random), tx_power 127, RSSI -127, CTE 0, data length 11, data: 0aff00000e000000000000
    

       

    Best regards,

    yuyou

  • Check the error status when using bt_le_ext_adv_set_data 

  • The reason I'm asking is that I have an error which I didn't have prior to SDK V1.8 which causes the advert to fail.

  • Hello,

    thanks for reply,

    i've add check the err code ,but not getting error, it's running.

    Best regards,

    yuyou

Related