I would like to know which is the current modern way to do DUN reverse tethering using Bluez version >= 5.
I have an old PDA that I use sometime (a Tapwave Zodiac running PalmOS5. It's similar to Palm Tungsten, etc.) These old devices don't have Wifi, only Bluetooth. For networking over Bluetooth, these old devices don't support PAN, only DUN.
So to provide them networking, one need to share a desktop PC's connection over bluetooth DUN.
Up until Bluez version 4, the standard way to provide networking over bluetooth for such PalmOS 5 devices was:
https://wiki.debian.org/BluetoothPalmOSConnection
Basically:
run "dund" to listen for incoming connection.
once the palmos device connects to the PC, have dund start PPPD with parameters tailored for the device
use iptables to forward the connection.
My problem:
I've read that bluez 5 changed the way DUN is handled and thus support for the old "dund" was dropped.
Indeed there's no "bluez-compat" package available anymore for my current distro (opensuse 13.1, runs bluez 5.18)
So my question:
What's the modern successor of "dund --listen" for bluez 5 ?
How should I setup a DUN service on my computer to which to connect from my PDA ?
I've looked around, but I haven't been able to find any guide.
The "dund" functionality should very probably be replicated using some scripting and dbus calls. But I can't find any pointer where to begin looking for a solution.
Thanks for your help.
I think you can
Run pppd with "rfcomm listen" in the "connect" script of your /etc/ppp/peers/ file
Use "sdptool add DUN" so that your service is discoverable
I guess you'll figure out the exact details yourself. Please respond if it won't work for you and I'll try that myself or be more specific.
Take care,
Lubo
Related
Over the last couple of years I have been looking for an easy way to control a few relays from Javascript. I want to build a web App to control starting sequence horns for sailing races.
I recently discovered webUSB and it seems like exactly what I need. A direct connection from JS in chrome to the USB world. Simple coding in a language I already use.
On the hardware side I am having trouble finding a product that is compatible. Googling USB Relay finds 100's of products that all seem to rely on some proprietary SW for the OS. I can find lots of educational demo's that turn an LED on and off.
Does anyone have any ideas where to find such a product?
While I'm sure you will be able to find USB relays that can be controlled via WebUSB, most USB relays will probably come with some kind of serial port driver, e.g. https://numato.com/product/1-channel-usb-powered-relay-module uses a CDC serial port driver. These can be controlled using Web Serial, available in Chrome 77 and later behind a feature flag. For a tutorial, see https://codelabs.developers.google.com/codelabs/web-serial/
Explainer: https://github.com/WICG/serial/blob/gh-pages/EXPLAINER.md
API docs: https://wicg.github.io/serial/
If you search for "5V USB Relay Programmable Computer Control For Smart Home" on eBay, you will also find low-cost relays that use HID instead. The advantage of these is that you don't need any serial port or USB drivers, as it will use the operating system's built-in HID drivers. For that you can use WebHID. For more info, see https://github.com/robatwilliams/awesome-webhid.
Qt: 5.10,
Linux Ubuntu 17.10,
Bluez 5.4x
and I´m using QBluetooth to connect with multiple Bluetooth Low Energy Devices. Everything works fine for one Connection. But when I connect to a second Device with QLowEnergyController::connectToDevice() I get the following error and the first Connection gets aborted:
qt.bluetooth.bluez: Cannot connect due to pending active LE Connections
qt.bluetooth.bluez: void QBluetoothSocketPrivate::_q_readNotify() 21 error: -1 "Software caused Connection abort"
After that the second connection gets established.
I`m using one instance of QLowEnergyController in Central Mode per Connection.
After a Research I think it should be possible to create multiple Connections to BLE Peripherals with the Bluez Bluetooth Protocol Stack. But I´m not sure if QBluetooth support this Feature...
Does anybody know something about multiple LE Connections with QBluetooth?
Is this the right way to establish a second Connection?
Does somebody know a good Workaround?
Thanks for your help!
The problem isn't BLE, but its Qt implementation. The documentation says that any attempt to connect simultaneously to two BLE devices using QLowEnergyController will fail. Check it there: http://doc.qt.io/qt-5/qlowenergycontroller.html ; Section "Detailed Description", paragraph 5:
"BlueZ based Linux cannot maintain two connected instances of QLowEnergyController to the same remote device. In such cases the second call to connectToDevice() may fail."
According to this, it should be possible to establish connexion to two different remote devices using two instances of the class, but it simply doesn't work. If you keep on reading the documentation, you'll find out that " This limitation may disappear at some stage in the future.".
I tried a workaround by disconnecting from the first device before connecting to the second device (both TI SensorTag), but since I had to re-discover the services and re-enable the sensors (see disconnectFromDevice() in the documentation) every time I would re-connect the program became way too slow.
If you want to connect to two devices using Qt, you have to use the Bluez API through the D-Bus with Qt's D-Bus classes.
Edit:
I managed to connect to multiple devices using D-Bus classes. The architecture of my program isn't much more complicated, only the syntax got a little more tricky. The only big issue was the BlueZ version: the D-Bus interface changed a lot between 5.3x (default Ubuntu 16.04) that doesn't support Low Energy (experimental...) and later versions. I think that's the reason why Qt's D-Bus Bluetooth hasn' been enabled yet. Since BLE isn't flagged as experimental since BlueZ 5.42, you should be fine using D-Bus with your current version. For the record, I'm perfectly fine using D-Bus with Raspbian's default 5.9 BlueZ.
I have a device with a few custom GATT services, and I would like to write a Linux program to interact with it. After some searching I found out that Linux is using BlueZ to handle the Bluetooth LE protocol. I'm using Ubuntu 15.10 with BlueZ 5.35, but I cannot figure out how use this BlueZ from a user-space program. I cannot find an API documentation anywhere, no tutorials, examples, nothing. Is it even possible to use this BlueZ stack to do anything other than just connecting to Bluetooth devices with default services? And if so, where is the documentation? (Preferably C/C++ API but at this point anything goes)
Have a look at attrib/gatttool.c in the bluez sources [1]. Gatttool is a command line utility for connecting to BTLE devices using the C "API". The GATT interface is not exposed in libbluetooth though.
A newer alternative to gatttool and thus another example to learn
from is the btgatt-client, which you can find in
tools/btgatt-client.c (to enable compilation configure bluez with
--enable-experimental).
Besides the C interface bluez integrated a DBUS interface.
bluetoothctl is an example tool using the DBUS interface. The code of
bluetoothctl can be found in client/ [2].
Another example program using the C interface of bluez is the Anki
Drive SDK [3]. It packaged the bluez GATT C interface in its own
library libbzle [4]. When using the C interface you have to connect a
socket when establishing a BTLE connection. The gatttool does this
via the GATT interface, which in turn uses glib iirc. But you can
also do this using syscalls (socket, connect, ...) as explained e.g.
here [5]. This document also explains:
Unfortunately, as of now there is no official API reference to refer to, so more curious readers are advised to download and examine the BlueZ source code.
Gilbert Brault also extracted the GATT interface from bluez [6] and links to a rudimentary doxygen documentation of the GATT interface [7] with the following disclaimer:
This is a work in progress with the intent of documenting all important functions and data structures
Also Szymon Janc gave a nice overview in his talk "Bluetooth on Modern Linux" at the Embedded Linux Conference 2016 [8]. Starting at 42:00 he talks about the unexposed C interface. But in general he seems to recommend the DBUS API (see "Tips" slide at 45:30). Some DBUS documentation can be found in doc/gatt-api.txt [9] and Python examples using the DBUS interface can be found in test/.
Hope this helps.
[1] http://git.kernel.org/cgit/bluetooth/bluez.git/tree/attrib/gatttool.c
[2] http://git.kernel.org/cgit/bluetooth/bluez.git/tree/client/
[3] https://github.com/anki/drive-sdk/
[4] https://github.com/anki/drive-sdk/tree/master/deps/bzle/
[5] https://people.csail.mit.edu/albert/bluez-intro/c404.html
[6] https://github.com/gbrault/gattclient
[7] http://gbrault.github.io/gattclient/index.html
[8] https://www.youtube.com/watch?v=tclS9arLFzk
[9] http://git.kernel.org/cgit/bluetooth/bluez.git/tree/doc/gatt-api.txt
I feel your pain. I needed to add user input from a custom BLE peripheral, a simple remote pushbutton, to an embedded program running under Linux (Stretch) on a Raspberry Pi. I was stunned by the needless complexity and Spartan (not a compliment) documentation of the BlueZ API. All the BlueZ “examples” are written from the perspective that Bluetooth is the center of the universe and the user wants to support every Bluetooth device ever invented. In my case I knew exactly the device, service, and GATT characteristics I needed to interact with, and I wanted a minimum overhead task that would do its thing in a low priority thread.
It turns out a BLE central client is pretty straightforward using BlueZ, but it was an arduous road starting with the source for the BlueZ utility bluetoothctl in release 5.49. I accomplished my needs using only three unmodified source files from the BlueZ distribution and excerpts from an additional three source files. Since the BlueZ source is inextricably dependent on D-Bus and the Gnome GLib main loop, I grudgingly included them.
Following OlivierM's generous lead, and in hopes that my embarrassingly massive investment in time saves someone else a month of their life, I have posted my example Bluetooth BLE client on GitHub: https://github.com/jjjsmit/BluetoothBLEClient
It would arguably be simpler and quicker to write a shell script on Linux to do what you need to do. The BlueZ commands are relatively simple and straightforward, and there are many tutorials and questions on how to use it.
Tutorials:-
http://www.jaredwolff.com/blog/get-started-with-bluetooth-low-energy/
https://learn.adafruit.com/reverse-engineering-a-bluetooth-low-energy-light-bulb/control-with-bluez
https://lilyhack.wordpress.com/2014/02/03/ble-read-write-arduino-raspberry-pi/
http://joost.damad.be/2013/08/experiments-with-bluetooth-low-energy.html
Questions:-
Using Bluetooth low energy in linux command line
Bluetooth Low Energy: listening for notifications/indications in linux
How can I connect to the FitBit Zip over Bluetooth 4.0 LE on Linux with bluez?
Once you are more familiar with using the commands manually you can then write a minimal shell script so that this is automated for you.
I had a similar issue which is to interact with a BLE device with a GATT C/C++ API. I have realized there was no such API existing.
The way I fixed my issue was to write my own GATT library. I have pushed the code on Github: https://github.com/labapart/gattlib
I use this library in my own BLE project and it fulfils my needs. I created few examples https://github.com/labapart/gattlib/tree/master/examples that use the library to encourage people to use it and have better feedback.
I recently found out that Qt has Bluetooth Low Energy support as host since Qt 5.7. Qt Bluetooth LE. It is available under LGPLv3 or commercial license, and exposes a C++ API.
I have a WPF desktop application that would make a good candidate as a Universal Windows App. The application has a must-have dependence on USB or Bluetooth devices that act as a Serial Port.
In all my reading I've yet to discover whether there is any access to a SerialPort API in a UWA.
I suspect the answer is 'No support'. If so, does anyone know of a USB or Bluetooth GPS that supports whatever APIs the UWA has for that sort of thing. I have to be able to read things like ground speed, elevation, rate of climb, etc.
If the answer is 'Supported', could you point me to some documentation.
For the "Bluetooth devices that act as a Serial Port", I assume you mean the RFCOMM. They are both supported on Windows Runtime since Windows 8.1 and you can also use them in the Universal Windows Application.
namespace: Windows.Devices.Usb and Windows.Devices.Bluetooth.Rfcomm.
About the Bluetooth GPS, I'm not sure if it uses RFCOMM or not (it depends on the devices), and it is also possible to use the GATT.
Code Sample: Custom USB device access sample
For my project I have an Android phone and an Arduino device that communicate via Bluetooth. I was wondering if anyone knows any software tools I could use to monitor a bluetooth communications between two devices. Something like a packet eavesdropping. Preferably for Linux.
Take a look at ubertooth one. In the linked webpage there are instructions on how to build the dongle, as well as links to shops selling assembled dongles may be bought. Ubertooth one should work well with Kismet, and thus in Linux, by using a BT plugin (disclaimer: I have no personal experience on this).
Sounds like you are after a Bluetooth sniffer.
Bad news: They are almost exclusively Windows OS based and cost mega-$.
http://www.fte.com/products/bluetooth.aspx
If you were using BlueZ for one side of the communication you could use the BlueZ HCIDUMP app and Wireshark.
I don't think anyone has made a Linuz/Bluez Sniffer - could be wrong.