Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bluetooth
- class btDevice:
- btId = ""
- btName = ""
- def listDevices():
- allDevices = bluetooth.discover_devices()
- allDeviceTypes = []
- for original in allDevices:
- newDevice = btDevice()
- newDevice.btId = original
- name = bluetooth.lookup_name(original)
- if len(name) > 12:
- name = name.replace(" ", "\n")
- newDevice.btName = name
- allDeviceTypes.append(newDevice)
- return allDeviceTypes
- socket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
- def connect(btId):
- socket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
- socket.connect((btId, 3))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement