I am trying to implement a C++ code (using bluez 5.43 and dbus) to read advertisement packets from a BLE sensor. As per the bluez DBus docs, there is a StartDiscovery API that can be used to scan for nearby devices. However, I am unable to find any APIs to store/parse the advertisement packets from nearby BLE devices. The advertising-api.txt lists registeradvertisement API but as per my understanding, it can be used only for creating advertisement packets and not reading from an external device (or am I wrong?) Can someone please guide me on the correct way to get advertisement packets from nearby BLE devices using bluez and DBus?
What is the correct way to read advertisement packets from a BLE sensor using bluez 5.43 and DBus
3.1k Views Asked by codingenthusiast At
2
There are 2 best solutions below
Related Questions in C++
- C++ using std::vector across boundaries
- Linked list without struct
- Connecting Signal QML to C++ (Qt5)
- how to get the reference of struct soap inherited in C++ Proxy/Service class
- Why we can't assign value to pointer
- Conversion of objects in c++
- shared_ptr: "is not a type" error
- C++ template using pointer and non pointer arguments in a QVector
- C++ SFML 2.2 vectors
- Lifetime of temporary objects
- I want to be able to use 4 different variables in a select statement in c ++
- segmentation fault: 11, extracting data in vector
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- How can I print all the values in this linked list inside a hash table?
- Configured TTL for A record(s) backing CNAME records
Related Questions in BLUETOOTH
- Bluetooth connection to Sphero is lost when smartphone "goes to sleep"
- MFi Program by Apple
- Android Wear Device as iBeacon
- android - How to get a iBecon detection state when I kill app from Background?
- IOException: broken pipe when sending file from android device to PC via Bluetooth
- How deploy an large number iBeacons
- Send a Android BLE GATT Notification
- burst notifications with Bluetooth Low Energy on Android
- Is there a way to change bluetooth module's baud rate via Bluetooth connection with Android device?
- NFC Bluetooth handover - WITHOUT user confirmation
- Is it possible to create an app that when installed the user can easily turn Bluetooth/NFC ON and OFF by double clicking the Home button?
- Difference between attributes and services in BLE
- Global name 'bluetooth' is not defined
- iOS Bluetooth list of devices already connected?
- Bluetooth discovery not starting on first click
Related Questions in BLUETOOTH-LOWENERGY
- How to read a characteristic (e.g. in WICED Smart example "speed_test")
- Android Wear Device as iBeacon
- How to get MAC Address of beacon when ranging and monitoring in iOS
- android - How to get a iBecon detection state when I kill app from Background?
- How to use core bluetooth framework to connect Headsets/handsfree?
- Android : auto connect to heartrate sensor ble
- bluetoothGatt writeCharacteristic returns false
- Android's BLE Service Discovery (BluetoothGatt#discoverServices()) and Low Energy vs BR/EDR
- How deploy an large number iBeacons
- Send a Android BLE GATT Notification
- burst notifications with Bluetooth Low Energy on Android
- How to share files with all other devices from my iOS device through application?
- Is it possible to create an app that when installed the user can easily turn Bluetooth/NFC ON and OFF by double clicking the Home button?
- Difference between attributes and services in BLE
- How do I use Meteor and a Cordova BLE plugin to connect to a BLE device
Related Questions in DBUS
- Cannot disable systemd service
- BlueZ 5.30: D-Bus GATT API - Simply Discover and Connect to a BLE device in C
- how I can get return code of org.gnome.SessionManager.CanShutsown in JS?
- Connecting to Bluetooth Device using bluetooth_client_connect_service() - gnome-bluetooth 3.8.2.1
- dbus c program - send(with reply) and receive using method_call
- "No D-BUS daemon running" when running phpunit test
- How to export DBUS_SESSION_BUS_ADDRESS
- DBus how to start service
- how to decode dbus.Array fromat to hex or string in python
- LEAdvertisingManager1 missing from DBus.ObjectManager.GetManagedObjects
- What is the correct way to read advertisement packets from a BLE sensor using bluez 5.43 and DBus
- D-Bus related runtime crash when trying to open SDL2 window
- The trait bound `dbus::arg::Get` is not satisfied when using the Rust DBUS library
- DBus configuration wild card
- How do you create a dictionary that maps onto an array in GLib?
Related Questions in BLUEZ
- BlueZ 5.30: D-Bus GATT API - Simply Discover and Connect to a BLE device in C
- BlueZ error: Sap driver initialization failed
- BlueZ map-client and iOS 8.x device
- Bluez-Can we connect to HSP/HFP service using 2 Bluetooth headset's with signficantly less time to switch audio
- org.bluez.LEAdvertisingManager1 interface disappeared in bluez 5.31
- develop BLE peripheral using C on intel edison
- Bluetooth Low Energy: listening for notifications/indications on Raspberry Pi B+
- Connecting to Bluetooth LE devices from raspberry pi using Bluez libraries in C language
- How to set bluez mode?
- Bluetooth socket constantly timing out
- Bluetooth Low Energy - Connecting to same device
- LEAdvertisingManager1 missing from DBus.ObjectManager.GetManagedObjects
- Not discovering services after connection in some android mobile
- How can I use Bluez5 DBUS API in C++ to pair and connect new devices?
- What is the correct way to read advertisement packets from a BLE sensor using bluez 5.43 and DBus
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The behavior you described in one your last comment is the right one (the advertising data is not beeing updated) : if I am correct a BLE device is not supposed to be up all the time, it can sleep or turn to low-power etc.
In this context, it is not weird that the data is in some way "cached". From my experience, when you perform a scan and discover a device (even if you don't Connect to it), the device information will be stored for some time.
In your case, that's problematic because you are passing data through the advertising. However there is a way to force bluez to remove all it's cached data about a device : the adapter-api provides a RemoveDevice(object device) method. It takes the object path (eg "/org/bluez/hci0/dev_AA_BB_AA_BB_AA") as argument.
If you're looking for DBus bindings in C, I suggest GLib GDBus (you will find links at the bottom of this tutorial on freedesktop website : https://dbus.freedesktop.org/doc/dbus-tutorial.html).
If you are familiar with bluetoothctl (a tool to interact with bluez using commands), it was developped by the bluez guys using Glib GDbus and you can find the source code here (look at the bottom to find the command list) : https://git.kernel.org/cgit/bluetooth/bluez.git/tree/client/main.c
There are more straigthforward ways to use GDBus with bluez but bluetoothctl source code is a start and you'll find examples for pretty much anything that is possible to do with bluez =)