Telink white logo with Telink word in small size

We noticed you are using Internet Explorer.

We recommend using one of the below listed browsers to enjoy the best experience of our website.

Click here to download:

Chrome

Firefox

Safari

Edge

Telink white logo with Telink word
Rotate your device top arrow

PLEASE ROTATE ME

Rotate your device bottom arrow
Preloader image
loading...
Telink white logo with Telink word in small size

Telink’s Bluetooth® LE Single Connection SDK (1): An Overview of the B85m_module Routine

Telink Staff

August 10, 2022

Applications

Bluetooth screen up close

Telink’s Wiki website provides various software SDK application scenarios. Several articles in this series focus on “Bluetooth® LE Single Connection,” an SDK for single-connection applications. In these applications, the Bluetooth chip establishes a point-to-point connection with the host (usually a mobile phone) or makes peer-to-peer connections with other devices.

Below, we describe the B85m_module in detail so that users can quickly familiarize themselves with it and speed up their project development progress.

1. Description of Module Routine

The B85m_module in the single-connection SDK uses TLSR825x chips and TLSR827x chips, so the compilation options are divided into 825x_module and 827x_module. With the included BLE-based data transmission functions, users do not need to worry about the complex implementation details of BLE and can just focus on the transmitted data. Telink also provides a set of proprietary instructions for data transmission. If users are more accustomed to using AT commands, they can replace the instructions in the routine.

2. Code Compile Configuration

If the developer directly compiles the source codes of the 825x_module or the 827x_module (which, moving forward, will be referred to as the B85m_module), the following error will occur:

This error occurs because implementing the B85m_module is more complex and needs to be compiled with the 32K retention configuration. Note that the SDK defaults to the selected 16K retention configuration.

Solution: To modify the retention configuration, please refer to the introduction of the Software bootloader in Chapter 1.3 of the SDK Handbook and use the 32K boot.link file and the cstartup_*_32K.S startup file. 

3. Hardware Connection Diagram

Note: The following uses the TLSR8258 chip as an example to describe the use of the B85m_module.

  1. Burn the compiled 825x_module.bin firmware to the 8258 development board. The default UART tx in code is PB1, and UART rx is PB0. Next, set up according to the hardware connection diagram. *Note: Make sure you’re connecting the UART tx of the chip to the UART rx of the serial port tool and the UART rx of the chip to the UART tx of the serial port tool.
  2. Open the serial port tool software on the PC. Set the baud rate to 115200, the data bit to 8, and the stop bit to 1.
  3. The app on the mobile phone uses LightBlue. It should scan the “kModule” Bluetooth device and establish a connection.
  4. If a pairing request pops up, select pairing. The SMP pairing function is enabled by default. If this function is not required, set the BLE_SECURITY_ENABLE macro definition in the app_config.h file to 0, and then recompile to generate the firmware.

4. Data Transfer
Once the mobile phone app and B85m_module establish a Bluetooth connection, data is divided into two directions: data reception and data transmission.

4.1 Data Reception

Data reception (Phone->Module) means that the mobile app sends data to the Bluetooth chip, which is then printed out via UART and displayed on the PC’s serial port tool software.

1. Bluetooth output

When you click connect or disconnect on the LightBlue app, the serial port tool will display Bluetooth connection events (hex data FF 02 83 07) and Bluetooth disconnect events (hex data FF 02 84 07), as shown in the following figure.


Note: FF028D07 is an event for map channel replacement.

2. Mobile phone sends hex data 00 11 22 33 44 55 66

On the LightBlue software, the UUID for data transmission is 0x000102030405060708090a0b0c0d2b11 (note that the UUID in the code is in reverse order). Click the red box to enter the data you want to send.

As shown in the figure below, the serial port tool software on the PC displays the received data. Note that the received data has a format, and the first 7 bytes are the header of the data.

4.2 Data Transmission

Data transmission (Module -> Phone) means that the serial port tool software on the PC side sends data to the Bluetooth chip, which then sends it to the mobile phone via BLE. You should see the transmission displayed on the LightBlue software.

  1. Enable notification permissions on the mobile app

The Bluetooth chip reports data to the mobile app using the notify method. You’ll need to enable the notification permissions before the mobile phone can monitor the transmitted data. Otherwise, the mobile app will not receive it.

Click “Listen” on the LightBlue software. A “Stop Listening” display signals that the permissions have been enabled.

  1. Enable wake-up pin

The B85m_module program enables low power consumption by default. The Bluetooth chip will automatically enter low power consumption mode and regularly wake to maintain a Bluetooth connection. But since it is in the low power consumption mode most of the time, the GPIO must first wake the chip before the UART can start receiving data.

The default setting marks PA2 as a high-level wake-up pin. Manually pull up the chip’s PA2 pin and connect it to 3.3V. You can wake up the Bluetooth chip and disable low power consumption. The corresponding macro definition in the app_config.h file should look like: 

#define GPIO_WAKEUP_MODULE      GPIO_PA2

  1. Send the data

In the serial port tool, enter the hex data: 1c ff 16 00 11 00 01 02 03 04 05 06 07 08 09 00 01 02 03 04 05 06 07 08 09 00, and then click Send.

Hex formatting instructions:

  • 1C FF: Indicates data send command
  • 16 00: Indicates data length, handle value (2bytes) + data length (20bytes)
  • 11 00: The handle value used for data transmission is 0x0011, which results from the Little Endian byte sequence.
  • 01 02 … 00: Indicates the data awaiting transmission.

Note that the length of the data needs to stay within 20 bytes. You can check the MTU and DLE functions in the Handbook to enable long packets if you want to send longer data.

You can view the received data on the LightBlue software, as shown in the figure below.