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?
  • 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

  • Hey, I tried it out, and It doesnt work. Also, I don't think this is something related because I don't disconnect the reflector, but stay connected and do the procedure consecutively with another reflector.

    Is there a specific way to reset my local counters on the reflector ? Either via the initiator or on the reflector directly?

  • The reason why I ask for counter reset on the reflector is that I always have this ranging counter mismatch or empty step data when I start measurement to the device 0 (which gets connected first). I have some logs below.

    I even use 2 Config_IDs to differentiate between these devices

    There are supposed to be at least 19 samples of distance measurement data, since I read and print distance results once every 500ms and switch between devices once every 10 seconds. But, I see this error either from the ranging_data_cb() or from the bt_ras_rreq_rd_subevent_data_parse()

     

    I: Disabling the CS procedure
    I: counters reset, local:-1, dropped:-1
    W: Procedure 584 aborted, reason - 0x1
    I: CS procedures disabled.
    I: Enabling the CS procedure
    I: Sounding to device 0
    I: CS procedures enabled:
    - config ID: 0
    - antenna configuration index: 0
    - TX power: 0 dbm
    - subevent length: 28198 us
    - subevents per event: 1
    - subevent interval: 0
    - event interval: 2
    - procedure interval: 5
    - procedure count: 0
    - maximum procedure length: 1000
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 691, local: 690)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 692, local: 691)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 693, local: 692)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 694, local: 693)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 695, local: 694)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 696, local: 695)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 697, local: 696)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 698, local: 697)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 699, local: 698)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 700, local: 699)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 701, local: 700)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 702, local: 701)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 703, local: 702)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 704, local: 703)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 705, local: 704)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 706, local: 705)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 707, local: 706)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 708, local: 707)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 709, local: 708)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 710, local: 709)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 711, local: 710)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 712, local: 711)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 713, local: 712)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 714, local: 713)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 715, local: 714)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 716, local: 715)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 717, local: 716)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 718, local: 717)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 719, local: 718)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 720, local: 719)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 721, local: 720)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 722, local: 721)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 723, local: 722)
    Data from Reflector 2
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 724, local: 723)
    Data from Reflector 1
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 725, local: 724)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 726, local: 725)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 727, local: 726)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 728, local: 727)
    I: Disabling the CS procedure
    I: counters reset, local:-1, dropped:-1
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 729, local: 4294967295)
    I: CS procedures disabled.
    I: Enabling the CS procedure
    I: Sounding to device 1
    I: CS procedures enabled:
    - config ID: 1
    - antenna configuration index: 0
    - TX power: 0 dbm
    - subevent length: 28198 us
    - subevents per event: 1
    - subevent interval: 0
    - event interval: 2
    - procedure interval: 5
    - procedure count: 0
    - maximum procedure length: 1000
    I: Dropped subevent results. Waiting for ranging data from peer.
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 585, local: 728)
    I: 1.756596,3.513278,2.610804,2.604011
    I: 1.756596,3.427624,2.751654,2.049362
    I: 2.049362,3.427624,2.837012,2.049362
    I: 2.049362,3.427624,2.837012,2.049362
    I: 2.049362,3.427624,2.854575,2.049362
    I: 2.049362,3.427624,2.854575,2.049362
    I: 2.049362,3.451425,3.105397,2.049362
    I: 2.049362,3.534048,3.157910,2.049362
    I: 2.049362,3.534048,3.105397,2.049362
    I: 2.049362,3.534048,3.157910,2.049362
    I: 2.049362,3.546767,3.382754,2.049362
    I: 2.049362,3.424742,3.265795,2.049362
    I: 2.049362,3.424742,3.265795,2.049362
    I: 2.049362,3.424742,2.969308,2.049362
    Data from Reflector 2
    Data from Reflector 1
    I: 2.049362,3.360484,2.927473,2.049362
    I: 2.049362,3.360484,2.792185,2.342129
    I: 2.195745,3.360484,2.820416,2.342129
    I: Disabling the CS procedure
    I: counters reset, local:-1, dropped:-1
    W: Procedure 623 aborted, reason - 0x1
    I: CS procedures disabled.
    I: Enabling the CS procedure
    I: Sounding to device 0
    I: CS procedures enabled:
    - config ID: 0
    - antenna configuration index: 0
    - TX power: 0 dbm
    - subevent length: 28198 us
    - subevents per event: 1
    - subevent interval: 0
    - event interval: 2
    - procedure interval: 5
    - procedure count: 0
    - maximum procedure length: 1000
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    Data from Reflector 2
    E: empty step data
    Data from Reflector 1
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    I: Disabling the CS procedure
    I: counters reset, local:-1, dropped:-1
    E: empty step data
    I: CS procedures disabled.
    I: Enabling the CS procedure
    I: Sounding to device 1
    I: CS procedures enabled:
    - config ID: 1
    - antenna configuration index: 0
    - TX power: 0 dbm
    - subevent length: 28198 us
    - subevents per event: 1
    - subevent interval: 0
    - event interval: 2
    - procedure interval: 5
    - procedure count: 0
    - maximum procedure length: 1000
    I: 2.049362,3.392859,2.921039,2.049362
    I: 2.049362,3.392859,3.176355,2.049362

