I have a respberry server and a windows client, both implemented in Python. The server transmits a BLE signal like a iBeacon signal.
Here is the code of the server:
import time
from bluetooth.ble import BeaconService
service = BeaconService()
uuid = "11111111-2222-3333-4444-555555555555"
major = 2 # 1 - 65535
minor = 1 # 1 - 65535
txpower = 1
interval = 200
service.start_advertising(uuid, major, minor, txpower, interval)
try:
time.sleep(300)
service.stop_advertising()
except KeyboardInterrupt:
print("cancelled")
finally:
service.stop_advertising()
print("Done.")
This code is working fine. I checked by installing an android app and I could find the device with that information.
Now I need to get that information in the windows client. In the windows client I'm using bleak library.
I have the following code to scan for beacon devices:
import asyncio
from bleak import discover
async def run():
devices = await discover()
for d in devices:
#if d.address == "B8:27:EB:03:5A:D6":
print(d.address, d.name, d.metadata, d.rssi)
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
The problem is when I check the console, I dont see the major, minor and UUID information:
There are showed other devices and I can see in one of them that the UUID is readable. What I'm doing wrong here? Is bleak impossible to get the information I want? (minor, major) or am I transmitting in the wrong way? I dont think so because the mobile app is reading fine. Is there another library available to windows to get this information? Thanks for the help. Have a good day.