You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use bluezero to advertise the data to BLE devices around me without pairing to them.
I try to implement the following sequence: (it works in Java already, using that is not an option)
Advertise "query" command to devices
Each device responds with its unique id
Advertise "flash" command with specific device id (all devices whose id is different ignore the command)
I can send "query" and receive the responses (using bleak library), the problem arises when I need to send 2-nd command.
Here's the code stripped of sensitive and non-relevant data:
class BluetoothSender:
beacon = broadcaster.Beacon()
def __init__(self):
self.ad_manager = advertisement.AdvertisingManager(self.beacon.dongle.address)
self.ads = []
def add_advertisement(self, manufacturer_data, uid):
global ad_id
new_ad = advertisement.Advertisement(ad_id+1, 'broadcast')
ad_id += 1
new_ad.manufacturer_data(INGY_ID, manufacturer_data)
# converting uid to format "12345678-1234-1234-1234-1234567890AB"
new_ad.service_UUIDs = [uid_str] # in
self.ads.append(new_ad)
self.ad_manager.register_advertisement(new_ad)
def start_advertising(self):
if not self.beacon.dongle.powered:
self.beacon.dongle.powered = True
for ad in self.ads:
ad.start()
def unregister_ads(self):
for ad in self.ads:
ad.stop()
self.ad_manager.unregister_advertisement(ad)
self.ads = []
async def advertise_for(self, timeout_seconds):
p = Process(target=self.start_advertising)
p.start()
await asyncio.sleep(timeout_seconds)
p.terminate()
driver code:
beacon = BluetoothSender()
beacon.add_advertisement(manufacturer_data, uuid)
task = asyncio.create_task(beacon.advertise_for(time))
await task
uuid, man_data = flash_command.encode()
# tried with the old beacon object as well
del beacon
new_beacon = BluetoothSender()
new_beacon.add_advertisement(man_data, uuid)
new_task = asyncio.create_task(new_beacon.advertise_for(time))
await new_task
Everything goes fine until I try to advertise the 2-nd time. On ad.start() DBus throws an error:
Failed to register advertisement: org.freedesktop.DBus.Error.UnknownMethod: Method "RegisterAdvertisement" with signature "sa{sv}" on interface "org.bluez.LEAdvertisingManager1" doesn't exist
I found this answer at stackoverflow, however I do not understand if this is done when I create a new beacon object (I guess so?) or not.
In any case, there is this issue and I require your help.
Thanks in advance!
The text was updated successfully, but these errors were encountered:
I use bluezero to advertise the data to BLE devices around me without pairing to them.
I try to implement the following sequence: (it works in Java already, using that is not an option)
I can send "query" and receive the responses (using bleak library), the problem arises when I need to send 2-nd command.
Here's the code stripped of sensitive and non-relevant data:
driver code:
Everything goes fine until I try to advertise the 2-nd time. On
ad.start()
DBus throws an error:I found this answer at stackoverflow, however I do not understand if this is done when I create a new beacon object (I guess so?) or not.
In any case, there is this issue and I require your help.
Thanks in advance!
The text was updated successfully, but these errors were encountered: