Connect Lopy to Windows over BLE
-
Hey, i could use some help.
I am traying to send pysense data to my Windows Pc from BLE.
My first problem is i see the Lopy and i can connect him. But a few second later the Lopy disconnected.
And the secouns Problem is the GATT service what is to do with the uuid and the characteristic?
This is my code:
from network import Bluetoothpycom.rgbled(0x00008b) # blue
#Bluetooth initialisierung
bluetooth = Bluetooth()
bluetooth.set_advertisement(name='LoPy', service_uuid=b'1234567890123456')def conn_cb (bt_o):
events = bt_o.events() # this method returns the flags and clears the internal registry
if events & Bluetooth.CLIENT_CONNECTED:
print("Client connected")
pycom.rgbled(0x00ff00)
elif events & Bluetooth.CLIENT_DISCONNECTED:
print("Client disconnected")
pycom.rgbled(0xFF0000)bluetooth.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=conn_cb)
bluetooth.advertise(True)
srv1 = bluetooth.service(uuid=b'1223190123456', isprimary=True)
chr1 = srv1.characteristic(uuid=b'ab3451230123456', value=5)
while True:
print("Send Data")
chr1.value("here is the data need to be send it should be a very very long string")
time.sleep(3.050)def char1_cb_handler(chr, data):
# The data is a tuple containing the triggering event and the value if the event is a WRITE event. # We recommend fetching the event and value from the input parameter, and not via characteristic.event() and characteristic.value() events, value = data if events & Bluetooth.CHAR_WRITE_EVENT: print("Write request with value = {}".format(value)) else: print('Read request on char 1')
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login