Advertisement
RoseStorm

bluetooth_search.py

Jul 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from bluetooth import *
  3.  
  4.  
  5. def looking_for():
  6. # Procura por dispositivos disponiveis
  7. devices = discover_devices(lookup_names = True)
  8. print devices
  9. # Retorna nome, endereco dos dispositivos
  10. return devices
  11.  
  12.  
  13. def connect(choose_device, message):
  14. # Abre o socket
  15. client = BluetoothSocket(RFCOMM)
  16.  
  17. # Conecta ao dispositivo escolhido
  18. client.connect( (choose_device, 3) )
  19. if client.connect: return True
  20.  
  21. def send(message):
  22. # Manda a mensagem em forma de string
  23. client.send(message)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement