Introduction

This article is for people who only have one WSTK and want to implement central role on it. If you have more than one WSTK, you could probably go through the SPP-over-BLE example which implements both the central and peripheral roles. Below is the link:

http://community.silabs.com/t5/Bluetooth-Wi-Fi-Knowledge-Base/SPP-over-BLE-C-example-for-BGMxxx/ta-p/195554

 

In case you only have one WSTK, we could use the smartphone as the peripheral and GATT server, then implement the central role and GATT client on the WSTK.

 

The typical connection process and GATT operations after connection are shown as below:

  1. Scanning for nearby advertisements, you could add your own filter on the advertisement or scan response to make decision which device the central device should connect to.
  2. After filtered device is found, establish connection.
  3. After connection established, discover all services and characteristics.
  4. Configure Client Characteristic Configuration(CCC) for characteristics if needed.

This is the typical behaviors central device does while connecting to a peripheral, but not all the processes are mandatory.

 

How to use this example

To run this example, you need to have below devices.

  • An EFR32BG or EFR32MG based board – Although this example was originally developed for BRD4103A Rev A01, on which there is an EFR32BG12 chip, it can be easily to migrate to other EFR32 variant based devices.
  • An Android smartphone – Make sure that this device supports BLE both on the hardware and software side, Android has BLE software support from Android 4.3.

GATT Server information, I added a so-called “Demo service” into the server, and this service contains 2 characteristics “NOTIFY_CHAR” and “RW_CAHR”.

 

UUID

Properties

Demo Service

df6a8b89-32d1-486d-943a-1a1f6b0b52ed

 

NOTIFY_CHAR

0ced7930-b31f-457d-a6a2-b3db9b03e39a

Notify

RW_CAHR

fb958909-f26e-43a9-927c-7e17d8fb2d8d

Read and Write

 

 

I attached the source code for the central which is based on BRD4103A Rev A01 radio board and Bluetooth SDK v2.4.0.1, as well as the apk file for Android smartphones. Though the project is based on BRD4103A Rev A01, it’s not hard to migrate to other P/N to fit your board. You could follow below steps to use them.

  1. Import the project to your SSv4, add symbol definition “RETARGET_VCOM” to use UART via USB cable, then compile and flash to your BRD4103A Rev A01 board. For more information about UART re-target, you could go through this article. http://community.silabs.com/t5/Bluetooth-Wi-Fi-Knowledge-Base/Retarget-stdio-to-UART-in-BLE-SDK-2-0-0-examples/ta-p/178710
  2. Or you can directly flash Central_Example.hex file into BRD4103A Rev A01 board, then install the apk file to your Android smartphone.
  3. Open a serial terminal to get the information of central side, open the app from smartphone. They will connect automatically and enable notification and send notification periodically.
  4. Press PB0 on the WSTK will write 0x01 or 0x05 to RW_CHAR back and forth, the notification interval depends on the value of RW_CHAR, for example, if the value is 5, then the notification interval is 5 seconds. Pressing PB1 will read back the value of RW_CHAR.

Below are screenshots of the serial terminal and smartphone.

terminal.png

S70706-170904.jpg

Android App

My expertise is not on Android side, I just wanted to develop a simple app which can help to demonstrate the central implementation on EFR32 chipset. I won’t spend a lot of time to test on the Android side, so if there are problems with the app, maybe you could ask Android develop engineer for help.

 

Tested devices are shown below

Model

Android version

Samsung Galaxy Tab S3

7.0

MEIZU MX_4

5.1

 

One known issue

 

  • CCC descriptor – CCC descriptor has the UUID 0x2902, but Android doesn’t support 16-bit UUID, so it needs to be change to 128-bit UUID - 00002902-0000-1000-8000-00805f9b34fb. The API gecko_cmd_gatt_set_characteristic_notification will return error that it can’t find CCC descriptor with UUID 0x2902 in the characteristic. So, I write the next handle of NOTIFY_CHAR which is the location of CCC descriptor of this characteristic on the server side as workaround. This problem didn’t happen when I tested with Android 7.0 devices. 

 

Android app source code is available from GitHub - https://github.com/fuzhen011/Android-Peripheral

  • Knowledge Base Articles
  • Bluetooth Low Energy
  • Bluetooth Classic
  • Hi,

    Just few questions here:

     

    - In How to use this example, Sept 2, I have no idea about "Central_Example.hex" file. I can't find it from unzipped "Central_Client_Exmple" folder. How can I get it?

    - And for "flash Central_Example.hex file into BRD4103A Rev A01 board", do you mean I can do this through "Flash Programmer" by selecting "Central_Example.hex" in File(please enter a valid path)? 

    - After importing "Central_Example", I got some errors in main.c (as screenshot shown below). Will this be solved by flashing hex file into the board?

    errors in main.c.png

    Sorry, I'm pretty new to simplicity studio and Silabs...

    (P.S. I'm using Thunderboard Sense)

     

    Many Thanks,

    GB

    0