This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to reduce the time to reduce the time to establish Periodic sync in direction finding ?

Hi, I am Marcous. 

Currently I am doing multiple beacons (transmitters) in direction finding demos. Since I found that there is no way to simultaneously receive the CTE containing IQ values. I just map the order of transmitters and receive IQ values from different beacons at different slots, for example: [tx0, tx0, tx0, tx0, tx1, tx1, tx1, tx1, tx2, tx2, tx2, tx0, tx0, .....] . This actually works well and enables me to receive iq values to determine direction of multiple beacons. And my question is: how can I reduce the time to create sync? 

When I print the log information in the windows, I found that it takes about over 300 ms to create the sync between rx and tx .

In the tx side, I change the gap between each broadcasting with CTE to 0x0021(41ms). However, the total time(found periodic advertising + establish periodic sync) to switch between beacons is much longer than one CTE interval, which means that if move the antenna array in the rx side, I can not calculate the instant directions of each beacons. How can I reduce this time? Thanks a lot!!!

  • Hey Marcous!

    I would advise you to use multiple advertising streams instead of having to resync. The zephyr controller allows you to have several so that you don't need to switch between beacons. The config is called CONFIG_BT_PER_ADV_SYNC_MAX, it is set to 1 by default.

    You might have to tinker a bit more with it in order to get it to work though. For instance:

    - When scanning callback in scan_recv you have to check for extended advertising points, then call the API to create a new sync if that is the case, and enable CTE sampling for that sync.

    - Create_sync needs to be updated too, it uses globals for sync establishment. 

    - cte_recv_cb must match IQ report to appropriate sync instance.

    Best regards,

    Elfving

  • Thanks for your reply, but How do I change the parameter CONFIG_BT_PER_ADV_SYNC_MAX to two or more in nrf connect sdk demos?

  • In the prj.conf or Kconfig file of the project. 

    Open the project folder of the demo, then find prj.conf, then add the line CONFIG_BT_PER_ADV_SYNC_MAX = 3.

    Best regards,

    Elfving

  • Hi Elfving,

    I have been trying to tinker the code as you said. And followings are what I have done.

    -I tried to add extended advertising points to scan_recv but got no idea how to deal with it. Hence I tried to get and record two per_addr(which is per_addr and per_addr1 ) in scan_recv in order successfully and then jump out the k_sem(&sem_per_adv).

    - Next I tried to create two synchronizations in create_sync(), the code is as followed:

    static void create_sync(void)
    {
    	struct bt_le_per_adv_sync_param sync_create_param;
    	struct bt_le_per_adv_sync_param sync_create_param1;
    	int err;
    	int err1;
    	printk("Creating Periodic Advertising Sync...");
    	bt_addr_le_copy(&sync_create_param1.addr, &per_addr1);
    	bt_addr_le_copy(&sync_create_param.addr, &per_addr);
    
    	sync_create_param.options = 0;
    	sync_create_param.sid = per_sid;
    	sync_create_param.skip = 0;
    	sync_create_param.timeout = 0xa;
    
    	sync_create_param1.options = 0;
    	sync_create_param1.sid = per_sid1;
    	sync_create_param1.skip = 0;
    	sync_create_param1.timeout = 0xa;
    
    	err1 = bt_le_per_adv_sync_create(&sync_create_param1, &sync1);
    	err = bt_le_per_adv_sync_create(&sync_create_param, &sync);
    	if (err) 
    	{
    		printk("err failed (err %d)\n", err);
    		return;
    	}
    	if (err1) 
    	{
    		printk("err1 failed (err1 %d)\n", err1);
    		return;
    	}
    	printk("success.\n");
    }

    This code goes wrong when it run at the line of 

    err = bt_le_per_adv_sync_create(&sync_create_param, &sync);
    and the wrong information is err = -16(EBUSY in the errno.h).
    Actually I added the CONFIG_BT_PER_ADV_SYNC_MAX = 3 to prj.conf file and this parameter in the code is changed to 3.
    Just as a reminder, If I chang the order of 
    err1 = bt_le_per_adv_sync_create(&sync_create_param1, &sync1);
    err = bt_le_per_adv_sync_create(&sync_create_param, &sync);
    to 
    err = bt_le_per_adv_sync_create(&sync_create_param, &sync);
    err1 = bt_le_per_adv_sync_create(&sync_create_param1, &sync1);
    The error information becomes err1 = -16, which means it always meets trouble in the latter one.
    Can you help me to create multile sync? Thx a lot !!!
  • Hi, Elfving. 

    Updates:

    From my debugging process, the code always encounters problems when traversing sync_pool, causing the problem of not generating a new sync. Do you have a solution?

Related