BLE central and peripheral Example

Source code path: example/ble/central_and_peripheral

Supported Platforms

All platforms

Overview

This example demonstrates how to simultaneously implement GAP central and peripheral roles as well as GATT client and server on this platform.

Usage Instructions

  1. The finsh commands for this example can be printed by entering “diss help” to show commands and usage methods.

  2. When operating as a slave device, the board starts advertising upon boot with the name SIFLI_APP-xx-xx-xx-xx-xx-xx, where xx represents the Bluetooth address of the device. It can be connected via BLE apps on mobile phones.

  3. When operating as a master device, you can search for other slave devices and initiate connections through finsh commands.

  4. When operating as a GATT server, write and read operations can be performed from the mobile client, or by enabling CCCD, the device will update the characteristic value every second.

  5. When operating as a GATT client, you can search and display the server’s database through finsh commands, and perform read or write operations on characteristic values.

Hardware Requirements

Before running this example, prepare:

Compilation and Flashing

Switch to the example project/common directory and run the scons command to compile:

> scons --board=eh-lb525 -j32

Switch to the example project/common/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:

  1. It can be discovered and connected by mobile BLE apps, allowing corresponding GATT characteristic value read/write operations.

  2. It can search for other BLE devices, connect to them and search the connected device’s GATT database, while performing GATT read/write operations.

Troubleshooting

Reference Documentation

Update History

Version

Date

Release Notes

0.0.1

01/2025

Initial version