Unreliable connectivity

Hello all,

I am trying to maintain consistent connectivity with the sensor and connect to it as fast as possible when it is in the range. However, sometimes the sensor takes much longer to connect as it has trouble discovering the services or the characteristics. I call device.connect() continuously from python (with ~1s breaks in between), I receive the Connected message, but immediately after that I get one of the following errors:
mbientlab.warble.WarbleException: Failed to discover gatt services (status = 1)
or
mbientlab.warble.WarbleException: Failed to discover gatt characteristics (status = 1)

This loop can continue for minutes!

I am using the latest combination of warble/PyWarble/Python SDK (I compiled the latest HEAD of warble). Meanwhile from a similar distance I easily connect to the sensor through the iOS app.

Do you have any idea how to make the behavior more reliable? I can play with the c++ code and try to understand what exactly causes this error or I can run some experiments if you have any advice.

Thanks!

Comments

  • .> @rhristov said:

    I am using the latest combination of warble/PyWarble/Python SDK (I compiled the latest HEAD of warble). Meanwhile from a similar distance I easily connect to the sensor through the iOS app.

    The iOS ble stack is probably the best out of all platforms.

    Do you have any idea how to make the behavior more reliable? I can play with the c++ code and try to understand what exactly causes this error or I can run some experiments if you have any advice.

    • Post your machine specs
    • Post the code that reliably exhibits this behaviour
    • Try the JavaScript SDK on the same machine
    • Monitor the Bluetooth adapter while the script is running
  • ~\Scripts\mbientlab\MetaWear-SDK-Python\examples>python scan_connect.py
    scanning for devices...
    [0] D6:67:20:8B:67:37 (MetaWear)
    [1] 57:5A:BE:01:E0:A8 ()
    [2] 72:43:91:CB:20:B7 ()
    Select your device (-1 to rescan): 0
    Connecting to D6:67:20:8B:67:37...
    Traceback (most recent call last):
    File "scan_connect.py", line 37, in
    device.connect()
    File "C:\Python27amd64\lib\site-packages\mbientlab\metawear\metawear.py", line 195, in connect
    raise result[0]
    mbientlab.warble.WarbleException: Failed to discover gatt services

    ~\Scripts\mbientlab\MetaWear-SDK-Python\examples>python scan_connect.py
    scanning for devices...
    [0] 57:5A:BE:01:E0:A8 ()
    [1] D6:67:20:8B:67:37 (MetaWear)
    [2] 58:05:36:DD:17:DA ()
    [3] 5F:A0:B6:0E:6B:06 ()
    [4] 72:43:91:CB:20:B7 ()
    Select your device (-1 to rescan): 1
    Connecting to D6:67:20:8B:67:37...
    Connected
    Device information: {u'hardware': u'0.2', u'model': u'4', 'firmware': u'1.3.6', u'serial': u'00D284', u'manufacturer': u'MbientLab Inc'}
    Disconnected

    I am also struggling with this error. In an ordinary cmd window (Win 10), HP Zbook Studio G4, after navigating to the folder with example scripts, I try python scan_connect.py
    The first time it returns the mbientlab.warble.WarbleException, the second time (without changing anything, just executing the same command) it works fine.

    Any comments why this is? I am a bit puzzled here.

  • @rjromijnders said:
    Any comments why this is? I am a bit puzzled here.

    That's expected; connect won't always succeed.

  • I faced the same issue on my Ubuntu OS when I was inside my virtual environment. When I deactivated my virtual environment, I am able to connect without any issue.
    Hope this will help others!

  • There is a section about this in our tutorials. You need to set up bluetooth in your virtual OS. You can google-fu this.

Sign In or Register to comment.