-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using with Bluez #1
Comments
Hi @ukBaz, First, I think its important to warn about the state of this "project". Now, about your code, I identified 3 "things" : The errors your provided was caused by a missing Interfaces The return of from pydbus import SystemBus
from pydbus.generic import signal
from pydbus_manager import Manager
from gi.repository import GLib
class Advertisement:
"""
<node>
<interface name='org.bluez.LEAdvertisement1'>
<method name='Release'>
<annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
</method>
<annotation name="org.freedesktop.DBus.Properties.PropertiesChanged" value="const"/>
<property name="Type" type="s" access="read"/>
<property name="ServiceUUIDs" type="as" access="read"/>
<property name="ManufacturerData" type="a{sv}" access="read"/>
<property name="SolicitUUIDs" type="as" access="read"/>
<property name="ServiceData" type="a{sv}" access="read"/>
<property name="IncludeTxPower" type="b" access="read"/>
</interface>
</node>
"""
def Release(self):
pass
@property
def Type(self):
return 'peripheral'
@property
def SolicitUUIDs(self):
return ['180F']
@property
def ServiceUUIDs(self):
return ['FEAA']
@property
def ServiceData(self):
return {}
# code above produce the following error:
# "GDBus.Error:unknown.TypeError: unhashable type: 'list'"
# return {'FEAA', [0x10, 0x08, 0x03, 0x75, 0x6B, 0x42, 0x61,
# 0x7A, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75,
# 0x62, 0x2E, 0x69, 0x6F]}
@property
def IncludeTxPower(self):
return False
@property
def ManufacturerData(self):
return []
if __name__ == '__main__':
bus = SystemBus()
obj_manager = Manager(bus, 'ukBaz.bluezero')
reg1 = obj_manager.register_object('/ukBaz/bluezero/advertisement1',
Advertisement(),
None)
ad_manager = bus.get('org.bluez', '/org/bluez/hci0')['org.bluez.LEAdvertisingManager1']
ad_manager.RegisterAdvertisement('/ukBaz/bluezero/advertisement1', {})
loop = GLib.MainLoop()
try:
loop.run()
except KeyboardInterrupt:
print("\nStopping ...")
loop.quit() Note I tested using Hope I helped. |
Thanks for the quick and helpful reply. Well spotted on me missing the leading slash and ServiceData not being a correct dictionary. |
Thanks for creating this library.
I am trying to apply it to apply it to accessing the BlueZ Advertising API and I am having a few problems.
The API is:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/advertising-api.txt
Below is the code I am trying to run and also the errors I'm getting. I am struggling to understand how to correct the errors. Do you have any insight?
The text was updated successfully, but these errors were encountered: