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

Unconnectable directed advertising with scan request callback and high duty cycle

Hi

I am working with a central_and_peripheral_hr sample (nRF Connect SDK v1.8.0)  and I want to get unconnectable directed advertising with scan request callback and high duty cycle.

These are the main steps I have followed so far:

1. If I want to get a scanned callback after a scan request it is required to use extended advertising (CONFIG_BT_EXT_ADV=y added to prj.conf). The following code is added to get scanned responses.

static void scanned(struct bt_le_ext_adv *adv,
                    struct bt_le_ext_adv_scanned_info *info){

   char addr[BT_ADDR_LE_STR_LEN];

   bt_addr_le_to_str(info->addr, addr, sizeof(addr));

   //if (info->addr->a.val[5] == 193)
                        
      printk("Scanned addr:%s\n", addr);
}


static struct bt_le_ext_adv_cb adv_callbacks = {
        .sent = NULL,
	.connected = NULL,
        .scanned = scanned
 };

            
            err = bt_le_ext_adv_create(&param, &adv_callbacks, &adv);
            if (err) {
                    printk("Failed to create advertiser set (%d)\n", err);
                    return;
            }

            printk("Created adv: %p\n", adv);

            err = bt_le_ext_adv_set_data(adv, ad, ARRAY_SIZE(ad),
                                              sd, ARRAY_SIZE(sd));
            if (err) {
                    printk("Failed to set advertising data (%d)\n", err);
                    return;
            }

            printk("Adv data set: %p\n", adv);

            err = bt_le_ext_adv_start(adv, NULL);
            if (err) {
                    printk("Failed to start advertising set (%d)\n", err);
                    return;
            }

            printk("Advertiser %p set started\n", adv);

2. Then, the adv params are modified to include a peer target device:

static bt_addr_le_t beacon_peer;

const static struct bt_le_adv_param param =
		BT_LE_ADV_PARAM_INIT( BT_LE_ADV_OPT_EXT_ADV |
                                      BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY |
                                      BT_LE_ADV_OPT_FILTER_SCAN_REQ |
                                      BT_LE_ADV_OPT_NOTIFY_SCAN_REQ |
                                      BT_LE_ADV_OPT_SCANNABLE,
                                      BT_GAP_ADV_INT_MIN, \
                                      BT_GAP_ADV_INT_MAX, &beacon_peer);

3. My problem now  is that it is required to include BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY as an option or an error will be triggered when starting to advertise. Please check adv.c valid_adv_ext_param function in line 237.

if (param->peer &&
		    !(param->options & BT_LE_ADV_OPT_EXT_ADV) &&
		    !(param->options & BT_LE_ADV_OPT_CONNECTABLE)) {
			/* Cannot do directed non-connectable advertising
			 * without extended advertising.
			 */
			return false;
		}

		if (param->peer &&
		    (param->options & BT_LE_ADV_OPT_EXT_ADV) &&
		    !(param->options & BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY)) {
			/* High duty cycle directed connectable advertising
			 * shall not be used with Extended Advertising.
			 */
			return false;
		}

Thus my questions

1. What are the implications of enabling BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY option?

2. Is there a way to perform an unconnectable directed advertising without enabling BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY option?

Many thanks

Parents
  • Hi Armand, 

    I assume this case is the same case as case #281865 and you just want to make it as a public case.

    Regarding your question, as you can find in the valid_adv_ext_param () code , directed advertising with high duty cycle (the default option) is not supported by extended advertising. 

    When you do scannable directed advertising, should be configured as extended advertising and low duty cycle. 
    You can consider removing BT_LE_ADV_OPT_EXT_ADV, but then it won't support scannable directed as I explained in the other case. 

  • What are the implications of enabling BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY option?

    Thanks

  • Hi again, 

    BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY  is to be used in either: 

    - Normal directed advertising with low duty cycle (this is non-scannable)

    - Extended advertising directed with low duty cycle (this can be configured as scannable directed) 

Reply
  • Hi again, 

    BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY  is to be used in either: 

    - Normal directed advertising with low duty cycle (this is non-scannable)

    - Extended advertising directed with low duty cycle (this can be configured as scannable directed) 

Children
No Data
Related