Direction Finding Project: Central and Peripheral Integration

Now I am using the https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/direction_finding_central/README.html and https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/bluetooth/direction_finding_peripheral/README.html for a direction finding project.
I am using the nRF52833DK and an antenna array designed by Nordic. The SDK I used is nRF Connect SDK v2.2.0.

Here I have an uncommon requirement: each of my devices needs to act as both a central and a peripheral.
For example, a device with a single antenna will act as a central to collect the CTE for AoD estimation and as a peripheral to transmit the CTE for AoA estimation. Conversely, a device with an antenna array will act as a central to collect the CTE for AoA estimation and as a peripheral to transmit the CTE for AoD estimation.
Yes, I admit this is not common in direction finding, but it is actually the core function of my project.

-----------------------------------------------------------------------------------

Firstly, I concat the two prj.conf, two nrf52833dk_nrf52833.conf, the overlay-aoa.conf the and overlay-aod.conf.
Now my central and peripheral is using the same prj.conf and nrf52833dk_nrf52833.conf. I added a variable AoA_AoD_Setting to control whether the estimation value is AoA or AoD, so I no longer need overlay-aoa.conf and overlay-aod.conf.
I have tested this setup and can obtain the correct AoA or AoD separately based on the AoA_AoD_Setting in main.c.


Next, I need to combine the main.c of the central and the main.c of the peripheral, and rewrite the main function to switch between AoA and AoD modes, as well as between central and peripheral modes.

Here let's focus on the antenna array side.
1) initialize the bluetooth as a RX.
while(true)
 2) Start scan(), and wait for a connection to calculate the AoA.
 3) Once a connection is established, call enable_cte_request and wait for CTE collection.
 4) Disconnect the connection and call bt_le_scan_stop() when the CTE collection complated In cte_recv_cb.
 5) The AoA is complated, call bt_le_adv_start() and request for a connection.
 6) When the connection is established, call enable_cte_response(conn) and start transmitting the CTE packet.
 7) Wait for the disconnection of the peer device once it completes the CTE collection for AoD estimation.
 8) Call bt_le_adv_stop().
end while

The single antenna side follows a similar process, but it first acts as a TX to transmit the CTE packet for AoA, and then switches to RX to collect the CTE packet for AoD.

Now the while loop above reaches step 6) successfully (or at least it appears to). I can get the correct AoA value from the CTE collected in step 3) and 4). However, when I switch to TX mode, the connection can't be estiblished. The TX(antenna array) just transmit all the time, and the RX(single antenna side) just scan all the time.
So why can't the connection be estiblished?

For switch modes, I just use the following functions:
bt_le_scan_start();
enable_cte_reqest();
bt_le_scan_stop();
bt_le_adv_start();
enable_cte_response(conn);
bt_le_adv_stop();

I guess there are two things I need to understand:
A) In enable_cte_request(), the functions bt_df_conn_cte_rx_enable() and bt_df_conn_cte_req_enable() set certain settings. So, when I call enable_cte_response(), do I need to drop or cancel the settings made by bt_df_conn_cte_rx_enable() and bt_df_conn_cte_req_enable()?
B) I know that Bluetooth can only be initialized once in Zephyr. Is there any operation similar to "drop", allowing me to call bt_enable() multiple times?

Thanks!