Reply
  • The reason why I ask for counter reset on the reflector is that I always have this ranging counter mismatch or empty step data when I start measurement to the device 0 (which gets connected first). I have some logs below.

    I even use 2 Config_IDs to differentiate between these devices

    There are supposed to be at least 19 samples of distance measurement data, since I read and print distance results once every 500ms and switch between devices once every 10 seconds. But, I see this error either from the ranging_data_cb() or from the bt_ras_rreq_rd_subevent_data_parse()

     

    I: Disabling the CS procedure
    I: counters reset, local:-1, dropped:-1
    W: Procedure 584 aborted, reason - 0x1
    I: CS procedures disabled.
    I: Enabling the CS procedure
    I: Sounding to device 0
    I: CS procedures enabled:
    - config ID: 0
    - antenna configuration index: 0
    - TX power: 0 dbm
    - subevent length: 28198 us
    - subevents per event: 1
    - subevent interval: 0
    - event interval: 2
    - procedure interval: 5
    - procedure count: 0
    - maximum procedure length: 1000
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 691, local: 690)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 692, local: 691)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 693, local: 692)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 694, local: 693)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 695, local: 694)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 696, local: 695)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 697, local: 696)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 698, local: 697)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 699, local: 698)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 700, local: 699)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 701, local: 700)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 702, local: 701)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 703, local: 702)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 704, local: 703)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 705, local: 704)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 706, local: 705)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 707, local: 706)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 708, local: 707)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 709, local: 708)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 710, local: 709)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 711, local: 710)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 712, local: 711)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 713, local: 712)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 714, local: 713)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 715, local: 714)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 716, local: 715)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 717, local: 716)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 718, local: 717)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 719, local: 718)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 720, local: 719)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 721, local: 720)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 722, local: 721)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 723, local: 722)
    Data from Reflector 2
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 724, local: 723)
    Data from Reflector 1
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 725, local: 724)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 726, local: 725)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 727, local: 726)
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 728, local: 727)
    I: Disabling the CS procedure
    I: counters reset, local:-1, dropped:-1
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 729, local: 4294967295)
    I: CS procedures disabled.
    I: Enabling the CS procedure
    I: Sounding to device 1
    I: CS procedures enabled:
    - config ID: 1
    - antenna configuration index: 0
    - TX power: 0 dbm
    - subevent length: 28198 us
    - subevents per event: 1
    - subevent interval: 0
    - event interval: 2
    - procedure interval: 5
    - procedure count: 0
    - maximum procedure length: 1000
    I: Dropped subevent results. Waiting for ranging data from peer.
    I: Ranging data dropped as peer ranging counter doesn't match local ranging data counter. (peer: 585, local: 728)
    I: 1.756596,3.513278,2.610804,2.604011
    I: 1.756596,3.427624,2.751654,2.049362
    I: 2.049362,3.427624,2.837012,2.049362
    I: 2.049362,3.427624,2.837012,2.049362
    I: 2.049362,3.427624,2.854575,2.049362
    I: 2.049362,3.427624,2.854575,2.049362
    I: 2.049362,3.451425,3.105397,2.049362
    I: 2.049362,3.534048,3.157910,2.049362
    I: 2.049362,3.534048,3.105397,2.049362
    I: 2.049362,3.534048,3.157910,2.049362
    I: 2.049362,3.546767,3.382754,2.049362
    I: 2.049362,3.424742,3.265795,2.049362
    I: 2.049362,3.424742,3.265795,2.049362
    I: 2.049362,3.424742,2.969308,2.049362
    Data from Reflector 2
    Data from Reflector 1
    I: 2.049362,3.360484,2.927473,2.049362
    I: 2.049362,3.360484,2.792185,2.342129
    I: 2.195745,3.360484,2.820416,2.342129
    I: Disabling the CS procedure
    I: counters reset, local:-1, dropped:-1
    W: Procedure 623 aborted, reason - 0x1
    I: CS procedures disabled.
    I: Enabling the CS procedure
    I: Sounding to device 0
    I: CS procedures enabled:
    - config ID: 0
    - antenna configuration index: 0
    - TX power: 0 dbm
    - subevent length: 28198 us
    - subevents per event: 1
    - subevent interval: 0
    - event interval: 2
    - procedure interval: 5
    - procedure count: 0
    - maximum procedure length: 1000
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    Data from Reflector 2
    E: empty step data
    Data from Reflector 1
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    E: empty step data
    I: Disabling the CS procedure
    I: counters reset, local:-1, dropped:-1
    E: empty step data
    I: CS procedures disabled.
    I: Enabling the CS procedure
    I: Sounding to device 1
    I: CS procedures enabled:
    - config ID: 1
    - antenna configuration index: 0
    - TX power: 0 dbm
    - subevent length: 28198 us
    - subevents per event: 1
    - subevent interval: 0
    - event interval: 2
    - procedure interval: 5
    - procedure count: 0
    - maximum procedure length: 1000
    I: 2.049362,3.392859,2.921039,2.049362
    I: 2.049362,3.392859,3.176355,2.049362

Children
Related