Logging is very important for developing embedded products, especially for connection based wireless products because the use of breakpoints will probably result in dropped connections. Whereas, we can easily address problems by walking through the log. This article will introduce a simple implementation of logging on EFR32 based devices. The key point of this article is to introduce a way to classify the log into different levels, and each level of log has its own identifier.
Introduction
Let’s start with 2 design sketches, which demonstrate outputting the log via RTT and VCOM(UART).
Figure 1. Using RTT
Figure 2. Using VCOM
From the pictures, you can see the different level of logging uses different colors, this article introduces 5 levels of logging as below.
Type
Error(Highest Level)
Warning
Information
Debug
Verbose(Lowest Level)
Color
Red
Yellow
Blue
Green
White
Table 1.Log types and colors
Settings
The symbol LOG_PORT, defined in log.h, can be set to SEGGER_JLINK_VIEWER or PORT_VCOM to determine which terminal the output should be sent to.
SEGGER_JLINK_VIEWER – the log will be out from J-Link RTT.
PORT_VCOM
If VCOMis enabled, the log will be out from VCOM via USB.
If VCOMis disabled, the log will be out from the UART TX pin directly.
The definitionofLOG_LEVEL in log.h determines which level of logging should be output to the terminal. As you can see from the table 1, error has the highest level while verbose has the lowest level. For example, If the LOG_LEVELis defined as information level, then error, warning and information log will be sent to terminal, the debug and verbose log which have lower level than information will not be sent to the terminal. See figure 3, which shows the log as information level without modifying anything from figure 1.
Figure 3. Log with information level
Logging Functions
There 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.
How to migrate it to your project
Follow below steps to enable this feature in your project and customize it to meet your requirements.
Add #include “log.h” and INIT_LOG(); to the initialization area, just as the attached main.c.
Modify the project settings, add ${workspace_loc:/${ProjName}/third_party/RTT}/"${workspace_loc:/${ProjName}/log_system}" to include paths
Set the HAL_VCOM_ENABLE symbol in hal-config.h to 1 if needed.
After all the above is done, your project should be able to send the log to the terminal.
Some notes.
The main.c in the attachment is based on Bluetooth SDK v2.8.1, if you are using other version than it, it might not work if you simply replace it because the structure changes of different SDKs. In this case, you need to modify the code manually as the second half of step 2.
This log system can be used to any EFR32 devices and it should be possible to use it on EFM32 device directly or with a few changes.
While developing with Silicon Labs Bluetooth SDK, users can use the API – gecko_cmd_le_gap_bt5_set_adv_data() to set the advertisement and scan response data. The data has a standard format, whereas the data passed to above API is uint8array. This article will focus on adding a middle layer between user application and the BG stack API to set the advertisement payload, which makes the payload more straightforward, visible and easier to understand for users.
For more information about the advertising data, you can go to the Bluetooth KBA Index and see the “Advertising” category.
Introduction
Below is the architecture of the advertisement constructor, which is developed on the latest Bluetooth SDK - v2.8.1, it can also be used on other versions of SDK directly or with just simple modification, depending on the specific SDK version.
adv_cons.c
adv_cons_ret_t construct_adv(adv_t adv) – function to set the advertisement and scan response data according to the input parameter.
void setup_adv(void) – example function to show how to set up advertisement and scan response data, the first three elements are used to set the advertisement data and the fourth element is used for scan response data.
adv_cons.h
ad_type_t – enumeration of all the assign numbers.
adv_packet_type_t – enumeration of all values for scan_rsp parameter of gecko_cmd_le_gap_bt5_set_adv_data()
adv_t – complete information of the advertisement or scan response data to be set.
The example sets the advertisement and scan response data as below:
Advertisement
Flags – 0x06
Complete local name – “AdvC”
More 128 uuids – Silicon Labs OTA service UUID
Scan response
Manufacturer specific data
Company ID – 0x02FF, Silicon Labs
Data - “KBA – Adv Constructor”
Import it to your project
Copy adv_cons.c and adv_cons.h to your project.
Add include ”adv_cons.h” to main.c
Call setup_adv() after gecko_evt_system_boot_id event received
Modify the second parameter of gecko_cmd_le_gap_start_advertising in main.c to le_gap_user_data.
Compile and run, verify it by e.g. Blue Gecko app, Figure 1 is a Blue Gecko app screenshot, from where you can see the advertisement details. Figure 2 is the breakdown of the advertisement payload and figure 3 is the breakdown of the scan response payload.
Schematics and other documentation for radio boards can be accessed easily from Simplicity Studio.
Studio is context sensitive, meaning it will try to show you the relevant content for the hardware that you are working with. You can plug in your kit using USB and Studio will recognize the kit automatically. In that case, the kit details will show up in the Devices window.
Alternatively, you can manually enter the kit / radio board number in the Solutions window. Studio has auto-complete feature that will suggest you list of available options, it is enough to enter just the first part of the board or kit ID (for example, typing BGM111 will show a list of all BGM111 radio boards). This method allows you to access schematics and other documentation for kits even if you don't have the physical kit available. For example, you can check the docs and schematics before even ordering a kit.
Following screenshot shows an example how to locate schematics, assembly drawing etc. for BGM13P radio board (BRD4306A). Note that the item that is selected in the Devices or Solutions tab dynamically changes the content that is shown on the right hand side of the window.
This same method can be used to access other documentation relevant to your target hardware, including:
Bluetooth Mesh Knowledge Base Articles are still VALID and maintained here.
Introduction
This Knowledge Base Article (KBA) aims to act as a “master” KBA which keeps a curated index of all the Bluetooth related KBAs divided into logical categories for an easier and more convenient look-up. It may also include non-KBA content which is relevant for designing your Bluetooth application (e.g. app notes or web pages).
If you are just getting started with Silicon Labs Bluetooth solutions then your starting point should be QSG139: Getting Started with Bluetooth® Software Development. At the end of that document you are presented with the flowchart below which shows what documents should be read and in which order. Additionally you can check out our Bluetooth Training page for more training material.
Knowledge Base Articles List
The content listed below is grouped together into categories to make it easier for you to find what you are looking for. Want to know more about security, or looking for a peripheral example, then head down to the right section and see what KBAs or other relevant content has been created under those topics.
Each category has an associated index number and each individual KBA has its own index number within the category. The KBA's are prefixed with KBA_BT_AABB where AA is the category index and BB is the KBA index within that category. The category index numbers are as follows:
[01] Bluetooth - General
[02] Bluetooth - Advertising
[03] Bluetooth - Stack features
[04] Bluetooth - Performance
[05] Bluetooth - Bluetooth Mesh
[06] Bootloading - General
[07] Bootloading - UART DFU
[08] Bootloading - OTA DFU
[09] Application Examples
[10] Peripheral Examples
[11] Security
[12] Tools
[13] Hardware
[14] Migration
[15] Mobile
[16] NCP
Note: Do you want to get automatic notifications when new content is added to the list? Just click the Follow button in upper right corner to subscribe to email notifications. We will make comments when new content is created to trigger those notifications.
Bluetooth Knowledge Base
[Deprecated] KBA_BT_1206: Log System
Note: This KBA has been marked as deprecated. A more updated KBA can be found here:
Log System
Logging is very important for developing embedded products, especially for connection based wireless products because the use of breakpoints will probably result in dropped connections. Whereas, we can easily address problems by walking through the log. This article will introduce a simple implementation of logging on EFR32 based devices. The key point of this article is to introduce a way to classify the log into different levels, and each level of log has its own identifier.
Introduction
Let’s start with 2 design sketches, which demonstrate outputting the log via RTT and VCOM(UART).
Figure 1. Using RTT
Figure 2. Using VCOM
From the pictures, you can see the different level of logging uses different colors, this article introduces 5 levels of logging as below.
Table 1.Log types and colors
Settings
The symbol LOG_PORT, defined in log.h, can be set to SEGGER_JLINK_VIEWER or PORT_VCOM to determine which terminal the output should be sent to.
The definition of LOG_LEVEL in log.h determines which level of logging should be output to the terminal. As you can see from the table 1, error has the highest level while verbose has the lowest level. For example, If the LOG_LEVEL is defined as information level, then error, warning and information log will be sent to terminal, the debug and verbose log which have lower level than information will not be sent to the terminal. See figure 3, which shows the log as information level without modifying anything from figure 1.
Figure 3. Log with information level
Logging Functions
There are 5 corresponding functions to send the log, the input parameter of these five functions is the same as standard printf();.
How to migrate it to your project
Follow below steps to enable this feature in your project and customize it to meet your requirements.
After all the above is done, your project should be able to send the log to the terminal.
Some notes.
KBA_BT_0205: Advertisement Constructor
While developing with Silicon Labs Bluetooth SDK, users can use the API – gecko_cmd_le_gap_bt5_set_adv_data() to set the advertisement and scan response data. The data has a standard format, whereas the data passed to above API is uint8array. This article will focus on adding a middle layer between user application and the BG stack API to set the advertisement payload, which makes the payload more straightforward, visible and easier to understand for users.
For more information about the advertising data, you can go to the Bluetooth KBA Index and see the “Advertising” category.
Introduction
Below is the architecture of the advertisement constructor, which is developed on the latest Bluetooth SDK - v2.8.1, it can also be used on other versions of SDK directly or with just simple modification, depending on the specific SDK version.
The example sets the advertisement and scan response data as below:
Import it to your project
Figure 1. Advertisement details
Figure 2. Advertisement payload breakdown
Figure 3. Scan response payload breakdown
KBA_BT_1301: How to find schematics and other documentation for radio boards?
Schematics and other documentation for radio boards can be accessed easily from Simplicity Studio.
Studio is context sensitive, meaning it will try to show you the relevant content for the hardware that you are working with. You can plug in your kit using USB and Studio will recognize the kit automatically. In that case, the kit details will show up in the Devices window.
Alternatively, you can manually enter the kit / radio board number in the Solutions window. Studio has auto-complete feature that will suggest you list of available options, it is enough to enter just the first part of the board or kit ID (for example, typing BGM111 will show a list of all BGM111 radio boards). This method allows you to access schematics and other documentation for kits even if you don't have the physical kit available. For example, you can check the docs and schematics before even ordering a kit.
Following screenshot shows an example how to locate schematics, assembly drawing etc. for BGM13P radio board (BRD4306A). Note that the item that is selected in the Devices or Solutions tab dynamically changes the content that is shown on the right hand side of the window.
This same method can be used to access other documentation relevant to your target hardware, including:
Bluetooth Knowledge Base Article List
NOTE
Bluetooth Low Energy (BLE) Knowledge Base Articles are now moved to https://docs.silabs.com/bluetooth/latest/. They are not maintained any more.
Bluetooth Mesh Knowledge Base Articles are still VALID and maintained here.
Introduction
This Knowledge Base Article (KBA) aims to act as a “master” KBA which keeps a curated index of all the Bluetooth related KBAs divided into logical categories for an easier and more convenient look-up. It may also include non-KBA content which is relevant for designing your Bluetooth application (e.g. app notes or web pages).
If you are just getting started with Silicon Labs Bluetooth solutions then your starting point should be QSG139: Getting Started with Bluetooth® Software Development. At the end of that document you are presented with the flowchart below which shows what documents should be read and in which order. Additionally you can check out our Bluetooth Training page for more training material.
Knowledge Base Articles List
The content listed below is grouped together into categories to make it easier for you to find what you are looking for. Want to know more about security, or looking for a peripheral example, then head down to the right section and see what KBAs or other relevant content has been created under those topics.
Each category has an associated index number and each individual KBA has its own index number within the category. The KBA's are prefixed with KBA_BT_AABB where AA is the category index and BB is the KBA index within that category. The category index numbers are as follows:
Note: Do you want to get automatic notifications when new content is added to the list? Just click the Follow button in upper right corner to subscribe to email notifications. We will make comments when new content is created to trigger those notifications.
[01] Bluetooth General
[02] Bluetooth - Advertising
[03] Bluetooth - Stack features
[04] Bluetooth - Performance
[05] Bluetooth - Bluetooth Mesh
[06] Bootloading - General
[07] Bootloading - UART DFU
[08] Bootloading - OTA DFU
[09] Application Examples
[10] Peripheral Examples
Additional Resources
[11] Security
[12] Tools
Additional Resources
[13] Hardware
Additional Resources
[14] Migration
[15] Mobile
[16] NCP