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.

  • Hi Edvin,
    I am actually doing my master's thesis on the implementation of this, so for the current scenario considered, it's going to be 2 moving devices with 1 stationary device.
    So I am using 1 central initiator (stationary) with 2 peripheral reflectors (moving). Does this make sense in terms of power consumption footprint?
    I implemented the part where I am currently sounding to 2 devices consecutively. At any given point in time, there is only 1 peripheral reflector connected to the central initiator. The problem arises as the switching (disconnection, connection, and CS parameters exchange) takes around 4-5 seconds. Is there any way I can get a better response time?
    I am looking into 2 directions of solutions for this:

    1) Find a way to make the CS params exchange faster (maybe store the params in flash)  - This reduces the time for CS param exchange

    2) Stay connected to 2 devices, but sound only to one device - This reduces the time taken for connection and disconnection

    Can I get some insights about these probable solution methods? I would also be glad to know if you have some other solution in mind.

    Thanks,
    Vinayaka KS

  • I would try to get the second scenario working. There is no point in keeping connecting and disconnecting all the time. Just stay connected to both, and do channel sounding measurements on one at the time. 

    When you have multiple devices, it is a good idea to have the central being the initiator (like you do), because it causes less timing issues. 

    You have a function:

    err = bt_le_cs_set_procedure_parameters(connection, &procedure_params);

    where the first parameter, "connection" points to the connection to the reflector. If you have two connections, you need to store two of these connection pointers, and then call bt_le_cs_set_procedure_parameters() on both of them.

    Best regards,

    Edvin

  • Thanks a lot, I will try implementing this now.

    Regards,

    Vinayaka KS

  • I am not able to enable the CS procedures for the 2nd device. Is this a problem with the memory?

    I: Disabling the CS procedure
    I: Free rreq 0x20002b18 for conn 0x200076d8
    I: CS procedures disabled.
    W: opcode 0x2094 status 0x07
    I: Enabling the CS procedure
    E: Failed to enable CS procedures (err -5) for Device1


    void switch_CS_device(void){
    	int err;
    	while (1) {
    		k_sleep(K_SECONDS(10));
    
    		if(cs_device_count > 1){
    			node_index_val = (node_index_val+1)%2; 
    
    			struct bt_le_cs_procedure_enable_param enable_params = {
    				.config_id = CS_CONFIG_ID,
    				.enable = BT_CONN_LE_CS_PROCEDURES_ENABLED,
    			};
    
    			struct bt_le_cs_procedure_enable_param disable_params = {
    				.config_id = CS_CONFIG_ID,
    				.enable = BT_CONN_LE_CS_PROCEDURES_DISABLED,
    			};
    
    			err = bt_le_cs_procedure_enable(conn_contexts[(node_index_val+1)%2].conn, &disable_params);
    			LOG_INF("Disabling the CS procedure");
    			if (err) {
    				LOG_ERR("Failed to disable CS procedures (err %d) for Device%d", err,node_index_val);
    				return;
    			}
    			k_sem_take(&sem_cs_enable_disable,K_FOREVER);
    
    			most_recent_local_ranging_counter = PROCEDURE_COUNTER_NONE;
    			dropped_ranging_counter = PROCEDURE_COUNTER_NONE;
    			buffer_index = 0;
    			buffer_num_valid = 0;
    			
    			// Reset step buffers
    			net_buf_simple_reset(&latest_local_steps);
    			net_buf_simple_reset(&latest_peer_steps);
    			
    			// Clear distance estimate buffer
    			memset(distance_estimate_buffer, 0, sizeof(distance_estimate_buffer));
    			
    			// Reset semaphores to clean state
    			k_sem_reset(&sem_local_steps);
    			k_sem_give(&sem_local_steps);
    			bt_ras_rreq_free(conn_contexts[(node_index_val+1)%2].conn);
    			k_msleep(1000);
    
    			err = bt_le_cs_procedure_enable(conn_contexts[node_index_val].conn, &enable_params);
    			LOG_INF("Enabling the CS procedure");
    			if (err) {
    				LOG_ERR("Failed to enable CS procedures (err %d) for Device%d", err,node_index_val);
    				return;
    			}
    			else{
    				LOG_INF("Sounding to device%d", node_index_val);
    			}
    			k_sem_take(&sem_cs_enable_disable,K_FOREVER);
    		}
    	}
    }

  • I don't have a multi-connection channel sounding sample at hand. Do you mind sending me what you already have, then perhaps I can have a look at it, and give it a go.

    I will not be able to look into it tomorrow, but hopefully during the beginning of next week.

    Best regards,

    Edvin

Related