Reset the channel sounding parameters after a disconnection

Hi, I am trying to sound two reflectors from a single initiator, and since the CS works on a one-to-one ACL system, I wanted to know how I can reset the CS-related stuff in the code. I did try this without reboot, the data becomes stagnant after a reconnection or when I connect 2 reflectors (not sound, but just connect)  

The sample provided by Nordic does a soft reboot, so it works flawlessly. I am trying to take a different path of not connecting to both of my nodes at once and do a soft reboot every time I wanna switch the sounding, but I wanted to know if a manual reset was possible for the CS params and buffer, so that I can continue with sounding another device without doing a soft reboot.

  • I have sent both the peripheral and central.

  • Hi Vinayaka, have you got any update on your attempts to do multi connection channel sounding ? I am also trying to do it but unfortunately, without success. 
    Regards, 
    Fhar

  • I found the issue, I was not setting one config 

    CONFIG_BT_CTLR_CHANNEL_SOUNDING=y

    And now I can sound, but the device has problems like this.
    W: Mismatch of local and peer step mode 1 != 2
    E: empty step data
    E: empty step data

    This happens to the device that gets connected first, and happens every time I sound it. The 2nd device is able to get the data.

  • Ok, I did find an issue. You are restarting the the advertising directly in the .recycled callback.

    I saw that the channel_sounding_ras_reflector sample just rebooted in the disconnected_cb event. This is a quick (and dirty) way to just reset the state of the reflector. But of course, this is maybe not allwals desireable.

    Attached is a modified channel_sounding_ras_reflector sample (tested in NCS v3.2.1):

    cs_refl.zip

    Note that the recycled_cb() calls advertising_start(), but this doesn't directly call bt_le_adv_start(). This needs to be done through a work handler, like it is done in e.g. the NCS\nrf\samples\bluetooth\peripheral_uart sample. It is a bit more lines of code, but the idea is that you can't call BT API directly from the recycled callback, as it will block itself. Therefore you need to add these small pieces of code:

    // in main.c:
    
    static struct k_work adv_work;
    
    ...
    
    static void adv_work_handler(struct k_work *work)
    {
    	int err = bt_le_adv_start(BT_LE_ADV_CONN_FAST_2, ad, ARRAY_SIZE(ad), NULL, 0);
    	if (err) {
    		LOG_ERR("Advertising failed to start (err %d)", err);
    		return;
    	}
    }
    
    ...
    
    static void recycled_cb(void)
    {
    	LOG_INF("Connection object available from previous conn. Disconnect is complete!");
    	advertising_start();
    }
    
    BT_CONN_CB_DEFINE(conn_cb) = {
    	...
    	.recycled = recycled_cb,
    };
    
    ...
    
    int main(void)
    {
    ...
    	k_work_init(&adv_work, adv_work_handler);
    	advertising_start();
    ...
    }

    Try that, and let me know if it doesn't work.

    Best regards,

    Edvin

Related