目录
  • 一、准备工作
  • 二、编译 BLE UART Server代码
  • 三、编译 BLE UART Client代码
  • 四、测试

BLE串口透传测试

该教程演示如何通过两块开发板实现BLE数据传输测试,A开发板通过串口接收数据,然后通过BLE传输给B开发板,B开发板通过串口将接收到的数据打印出来;同样,B开发板通过串口接收数据,然后通过BLE传输给A开发板,A开发板通过串口将接收到的数据打印出来。在测试中需要一块开发板做为Server端,另外一块开发板做为Client端,两块开发板配对后就可以互发消息了。

一、准备工作

  • 准备2块BearPi-Pico H2821开发板

二、编译 BLE UART Server代码

在Windows下编译操作
  1. 点击左侧的“KConfig”,打开配置界面.

    Alt text

  2. 选择Enable BLE UART Server sample

    Application  --->
        [*] Enable Sample.
        [ ]     Enable the Sample of peripheral.
        [*]     Enable the Sample of products.
        [ ]         Enable all the sample of product, it's just for build.
        [*]         Support BLE UART sample.
                        BLE UART Sample Configuration  --->
                            Select ble uart type (Enable BLE UART Server sample.)  --->
                                    (X) Enable BLE UART Server sample.
                                    ( ) Enable BLE UART Client sample.
        [ ]         Support SLE UART sample.
    
    

    Alt textAlt text

  3. 选择协议

    Protocol  --->
        Select sle ble support  --->
            ( ) Select sle ble central default.
            (X) Select sle ble peripheral.
            ( ) Select sle peripheral.
            ( ) Select sle central.
            ( ) Select ble peripheral.
    
    
    

    Alt text

  4. 按下"Save"键保存配置。

    Alt text

  5. 编译烧录固件

    参考环境搭建教程编译烧录代码

三、编译 BLE UART Client代码

在Windows下编译操作
  1. 点击左侧的“KConfig”,打开配置界面.

    Alt text

  2. 选择Enable BLE UART Client sample

    Application  --->
        [*] Enable Sample.
        [ ]     Enable the Sample of peripheral.
        [*]     Enable the Sample of products.
        [ ]         Enable all the sample of product, it's just for build.
        [*]         Support BLE UART sample.
                        BLE UART Sample Configuration  --->
                            Select ble uart type (Enable BLE UART Server sample.)  --->
                                    ( ) Enable BLE UART Server sample.
                                    (X) Enable BLE UART Client sample.
        [ ]         Support SLE UART sample.
    
    

    Alt textAlt text

  3. 选择协议

    Protocol  --->
        Select sle ble support  --->
            (X) Select sle ble central default.
            ( ) Select sle ble peripheral.
            ( ) Select sle peripheral.
            ( ) Select sle central.
            ( ) Select ble peripheral.
    
    
    

    Alt text

  4. 按下"Save"键保存配置。

    Alt text

  5. 编译烧录固件

    参考环境搭建教程编译烧录代码

四、测试

烧录固件后先启动server设备,再启动client设备,在串口工具的输入框中输入数据并发送,测试server和client设备之间的数据收发,如下图所示。

Alt text