Files
esp-idf/examples/bluetooth/nimble/ble_periodic_sync
Rahul Tank 432cd1ebdd fix(nimble): Improve safety, fix bugs, and update docs across NimBLE examples
- Remove unused headers from examples
- Improve periodic adv/sync example functionality and readability
- Use ble_hs_id_infer_auto() instead of hardcoded BLE_OWN_ADDR_PUBLIC/RANDOM
- Add ble_hs_util_ensure_addr() calls in on_sync for proper address setup
- Use correct ext adv instance (0 instead of 1) in phy_prph, l2cap_coc, multi_conn
- Fix struct name: ble_gap_periodic_adv_enable_params -> ble_gap_periodic_adv_start_params
- Add CONFIG_BT_NIMBLE_GAP_SERVICE guards around ble_svc_gap_device_name_set
- Fix unsafe AD data parsing with bounds checks in central examples
- Fix UUID matching bugs (off-by-one loop condition and byte order) in
  phy_cent, htp_cent, and proximity_sensor_cent
- Fix ble_multi_conn_cent address type to use dynamic inference
- Remove contradictory sm_sc=0 after sm_sc=1 in ble_multi_adv
- Add CONFIG_BT_NIMBLE_EXT_ADV=y to ble_multi_adv sdkconfig defaults
- Check return values for ble_gap_set_host_feat, nimble_port_init
- Update tutorials and READMEs to match code changes
2026-02-25 12:59:48 +05:30
..

Supported Targets ESP32-C2 ESP32-C3 ESP32-C5 ESP32-C6 ESP32-C61 ESP32-H2 ESP32-S3

BLE Periodic Sync Example

(See the README.md file in the upper level 'examples' directory for more information about examples.)

This example performs passive scan for non-connectable non-scannable extended advertisement, it then establishes the periodic sync with the advertiser and then listens to the periodic advertisements.

It uses Bluetooth controller and NimBLE stack based BLE host.

This example aims at understanding BLE periodic sync establishment and periodic advertisement reports.

To test this demo, use the ble_periodic_adv example or any periodic advertiser with SID 2.

Note :

  • Make sure to run python -m pip install --user -r $IDF_PATH/requirements.txt -r $IDF_PATH/tools/ble/requirements.txt to install the dependency packages needed.
  • Currently this Python utility is only supported on Linux (BLE communication is via BLuez + DBus).

How to Use Example

Before project configuration and build, be sure to set the correct chip target using:

idf.py set-target <chip_name>

Hardware Required

  • A development board with a supported SoC (e.g., ESP32-C3, ESP32-C6, ESP32-H2, ESP32-S3, etc.)
  • A USB cable for Power supply and programming

See Development Boards for more information about it.

Build and Flash

Run idf.py -p PORT flash monitor to build, flash and monitor the project.

(To exit the serial monitor, type Ctrl-].)

See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.

Example Output

This is the console output on successful periodic sync:

I (311) BTDM_INIT: BT controller compile version [3a49744]
I (311) phy_init: phy_version 912,d001756,Jun  2 2022,16:28:07
I (351) system_api: Base MAC address is not set
I (351) system_api: read default base MAC address from EFUSE
I (351) BTDM_INIT: Bluetooth MAC: 84:f7:03:08:14:8e

I (361) NimBLE_BLE_PERIODIC_SYNC: BLE Host Task Started
I (941) NimBLE: Periodic sync event :

I (941) NimBLE: Periodic adv report event:

I (4241) NimBLE: Periodic adv report event:

I (7541) NimBLE: Periodic adv report event:

I (10841) NimBLE: Periodic adv report event:

Troubleshooting

For any technical queries, please open an issue on GitHub. We will get back to you soon.