Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import bluetooth
  2.  
  3. class btDevice:
  4. btId = ""
  5. btName = ""
  6.  
  7. def listDevices():
  8. allDevices = bluetooth.discover_devices()
  9. allDeviceTypes = []
  10. for original in allDevices:
  11. newDevice = btDevice()
  12. newDevice.btId = original
  13.  
  14. name = bluetooth.lookup_name(original)
  15. if len(name) > 12:
  16. name = name.replace(" ", "\n")
  17. newDevice.btName = name
  18.  
  19. allDeviceTypes.append(newDevice)
  20.  
  21. return allDeviceTypes
  22.  
  23. socket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
  24. def connect(btId):
  25. socket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
  26. socket.connect((btId, 3))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement