Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Bluetooth - Log System

Technology badge License badge SDK badge Build badge Flash badge RAM badge

Type badge Type badge Type badge

Description

Logging is very important for developing embedded products. This is especially true for connection-based wireless products because the use of breakpoints will probably result in dropped connections, whereas issues can be easily addressed by walking through the log.

This example introduces a simple implementation of logging on the EFR32 based devices. The key point of the example code is to introduce a way to classify the log into different levels, where each level of the log has its own identifier. Let’s start with 2 design sketches, which demonstrate outputting the log via RTT and VCOM(UART).

rtt_viewer

Using RTT

vcom

Using VCOM

The images above show different levels of logging in different colors. This example introduces 5 logging levels, as shown below.

Type color
Error (highest level) Red
Warning Yellow
Information Blue
Debug Green
Verbose (lowest level) White

Table Of Contents


SDK version


Software Required


Hardware Required


Connections Required

  • Connect the Bluetooth Development Kits to the PC through a compatible-cable. For example, a micro USB cable for the BGM220 Bluetooth Module Explorer Kit.

Setup

To test this application, you can either create a project based on an example project or start with a "Bluetooth - SoC Empty" project based on your hardware.

Note

Make sure that the bluetooth_applications repository is added to Preferences > Simplicity Studio > External Repos.

Create a project based on an example project

  1. From the Launcher Home, add your hardware to My Products, click on it, and click on the EXAMPLE PROJECTS & DEMOS tab. Find the example project filtering by "logging".

  2. Click Create button on the Bluetooth - Log System RTT or Bluetooth - Log System VCOM example. Example project creation dialog pops up -> click Create and Finish and Project should be generated.

    create_project

  3. Build and flash this example to the board.

Start with a "Bluetooth - SoC Empty" project

  1. Create a Bluetooth - SoC Empty project for your hardware using Simplicity Studio 5.

  2. Copy the attached src/app.c, inc/**/log.h files into your project (overwriting existing app.c).

    • inc/rtt/log.h – the log will be out from J-Link RTT.
    • inc/vcom/log.h – the log will be out from VCOM via USB.
  3. Open the .slcp file. Select the SOFTWARE COMPONENTS tab and install the software components:

    • If you use J-Link RTT for logging, find and install the following components:
      • [Third Party] → [SEGGER] → [RTT] → [SEGGER RTT]
      • [Third Party] → [SEGGER] → [RTT] → [SEGGER RTT printf]
    • If you use the VCOM port (UART) for logging, find and install the following components:
      • [Services] → [IO Stream] → [IO Stream: EUSART] → default instance name: vcom
      • [Platform] → [Board] → [Board Control] → enable Virtual COM UART
      • [Application] → [Utility] → [Log]
  4. Define LOG_LEVEL in log.h. The definition of LOG_LEVEL determines, which level of logging is sent to the terminal. As you can see from the table above, an error has the highest level while verbose has the lowest level. For example, if the LOG_LEVEL is defined as the information level, then error, warning and information logs are sent to the terminal. The debug and verbose logs, which have a lower level than information, are not sent to the terminal. See the figure below, which shows the log as an information level without modifying anything from the first figure, using RTT.

    rtt_viewer_info_level

  5. Build and flash the project to your device.

Note

  • A bootloader needs to be flashed to your board if the project starts from the "Bluetooth - SoC Empty" project, see Bootloader for more information.

How It Works

  1. On your PC open a terminal program and connect to the chosen port (e.g. you can use Tera Term to connect via VCOM and RTT Viewer to connect via DEBUG port).

  2. Reset your device and observe the log messages.

  3. You may also use a Bluetooth connection app (Simplicity Connect) to see more logs. Follow the below steps to test the example with the Simplicity Connect application:

    • Open the Simplicity Connect app on your smartphone and allow the permission requested the first time it is opened.
    • Find your device in the Bluetooth Browser, advertising as Empty Example, and tap Connect then Disconnect and check the logs.

    rtt_viewer_usage Using RTT viewer

    vcom_usage Using VCOM

You can add new logs to your project. The following are 5 corresponding functions to send the log. The input parameter of these five functions is the same as standard printf();.

  • LOGE() – Send ERROR log.
  • LOGW() – Send WARNING log.
  • LOGI() – Send INFORMATION log.
  • LOGD() – Send DEBUG log.
  • LOGV() – Send VERBOSE log.

Use these functions in your code to print different-level logs.


Report Bugs & Get Support

To report bugs in the Application Examples projects, please create a new "Issue" in the "Issues" section of bluetooth_applications repo. Please reference the board, project, and source files associated with the bug, and reference line numbers. If you are proposing a fix, also include information on the proposed fix. Since these examples are provided as-is, there is no guarantee that these examples will be updated to fix these issues.

Questions and comments related to these examples should be made by creating a new "Issue" in the "Issues" section of bluetooth_applications repo.