QtBlueTooth not functional on Linux - linux

I'm developing an embedded application with bluetooth LE function enabled using Qt 5.7. The device I'm developing are meant to act as peripheral role, it can broadcast advertising packets and let smartphones to connect to.
The target board are running with Ubuntu Linux 14.04, with bluez version 5.43 (the latest) Since Qt documentation says "In Qt 5.7, additional API supporting the peripheral role was added as a Technology Preview, with the backend only implemented for Linux/BlueZ." So, I think the Qt bluetooth API are exactly what I need.
But when I build and run the Qt bluetooth examples (BlueTooth Low Energy Heart Rate Server Example and Bluetooth Scanner Example), none of them are working. I can only get console output: "qt.bluetooth: Dummy backend running. Qt Bluetooth module is non-functional."
I googled that error message, it seems many developers get that error message because they are using Qt bluetooth API on windows platform, and qt bluetooth api does not support Windows. But I'm using Ubuntu Linux, so clearly something wrong but I don't know what exactly cause the issue.
What I'm trying:
Enable QtBluetooth logging. But nothing more interesting message to show.
Don't use any Qt bluetooth API, just use command line tool hciconfig and hcitool to manually set up an advertising action. And it actually works ! My iPhone can "see" the device, and I can connect to it !
Based on what I'm trying, I think my hardware are OK, the bluetooth chip can work, but I really need the QtBluetooth API to work correctly. Maybe I miss something important ? The bluez need some configuration ? Please help.

I've encountered the same problem.
When i tried to cross compile Qt framework for my hardware, Bluetooth related libraries showed the same log:
"qt.bluetooth: Dummy backend running. Qt Bluetooth module is non-functional."
The root cause of this issue in my case was in sysroot. It had no Bluetooth includes and libraries. That's why Qt bluetooth test failed to pass.
In this situation i suggest to add -v flag so it will show complete logs, and you can check exact problem why Qt tests fails.
My problem was solved when i downloaded necessary folders from the device with all libraries and includes and used it as -sysroot argument. Tests passed successfully and there was no need to use workaround suggested by #colin.

OK, finally I've managed to solve the issue. Qt has some feature test functions when you build it by source. If you don't have some development packages installed on the host, the test will fail and the function won't work properly. In this case qt will use dummy backend instead, so the example apps can still compile OK and run, but without any practical usage.
Speaking of the qt bluetooth, the required dev-packages are libbluetooth-dev bluetooth blueman bluez libusb-dev libdbus-1-dev bluez-hcidump bluez-tools (I've list more installs than needed, just in case), make sure install all these on the host BEFORE make.
After I've done all the prepare work, I run the configure script to generate the Makefile for Qt. This is the configure script I use:
#!/bin/sh
./configure \
-v \
-prefix /opt/qt-5.7.0 \
-release \
-opensource \
-xplatform linux-arm-gnueabi-g++ \ # yes, I need to cross-compile
-qt-sql-sqlite \
-qt-zlib \
-qt-pcre \
-no-opengl \
-no-sse2 \
-no-openssl \
-qt-freetype \
-nomake examples \
-nomake tests \
-no-separate-debug-info \
-no-qml-debug \
-pkg-config \
-confirm-license
After running the configure script, you'll get a qmake executable under yourQtSourcePath/qtbase/bin/, then you can test your qtbluetooth function by execute:
qtSourcePath/qtbase/bin/qmake qtSourcePath/qtconnectivity/qtconnectivity.pro
If you see something like:
Checking for bluez... yes
Checking for bluez_le... yes
Checking for linux_crypto_api... yes
then you are good to go, just make && make install for the whole Qt source, qt bluetooth can work properly now.
EDIT:
If by any means you can't pass the bluetooth test (It's very possible when you need to cross-compile, like my case), I've figured out a workaround. You still have to install all the required dev-packages before make, this time in order to pass the bluetooth function test, you can use your system built-in qmake (apt-get install qt5-qmake, NOT the qmake you generated by running configure script) to work with qtconnectivity.pro. This way, you can pass the bluetooth function test and generate a Makefile for qtconnectivity module.
Modify the Makefile, change the QMAKE parameter. In my case, this is the result:
- QMAKE = /usr/lib/x86_64-linux-gnu/qt5/bin/qmake
+ QMAKE = /opt/qt-everywhere-opensource-src-5.7.0/qtbase/bin/qmake
Then, you can cross-compile the whole Qt source by make && make install.
I've test the workaround, the example app (heartRate server) can work properly now. The annoying message "qt.bluetooth: Dummy backend running. Qt Bluetooth module is non-functional" is gone :)

