3
0

bluetooth.py 629 B

123456789101112131415161718192021222324252627
  1. def bt_ctrl_ispowered():
  2. # this method will return available bluetooth devices as a list for the web template output
  3. import bluew
  4. #return len(bluew.controllers())
  5. bt_ctrl_powered = False
  6. for dev in bluew.controllers():
  7. if dev.Powered == True:
  8. bt_ctrl_powered = True
  9. return bt_ctrl_powered
  10. def bt_getDevices():
  11. import bluew
  12. #return len(bluew.devices())
  13. if bt_ctrl_ispowered() == True:
  14. retdevs = bluew.devices()
  15. else:
  16. retdevs = []
  17. return retdevs
  18. def bt_getControllers():
  19. import bluew
  20. retctrl = bluew.controllers()
  21. return retctrl