Reputation: 383
I want to automate the connection of a device running linux with my Windows PC. On the device side, I'm able to automate the connection using 'expect' in bash. On windows, I downloaded Bluetooth Command Line Tools to attempt to automate the PC side. I was able to pair with my device using the friendly name of the device, however I did need to manually accept a prompt in Windows that asked me whether a Pin on my device matched the pin in the prompt. The terminal on my linux device did indeed show the same pin, so I clicked 'matches', and then was able to pair the device.
I tried to configure Windows Bluetooth service not to alert me when a new connection comes in, but when I change that, I am just unable to pair in this case. When I start a pairing session from the Windows PC, it just hangs indefinitely. Is it possible to do what I'm trying to do from a Windows PC, or am I out of luck?
Upvotes: 1
Views: 601
Reputation: 13345
I haven't used this myself, but you can maybe try and use Bleak for what you want. According to the website:-
One can use the BleakClient to connect to a Bluetooth device and read its model number via the asynchronous context manager like this:
import asyncio
from bleak import BleakClient
address = "24:71:89:cc:09:05"
MODEL_NBR_UUID = "00002a24-0000-1000-8000-00805f9b34fb"
async def main(address):
client = BleakClient(address)
try:
await client.connect()
model_number = await client.read_gatt_char(MODEL_NBR_UUID)
print("Model Number: {0}".format("".join(map(chr, model_number))))
except Exception as e:
print(e)
finally:
await client.disconnect()
asyncio.run(main(address))
You can find more relevant information here:-
Upvotes: 0