Parents
  • Hi,

    However, when I switch to TX mode, the connection can't be estiblished. The TX(antenna array) just transmit all the time, and the RX(single antenna side) just scan all the time.
    So why can't the connection be estiblished?

    Can you check CONFIG_BT_PERIPHERAL, CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT, CONFIG_BT_CENTRAL, CONFIG_BT_CTLR_SDC_CENTRAL_COUNT and CONFIG_BT_MAX_CONN?

    Are there any error return values, or anything else indicating in what way it fails?

    A) In enable_cte_request(), the functions bt_df_conn_cte_rx_enable() and bt_df_conn_cte_req_enable() set certain settings. So, when I call enable_cte_response(), do I need to drop or cancel the settings made by bt_df_conn_cte_rx_enable() and bt_df_conn_cte_req_enable()?

    I see that those API calls have ..._disable() variants. Have you tried, after stopping scanning and advertising respectively, disabling the corresponding cte? I.e. create a corresponding disable_cte_request() to enable_cte_request() and a corresponding disable_cte_response() to enable_cte_response(), containing the API calls for disabling what was enabled in the ..._enable() variants.

    B) I know that Bluetooth can only be initialized once in Zephyr. Is there any operation similar to "drop", allowing me to call bt_enable() multiple times?

    One workaround is to do a soft reset, but of course it depends on what you are trying to achieve. Other workarounds may be applicable, depending on the use case. Why do you want to call bt_enable() multiple times, what are you trying to achieve?

    Regards,
    Terje

  • Hi, thank you for your reply.

    1) I just merge the config of the official central and peripheral. So in the final prj.conf I used, I can check that the values of CONFIG_BT_PERIPHERAL and CONFIG_BT_CENTRAL are 'y'. But I don't know the 'CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT', 'CONFIG_BT_CTLR_SDC_CENTRAL_COUNT ' and 'CONFIG_BT_MAX_CONN', which do not appear in the default direction finding samples.

    2) No, I didn't see any error return values. As I said before, the TX seems transmit all the time, while the RX scan all the time. But the connection did not occur. However, see 3).

    3) Yes, I added some function like XXX_disable() today and got some progress. I got the AoA and AoD successfully! But only the fisrt loop worked in my project. I still meet something error here. So please help me because I need the loop to run continuously.
        a) When the RX complete the CTE collection and ready to switch to TX, I call the bt_le_scan_stop() then it report an error: Scanning failed to stop (err -120). I don't know why I can't stop the scan.
    Before that, I have called the disable_cte_reqest() and it seem's execute right. All the functions were called in the disconnected call back function. And the disconnect function (bt_conn_disconnect()) was called in the cte_recv_cb() when it received enough CTE packets.
        b) When the TX complete the CTE transmission and ready to switch to RX, the disable_cte_response(conn) should be called. But I don't know where should it be. In my understand, I can determine when the CTE transmission has completed only through the disconnection event. So I call disable_cte_response(conn) in the disconnected call back function. The result is, err -128, which means "Socket is not connected.". I think I can't call it in the disconnected callback function because the connection is over but it is needed by the function (requires parameter 'conn').

        c) Disable the request CTE from peer device... failed (err -22).
        The function I called is bt_df_conn_cte_req_disable().

        My _disable() function:

    // both the functions are called in the disconnected call back function.
    static void disable_cte_response(struct bt_conn *conn)
    {
    	int err;
    	printk("Set CTE response disable...");
    	err = bt_df_conn_cte_rsp_disable(conn);
    	if (err) {
    		printk("failed (err %d).\n", err);
    		return;
    	}
    	printk("success.\n");
    }
    
    static void disable_cte_reqest(void)
    {
    	int err;
    
    	printk("Disable the request CTE from peer device...\n");
    	err = bt_df_conn_cte_req_disable(default_conn);
    	if (err) {
    		printk("failed (err %d)\n", err);
    		return;
    	}
    	printk("success. CTE request disabled.\n");
    
    	printk("Disable receiving of CTE...\n");
    	err = bt_df_conn_cte_rx_disable(default_conn);
    	if (err) {
    		printk("failed (err %d)\n", err);
    		return;
    	}
    	printk("success. CTE receive disabled.\n");
    }

    4) I want to call bt_enable() multiple times because I need to switch between TX and RX on one device. I just thought that initializing it again and again might be an easy way to achieve the switching. If I'm wrong, I apologize.

    5) I don't know if there is something wrong in my main function. I wrote two while loops with a k_sleep function to control the TX or RX operations like this:

    while(true){
    
    	AoA_Setting();
    	CENTRAL_Setting();
    
    	MAIN_RX_IS_COMPLETED = false;
    	start_scan();
    	while(!MAIN_RX_IS_COMPLETED){k_sleep(K_MSEC(100));}
    
    	printk("The AoA is completed!\n");
    	
    	
    	AoD_Setting();
    	PERIPHERAL_Setting();
    
    	MAIN_TX_IS_COMPLETED = false;
    	bt_ready();
    	while(!MAIN_TX_IS_COMPLETED){k_sleep(K_MSEC(100));}
    
    	printk("The AoD is completed!\n");
    
    }

    Thanks again!!

  • However, today I discovered that the case where AoA and AoD are obtained simultaneously is not reproducible.

    Now, I'm encountering a situation where after my RX switches to TX, it keeps sending packets. Meanwhile, my TX switches to RX and keeps scanning. However, they do not establish a connection. The log appears to be very normal.

    Antenna array side:

     Hello, this is the Antenna Array Side!!
    
    Bluetooth initialized
    Now I am going into the Switch Loop...
    
    -----------------------------------------------------------------------LOOP START
    
    Now I am using the AoA Setting.
    First, calculate the AoA.
     Now I am waiting for a connection and becoming a RX.
    Scanning successfully started
    [00:00:00.267,364] <inf> bt_hci_core: hci_vs_in[DEVICE]: 12:89:A5:62:96:36 (random), AD evt type 3, AD data len 31, RSSI -53
    [DEVICE]: 7C:27:BC:D1:9D:2E (public), AD evt type 3, AD data len 19, RSSI -87
    [DEVICE]: D1:8D:C5:A0:52:24 (random), AD evt type 3, AD data len 8, RSSI -58
    it: HW[DEVICE]: 2A:34:53:29:E5:23 (random), AD evt type 3, AD data len 31, RSSI -81
    [DEVICE]: 11:8E:BB:9F:5C:D4 (random), AD evt type 3, AD data len 31, RSSI -84
    [DEVICE]: 38:71:41:40:89:0F (random), AD evt type 3, AD data len 31, RSSI -81
    [DEVICE]: 11:8E:BB:9F:5C:D4 (random), AD evt type 3, AD data len 31, RSSI -85
    [DEVICE]: 04:95:9E:85:E4:31 (random), AD evt type 3, AD data len 31, RSSI -76
    [DEVICE]: 12:89:A5:62:96:36 (random), AD evt type 3, AD data len 31, RSSI -53
    [DEVICE]: 7C:27:BC:D1:9D:2E (public), AD evt type 3, AD data len 19, RSSI -78
    [DEVICE]: 4A:3F:F9:A9:00:C2 (random), AD evt type 0, AD data len 17, RSSI -54
    [AD]: 1 data_len 1
    [AD]: 10 data_len 1
    [AD]: 255 data_len 9
    [DEVICE]: 4A:3F:F9:A9:00:C2 (random), AD evt type 4, AD data len 0, RSSI -54
    [DEVICE]: 0F:ED:AB:B2:EC:75 (random), AD evt type 3, AD data len 31, RSSI -80
    [DEVICE]: 04:95:9E:85:E4:31 (random), AD evt type 3, AD data len 31, RSSI -69
    [DEVICE]: 2A:34:53:29:E5:23 (random), AD evt type 3, AD data len 31, RSSI -73
    [DEVICE]: 12:89:A5:62:96:36 (random), AD evt type 3, AD data len 31, RSSI -50
     Platform: Nordic Semiconductor (0x0002)
    [00:00:00.267,395] <inf> bt_hci_core: hci_vs_init: HW Variant: nRF52x (0x0002)
    [00:00:00.267,425] <inf> bt_hci_core: hci_vs_init: Firmware: Standard Bluetooth controller (0x00) Version 3.2 Build 99
    [00:00:00.268,188] <inf> bt_hci_core: bt_dev_show_info: Identity: E7:8C:85:B4:1[DEVICE]: 4E:2F:34:97:F8:64 (random), AD evt type 3, AD data len 31, RSSI -86
    C:E6 (random)
    [00:00:00.268,218] <inf> bt_hci_core: bt_dev_show_info: HCI: version 5.3 (0x0c) revision 0x0000, manufacturer 0x05f1
    [00:00:00.268,249] <inf> bt_hci_core: bt_dev_show_info: LMP: version 5.3 (0x0c) subver 0xffff
    [DEVICE]: 11:8E:BB:9F:5C:D4 (random), AD evt type 3, AD data len 31, RSSI -84
    [DEVICE]: 2A:34:53:29:E5:23 (random), AD evt type 3, AD data len 31, RSSI -66
    [DEVICE]: FC:01:50:FD:5F:53 (random), AD evt type 0, AD data len 8, RSSI -50
    [AD]: 1 data_len 1
    [AD]: 39 data_len 3
    Connected as a CENTRAL: FC:01:50:FD:5F:53 (random)
    Enable receiving of CTE...
    success. CTE receive enabled.
    Request CTE from peer device...
    success. CTE request enabled.
    CTE[FC:01:50:FD:5F:53 (random)]: samples count 3, cte type AOA, slot durations: 2 [us], packet status CRC not OK, CTE Info OK, RSSI -570
    CTE[FC:01:50:FD:5F:53 (random)]: samples count 3, cte type AOA, slot durations: 2 [us], packet status CRC not OK, CTE Info OK, RSSI -500
    CTE[FC:01:50:FD:5F:53 (random)]: samples count 45, cte type AOA, slot durations: 2 [us], packet status CRC OK, RSSI -510
    I got the AoA CTE! Now I'm gonna stop the scan!
    Now I'm gonna disconnect!
    The RX Disconnected!
    The AoA is completed!
    Now I am using the AoD Setting.
    Second, calculate the AoD.
     Now I am asking a connection and becoming a TX.
    Bluetooth initialized
    Advertising successfully started

    Single antenna side:

     Hello, this is the Single Antenna Side!! 
    
    Bluetooth initialized
    Now I am going into the Switch Loop... 
    
    -----------------------------------------------------------------------LOOP START 
    
    Now I am using the AoA Setting.
    First, calculate the AoA.
     Now I am asking a connection and becoming a TX.
    Bluetooth initialized
    Advertising successfully started
    [00:00:00.268,493] <inf> bt_hci_core: hci_vs_init: HW Platform: Nordic Semiconductor (0x0002)
    [00:00:00.268,524] <inf> bt_hci_core: hci_vs_init: HW Variant: nRF52x (0x0002)
    [00:00:00.268,554] <inf> bt_hci_core: hci_vs_init: Firmware: Standard Bluetooth controller (0x00) Version 3.2 Build 99
    [00:00:00.269,317] <inf> bt_hci_core: bt_dev_show_info: Identity: FC:01:50:FD:5F:53 (random)
    [00:00:00.269,348] <inf> bt_hci_core: bt_dev_show_info: HCI: version 5.3 (0x0c) revision 0x0000, manufacturer 0x05f1
    [00:00:00.2Connected as a PERIPHERAL
    Set CTE transmission params...success.
    Set CTE response enable...success.
    69,378] <inf> bt_hci_core: bt_dev_show_info: LMP: version 5.3 (0x0c) subver 0xffff
    The other side has completed the CTE collection, and want to disconnect...
    Disconnected (reason 0x13)
    Second, calculate the AoD.
     Now I am waiting for a connection and becoming a RX. 
    Now I am using the AoD Setting.
    Scanning successfully started
    [DEVICE]: 04:95:9E:85:E4:31 (random), AD evt type 3, AD data len 31, RSSI -65
    [DEVICE]: 11:8E:BB:9F:5C:D4 (random), AD evt type 3, AD data len 31, RSSI -73
    [DEVICE]: 53:92:EB:C2:9D:CE (random), AD evt type 3, AD data len 17, RSSI -48
    [DEVICE]: 12:89:A5:62:96:36 (random), AD evt type 3, AD data len 31, RSSI -33
    [DEVICE]: 2A:34:53:29:E5:23 (random), AD evt type 3, AD data len 31, RSSI -54
    [DEVICE]: 7C:27:BC:D1:9D:2E (public), AD evt type 3, AD data len 19, RSSI -64
    [DEVICE]: 12:89:A5:62:96:36 (random), AD evt type 3, AD data len 31, RSSI -43
    [DEVICE]: 2A:34:53:29:E5:23 (random), AD evt type 3, AD data len 31, RSSI -59
    [DEVICE]: 4E:2F:34:97:F8:64 (random), AD evt type 3, AD data len 31, RSSI -77
    [DEVICE]: 0F:ED:AB:B2:EC:75 (random), AD evt type 3, AD data len 31, RSSI -81
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 0, AD data len 24, RSSI -82
    [AD]: 1 data_len 1
    [AD]: 22 data_len 19
    [DEVICE]: 04:95:9E:85:E4:31 (random), AD evt type 3, AD data len 31, RSSI -55
    [DEVICE]: 4E:2F:34:97:F8:64 (random), AD evt type 3, AD data len 31, RSSI -79
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 0, AD data len 24, RSSI -83
    [AD]: 1 data_len 1
    [AD]: 22 data_len 19
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 4, AD data len 28, RSSI -82
    [DEVICE]: 04:95:9E:85:E4:31 (random), AD evt type 3, AD data len 31, RSSI -66
    [DEVICE]: 12:89:A5:62:96:36 (random), AD evt type 3, AD data len 31, RSSI -32
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 0, AD data len 24, RSSI -79
    [AD]: 1 data_len 1
    [AD]: 22 data_len 19
    [DEVICE]: 7C:27:BC:D1:9D:2E (public), AD evt type 3, AD data len 19, RSSI -65
    [DEVICE]: 4A:3F:F9:A9:00:C2 (random), AD evt type 0, AD data len 17, RSSI -51
    [AD]: 1 data_len 1
    [AD]: 10 data_len 1
    [AD]: 255 data_len 9
    [DEVICE]: 4A:3F:F9:A9:00:C2 (random), AD evt type 4, AD data len 0, RSSI -49
    [DEVICE]: 2A:34:53:29:E5:23 (random), AD evt type 3, AD data len 31, RSSI -52
    [DEVICE]: 12:89:A5:62:96:36 (random), AD evt type 3, AD data len 31, RSSI -33
    [DEVICE]: 2A:34:53:29:E5:23 (random), AD evt type 3, AD data len 31, RSSI -54
    [DEVICE]: 04:95:9E:85:E4:31 (random), AD evt type 3, AD data len 31, RSSI -65
    [DEVICE]: 4E:2F:34:97:F8:64 (random), AD evt type 3, AD data len 31, RSSI -73
    [DEVICE]: 0F:ED:AB:B2:EC:75 (random), AD evt type 3, AD data len 31, RSSI -72
    [DEVICE]: 7C:27:BC:D1:9D:2E (public), AD evt type 3, AD data len 19, RSSI -64
    [DEVICE]: 04:95:9E:85:E4:31 (random), AD evt type 3, AD data len 31, RSSI -66
    [DEVICE]: 11:8E:BB:9F:5C:D4 (random), AD evt type 3, AD data len 31, RSSI -73
    [DEVICE]: 0F:ED:AB:B2:EC:75 (random), AD evt type 3, AD data len 31, RSSI -80
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 0, AD data len 24, RSSI -79
    [AD]: 1 data_len 1
    [AD]: 22 data_len 19
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 4, AD data len 28, RSSI -79
    [DEVICE]: 68:E4:78:EA:52:FF (public), AD evt type 0, AD data len 31, RSSI -92
    [AD]: 1 data_len 1
    [AD]: 9 data_len 8
    [AD]: 22 data_len 16
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 0, AD data len 24, RSSI -82
    [AD]: 1 data_len 1
    [AD]: 22 data_len 19
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 4, AD data len 28, RSSI -81
    [DEVICE]: 2A:34:53:29:E5:23 (random), AD evt type 3, AD data len 31, RSSI -60
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 0, AD data len 24, RSSI -82
    [AD]: 1 data_len 1
    [AD]: 22 data_len 19
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 4, AD data len 28, RSSI -82
    [DEVICE]: 11:8E:BB:9F:5C:D4 (random), AD evt type 3, AD data len 31, RSSI -74
    [DEVICE]: 12:89:A5:62:96:36 (random), AD evt type 3, AD data len 31, RSSI -32
    [DEVICE]: 4E:2F:34:97:F8:64 (random), AD evt type 3, AD data len 31, RSSI -78
    [DEVICE]: 4A:3F:F9:A9:00:C2 (random), AD evt type 0, AD data len 17, RSSI -49
    [AD]: 1 data_len 1
    [AD]: 10 data_len 1
    [AD]: 255 data_len 9
    [DEVICE]: 4A:3F:F9:A9:00:C2 (random), AD evt type 4, AD data len 0, RSSI -49
    [DEVICE]: 04:95:9E:85:E4:31 (random), AD evt type 3, AD data len 31, RSSI -55
    [DEVICE]: 4E:2F:34:97:F8:64 (random), AD evt type 3, AD data len 31, RSSI -79
    [DEVICE]: 0F:ED:AB:B2:EC:75 (random), AD evt type 3, AD data len 31, RSSI -66
    [DEVICE]: 7C:27:BC:D1:9D:2E (public), AD evt type 3, AD data len 19, RSSI -67
    [DEVICE]: 2A:34:53:29:E5:23 (random), AD evt type 3, AD data len 31, RSSI -54
    [DEVICE]: 04:95:9E:85:E4:31 (random), AD evt type 3, AD data len 31, RSSI -64
    [DEVICE]: 68:E4:78:EA:52:FF (public), AD evt type 0, AD data len 31, RSSI -91
    [AD]: 1 data_len 1
    [AD]: 9 data_len 8
    [AD]: 22 data_len 16
    [DEVICE]: 38:71:41:40:89:0F (random), AD evt type 3, AD data len 31, RSSI -63
    [DEVICE]: 11:8E:BB:9F:5C:D4 (random), AD evt type 3, AD data len 31, RSSI -74
    [DEVICE]: 2A:34:53:29:E5:23 (random), AD evt type 3, AD data len 31, RSSI -64
    [DEVICE]: 12:89:A5:62:96:36 (random), AD evt type 3, AD data len 31, RSSI -32
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 0, AD data len 24, RSSI -79
    [AD]: 1 data_len 1
    [AD]: 22 data_len 19
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 4, AD data len 28, RSSI -78
    [DEVICE]: F4:B3:B1:AE:33:46 (public), AD evt type 3, AD data len 30, RSSI -67
    [DEVICE]: 12:89:A5:62:96:36 (random), AD evt type 3, AD data len 31, RSSI -43
    [DEVICE]: 11:8E:BB:9F:5C:D4 (random), AD evt type 3, AD data len 31, RSSI -69
    [DEVICE]: 2A:34:53:29:E5:23 (random), AD evt type 3, AD data len 31, RSSI -52
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 0, AD data len 24, RSSI -83
    [AD]: 1 data_len 1
    [AD]: 22 data_len 19
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 4, AD data len 28, RSSI -82
    [DEVICE]: 4E:2F:34:97:F8:64 (random), AD evt type 3, AD data len 31, RSSI -73
    [DEVICE]: 04:95:9E:85:E4:31 (random), AD evt type 3, AD data len 31, RSSI -65
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 0, AD data len 24, RSSI -83
    [AD]: 1 data_len 1
    [AD]: 22 data_len 19
    [DEVICE]: 0F:ED:AB:B2:EC:75 (random), AD evt type 3, AD data len 31, RSSI -77
    [DEVICE]: 7C:27:BC:D1:9D:2E (public), AD evt type 3, AD data len 19, RSSI -63
    [DEVICE]: 4E:2F:34:97:F8:64 (random), AD evt type 3, AD data len 31, RSSI -80
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 0, AD data len 24, RSSI -79
    [AD]: 1 data_len 1
    [AD]: 22 data_len 19
    [DEVICE]: 78:11:DC:C2:89:2F (public), AD evt type 4, AD data len 28, RSSI -79
    [DEVICE]: 4A:3F:F9:A9:00:C2 (random), AD evt type 0, AD data len 17, RSSI -50
    [AD]: 1 data_len 1
    [AD]: 10 data_len 1
    [AD]: 255 data_len 9
    [DEVICE]: 4E:2F:34:97:F8:64 (random), AD evt type 3, AD data len 31, RSSI -80
    [DEVICE]: 12:89:A5:62:96:36 (random), AD evt type 3, AD data len 31, RSSI -32
    [DEVICE]: 11:8E:BB:9F:5C:D4 (random), AD evt type 3, AD data len 31, RSSI -73
    [DEVICE]: 04:95:9E:85:E4:31 (random), AD evt type 3, AD data len 31, RSSI -55

  • I want to correct something.

    Although TX seems to have started normally because no error was reported when calling this function:

    static void bt_ready(void)
    {
    	int err;
    
    	err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, ad, ARRAY_SIZE(ad), NULL, 0);
    	if (err) {
    		printk("Advertising failed to start (err %d)\n", err);
    		return;
    	}
    
    	printk("Advertising successfully started\n");
    }

    However, when I use the nRF Connect APP to check the device, I didn't find it. Therefore, even though bt_le_adv_start() did not return an error, it seems it did not actually start advertising packets successfully. I don'tunderstand why this is happening. 

    Before bt_le_adv_start() , I called disable_cte_reqest(), bt_conn_disconnect(). And the bt_le_scan_stop() has been called in eir_found() when the target device is found. So everything seems fine but it does not advertise packets...

     Hello, this is the Antenna Array Side!!
    
    Bluetooth initialized
    Now I am going into the Switch Loop...
    
    -----------------------------------------------------------------------LOOP START
    
    Now I am using the AoA Setting.
    First, calculate the AoA.
     Now I am waiting for a connection and becoming a RX.
    Scanning successfully started
    [DEVICE]: 05:11:54:C3:FA:10 (random), AD evt type 3, AD data len 31, RSSI -52
    [DEVICE]: 15:14:A7:6D:1F:25 (random), AD evt type 3, AD data len 31, RSSI -84
    [DEVICE]: 2B:46:3A:94:AD:5B (random), AD evt type 3, AD data len 31, RSSI -84
    [DEVICE]: 56:F2:B2:D7:E2:90 (random), AD evt type 3, AD data len 31, RSSI -80
    [DEVICE]: FC:01:50:FD:5F:53 (random), AD evt type 0, AD data len 8, RSSI -42
    [AD]: 1 data_len 1
    [AD]: 39 data_len 3
    Connected as a CENTRAL: FC:01:50:FD:5F:53 (random)
    Enable receiving of CTE...
    success. CTE receive enabled.
    Request CTE from peer device...
    success. CTE request enabled.
    CTE[FC:01:50:FD:5F:53 (random)]: samples count 45, cte type AOA, slot durations: 2 [us], packet status CRC OK, RSSI -500
    I got the AoA CTE! Now I'm gonna stop the scan!
    Disable the request CTE from peer device...
    success. CTE request disabled.
    Disable receiving of CTE...
    success. CTE receive disabled.
    Now I'm gonna disconnect!
    The RX Disconnected!
    From the DISconnected call back function of TX: Disconnected...
    The AoA is completed!
    Now I am using the AoD Setting.
    Second, calculate the AoD.
     Now I am asking a connection and becoming a TX.
    Advertising successfully started

  • Hi,

    Zihao said:
    But I don't know the 'CONFIG_BT_CTLR_SDC_PERIPHERAL_COUNT', 'CONFIG_BT_CTLR_SDC_CENTRAL_COUNT ' and 'CONFIG_BT_MAX_CONN', which do not appear in the default direction finding samples.

    Most configs get default values, or get values based on other configs. You can check all resulting configs for a build in the .config file, which is generated among the outputs. Find it under "Output files" in VS Code.

    Zihao said:
    When the RX complete the CTE collection and ready to switch to TX, I call the bt_le_scan_stop() then it report an error: Scanning failed to stop (err -120). I don't know why I can't stop the scan.

    You get -120 EALREADY if the scan has already been stopped. If for instance you were scanning for a connection, and you get the connection set up, scan is automatically stopped. Therefore there is no need to stop the scan after this has happened. In many situations, this error value can be treated equal to a return code of 0 (success), since it basically means that what you called for is already effectuated.

    Zihao said:
    Disable the request CTE from peer device... failed (err -22).
        The function I called is bt_df_conn_cte_req_disable().

    This can only be called if in a connection. It looks like this is automatically disabled on disconnection. Similar as with -120 from bt_le_scan_stop(), an error code of -22 here basically means what you attempt to do is already done.

    Zihao said:
    I want to call bt_enable() multiple times because I need to switch between TX and RX on one device. I just thought that initializing it again and again might be an easy way to achieve the switching. If I'm wrong, I apologize.

    There is no need to reinitialize BLE for switching between BLE roles. Just use the APIs for connectable advertising, scanning, connecting, disconnecting, etc. appropriately for what you want to do, and in the order you want to do it.

    Regards,
    Terje

  • Thanks for the reply,

    It seems these operations are really quite decoupled and convenient: advertising, scanning, connecting, disconnecting, etc. I was able to resolve error -120 and error -22.

    However, I still face an issue when my two devices switch roles for the first time. One device keeps advertising and the other keeps scanning, but they just won't establish a connection. Everything looks good. There is no error, no failed, no warnning.

    I believe my implementation is quite straightforward: start advertising, connecting, disconnecting, disable advertising, start scanning. The other device performs the opposite operations. Is there anything specific I need to pay attention to during this process?

  • Thank you for your reply! I have resolved the issue!

Reply Children
No Data
Related