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

Directed Advertising not seen by the addressed device

Hi,

I am testing direct advertising with two nRF52-DK. One performs a direct advertising and the other scans for the directed adverts. Unfortunately, the scanning device cannot see the directed advertising packages.

For simplicty and to reduce variables, I have set a test where I use the below code on a nRF52 dk (nRF52832) and the BLE tool on the nRF Connect SDK for Desktop (using a nRF52840-donge). I have hardcoded the dongle address on the directed advertiser code. Unfortunately, I still cannot see the directed advertising packages. Why is that? Any help most welcome.

prj.conf file:

#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
#CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_BOARD_ENABLE_DCDC=n

CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_EXT_ADV=y
CONFIG_BT_DEVICE_NAME="directed_adv"
CONFIG_BT_PRIVACY=n
CONFIG_BT_EXT_ADV_MAX_ADV_SET=1

CONFIG_BT_GATT_CLIENT=y

CONFIG_BT_SETTINGS=y

CONFIG_HEAP_MEM_POOL_SIZE=1024

CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_NVS=y
CONFIG_SETTINGS=y


# RTT Log Enanble
CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BUFFER_SIZE=4096
CONFIG_RTT_CONSOLE=y
CONFIG_PRINTK=y

Direct Advertiser logs

*** Booting Zephyr OS build v2.7.0-ncs1  ***
11-directed_adv init
[00:00:01.327,239] <inf> fs_nvs: 6 Sectors of 4096 bytes
[00:00:01.327,270] <inf> fs_nvs: alloc wra: 0, f70
[00:00:01.327,270] <inf> fs_nvs: data wra: 0, 118
[00:00:01.327,392] <inf> sdc_hci_driver: SoftDevice Controller build revision: 
                                         df c0 4e d6 1f 7c 66 09  0a f5 2b a0 98 f2 43 64 |..N..|f. ..+...Cd
                                         62 c5 a6 2a                                      |b..*             
[00:00:01.330,413] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
[00:00:01.330,413] <inf> bt_hci_core: HW Variant: nRF52x (0x0002)
[00:00:01.330,413] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 223.20160 Build 1719410646
[00:00:01.330,718] <inf> bt_hci_core: No ID address. App must call settings_load()
Bluetooth initialized
[00:00:01.330,902] <err> settings: set-value failure. key: bt/keys/e394a91ee9ef1 error(-2)
[00:00:01.331,634] <inf> bt_hci_core: Identity: F2:A4:36:CA:06:73 (random)
[00:00:01.331,634] <inf> bt_hci_core: HCI: version 5.2 (0x0b) revision 0x12b0, manufacturer 0x0059
[00:00:01.331,634] <inf> bt_hci_core: LMP: version 5.2 (0x0b) subver 0x12b0
Directed B2B Advertising Started addr: C7:45:56:34:0F:F0 (random)

BLE Tool

  • Hi Armand

    My apologies, I had back to back meetings today and didn't get time. I will do my best to test this tomorrow and get back to you. 

    Best regards
    Torbjørn

  • Hi Armand

    I had a chat with Hung, a colleague of mine, who mentioned that he handled a similar case some time ago (with you possibly). 

    He sent me some code that I could use to test this. 

    I made some minor changes to his code, and was able to get extended directed advertising working. 

    Please note that you have to find the local address of the scanner by looking at the log output, and update the advertiser code to use this address. 

    Could you give this code a try and see if it works OK?

    Best regards
    Torbjørn

  • Hi 

    Thanks for your reply. I have been going through the code and it is my understanding that it will detect any extended advertising but it does not discriminate for directed advertising. Please check the flags it is reading on the central_bas2 sample code:

    static void scan_filter_no_match(struct bt_scan_device_info *device_info,
    				 bool connectable)
    {
    	int err;
    	uint8_t i;
    	struct bt_conn *conn;
    	char addr[BT_ADDR_LE_STR_LEN];
    		bt_addr_le_to_str(device_info->recv_info->addr, addr,
    				  sizeof(addr));
    	if ((addr[0]=='F')&&(addr[1]=='6'))
    	{
    		printk("address %s\n",addr);	
    		for (i=0;i<device_info->adv_data->len;i++)
    		{
    			printk("%x",device_info->adv_data->data[i]);
    		}		  
    		printk("\n");
    	}
    	if ((device_info->recv_info->adv_type == BT_GAP_ADV_TYPE_EXT_ADV) && 
    		(device_info->recv_info->adv_props & BT_GAP_ADV_PROP_EXT_ADV)) {
    		bt_addr_le_to_str(device_info->recv_info->addr, addr,
    				  sizeof(addr));
    		printk("Extended directed advertising received from %s\n", addr);
    	}
    }

    The flags are specific to detect  devices that are performing extended advertising but not exclusively directed advertising:

    if ((device_info->recv_info->adv_type == BT_GAP_ADV_TYPE_EXT_ADV) && 
    		(device_info->recv_info->adv_props & BT_GAP_ADV_PROP_EXT_ADV))
     

    Please check this out.

  • Hi Armand

    This was something I had to add myself to make the directed advertising packets detected properly in the example. 

    When doing extended advertising then the adv_type field will no longer indicate whether or not you are receiving a directed or undirected advertising packet, since adv_type is BT_GAP_ADV_TYPE_EXT_ADV for all extended advertising packets. 

    Instead I had to check the adv_props field in order to figure out whether or not I was receiving an extended directed advertising packet from my advertiser, rather than some other advertise packet from other advertisers in the area. 

    If you want to also be able to read normal directed advertising packets (not using extended advertising) then you need to add a separate check for this. 

    Does that answer your question?

    Best regards
    Torbjørn

Related