BLE Periodic Advertisement Sync Example
Source code path: example/ble/periodic_adv_sync
Supported Platforms
eh-lb52x
eh-lb56x
eh-lb58x
Overview
This example demonstrates the usage of periodic advertisement synchronization.
Usage Instructions
After boot, use finsh command “diss sync create” to create periodic advertisement sync. If created successfully, you can see “PER_ADV_SYNC created [idx]” in the log, where idx is the allocated handle.
Use finsh command “diss scan start [is_dup] [scan_interval] [scan_window] [duration]” to start scan to search for periodic advertisements.
Command example: “diss scan start 1 60 30 30000”. This command will scan continuously for 30 seconds.
If a periodic advertisement is found, it will print “Periodic adv found addr_type [type], addr:0xXX:XX:XX:XX:XX:XX, adv_sid:[adv_sid]”.
To establish periodic advertisement synchronization, use finsh command “diss sync start [addr] [addr_type] [adv_sid] [sync_to]”, where addr, addr_type and adv_sid are the address, address type and advertisement SID printed after finding the periodic advertisement; sync_to represents the sync timeout in units of 10ms
Example: “diss sync start be:56:44:33:22:c2 0 0 80”
Since establishing periodic advertisement sync requires scan to be enabled, the 30-second scan set by the previous command may have stopped when establishing periodic advertisement sync. If scan has stopped, you can see “Scan stopped” in the log. When scan is stopped, you need to restart scan.
After periodic advertisement sync is established, it will print “PER_ADV_SYNC established(addr)” and “per_adv_data:”
Hardware Requirements
Before running this example, prepare:
One development board supported by this example (Supported Platforms).
Mobile device.
Compilation and Flashing
Switch to the example project directory and run the scons command to compile:
> scons --board=eh-lb525 -j32
Switch to the example project/build_xx
directory and run uart_download.bat
, then select the port as prompted to download:
$ ./uart_download.bat
Uart Download
please input the serial port num:5
For detailed compilation and download steps, please refer to the Quick Start Guide.
Expected Results
After the example starts:
It can search for periodic advertisements and establish periodic advertisement synchronization.
Troubleshooting
Reference Documentation
Update History
Version |
Date |
Release Notes |
---|---|---|
0.0.1 |
01/2025 |
Initial version |