Inconsistent connecting with python client
I have recently bought four MetaWearC boards. They are running firmware version 1.3.6. I am experiencing inconsistent behaviour when trying to connect to the sensors via the pymetawear package. Sometimes things work fine, but after using any of the sensors for a while I fail to connect. The stack traces vary but the most common one I see is the following:
client = MetaWearClient("E6:E6:5A:18:7A:57")
error 1543082933.873459: Error on line: 296 (src/blestatemachine.cc): Operation now in progress
Traceback (most recent call last):
File "/home/peter/repos/venv36/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3267, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
client = MetaWearClient("E6:E6:5A:18:7A:57")
File "/home/peter/repos/venv36/lib/python3.6/site-packages/pymetawear/client.py", line 87, in init
self.connect()
File "/home/peter/repos/venv36/lib/python3.6/site-packages/pymetawear/client.py", line 122, in connect
self.mw.connect()
File "/home/peter/repos/venv36/lib/python3.6/site-packages/mbientlab/metawear/metawear.py", line 160, in connect
raise RuntimeError("Error initializing the API (%d)" % (self._init_status))
RuntimeError: Error initializing the API (64)
I have attatched a bluetooth trace whilst running the connect command above.
I have tried to use the MetaBase app to update the firmware on the sensors. I get the following error:
Error
Firmware update failed
(reason = Cannot use firmware v1.3.6 with this board)
Any help much appreciated!
Comments
Hi there, I'm getting an error
RuntimeError: Error initializing the API (64)
when connecting to my MetaMotionR. From looking at the code, 64 isSTATUS_ERROR_ENABLE_NOTIFY
, but not sure what that really means.The code that I run to do this is pretty simple I think:
Any ideas what could be going on?
thanks!
-zo
Hi Eric, thanks for the quick response! Metabase is running on iOS. The code is running on Raspbian, very Ubuntu-like. Soft-resetting it indeed makes the
initializing the API
error disappear, but since soft-reset now it just hangs indefinitely on connect.Perhaps relatedly, I've also intermittently seen
Failed to write value to characteristic(Error trying to issue command mid state)
errors, that also seem to disappear when soft-resetting.Luckily, Metabase appears to work perfectly fine - can connect, get accelerometer data, etc. So it appears something's up with the API, perhaps with PyWarble / liblepp? Looks like I'm fundamentally misunderstanding something here, but I'm not sure what.
Raspbian 4.14.71
metawear 0.6.1
warble 1.1.0
requests 2.12.4
liblepp latest version from its master branch
Bluez 5.50
boost 1.62
dbus 1.10.26, if that matters
firmware 1.4.2
RSSI in the 70's, battery close to 100%
And apologies, this should have been a new thread! I blindly hijacked someone else's, a bit rude.
Any ideas?
thanks!
-zo
If it helps, this is a program that consistently requires me to soft-reset:
Am I just missing something obvious here?
thanks,
-zo
I'll try to replicate these issues when I can. It seems like other users are also seeing issues with the Linux ble code.
We have also seen this issue a few times on Linux (RPi), usually when trying to communicate with multiple sensors simultaneously. A few reconnection attempts usually resolve it.
If it helps, I can also reproduce by running the
stream_data.py
example code.I can run
python stream_data.py
once, and it works just fine.If I try to run it a second time - immediately afterwards - it just hangs on connect.
If I soft-reset, then I can run it again.
Also tried upgrading to the firmware 1.4.4 but unfortunately same issue.
I'm am consistently seeing the same issues as zoo, meaning my sensors are effectively unusable with a Linux environment. Having had no luck upgrading the firmware via the metabase app I tried to do the upgrade programatically with the following code:
This appears to load the latest firmware onto the sensor but then fails with the following message:
Failed to write value to characteristic(Read Error.)
@pwwooldridge,
Please don't update firmware via our Python script/example. We have actually removed the update_firmware.py script from the Python repository.
You can only update firmware using the latest Android and iOS MetaBase App (and you should do so asap).
@Laura any thoughts on what the issue might be?
thanks,
-zo
The underlying issue is with how the libblepp library is used. We are still looking into it.
Hi Laura,
attached is a screenshot of what the app shows when I try to do update the firmware inside the metabase app
v1.4.4 is not supported with your board.
https://mbientlab.com/community/discussion/2773/firmware-upgrade-path#latest
Cool - thanks for the update Eric
-zo
Is there perhaps a previous version of libblepp that's known to work? I installed the latest master version, perhaps being overly optimistic.
thanks,
-zo
@Eric - Thanks for clarifying!
Just checking in - any news / progress here?
I still have the same condition
I have not been able to replicate the init status 64 error in my VM or on our Pi.
Record the BT adapter activity when you encounter this error and post it in the thread;
I added a trace to my first post on this discussion, if this is not useful then I can get another. In terms of recreating the error, it seems to happen mostly when trying to initiate connections to multiple sensors.
How many is multiple?
I'm getting the issue fairly consistently trying to connect to 3 Metawear-C sensors
Hi All,
Updating this thread.
I did a fresh ubuntu install and tried Python examples using Python2 and Python3 and everything worked like a charm. I updated the tutorials as such: www.mbientlab.com/tutorials. It might help a few folks here.
Hi Laura,
we are working since couple of months in a project with Python (linux) and we are struggling with randomly connection problems with multiple boards and cannot determine the origin of the issues.
Could you please share with us your working environment:
.1. OS Version (is it native Linux installation or in a VM, if in VM then which VM Version is used)
2. BlueZ Version
3. Bluetooth dongle (which chip is used)
4. Metaboard type and Firmware
Have you tried to connect multiple board to one BLE dongle/multiple BLE Dongles (we are experiencing connection probems here too)?
Thanks in advance
@Akash,
A few things to note in our experience with Bluetooth and multiple devices:
Hope this helps.
I'm having the same issue:
python led.py "CA:0A:65:86:22:1B"
error 1561471015.358345: Error on line: 296 (src/blestatemachine.cc): Operation now in progress
Traceback (most recent call last):
File "led.py", line 11, in
device.connect()
File "/home/ssqr/SSquare/sspy35_env/lib/python3.5/site-packages/mbientlab/metawear/metawear.py", line 160, in connect
raise RuntimeError("Error initializing the API (%d)" % (self._init_status))
RuntimeError: Error initializing the API (64)
I reinstalled MetaWear-SDK-Python first from master branch and the from 0.7.0 tag.
I also upgraded the sensor firmware to 1.4.4.
/first, I tested in master and 0.7.0 w/o firmware change.
Then with the 1.4.4 firmware. Same result.
uname -a
Linux SSQR 4.19.42-v7+ #1219 SMP Tue May 14 21:20:58 BST 2019 armv7l GNU/Linux
python --version
Python 3.5.3
Am I missing something here?
Please help.
Post a log of bt adapter activity like OP