Guest User

Untitled

a guest
Jul 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. from network import Bluetooth
  2.  
  3. bluetooth = Bluetooth()
  4. bluetooth.set_advertisement(name='LoPy', service_uuid=b'1234567890123456')
  5.  
  6. def conn_cb (bt_o):
  7. events = bt_o.events() # this method returns the flags and clears the internal registry
  8. if events & Bluetooth.CLIENT_CONNECTED:
  9. print("Client connected")
  10. elif events & Bluetooth.CLIENT_DISCONNECTED:
  11. print("Client disconnected")
  12.  
  13. bluetooth.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=conn_cb)
  14.  
  15. bluetooth.advertise(True)
Add Comment
Please, Sign In to add comment