Related

How to Cross Compile Alsa library for Windows Eclipse

I would like to know how could it be possible to cross compile the Alsa library in Windows for my linux host.
I am using an iMX8X with a Linux image, made by Yocto, and I need to implement the Alsa library in my Eclipse to be able to use the functions it gives. I have tried to,
CC=aarch64-linux-gnu-gcc(in my case) ./configure host=arm-linux
It goes by properly but when I do make with cygwin it fails and I cannot figure it out.
Anyone know how to approach the cross-compilation of a library for Windows Eclipse?
Thanks in advance!
There is no point on compiling Alsa on Windows, this library works with Linux Core in order to work. There is no actual way, for what I found, to compile it on Windows. Best approach has been to make a Virtual Box machine with Ubuntu 20.04, install Eclipse and compile and add Alsa library in the Ubuntu machine. For more information, just ask me about it, glad to help.

Beyond Linux From Scratch: avrdude was compiled without usb support

Out of interest and learning purposes I have built Linux from scratch (LFS+BLFS, both version 10.0) according to the descriptions on www.linuxfromscratch.org.
In general the OS can boot and I can basically work with it. There are a few things which are not smooth, therefore I would like to address the experts here.
I would like to get going the AVRDragon, a programmer for Atmel microcontrollers. To use it on Linux, I work with the program "avrdude". My goal is to learn how avrdude works and interacts with the OS. Therefore I would like to build it from source with debug information.
For building avrdude from source, libusb/libusb_1_0 and libelf are required. I understand that libusb_1_0 was installed with BLFS. avrdude asks for either libusb and/or libusb_1_0. I cannot say if there is a problem with having only libusb_1_0. (libusb_1_0 is newer than libusb, isn't it?) Additionally I have installed libelf (since libelf is installed, I cannot build the kernel anymore, but this should not be a problem for now). In the kernel, USB support is enabled (Device Drivers -> USB Support -> Support for Host-side USB).
I have created a udev rule:
# Dragon
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2107", GROUP="plugdev", MODE="0666"
...and lsusb says this:
# lsusb
...
Bus 003 Device 006: ID 03eb:2107 Atmel Corp. AVR Dragon
...
Also, I use a script to program a sample application onto the microcontroller, which works on my reference system.
However, running avrdude on my BLFS, I get an error message, that avrdude was not built with USB support:
# avrdude -p m328p -c dragon_isp -B5 -F -P usb -V -U flash:w:Debug/hello_world.elf
avrdude was compiled without usb support.
avrdude done. Thank you.
Researching the internet, indicated installing the prerequisites stated above and setting up the udev rule.
I have a good understanding of the Linux command line, the GCC tool chain and the usual Linux tools. But I am completely lost with how to correctly configure my BLFS with USB support. Is there somebody who can give me a hint on how to solve this problem? Many thanks!
Apparently, for full functionality you need both libusb-1.0 and libusb-0.1. The configure.ac script defines HAVE_LIBUSB_1_0 only for the former and HAVE_LIBUSB for the latter, while the *.c files containing your error message only check for HAVE_LIBUSB.
While current BLFS doesn't have instructions to build libusb-0.1, you can see them for libusb-0.1.12 in BLFS 6.3.

Embedded Electron on NXP i.MX6

Earlier this year, I developed an app with the framework Electron (made by Github) and now I would like to embed it on a SBC I bought.
The SBC is the ConnectCore6 from DIGI, based on the NXP i.MX6 processor, and connected to a screen with HDMI.
I can generate linux images for this SBC with Yocto and load GTK & QT applications on it. However, I would like to understand if create a compatible version of my Electron app for this hardware is an easy, hard or impossible task.
I don't realize what is needed by Electron to work on PCs (Windows, Linux and OS X) and should be set up on the SBC to get the same result.
Could you help me with that and possibly guide me to find a way to execute the Electron App on the board ?
Thank you
Antoine
The job can be quite easy.
You can simply configure your tools (e.g. qt creator) to use cross compiler and cross libs of Yocto SDK.
Looking at the Electron web site I found
Cross compilation
If you want to build for an arm target you should also install the following >dependencies:
$ sudo apt-get install libc6-dev-armhf-cross linux-libc-dev-armhf-cross \
g++-arm-linux-gnueabihf
And to cross compile for arm or ia32 targets, you should pass the --target_arch parameter to the bootstrap.py script:
$ ./script/bootstrap.py -v --target_arch=arm
The main problem is if a lib, required by Electron framework, is not available as open source or already cross compiled. In that case you'll have to ask it to the lib provider.

How to get started with Bluetooth for Ubuntu

I really need help getting started. I want to make a basic program (in C) that can read a bluetooth socket and print whatever it is sent. I tried to get Bluez (followed this:http://hackgnar.com/article/installing-the-latest-bluez-software-in-ubuntu-12/ it went great until the "make" at the end and then no luck, would not make and example program could not find bluetooth/bluetooth.h).
I guess my hopeful options are:
some one can tell me what I'm missing with Bluez's install and possibly how to get started with it (compiling etc)
Alternative to bluez? Laptop could do bluetooth file transfers before I installed bluez so do I even need it for this application?
Any sort of comprehensive hello world (download, install, example, compile and run)
I have a strong programming background, just not in Linux (you can gloss over the C stuff but please not the Linux/Ubuntu stuff).
Thanks!
I can only guess that you have an old version of the kernel, or one of the required libraries. Try updating your linux installation (e.g. to a 3.5.x kernel or thereabouts).
I had no problem completing the steps you took.
If you are looking for example programs, you can always look at the simpler tools.
On my ubuntu box I'd do e.g.
sudo apt-get build-dep bluez-tools
apt-get source --compile bluez-tools
which gets all build dependencies, sources and builds the bluez-tools package on your system.

How to Upload Source Code to Arduino from bash?

Right now I am using the standard Arduino IDE 1.0.1.
Yet I find both the IDE itself flunky and myself editing the code in other editors only to have to copy paste it inside the IDE and upload it there to my Arduino.
I really dislike this workflow.
So I am wondering: Is there a different way to deploy an Arduino project at best via commandline? Basically I am looking for a way to run something like arduino deploy /path/to/project /dev/ttyUSB0 from bash.
You need a program called avrdude to upload the binary onto your target, and modify the parameters according to your setup and target:
mcu=atmega8
f_cpu=16000000
format=ihex
rate=19200
port=/dev/ttyusb0
programmer=stk500
target_file=test.hex
avrdude -F -p $mcu -P $port -c $programmer -b $rate -U flash:w:$target_file
If you're on a Debian or an Ubuntu machine, you should be able to do this to install avrdude:
sudo apt-get install avrdude
Otherwise you should be able to grab the sources from here and build it yourself.
Also there is a comprehensive Makefile that you could use to build and upload to your Arduino which again uses the similar avrdude commands to upload to the target. After changing the parameters in the Makefile, run make upload to upload the hex file to the target.
NOTE: You need to have gcc-avr and avr-libc packages installed to build the binaries (which from the question looks like you're already doing).
Following are two options which you can try
Arduino 1.5.x only
If you are using Arduino 1.5.x then you can use the arduino executable can accept commandline parameters.
Note that Arduino 1.5.x is still in beta, so you may face some issues.
Arduino 1.0.x
If you are using Arduino 1.0.x then you can use my makefile for Arduino which can be used to compile and upload Arduino (or plain AVR C) programs to Arduino from the commandline.
Following are some of the important features of this makefile
Supports upload via Arduino as ISP or any programmer
Communicate with Arduino through serial
Supports compiling plain AVR C programs
Supports user as well as system libraries.
Generate assembly and symbol files
Program using alternate Arduino core (like ATtiny or Arduino alternate cores)
I have made a arduino builder for ubuntu/linux which helps
Build
Upload
Listen serial port
Track changes in sketch files
Builder and instructions how to setup everything can be found here:
https://github.com/limitium/arduino_builder
Also you can see small demonstration video about it here:
https://youtu.be/Nu3YGMoXORI

Resources