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.

Parents
  • Hello,

    This should be possible. You mention that you want one initiator and two reflectors. This will probably work, but if you are planning to have many reflectors, you may want to switch it around. You see, the main CPU usage is in the initiator, and the reflector is not doing any heavy lifting. This means that if you plan to have many stationary devices and one moving device, it may make sense to have the stationary devices being the initiators, all doing channel sounding towards the same reflector. This means that the moving device (reflector) can last longer on a smaller battery.

    without reboot, the data becomes stagnant after a reconnection

    What does it mean? do you get any channel sounding data from the second connection, or none at all?

    Best regards,

    Edvin

  • I have found my answer and also a mistake.

    bt_le_cs_procedure_enable() was returning an error because the connection would already be stale after the disconnection. Hence, I tried to run it just by resetting the buffers, but I soon faced this issue of 

    W: Could not locate mandatory
    On-demand ranging data characteristic E: RAS RREQ alloc init failed (err -22)
    Then I started looking into my device discovery and found a problem there. I use NUS and RAS as well, so I chained their discoveries. And I was not resetting some states to do this properly.
     
    Now I need to work on the multiple connections part. This whole RAS and NUS were running on the multilink_central code, so do you have any suggestions on the multiple connections and the sounding part?
  • 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

  • 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

Reply Children
No Data
Related