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,

    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

Related