Simplifying BLE Application Development for C++ Developers with the BleuIO C++ Library

October 7, 2024
Simplifying BLE Application Development for C++ Developers with the BleuIO C++ Library

BleuIO BLE USB dongle was designed with developers in mind, offering a simple yet powerful way to create BLE applications using AT commands. Now, we’ve taken this a step further by creating a C++ library that makes it even easier for C++ developers to integrate BleuIO into their BLE projects.

In this article, we’ll introduce the BleuIO C++ library and how it simplifies BLE development for C++ developers. Whether you’re building IoT devices, smart home solutions, or any application requiring BLE communication, our library streamlines the process, allowing you to focus on your application logic.

What is BleuIO?

BleuIO is a Bluetooth Low Energy USB dongle that enables BLE communication through simple AT commands. It acts as a bridge between your application and Bluetooth devices, making it easier to scan, connect, and communicate with other BLE devices. The dongle supports all major operating systems, including Windows, macOS, and Linux, and is compatible with multiple programming languages, including C++.

With its AT command interface, BleuIO abstracts the complexity of BLE communication, making it accessible even to those with limited knowledge of BLE protocols. Developers can send and receive BLE commands without diving deep into low-level BLE stack programming.

Introducing the C++ Library for BleuIO

To further simplify BLE development, we’ve developed a dedicated C++ library that integrates with BleuIO’s AT command interface. This library allows C++ developers to quickly start building BLE applications using BleuIO without needing to manually manage serial communication or handle raw AT commands.

The library takes care of the low-level communication, so you can focus on higher-level logic. With just a few lines of code, you can send commands to the dongle, scan for devices, and establish BLE connections.

Why Use the BleuIO C++ Library?

The BleuIO C++ library provides a number of benefits for developers:

Ease of Use: No need to write low-level serial port communication code. The library handles sending AT commands and reading responses, allowing you to focus on building your BLE application.

Cross-Platform: The library is compatible with all major operating systems, including macOS, Linux, and Windows. C++ developers can seamlessly integrate BleuIO into their projects regardless of the platform.

Faster Development: By using AT commands through the C++ library, you significantly reduce the time required to implement BLE communication in your application. The library enables quick scanning for devices, connecting to peripherals, and exchanging data.

Highly Customizable: While the library handles serial communication and command parsing, you still retain control over how you use the AT commands. You can extend and adapt the library to fit the specific needs of your BLE project.

How to Install the Library

We’ve made the library available on Homebrew (for macOS and Linux) and provided easy installation steps:

Installation via Homebrew

Install Homebrew (if you don’t have it installed):

   /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Add the BleuIO C++ library tap:

   brew tap smart-sensor-devices-ab/homebrew-bleuio-library

Install the library:

   brew install bleuio-library

Example: Scanning for BLE Devices Using BleuIO

Let’s take a look at how you can use the BleuIO C++ library to scan for nearby BLE devices. Below is a simple example that demonstrates how to send the AT+GAPSCAN command to the dongle and retrieve a list of nearby BLE devices.

#include <iostream>
#include "BleuIO.h"

int main() {
    // Initialize BleuIO dongle connected to /dev/ttyUSB0 (adjust the port for your system)
    BleuIO dongle("/dev/ttyUSB0");

    // Put the dongle in central role
    std::string response = dongle.send_command("AT+CENTRAL");
    // Send command to scan for nearby BLE devices for 3 seconds
    response = dongle.send_command("AT+GAPSCAN=3");

    // Print the response from the dongle
    std::cout << "Response: \n" << response << std::endl;

    return 0;
}

Using the Library in Your C++ Project

Once installed, you can include the library in your project and start using it immediately. The typical workflow involves creating an instance of the BleuIO class, sending AT commands, and handling the responses.

To compile your program, you can use the following commands depending on your system:

macOS (Intel)

g++ -o my_bleuio_app main.cpp -I/usr/local/include -L/usr/local/lib -lBleuIO -lserialport

macOS (Apple Silicon)

g++ -o my_bleuio_app main.cpp -I/opt/homebrew/include -L/opt/homebrew/lib -lBleuIO -lserialport

Linux

g++ -o my_bleuio_app main.cpp -I/home/linuxbrew/.linuxbrew/include -L/home/linuxbrew/.linuxbrew/lib -lBleuIO -lserialport

After compiling, run your application:

./my_bleuio_app

The BleuIO C++ library makes it easier than ever for C++ developers to integrate BLE communication into their projects using the BleuIO USB dongle. With the power of AT commands and the simplicity of the library, you can quickly prototype and build Bluetooth-enabled applications without the complexity of managing BLE protocols manually.

Whether you’re working on IoT, smart home devices, or any project requiring Bluetooth communication, the BleuIO C++ library helps you get started faster, with fewer lines of code, and more focus on your application logic.

We encourage you to try out the library and join the growing community of developers building BLE applications with BleuIO.

Share this post on :

Leave a Reply

Your email address will not be published. Required fields are marked *

Follow us on LinkedIn :

Order Now