AoA direction finding sync delete/disable

I'm working on an application with the NRF52833 as an AoA receiver. 

My application requires that I am able to enable the scanner for a set period of time and then stop scanning. I have an initial AoA dev/demo set up that is working relatively well with constant CTE scanning, but I am having trouble getting the stop/restart functionality working correctly with the AoA library.

My first scan after startup is working as expected, but when I attempt to stop and restart the scan a second time I cannot seem to get the second init sequence to work correctly.

Because I may have different tag(s) in the area after I stop and restart my scanner each time, I assumed it would be best to delete my existing sync when I stop so that I can establish a new sync on the next startup. So I have been calling bt_le_per_adv_sync_delete() when I finish my scan sequence.

However, on the next startup and sync attempt I get a '-22' (-EINVAL) error from bt_df_per_adv_sync_cte_rx_enable(). It kind of seems like the sync->flags field from my sync structure are not getting properly reset when I delete the prior sync such that when I try to start a new sync it thinks that my sync object is perhaps still synced. I don't think there is an issue with my parameters or config because my first scan after startup functions without an error, this only happens on subsequent scans so must be an issue with my stop/cleanup process.

What is the proper method for user termination of a sync such that the sync can be restarted later (with potentially a new tag)?

  • After further debug I found a bug in my code that caused me to skip waiting for the sync callback to occur before proceeding to calling bt_df_per_adv_sync_cte_rx_enable(), which is why I was getting -EINVAL due to a missing sync.

     

    That said, is deleting the sync with bt_le_per_adv_sync_delete() the correct method for terminating an ongoing sync or is there a better/cleaner way to do this?

  • Hi Dan

    Using the bt_le_per_adv_sync_delete() is perfectly fine/correct to delete/terminate/cancel an ongoing advertising sync object. I guess instead of deleting the sync, you can disable receiving periodic advertiisng reports for a sync with bt_le_per_adv_sync_recv_disable and reenable said sync with bt_le_per_adv_sync_recv_enable when necessary. That might be a cleaner option for you perhaps?

    Best regards,

    Simon

Related