Distance measurement synchronization via GATT notification?

Hello, I am trying to use the distance measurement library (in NCS 2.8.0 using nrf52833), but instead of using "scanned" events for synchronization I would like to trigger the measurement from inside an connection by sending a GATT write and a notification.

The idea is that the initiator sends a GATT write to a peripheral, which then starts the DM in reflector role and sends a notification back to the initiator which would use this event to start DM in initiator role. Unfortunately the devices don't seem to be able to synchronize this way ("nrf_dm: dm_thread: Ranging failed (nrf_dm status: 1)").

My first question is, is this approach even feasible?

Can DM be done with an active connection?

If not, can you suggest other synchronization methods over BLE other than using scan events? Could disconnection events be used?

Thank you

  • Hi Bruno,

    That should be possible, but we have limited support on this. But there have been questions about this in the past.

    If not, can you suggest other synchronization methods over BLE other than using scan events? Could disconnection events be used?

    Using radio notifications for syncing is an idea. 

    I believe the nrf_dm sample allows you to connect to the GATT Direction and Distance Finding Service. Once connected, advertising and scanning are still active and used for synchronization. Maybe you can use this.

    Regards,

    Elfving

  • Hello, i have tried to use GATT notifications and analyzed the DM timing with the GPIOs. The main problem is that in a connection, all data is exchanged within the connection interval (7.5ms minimum). So notifications usually arrive within a delay of ~7ms. If i adapt CONFIG_DM_INITIATOR_DELAY_US=-7000 it sometimes works, but not reliably since sometimes it takes even longer for the notification to arrive. So I conclude that due to the latency within a connection, it is not feasible to use GATT read/write or notifications as a synchronization point.

    What is the idea of using radio notifications for syncing? The radio notifications would come before each connection interval, so what's the point? Please explain. (also the link is broken).

    Using advertising and scanning for synchronization is ok for a demo but not very useful for a product in my opinion. We need peripherals to consume as little power as possible, and not do any scanning as that is very energy demanding. So as mentioned in the other ticket, we can remove the scanning part in peripherals (I have also tested that) but then that would mean that it would start DM on any "scan" request, and in a real situation scan requests can happen any time from any device, and not only from DM capable NRF devices.

  • Sorry about the bad link, I was thinking of this. Here is a sample on how to use it, and here is another for syncing the time between two nRFs. 

    My understanding is that this would be fast enough way to synchronize for this use-case, but I am bit uncertain about the reasoning here, so I'll ask the relevant R&D. I'll let you know once I hear from them.

    Regards,

    Elfving

  • Hi, thank you for the links! Especially the clock syncing example is very interesting, I will have a closer look on that.

    By now I have working code, which uses the "connected" callback on both sides as a reference point and the DM ranging requests are scheduled relative to that. That works reasonably well so far...

  • I've gotten a response from the relevant team here. 

    So we haven't tried syncing using this way ourselves, not using GATT write and a notification.

    Your original idea should work, as long as you find a way of getting the timing out (forking PPI signals to get the accurate timing out may be one option), though it might just not be very efficient. You could try again after increasing the timeout that is passed to nrf_dm_proc_execute(). 

    One other thing you could try to get a good synchronization is to integrate it with the ideas from this sample: https://github.com/nrfconnect/sdk-nrf/tree/main/samples/bluetooth/conn_time_sync

    Regards,

    Elfving

Related