PLEASE ROTATE ME
August 22, 2022
Telink’s Wiki website provides software SDKs of various application scenarios for customers to use. This series of articles focuses on the “Bluetooth® Low Energy (LE) Single Connection,” a SDK for single-connection applications where a Bluetooth chip makes a point-to-point connection with a host (usually a mobile phone) or a host makes a point-to-point connection with another host.
This article describes the uses of this SDK’s B85m_ble_sample routine in detail to help customers familiarize themselves with it quickly and speed up the development of projects.
B85m_ble_sample in the single-connection SDK is compatible with 825x chips and 827x chips, so the compilation options are divided into 825x_ble_sample and 827x_ble_sample (which, moving forward, will collectively be referred to as ble_sample).
The ble_sample routine is a simple slave demo with broadcast and connection capabilities. The BLE service has HID service, which, after a connection has been made, can be itemized as a HID device and can control volume, input numbers, and perform other functions.
Let’s look at the TLSR8258 chip as an example. There are two commonly used development boards. One is the TLSR8258 Development Board (model C1T139A30_V1.2), as shown in the following figure:
The other is the TLSR8258 Dongle board (model C1T139A3_V2.0A), as shown below:
Similarly, the TLSR8278 chip has these two types of development boards, which will not be described here.
1. By default, the current test is enabled in the code (key presses are disabled). Disable the current test first. In the ble_sample/app_config.h file, the modifications are as follows:
#define TEST_CONN_CURRENT_ENABLE 0
2. Depending on the type of development board, the macro definitions enabled in the code are different. In the ble_sample/app_config.h file, the modified macro definitions are as follows:
3. Clean the project, rebuild, compile, and download the generated firmware to the development board. Power on again or reset it once.
4. On the phone → Settings → Bluetooth page. Scan to “VHID.” Click to establish a connection and select pairing.
5. Click the button on the development board and the corresponding display will appear on the mobile phone.
On the TLSR8258 Development Board:
On the TLSR8258 Dongle Board:
*Note: The ble_sample routine is an HID device and does not need to be used in the mobile app. If you use the mobile app to connect, you will not see the effects from the above buttons.
By default, the ble_sample routine enables the current test function and disables the display of buttons and LEDs.
#define TEST_CONN_CURRENT_ENABLE 1
If the developer needs to test the low-power data of various broadcast intervals or connection intervals, the main parameters to modify are as follows:
1. Transmission power
The higher the transmission power, the higher the instantaneous current of RF transmission. The macros are defined as follows:
#define MY_RF_POWER_INDEX RF_POWER_P0dBm
2. Broadcast interval
The smaller the broadcast interval, the more frequently the RF sends data and the higher the power consumption. The macros are defined as follows:
#define MY_ADV_INTERVAL_MIN ADV_INTERVAL_1S
#define MY_ADV_INTERVAL_MAX ADV_INTERVAL_1S
It is recommended to set the maximum and minimum values as the same or to differ by 5ms. If the maximum value is much larger than the minimum value, the SDK will use the maximum value by default.
3. Broadcast channel
There are a total of three broadcast channels. When all three channels are selected, each broadcast is sent once in each channel. The macros are defined as follows:
#define MY_APP_ADV_CHANNEL BLT_ENABLE_ADV_ALL
4. Broadcast content
For broadcast data and scan response data, the larger the set data length (maximum 31 bytes), the longer each broadcast transmission will take, and the higher the power consumption will be. The tbl_advData[ ] array is the broadcast content data; the tbl_scanRsp[ ] array is the scan response data.
5. Connection interval
After the connection is established, the slave can actively change the connection parameters. The API functions used are:
For specific function descriptions, please refer to the documentation in the handbook.
After setting the above, you can recompile the ble_sample routine, download it to the development board, and use a current analyzer and other equipment to test power consumption.
*Note: When testing power consumption on the TLSR8258 Development Board, unplug the jumper caps J29 and J35. If you’re using the TLSR8258 Dongle Board, unplug the J8 jumper cap.
1. The ble_sample routine enables the low-power function by default, and the macro is defined as:
#define BLE_APP_PM_ENABLE 1
#define PM_DEEPSLEEP_RETENTION_ENABLE 1
2. In the ble_sample routine, if the broadcast exceeds 60s, it will automatically enter deep sleep mode and stop broadcasting. If after a connection has been established and there are no keystrokes within 60s, it will disconnect and enter deep sleep mode. The code is shown in the figure below. In blt_pm_proc(), developers can make changes as needed.