0

I have a peripheral device that advertises custom data using a custom ad type of 0x42 in its scan response. I implemented a scanner using the Python library bluepy (https://github.com/IanHarvey/bluepy) and was able to retrieve all advertising data, including this custom ad type, from the peripheral when scanning.

For some reason, I am now moving my implementation to a bluez dbus implementation. I tried to implement a basic scanner using both dbus-python (https://pypi.org/project/dbus-python/) and pydbus (https://pypi.org/project/pydbus/), which are quite similar, and I am facing an issue: I am not able to retrieve data from this custom ad type when scanning my device. I can retrieve other standard data from the advertising of my peripheral, but I am not able to get this specific one.

Is there a way to achieve this?

pydbus simple implementation:

from gi.repository import GLib
from pydbus import SystemBus
import uuid
DEVICE_INTERFACE = 'org.bluez.Device1'
PROPERTIES_INTERFACE = 'org.freedesktop.DBus.Properties'

def on_iface_added(owner, path, iface, signal, interfaces_and_properties):
    iface_path, iface_props = interfaces_and_properties
    print("interface added:")
    print(iface_props[DEVICE_INTERFACE])


bus = SystemBus()
adapter = bus.get('org.bluez', '/org/bluez/hci0')

bus.subscribe(iface='org.freedesktop.DBus.ObjectManager',
                signal='InterfacesAdded',
                signal_fired=on_iface_added)

mainloop = GLib.MainLoop()

adapter.SetDiscoveryFilter({'DuplicateData': GLib.Variant.new_boolean(False)})
adapter.StartDiscovery()

mainloop.run()

Result: Result trace The first device is my peripheral.

  • Welcome to Stack Overflow. It has always been a bad idea to use 'reserved' code points. In the simplest case, this generates inexplicable errors because, for example, the underlying software filters the data on the basis of these code points. It is worse if you also disturb the function of others who are not involved. The best solution is to use another AD-Type, for example 'Service Data' or 'Manufacturer Specific Data'. – Risto Mar 01 '23 at 12:47

0 Answers0