nrf5/modules: Updating ubluepy example to turn led2 on and off when receiving connected and disconnect bluetooth event.

This commit is contained in:
Glenn Ruben Bakke 2017-02-15 23:58:23 +01:00
parent d88320b5b3
commit 18365135f7
1 changed files with 10 additions and 1 deletions

View File

@ -37,10 +37,19 @@ p.advertise(device_name="MicroPython")
DB setup:
from ubluepy import Service, Characteristic, UUID, Peripheral
from pyb import LED
def event_handler(id, length, data):
print("BLE event:", id, " length: ", length)
from ubluepy import Service, Characteristic, UUID, Peripheral
if id == 16:
# connected
LED(2).on()
elif id == 17:
# disconnect
LED(2).off()
u0 = UUID("6e400001-b5a3-f393-e0a9-e50e24dcca9e")
s = Service(u0)
u1 = UUID("6e400002-b5a3-f393-e0a9-e50e24dcca9e")