Lopy Bluetooth connection is lost after few seconds
Hi guys, I'm here to report a strange behavior I'am getting with Lopy.
I'm trying to establish a connection between Lopy (server/peripheral role) and a Raspberry Pi 3 B (client/central role).
From the RPi3 side I'm trying to connect to the Lopy using a Python script I wrote using Bluepy. Unfortunately, after I establish a connection, it lasts for a few seconds. This is very random: sometimes the connection lasts for half a second, sometimes it lasts for a minute (in this case I am able to see the services in the Lopy). I get the same issue if, instead of using my python script, I use the well known gatttool: even here same behavior (connections drops after few seconds).
Both my python script and gatttool work fine if I connect my RPi3 to a BLENano2.
Strangely, if I use the android app nRF Connect and try to connect with Lopy everything works fine! In this case the connection lasts untill I manually disconnect and I'm free to see the GATT server.
Here is the code in the Lopy, as you can see I didn't create a GATT server (there are only the default services Generic Attribute and Generic Access and it works with nRF Connect) in order to keep the code smooth, I assure you that I get the same issue with services and characteristics:
from network import Bluetooth import pycom import os print (os.uname()) pycom.heartbeat(False) pycom.rgbled(0x110000) myBle = Bluetooth() def connection_cb (bt_o): events = bt_o.events() if events & Bluetooth.CLIENT_CONNECTED: pycom.rgbled(0x000555) #If connected the RGB led has this color. I can see the disconnection if the color changes. myBle.advertise(False) print("Client connected") elif events & Bluetooth.CLIENT_DISCONNECTED: pycom.rgbled(0x555000) myBle.advertise(True) print("Client disconnected") myBle.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=connection_cb) myBle.set_advertisement(name='LoPy_Marco') myBle.advertise(True)
(sysname='LoPy', nodename='LoPy', release='1.18.1', version='v1.8.6-849-f517b1d on 2018-08-28', machine='LoPy with ESP32', lorawan='1.0.2')
Let me know if you need to know more. Thank you guys for your help!