Created by Alien as it Intercepted #Technology #NodeDevice #BLE #Wi-Fi #CoExistence #Protocol #Linux #gdbus #Rust

Linux-based MPUs offers the provision for adding Wi-Fi and Bluetooth Low Energy (BLE) connectivity to embedded devices. However, there are situations where using Linux-based MPUs might not be an option due to various reasons such as cost, power consumption, or size constraints. In such cases, engineers need to look for alternative solutions that can provide reliable Wi-Fi and BLE coexistence.

One such solution is using the ESP32 System-on-Chip (SoC) variant, which comes with built-in support for Wi-Fi and BLE coexistence software feature. In this article, we’ll explore how to implement a client application running on a Linux-based gateway device that connects to an ESP32 node device over BLE or Wi-Fi, particularly BLE using GD-Bus with BlueZ library in C programming language or in Rust.


Exploring Options

While the ESP32 SoC variant is a viable option for implementing Wi-Fi and BLE connectivity on embedded devices, there are other alternatives available in the market as well. One such alternative is the product line offered by Nordic Semiconductor.

Nordic Semiconductor specializes in low-power wireless technology and offers a range of products that support both Wi-Fi and BLE. However, it’s important to note that this article is not focused on power consumption, and Nordic Semiconductor’s products are generally known for their superior power performance.

Some of the products offered by Nordic Semiconductor that support both Wi-Fi and BLE include the nRF52832, nRF52840, and nRF5340.

The nRF52840 is a more advanced SoC that supports Bluetooth 5, Bluetooth Mesh, and Thread, in addition to supporting Wi-Fi. It features a Cortex-M4F processor and offers up to 1 MB flash memory and 256 KB RAM.

By adding nRF7002 Wi-Fi companion IC to your solution, you can enable Wi-Fi connectivity to your Bluetooth LE or cellular IoT application. Read more about Nordic Semiconductor’s Wi-Fi and BLE Solution Portfolio on their website.


Enabling Wi-Fi & BLE Co-Existence Software Control with ESP32 — IDF

  • ESP32 uses a coexistence mechanism to enable Wi-Fi and BLE to work together on a single antenna. The coexistence mechanism is implemented in software and is controlled by the IDF (IoT Development Framework) for ESP32
  • To enable the coexistence mechanism in the IDF, you can use the “menuconfig” command and select the appropriate options for your project or via VSCode and going to SDK Configuration Editor enable “Wi-Fi/BLE Software Control Co-Existence” feature.
  • The coexistence mechanism is based on time-division multiplexing (TDM) and frequency-division multiplexing (FDM), which allow Wi-Fi and BLE to use the same antenna at different times or frequencies.

This git repository “ESP32 Wi-Fi BLE CoExist Template” contains a template project that demonstrates the coexistence of Wi-Fi and BLE on the ESP32 using the IDF library, with an added MQTT client feature. This project provides a starting point for developers who want to implement Wi-Fi and BLE coexistence on their ESP32 devices and also utilize the MQTT protocol for IoT applications.


BLE Client Application on Linux based Gateway Device

When it comes to developing a client application that can scan, connect, and communicate with a BLE master or server device, there are a variety of languages and tools available. While Python is a popular choice, we will be focusing on utilizing C/C++ and Rust with BlueZ to develop a client application that can interact with the ESP32 end-node device. With the right tools and knowledge, developing a client application that communicates over BLE is a straightforward process that can open up a world of possibilities for IoT applications.

BlueZ — GDBus Communication

GDBus is a high-level communication API provided by the D-Bus message bus system that allows applications to communicate with one another and exchange information in a secure and reliable way. It is widely used in Linux-based systems and is essential for building robust and scalable applications.

BlueZ is an open-source Bluetooth protocol stack that is widely used in Linux-based systems to provide Bluetooth functionality. It is used in a wide range of devices, from smartphones and laptops to IoT devices, and provides a comprehensive set of tools and libraries for building Bluetooth-enabled applications. With BlueZ, developers can easily build applications that can discover, connect, and communicate with Bluetooth devices, making it an essential tool for IoT developers.

D-Feet Application to Debug DBUS calls.

D-Feet and Bustle are two useful tools for understanding the gdbus calls made by Bluetoothctl in BlueZ. D-Feet is a D-Bus debugger which allows you to browse and interact with D-Bus objects on your system. It provides a graphical user interface to view the objects and their properties, and to call their methods.

Bustle is a D-Bus activity visualizer, which records all D-Bus activity on your system and presents it in a graphical form. By using these tools, you can monitor the D-Bus traffic between bluetoothctl and BlueZ and understand the gdbus calls being made.

You can then replicate these calls in your own C client application, allowing you to perform similar actions over BLE. This makes it easier to develop your own BLE client application using gdbus with BlueZ in C or Rust.

If you are developing an application in Rust then there is a BlueZ port for it here named as BlueR. Here is the repository where I play with BlueZ and written in C language — blue_test_codegen.


Author: Annim Banerjee

github.com/pixma | Annim Banerjee /