PLEASE ROTATE ME
Telink Staff
August 10, 2022
Applications
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.
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.
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.
Note: The following uses the TLSR8258 chip as an example to describe the use of the B85m_module.
Once the mobile phone app and B85m_module establish a Bluetooth connection, data is divided into two directions: data reception and data transmission.
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.
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.
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.
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
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:
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.