Skip to content

Application Development

A specific toolchain is provided to build applications for the BrioSens. Qt tools are also available for application development. Qt can speed up the development of Bluetooth applications.

The toolchain, Qt tools, along with templates and examples, can be downloaded here

All the tools and examples are contained within a single archive. To extract the contents of the archive, use the following command:

tar -xvzf briosens-dev-TOOLCHAIN-<VERSION>.tar.gz

<VERSION> corresponds to the BrioSens development tools' version.

The archive should contain the following folders:

  • toolchain: a toolchain required to build all applications (including Qt)

  • qt-briosens-5.7: Qt tools used to compile applications

  • sysroot: all libraries required for the target device

  • examples: a hello world examples for GCC and Qt

Building an application with a Makefile

A template Makefile is provided to create basic applications. The Makefileis located in the following folder:

examples/gcc-hello

It can be modified to suit the users needs.

Cross-compiler and its path

The following variables should be updated to build an application:

  • TOOLS_PATH: Absolute path where the tools were extracted

  • CC_PATH: Path where the cross-compiler (toolchain folder) is located

  • SYSROOT_PATH: Path to the logical root directory for headers and libraries. For example, if the compiler normally searches for headers in /usr/include and libraries in /usr/lib, it instead searches SYSROOT_PATH/usr/include and SYSROOT_PATH/usr/lib.

  • CC: Cross-compiler used to build applications.

The cross-compiler depends on the application that needs to be built. By default, the gcc compiler has been chosen. For C++, arm-unknown-linux-gnueabi-g++ should be used.

Warning

The path for the sysroot directory must be absolute. Otherwise, the cross-compilation will fail due to missing headers and libraries.

Includes and libraries

Any directories containing header files should be added to the INCLUDES variable. If libraries need to be included, their path can be specified using -Lpath. If libraries need to be linked, the -l option should be used.

Sources and executable name

The application sources need to be provided for the application to build. For the basic needs of the user, specifying individual files is sufficient. However, the Makefile can be modified by the user to compile all sources in a given directory.

The executable is the name of the output file. The MAIN variable is the name of the executable that will be created during the build process.

Building the application

The application can be built by executing the make command from the location of the Makefile. The make command will build the application according to the variables of the Makefile.

The build output will be sent to the bin folder of the current directory. The executable file name will be as specified by the MAIN variable in the Makefile.

Several options are available:

make all: The same as make by itself.

make clean: Will remove all the compilation outputs and executable file from the bin folder.

Qt Application

In order to use the Qt tools, the environment needs to be set up.

A script has been provided, however, it requires modifications so that the variables point to the correct folder locations. Open the following script:

qt-briosens-5.7/qt-configure.sh

Info

The paths can be absolute or relative. By default, the configuration script points to the relative paths where the archive was created. If the user does not move the folders, the script should already point to the correct locations.

Verify and update the following variable to point to the location of the previously extracted toolchain (make sure the path does not contain the bin folder):

TOOLCHAIN_DIR=<path to toolchain>

Also, verify and update the following variable to point to the location of the previously extracted toolchain (make sure the path does not contain the bin folder):

SYSROOT_DIR=<path to sysroot>

Save the changes and run the script. This might take some time depending on the build machine.

Info

The configuration script will build and configure qmake. The script will also build qtbase as well as the Bluetooth library. If the user wishes to use other modules, they will have to be built separately.

Building the application

This section describes the procedure to build applications with Qt. The Qt applications can be developed with the Qt GUI on any OS and then copied to the build machine to be compiled.

Warning

qmake only specifies the name of the cross-compiler to use, not its location. Therefore, the path to the cross-compiler needs to be specified when building Qt applications. The path can be specified through a script or in the user space using the following command: export PATH="<path to toolchain> bin:$PATH"

A hello world application has been provided to show a basic application built with Qt. The example is located in the following folder:

examples/qt-hello

Change the working directory to the location of the project files.

cd <location of the Qt project files>

Execute qmake from the current path. qmake should be located in the qt-target/bin folder of the Qt tools folder.

<path to qmake>/qmake

qmake will create a Makefile which will allow the project to be compiled.

Run the make command to build the application.

Info

The build output will be located in the current working directory. The Makefile created by running qmake specifies the output file names. By default, the name of the executable will be the same as the project name. For the case of the hello world example, the executable name will be qt-hello.

Qt Bluetooth examples

The Qt tools package contains Bluetooth examples which help developing Bluetooth applications. The examples contain the project and all source files which allow the user to build the project directly.

The Bluetooth examples are located in the following folder of the archive:

qt-everywhere-opensource-src-5.7.0/qtconnectivity/examples/bluetooth

The build a project, change the working directory to the desired example’s folder. Run qmake followed by make from the example’s directory.

Testing the Qt Bluetooth heartrate server example

The heartrate server example is a good example to start understanding how the Bluetooth library works. The example does not require any GUI elements and can be run directly from the console of the BrioSens Gateway. The heartrate server example is located in the following folder:

qt-everywhere-opensource-src-5.7.0/qtconnectivity/examples/bluetooth/heartrate-server

Follow the steps to build, run and test the application:

  • Build the application (qmake followed by make).

  • Copy the executable to the BrioSens Gateway file system.

  • Execute the application.

  • The heartrate server is now running

To test the heartrate server example, you can connect to the BrioSens Gateway from another Linux computer with Bluetooth capabilities using the following commands:

  • Scan for Bluetooth devices
1
2
3
hcitool lescan 
78:A5:04:21:6D:60 HeartRateServer  
F4:B8:5E:E5:04:2C (unknown)
  • Use the GATT tool to connect by using the heartrate server’s MAC address:
1
gatttool -i hci0 -b 78:A5:04:21:6D:60 I
  • Connect to the server with the connect command:
1
2
3
[78:A5:04:21:6D:60][LE]\> connect 
Attempting to connect to 78:A5:04:21:6D:60  
Connection successful
  • Get the device information with the characteristics command:
1
2
3
4
5
[78:A5:04:21:6D:60][LE]\> characteristics  
handle: 0x0004, char properties: 0x02, char value handle: 0x0006, uuid:
00002a00-0000-1000-8000-00805f9b34fb  
handle: 0x0007, char properties: 0x02, char value handle: 0x0008, uuid:
00002a01-0000-1000-8000-00805f9b34fb