5553 views|0 replies

252

Posts

0

Resources
The OP
 

[Silicon Labs BG22-EK4108A Bluetooth Development Review] Part 3: Bluetooth-Soc Blinky Example Development Experience [Copy link]

 This post was last edited by jj1989 on 2022-1-23 22:51

【Silicon Labs BG22-EK4108A Bluetooth Development Review】Part 3: Official Bluetooth-Soc Blinky Example Development Experience

Preface

Last time, I experienced the ease of use and convenience of the Simplicity Studio IDE through the official demo called Bluetooth-NCP. This time, I will use the official demo as a template to create a project and experience the IDE in depth.

Project creation

Under the EXAMPLE PROJECT & DEMOS menu, many examples are provided. Here, select the Bluetooth-Soc Blinky example, click the "CREATE" button, and complete the project import and creation according to the prompts.

After the project is established, the first thing displayed is a readme document. This document gives a detailed introduction to the functions and usage of this example. At the beginning of the document, it is mentioned that this project can be said to be the "hello world" of BLE development. Therefore, friends who intend to learn BLE may wish to start with this example.

IDE Function Experience

GATT Configuration

The configuration of GATT is similar to the Bluetooth NCP Commander tool used last time. It uses a graphical method to configure GATT, which is more concise and intuitive than source code configuration. As shown below:

Check the LED Control feature and you can modify the UUID directly. For feature attributes, you only need to move the mouse a few times to complete the configuration. As shown below:

Pin Configuration

Open the file with the suffix pintool, and configure the chip IO in a graphical way. As shown below:

Source code analysis

The function of this application is that when BTN0 on the development board is pressed, the button status will be sent to the host (mobile phone) in the form of BLE notification. The host can control the on and off of LED0 on the development board through BLE Write. See the source code for details:

In the sl_bt_on_event() function of the app.c file , the code to control LED0 is as follows:

        if (data_recv == 0x00) {
          sl_led_turn_off(SL_SIMPLE_LED_INSTANCE(0));
          app_log_info("LED off.n");
        } else if (data_recv == 0x01) {
          sl_led_turn_on(SL_SIMPLE_LED_INSTANCE(0));
          app_log_info("LED on.n");
        } else {
          app_log_error("Invalid attribute value: 0x%02xn", (int)data_recv);
        }

When the data received by BLE is 0x00, LED0 will be turned off, and when the data received is 0x01, LED0 will be turned on. In the update_report_button_characteristic() function, the state processing code of button BTN0 is as follows:

  switch (sl_button_get_state(SL_SIMPLE_BUTTON_INSTANCE(0))) {
    case SL_SIMPLE_BUTTON_PRESSED:
      data_send = (uint8_t)SL_SIMPLE_BUTTON_PRESSED;
      break;

    case SL_SIMPLE_BUTTON_RELEASED:
      data_send = (uint8_t)SL_SIMPLE_BUTTON_RELEASED;
      break;

    default:
      // Invalid button state
      return SL_STATUS_FAIL; // Invalid button state
  }

That is, when BTN0 is in the pressed state, the data sent is 0x01. When it is in the released state, the data sent is 0x00.

test

The official website provides a mobile app called EFR Connect for BLE testing, and

链接已隐藏,如需查看请登录或者注册
is open on github .

Here I still use Lightblue for testing. Compile, burn, and run, let our code run on the BG22-EK4108A kit, and then open the mobile phone APP to connect.

After that, test it and press the button. The APP will receive a button status notification as follows:

The APP sends data to control the LED light on and off, as follows:

Summarize

I have to say that the development experience of the BG22-EK4108A kit is so good. Simplicity Studio integrates almost all the resources that developers need. In this IDE, in addition to basic coding, debugging and other functions, various development tools, routines, and documents are also integrated. You don't need to go to the official website to find information, nor do you need to install other software. Simplicity Studio is enough.

 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list