This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Enable connectable advertising and scan role simultaneously using nRF connect SDK

Hi,

I am using NCS v1.3.0 for nRF9160. How to enable both scanner and advertiser roles simultaneously?

Currently even I enable both, HCI LE set random address failing with command disallowed error.

  • I have loaded hci_uart into nrf9160dk_nrf52840.

    I have added below in ncs\zephyr\samples\bluetooth\scan_adv 

    1. child_secure_partition_manager.conf

    CONFIG_SPM_NRF_UARTE2_NS=y

    2. nrf9160dk_nrf9160ns.overlay

    / {
    	chosen {
    		zephyr,bt-uart=&uart2;
    	};
    };
    
    &uart2 {
    	compatible = "nordic,nrf-uarte";
    	current-speed = <1000000>;
    	status = "okay";
    	tx-pin = <18>;
    	rx-pin = <17>;
    	rts-pin = <21>;
    	cts-pin = <19>;
    };
    

    I have modified prj.conf as

    CONFIG_BT=y
    CONFIG_BT_BROADCASTER=y
    CONFIG_BT_OBSERVER=y
    CONFIG_BT_DEBUG_LOG=y
    CONFIG_BT_H4=y
    CONFIG_BT_WAIT_NOP=y
    CONFIG_BT_CENTRAL=y
    CONFIG_BT_GATT_CLIENT=y
    CONFIG_BT_GATT_DM=y
    CONFIG_BT_SCAN=y
    CONFIG_BT_SCAN_FILTER_ENABLE=y
    CONFIG_BT_SCAN_UUID_CNT=2
    
    CONFIG_UART_2_NRF_FLOW_CONTROL=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_BT_SMP=y
    
    
    # Enable the BLE modules from NCS
    CONFIG_BT_GATT_NUS_C=y
    CONFIG_BT_MAX_CONN=10
    CONFIG_BT_MAX_PAIRED=2
    CONFIG_BT_ID_MAX=2
    CONFIG_BT_PERIPHERAL=y
    
    

    In main.c I replaced BT_LE_ADV_NCONN with BT_LE_ADV_CONN and I observed following prints in LTE link monitor

    Advertising failed to start (err -5)
    
    
    
    
    bt_hci_core: opcode 0x0000 pool id 6 pool 0x200205ec != &hci_cmd_pool 0x200205c4
    bt_hci_core: ECC HCI commands not available
    bt_hci_core: Identity: d8:56:51:0d:97:1b (random)
    bt_hci_core: HCI: version 5.2 (0x0b) revision 0x0000, manufacturer 0x05f1
    bt_hci_core: LMP: version 5.2 (0x0b) subver 0xffff
    bt_hci_core: opcode 0x2005 status 0x0c

    Please tell me what I am doing wrong.

  • Hi,

    You can make the "peripheral_uart" work on the nRF9160DK (nrf9160dk_nrf9160ns) and the "hci_uart" on the nrf52840 (nrf9160dk_nrf52840) in NCS v1.3.0:

    You change the following in ncs/v1.3.0/nrf/samples/bluetooth/peripheral_uart:

    • Add the following in prj.conf:

    CONFIG_BT_H4=y
    CONFIG_BT_WAIT_NOP=y
    CONFIG_MAIN_STACK_SIZE=8192

    • Add the following in CMakeLists.txt (under the line "cmake_minimum_required(VERSION 3.8.2))

    set(spm_CONF_FILE
        prj.conf
        ${CMAKE_CURRENT_LIST_DIR}/child_secure_partition_manager.conf
    )

    From lte_ble_gateway

    • Add ncs\v1.3.0\nrf\samples\nrf9160\lte_ble_gateway\child_secure_partition_manager.conf to ncs\v1.3.0\nrf\samples\bluetooth\peripheral_uart
    • Add ncs\v1.3.0\nrf\samples\nrf9160\lte_ble_gateway\nrf9160dk_nrf9160ns.overlay to ncs\v1.3.0\nrf\samples\bluetooth\peripheral_uart

    note that hci_uart should just be programmed to the nrf9160_nrf52840 as is. (no modification needed)

  • Ok. Is it satisfy both scan and connectable advertising at a time?

Related