Sync fail for Periodic Advertisement

I ran periodic_adv and periodic_sync but I see that in the periodic_sync running node after the sync it calls sync terminate. I don't understand why if it is periodic advertisement? 

I use nrf connect sdk1.9.0.

Periodic Adv logs:

.*** Booting Zephyr OS build v2.7.99-ncs1 ***
15>
15> Starting Periodic Advertising Demo
15>
15> bt_hci_cmd_send_sync: opcode 0x0c03 len 3
15> bt_hci_cmd_send_sync: opcode 0x1003 len 3
15> bt_hci_cmd_send_sync: opcode 0x1001 len 3
15> bt_hci_cmd_send_sync: opcode 0x1002 len 3
15> bt_hci_cmd_send_sync: opcode 0x2003 len 3
15> bt_hci_cmd_send_sync: opcode 0x201c len 3
15> bt_hci_cmd_send_sync: opcode 0x2001 len 11
15> bt_hci_cmd_send_sync: opcode 0x0c01 len 11
15> bt_hci_cmd_send_sync: opcode 0xfc01 len 3

15> [00:00:00.506,530] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
15> [00:00:00.506,530] <inf> bt_hci_core: HW Variant: nRF52x (0x0002)
15> [00:00:00.506,561] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 2.7 Build 99
15>
15> bt_hci_cmd_send_sync: opcode 0xfc02 len 3
15> bt_hci_cmd_send_sync: opcode 0xfc03 len 3
15> bt_hci_cmd_send_sync: opcode 0x1009 len 3
15> bt_hci_cmd_send_sync: opcode 0xfc09 len 3
15> bt_hci_cmd_send_sync: opcode 0x2005 len 9 

15> Set Periodic Advertising Data.
15> bt_hci_cmd_send_sync: opcode 0x203f len 258
15> done.

Periodic Sync logs:

# SEGGER J-Link RTT Viewer V6.88a Terminal Log File
# Compiled: 15:12:58 on Nov 18 2020
# Logging started @ 08 Mar 2022 15:37:42
15> [DEVICE]: 1F:29:0C:DD:6B:0F (random), AD evt type 5, Tx Pwr: 127, RSSI -60 Test Periodic Advertising C:0 S:0 D:0 SR:0 E:1 Prim:
15> -------type: 9 Data received: Length =25, data = Test Periodic AdvertisingÖ{SJàç÷obçÓÏ‹ÏCÇ ----------
15> [DEVICE]: 1F:29:0C:DD:6B:0F (random), AD evt type 5, Tx Pwr: 127, RSSI -66 Test Periodic Advertising C:0 S:0 D:0 SR:0 E:1 Prim:bt_hci_cmd_send_sync: opcode 0x2044 len 17
15> success.
15>
15> Waiting for periodic sync...

15> -------type: 9 Data received: Length =25, data = Test Periodic AdvertisingÖ{SJ^Tm«qÕñ1n×ßÇŠªÐ»´¼È)[ÜÈä§év+-ÀKƒÄ-“âVRïM|²…

15> sync_cb: PER_ADV_SYNC[0]: [DEVICE]: 1F:29:0C:DD:6B:0F (random) synced, Interval 0x03c0 (1200 ms), PHY LE 2M
15>
15> term_cb: PER_ADV_SYNC[0]: [DEVICE]: 1F:29:0C:DD:6B:0F (random) sync terminated
15>
15> Periodic sync established.
15>
15> Waiting for periodic sync lost...
15>
15> Periodic sync lost.
15>
15> Waiting for periodic advertising...
15>

  • Hi

    Have you made any changes at all to the sample projects? There must be some function calling this terminate callback term_cb() which is causing the periodic sync to be terminated and lost. Are both the advertising and central devices nRF52832 DKs or some other boards?

    Best regards,

    Simon

  • Hi Simon, Just to be sure that the periodicity is maintained I remove the stop functions as below from Periodic Adv logs:

    printk("\nStart Extended Advertising...");
    err = bt_le_ext_adv_start(adv, BT_LE_EXT_ADV_START_DEFAULT);
    if (err) {
        printk("Failed to start extended advertising (err %d)\n", err);
        return;
    }

    while (true) {

    //for (int i = 0; i < 3; i++)
    {
        k_sleep(K_SECONDS(10));

        mfg_data[2]++;

        printk("\nSet Periodic Advertising Data...");

        err = bt_le_per_adv_set_data(adv, ad, ARRAY_SIZE(ad));
        if (err) {
            printk("Failed (err %d)\n", err);
            return;
        }
        printk("\ndone.");
    }

    /*
    k_sleep(K_SECONDS(10));

    printk("Stop Extended Advertising...");
    err = bt_le_ext_adv_stop(adv);
    if (err) {
    printk("Failed to stop extended advertising "
    "(err %d)\n", err);
    return;
    }
    printk("done.\n");

    k_sleep(K_SECONDS(10));
    */
    }

    Moreover, without this change also I doubt the devices are being sync as there is a for loop for 3 messages.

    Can you please check?

    Yes, for both the application, I am using nrf52832 board.

  • An update: when I enable CONFIG_BT_LL_SW_SPLIT=y, then I don't see the sync termination callback.
    It seems okay.

    Now when I send small data size (I think sent on primary channels) then I see it is received at the recv_cb() but when the packet size is large e.g. 80 bytes (which should be send on the secondary channels) the recv_cb() has zero byte received.
    Can you please let me know how to check the data on secondary channels?

  • Update:

    Based on https://github.com/zephyrproject-rtos/zephyr/discussions/43092 

    I changed CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX and it is able to receive data on recv_cb()

Related