BLE Peripheral Example

Source path: example/ble/peripheral

Supported Platforms

All platforms

Overview

This example demonstrates how this platform implements GAP peripheral and GATT server functionalities.

Usage

  1. As a slave device, advertising will be enabled at startup with the advertising name SIFLI_APP-xx-xx-xx-xx-xx-xx, where xx represents the Bluetooth address of this device. Connection can be established through a mobile BLE APP.

  2. As a GATT server, write and read operations can be performed from the mobile device, or CCCD can be enabled, and the device will update the characteristic value every second.

  3. In the initialization stage, bond_ack is set to BOND.Pending by default. You need to pay attention to CONNECTION_MANAGER_BOND_AUTH_INFOR and call connectionManager_bond_ack_reply in time.

connection_manager_set_bond_ack(BOND_PENDING);

4.You can reset the IO by setting IO cap to GAP_IO.cap_DISPLAY_ONLY by default, or you can also reset the IO by using the finsh command cmd_diss set_io iocap.

connection_manager_set_bond_cnf_iocap(GAP_IO_CAP_DISPLAY_ONLY);
  1. When INPUT_ONLY is set, the key must be entered by the finsh command cmd_diss set_key conn_IDX key

  2. The finsh command cmd_diss set_key conn_idx sec_level can be used to request the central to initiate a pairing

Hardware Requirements

Before running this example, prepare:

Compilation and Flashing

Navigate to the example project directory and run the scons command to compile:

> scons --board=eh-lb525 -j32

Navigate to the example’s project/build_xx directory, run uart_download.bat, and select the port as prompted to download:

$ ./uart_download.bat

     Uart Download

please input the serial port num:5

For detailed steps on compilation and downloading, please refer to the relevant section in the Quick Start Guide.

Expected Results

After the example starts:

  1. The device can be discovered and connected by mobile BLE APP, and corresponding GATT characteristic value read/write operations can be performed.

  2. By modifying io and then initiating pairing on the mobile terminal, different pairing authentication methods can be implemented.

  3. You can also initiate an encryption request from the periphery development board side and then pair it through the finsh command.

Troubleshooting

Reference Documentation

Update History

Version

Date

Release Notes

0.0.1

01/2025

Initial version