Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with MiaoMiao 2 ? #11

Open
bordeb opened this issue May 23, 2021 · 51 comments
Open

Problem with MiaoMiao 2 ? #11

bordeb opened this issue May 23, 2021 · 51 comments

Comments

@bordeb
Copy link

bordeb commented May 23, 2021

Dear @tzachi-dar , yesterday I have made a switch from MiaoMiao 1 to MiaoMiao 2 and it seams that LibreAllHouse is not collecting data any more. Is it a compatibility issue with MiaoMiao 2 or am I missing something? We are using libreallhouse for at least 3 years and I am afraid that this is a compatibility issue which I was not aware till now. Is there anything I could do to resolve this? THANK YOU very much in advance!

@bordeb
Copy link
Author

bordeb commented May 23, 2021

Now I have noticed the new info in the documentation https://docs.google.com/document/d/1955quKMUfaVHyQZLw3k8IEkPFv3od00bA0AoJKY96xE/edit?usp=sharing
Sorry for not seeing it earlier.
Can I now just proceed to build bluepy from sources as it is suggested in documentation or do I need to start from the begining, because the Pi that is serving for libreallhouse is all prepared in accordance with the guidance for miaomiao 1 ?

@tzachi-dar
Copy link
Owner

You can install it on the sam rpi.
I have noticed that on new pi's installation, there is a need to also copy the files manually, but I don't think it will be a problem with old rpis.

@bordeb
Copy link
Author

bordeb commented May 23, 2021

Dear @tzachi-dar thank you very much on your valuable time spent to provide support!!
When going through the documentation and trying to execute
sudo cp bluepy/*.py /usr/local/lib/python3.7/dist-packages/bluepy/
it returns error that cp target is not a directory. Probably there is some issue with python 3 version?
I started from scratch with blank installation of 2018-03-13-raspbian-stretch as it is suggested in the latest version of guidance.
Can you please provide some guidance!

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 23, 2021 via email

@bordeb
Copy link
Author

bordeb commented May 23, 2021

I will report it here. Now I have started the apt-get upgrade but it takes long time as it is RPI-zero. Thanks for such a quick response

@bordeb
Copy link
Author

bordeb commented May 23, 2021

Hi @tzachi-dar
Here is my report. Unfortunately it does not work for me. Here is the exact steps

clean install of the 2018-03-13-raspbian-stretch and then following commands:

`sudo apt-get update

sudo apt-get install git

sudo apt-get install screen

sudo apt-get install python3-pip build-essential libglib2.0-dev

sudo pip3 install bluepy

sudo pip3 install pymongo

sudo pip3 install dnspython

git clone https://github.com/IanHarvey/bluepy.git

cd bluepy

python3 setup.py build

sudo python3 setup.py install

git clone https://github.com/tzachi-dar/LibreAllHouse.git

cd LibreAllHouse

sudo nano config.cfg
MAC address of the MM2 inserted manually

sudo nano /etc/rc.local
/usr/bin/screen -L /home/pi/LibreAllHouse/screen.log -dmS tomato python3 /home/pi/LibreAllHouse/main.py

tail -F ~/LibreAllHouse/screen.log
`
The screen log says:
2021-05-23 19:10:42.991: event wait ended, ret = False
INFO 2021-05-23 19:11:25,149 restarting since time from last packet is 298 already acumulated 60
10
2021-05-23 19:11:42.998: event wait ended, ret = False
INFO 2021-05-23 19:16:33,268 cought btle.BTLEException Failed to connect to peripheral xx:xx:xx:xx:xx:xx, addr type: random
Connecting...
2021-05-23 19:17:52.970: event wait ended, ret = False
Services...
Service <uuid=Generic Access handleStart=1 handleEnd=9>
Service <uuid=Generic Attribute handleStart=10 handleEnd=13>
Service <uuid=6e400001-b5a3-f393-e0a9-e50e24dcca9e handleStart=14 handleEnd=19>
Service <uuid=8ec9fe59-f315-4f60-9fb8-838830daea50 handleStart=20 handleEnd=65535>
charterstics...
Characteristic <6e400002-b5a3-f393-e0a9-e50e24dcca9e>
Characteristic <6e400003-b5a3-f393-e0a9-e50e24dcca9e>
nrfGattCharacteristic = [<bluepy.btle.Characteristic object at 0xb5c10330>]
NOTIFY
Init called.
b'\xf0'
INFO 2021-05-23 19:18:09,945 restarting since time from last packet is 136 already acumulated 0
021-05-23 19:18:52.979: event wait ended, ret = False
2021-05-23 19:19:52.986: event wait ended, ret = False
2021-05-23 19:20:52.994: event wait ended, ret = False
2021-05-23 19:21:53.003: event wait ended, ret = False

EDIT: Something must be happening regarding Bluetooth connection as it seams that RPI is somehow connecting to MM2 because it is not visible for other devices until the RPI is shut down. Then it becomes visible. Nevertheless, the glucose data is not transmitted.

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 23, 2021 via email

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 23, 2021 via email

@bordeb
Copy link
Author

bordeb commented May 23, 2021

Hi @tzachi-dar , tnx very much

After runing the code again nothing improved so I continued with two making copies of the two files:

My python is 3.5 so I was able to copy with the first command sligthly changed to:
sudo cp bluepy/*.py /usr/local/lib/python3.5/dist-packages/bluepy/

But with the seconda command I have no luck and can not detect exact numbers version to change. I have detected that my rpi os is armv6l instead of armv7l , but other two numbers can not detect. I have tried with 2.6 and 2.7 and also without them but no luck here:?

sudo cp ./build/lib.linux-armv6l-?.?/bluepy/bluepy-helper /usr/local/lib/python3.5/dist-packages/bluepy/bluepy-helper

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 23, 2021 via email

@bordeb
Copy link
Author

bordeb commented May 23, 2021

Thank you very much on your support!
Seams that I have broken something with this coping. Now the logs says

File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 630, in del
self.disconnect()
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 453, in disconnect
self._writeCmd("disc\n")
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 305, in _writeCmd
self._helper.stdin.flush()
BrokenPipeError: [Errno 32] Broken pipe

I am not sure what is happening. MM1 works for years with RPI Zero W.
Maybe I should try again from clean install od the raspbian and then update to the latest "stretch" version. This will update the python to 3.5.3 so it might work better. I think python 3.5.3 is latest for now on raspbian stretch. Should I try to manually install python 3.7?

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 24, 2021 via email

@bordeb
Copy link
Author

bordeb commented May 24, 2021

Thanks so so much!!
I have now prepared clean install fully updated (apt-get update) of the "stretch" raspbian OS version and will now proceed with the tutorial once more and report here the result.

If it goes wrong again, I will try "buster" then. On buster, is it also necessary to?:

$ sudo apt-get install git build-essential libglib2.0-dev
$ git clone https://github.com/IanHarvey/bluepy.git
$ cd bluepy
$ python3 setup.py build
$ sudo python3 setup.py install

?

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 24, 2021 via email

@bordeb
Copy link
Author

bordeb commented May 24, 2021

I have performed clean install of the stretch, full update, full install LibreAllHouse according to the guidance but it does not work.
Only thing I did not perform yest is the manual copy that last time broke my installation. Please advise me not to kill this installation:

Linux rpi 4.19.66+ #1253 Thu Aug 15 11:37:30 BST 2019 armv6l

find /home/pi/bluepy -name bluepy-helper
returns:
**/home/pi/bluepy/build/lib/bluepy/bluepy-helper**
**/home/pi/bluepy/bluepy/bluepy-helper**

find /usr/local/lib -name bluepy-helper
returns:
**/usr/local/lib/python3.5/dist-packages/bluepy-1.3.0-py3.5.egg/bluepy/bluepy-helper**
**/usr/local/lib/python3.5/dist-packages/bluepy/bluepy-helper**

python3 --version
Python 3.5.3

How to properly try to copy the files?

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 24, 2021 via email

@bordeb
Copy link
Author

bordeb commented May 24, 2021

here they are:
$ ls -l /home/pi/bluepy/build/lib/bluepy/bluepy-helper
-rwxr-xr-x 1 root root 702776 May 24 11:37 /home/pi/bluepy/build/lib/bluepy/bluepy-helper
$ ls -l /home/pi/bluepy/bluepy/bluepy-helper
-rwxr-xr-x 1 root root 702776 May 24 11:37 /home/pi/bluepy/bluepy/bluepy-helper

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 24, 2021 via email

@bordeb
Copy link
Author

bordeb commented May 24, 2021

Thank you very much! I did it, but unfortunately, it seams that again it broke. Here is the log:
Waiting for connections
INFO 2021-05-24 13:58:05,184 cought btle.BTLEException Failed to connect to peripheral d8:c1:7a:f5:a1:d0, addr type: random
2021-05-24 13:58:24.395: event wait ended, ret = False
Connecting...
2021-05-24 13:59:24.405: event wait ended, ret = False
Services...
INFO 2021-05-24 13:59:31,647 cought btle.BTLEException Helper exited
Exception ignored in: <bound method Peripheral.del of <bluepy.btle.Peripheral object at 0xb6a7de10>>
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 630, in del
self.disconnect()
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 453, in disconnect
self._writeCmd("disc\n")
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 305, in _writeCmd
self._helper.stdin.flush()
BrokenPipeError: [Errno 32] Broken pipe

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 24, 2021 via email

@bordeb
Copy link
Author

bordeb commented May 24, 2021

Yes, the copy was sucesfull. No errors.

After enabling Debugging the log is:

Connecting...
2021-05-24 14:06:24.469: event wait ended, ret = False
INFO 2021-05-24 14:06:34,623 cought btle.BTLEException Failed to connect to peripheral d8:c1:7a:f5:a1:d0, addr type: random
['BTDevice', 'MongoData', 'TcpSockets']
/home/pi/LibreAllHouse/LibreReadings.db
2021-05-24 14:08:21.298: Mongo caught exception in first write A '/' is required between the host list and any options.InvalidURI
2021-05-24 14:08:21.336: Starting mongo thread
Connecting...
Running /usr/local/lib/python3.5/dist-packages/bluepy/bluepy-helper
Socket created

Waiting for connections
Sent: conn d8:c1:7a:f5:a1:d0 random

Got: '# bluepy-helper.c version 1.3.0 built at 11:35:31 on May 24 2021\n'
Got: "rsp=$stat\x1estate=$tryconn\x1edst='d8:c1:7a:f5:a1:d0\x1emtu=h0\x1esec='low\n"
Got: "rsp=$stat\x1estate=$conn\x1edst='d8:c1:7a:f5:a1:d0\x1emtu=h0\x1esec='low\n"
Services...
Sent: svcs

Got: "rsp=$stat\x1estate=$conn\x1edst='d8:c1:7a:f5:a1:d0\x1emtu=hF7\x1esec='low\n"
Got: ''
Got: ''
Got: ''
Got: ''
INFO 2021-05-24 14:08:22,300 cought btle.BTLEException Helper exited
Sent: disc

Exception ignored in: <bound method Peripheral.del of <bluepy.btle.Peripheral object at 0xb5bbedb0>>
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 630, in del
self.disconnect()
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 453, in disconnect
self._writeCmd("disc\n")
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 305, in _writeCmd
self._helper.stdin.flush()
BrokenPipeError: [Errno 32] Broken pipe
2021-05-24 14:09:21.345: event wait ended, ret = False
Connecting...
Running /usr/local/lib/python3.5/dist-packages/bluepy/bluepy-helper
Sent: conn d8:c1:7a:f5:a1:d0 random

Got: '# bluepy-helper.c version 1.3.0 built at 11:35:31 on May 24 2021\n'
Got: "rsp=$stat\x1estate=$tryconn\x1edst='d8:c1:7a:f5:a1:d0\x1emtu=h0\x1esec='low\n"
Got: "rsp=$stat\x1estate=$conn\x1edst='d8:c1:7a:f5:a1:d0\x1emtu=h0\x1esec='low\n"
Services...
Sent: svcs

Got: "rsp=$stat\x1estate=$conn\x1edst='d8:c1:7a:f5:a1:d0\x1emtu=hF7\x1esec='low\n"
Got: ''
Got: ''
Got: ''
INFO 2021-05-24 14:09:23,681 cought btle.BTLEException Helper exited
Sent: disc

Exception ignored in: <bound method Peripheral.del of <bluepy.btle.Peripheral object at 0xb69b0e10>>
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 630, in del
self.disconnect()
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 453, in disconnect
self._writeCmd("disc\n")
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 305, in _writeCmd
self._helper.stdin.flush()
BrokenPipeError: [Errno 32] Broken pipe
2021-05-24 14:10:21.356: event wait ended, ret = False
Connecting...
Running /usr/local/lib/python3.5/dist-packages/bluepy/bluepy-helper
Sent: conn d8:c1:7a:f5:a1:d0 random

Got: '# bluepy-helper.c version 1.3.0 built at 11:35:31 on May 24 2021\n'
Got: "rsp=$stat\x1estate=$tryconn\x1edst='d8:c1:7a:f5:a1:d0\x1emtu=h0\x1esec='low\n"
Got: "rsp=$stat\x1estate=$conn\x1edst='d8:c1:7a:f5:a1:d0\x1emtu=h0\x1esec='low\n"
Services...
Sent: svcs

Got: "rsp=$stat\x1estate=$conn\x1edst='d8:c1:7a:f5:a1:d0\x1emtu=hF7\x1esec='low\n"
Got: ''
Got: ''
INFO 2021-05-24 14:10:24,754 cought btle.BTLEException Helper exited
Sent: disc

Exception ignored in: <bound method Peripheral.del of <bluepy.btle.Peripheral object at 0xb691ce10>>
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 630, in del
self.disconnect()
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 453, in disconnect
self._writeCmd("disc\n")
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 305, in _writeCmd
self._helper.stdin.flush()
BrokenPipeError: [Errno 32] Broken pipe
2021-05-24 14:12:21.375: event wait ended, ret = False
Connecting...
Running /usr/local/lib/python3.5/dist-packages/bluepy/bluepy-helper
Sent: conn d8:c1:7a:f5:a1:d0 random

Got: '# bluepy-helper.c version 1.3.0 built at 11:35:31 on May 24 2021\n'
Got: "rsp=$stat\x1estate=$tryconn\x1edst='d8:c1:7a:f5:a1:d0\x1emtu=h0\x1esec='low\n"
Got: "rsp=$stat\x1estate=$disc\x1emtu=h0\x1esec='low\n"
Stopping /usr/local/lib/python3.5/dist-packages/bluepy/bluepy-helper
INFO 2021-05-24 14:13:06,002 cought btle.BTLEException Failed to connect to peripheral d8:c1:7a:f5:a1:d0, addr type: random
2021-05-24 14:13:21.384: event wait ended, ret = False
Connecting...

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 24, 2021 via email

@bordeb
Copy link
Author

bordeb commented May 24, 2021

Thank you very very much! Your expertise will be so valuable to evaluate rpi zero w. Please let me know if I can buy a test RPI zero W for you or any other contribution!

Just to provide additional info:
I tried with clean install of the buster instead of scratch but with no sucess at the end. Only thing that is better is that the copy/paste thing did not broke the installation.

The debug logfile now says:
bad start byte 201
bad end byte 0
bad length of buffer 968
2021-05-24 19:05:29.169: event wait ended, ret = True
INFO 2021-05-24 19:05:29,168 tryAgainAlowed numberOfCrcErrors_ = 1 NumberOfDiscnections_ = 0
INFO 2021-05-24 19:05:29,179 We are still allowed to retry
INFO 2021-05-24 19:05:34,186 Sending a request for more data after send failure
INFO 2021-05-24 19:05:34,190 restarting since time from last packet is 5 already acumulated 363
INFO 2021-05-24 19:05:34,706 cought btle.BTLEException Device disconnected
['BTDevice', 'MongoData', 'TcpSockets']
/home/pi/LibreAllHouse/LibreReadings.db
2021-05-24 19:06:48.462: Mongo caught exception in first write A '/' is required between the host list and any options.InvalidURI
2021-05-24 19:06:48.499: Starting mongo thread
Socket created

Waiting for connections
Connecting...
Running /usr/local/lib/python3.7/dist-packages/bluepy/bluepy-helper
Sent: conn d8:c1:7a:f5:a1:d0 random

Got: '# bluepy-helper.c version 1.3.0 built at 18:29:15 on May 24 2021\n'
Got: "rsp=$stat\x1estate=$tryconn\x1edst='d8:c1:7a:f5:a1:d0\x1emtu=h0\x1esec='low\n"
Got: "rsp=$stat\x1estate=$conn\x1edst='d8:c1:7a:f5:a1:d0\x1emtu=h0\x1esec='low\n"
Services...
Sent: svcs

Got: "rsp=$stat\x1estate=$conn\x1edst='d8:c1:7a:f5:a1:d0\x1emtu=hF7\x1esec='low\n"
Got: "rsp=$find\x1ehstart=h1\x1ehend=h9\x1euuid='00001800-0000-1000-8000-00805f9b34fb\x1ehstart=hA\x1ehend=hD\x1euuid='00001801-0000-1000-8000-00805f9b34fb\x1ehstart=hE\x1ehend=h13\x1euuid='6e400001-b5a3-f393-e0a9-e50e24dcca9e\x1ehstart=h14\x1ehend=hFFFF\x1euuid='8ec9fe59-f315-4f60-9fb8-838830daea50\n"
Service <uuid=Generic Access handleStart=1 handleEnd=9>
Service <uuid=Generic Attribute handleStart=10 handleEnd=13>
Service <uuid=6e400001-b5a3-f393-e0a9-e50e24dcca9e handleStart=14 handleEnd=19>
Service <uuid=8ec9fe59-f315-4f60-9fb8-838830daea50 handleStart=20 handleEnd=65535>
charterstics...
Sent: char E 13

Got: "rsp=$find\x1ehnd=hF\x1eprops=hC\x1evhnd=h10\x1euuid='6e400002-b5a3-f393-e0a9-e50e24dcca9e\x1ehnd=h11\x1eprops=h10\x1evhnd=h12\x1euuid='6e400003-b5a3-f393-e0a9-e50e24dcca9e\n"
Characteristic <6e400002-b5a3-f393-e0a9-e50e24dcca9e>
Characteristic <6e400003-b5a3-f393-e0a9-e50e24dcca9e>
nrfGattCharacteristic = [<bluepy.btle.Characteristic object at 0xb4d87230>]
NOTIFY
Sent: desc 13 FFFF

Got: "rsp=$desc\x1ehnd=h13\x1euuid='00002902-0000-1000-8000-00805f9b34fb\x1ehnd=h14\x1euuid='00002800-0000-1000-8000-00805f9b34fb\x1ehnd=h15\x1euuid='00002803-0000-1000-8000-00805f9b34fb\x1ehnd=h16\x1euuid='8ec90003-f315-4f60-9fb8-838830daea50\x1ehnd=h17\x1euuid='00002902-0000-1000-8000-00805f9b34fb\n"
Sent: wr 13 0100

Got: 'rsp=$wr\n'
Init called.
b'\xf0'
Sent: wr 10 f0

Got: 'rsp=$wr\n'
Got: 'rsp=$ntfy\x1ehnd=h12\x1ed=b28016B0ECE98FE980700A007E0530004100152E1D01803000000000000000000000000000000000000003BD50E1CBC03C8D8D700B203C8D09700AB03C8B09700A803C8A8D7009F03C8A817809603C8B017808D03C8B417808D03C8AC17808D03C89C57808503C8A057008303C8A057007F03C88817808003887217807B03C8641780\n'
INFO 2021-05-24 19:06:51,902 restarting since time from last packet is 3 already acumulated 0
Select timeout
Select timeout
Select timeout
Select timeout

Select timeout
Select timeout
......
Select timeout
Select timeout
Select timeout
Got: 'rsp=$ntfy\x1ehnd=h12\x1ed=bC903C8DC9700BF03C8D89700A302C8545A808602C88419804D02C84019805A02C82819802A03C8C0D8005103C8FC5800F902C84419806702C85059004F02C8141901D402C8505800A202C8085800A102C87018019902C85C1801AA02C8B49800E902C89817802603C88C17804103C86C58014F03C8A018016303C8B0D8009303C868\n'
INFO 2021-05-24 19:11:51,270 restarting since time from last packet is 299 already acumulated 130
Got: 'rsp=$ntfy\x1ehnd=h12\x1ed=b1801D903C8EC57002C04C89018017504C83098007A04C88818013B04C87818011504C83CD800E703C8581801A503C8A8D7007803C8641A802503C8885A80DA02C8A01A80A902C8B85A80CE0E000048090001C40AB051140796805A00EDA6107B1AC804BD286A29\n'
Got: 'rsp=$ntfy\x1ehnd=h12\x1ed=b28016B0ED398FE980700A007E0530004100152E1D018030000000000000000000000000000000000000007AB031C6B03C86857806103C87057805403C8781780A803C8A8D7009F03C8A817809603C8B017808D03C8B417808D03C8AC17808D03C89C57808503C8A057008303C8A057007F03C88817808003887217807B03C8641780\n'
we have enough data len = 363
checksum_ok1 = False
checksum_ok2 = False
checksum_ok3 = False
INFO 2021-05-24 19:11:51,286 checksum_ok = False
start byte = 201
end byte = 128
len = 968
battery = 2
<class 'str'>
fw version = c854
hw version = 5a80
sensor serial number 0KZDDH0XZ00
bad start byte 201
bad end byte 128
bad length of buffer 968

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 24, 2021 via email

@bordeb
Copy link
Author

bordeb commented May 24, 2021

Ok, tnx, I will keep it running and report. I am suspicious about result as it was collecting for half an hour (master phone was away) and nothing collected... But we will see..
tnx!!

@bordeb
Copy link
Author

bordeb commented May 24, 2021

For now it still works and keeps getting 363 but it seams that it does not understand data properly. The serial number of the sensor is showing wrong. There are also multiple checksum_ok1 = False, checksum_ok2 = False, checksum_ok3 = False.
I will report in addition:

EDIT: I can also see in the log file that the master xDrip+ phone is connecting to rpi, but xDrip+ obviously does not receive usable glucose data.
Something does not work

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 24, 2021 via email

@bordeb
Copy link
Author

bordeb commented May 24, 2021

This is for my little doughter. For last couple of days we are running for her with new MM2 and the firmware is 0004 (tomato firmware as xdrip displays).
We have two additional MM1s. I am using one , and one is spare one... If you need to test something please say.
I would not be so happy if I need to swap MM2 as it is sticked with tegaderm - we do not use those elastic straps. But I can experiment on me whatever you want :-)

@bordeb
Copy link
Author

bordeb commented May 24, 2021

Sorry, I now seen what actually you were asking? Apologies!
Yes, we are using Libre1 sensors! 100%

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 24, 2021 via email

@bordeb
Copy link
Author

bordeb commented May 24, 2021

In the meanwhile I performed clean install and setup on another RPI Zero W using buster raspbian and after copying the relevant files at first rpi successfully collected some data from MM2 and than xdrip successfully collected that data (I was so happyat at the moment thinking that it is resolved, but...), but after that no additional data from MM2 was collected. In the log file I can not see anything special. That old glucose data collected at first from MM2 is visible but no newer glucose data is collected. The log constantly says that connection to MM2 is not successfull (btle.BTLEException Failed to connect to peripheral xx:xx:xx:xx:xx:xx, addr type: random) but I am sure that it is somehow "partially" connected because the MM2 is not visible to other devices (phones scanning within xdrip app) untill the RPI is shutdown. I am 100% sure that phone can not be blamed for "stealing" the connection with MM2, so this can not be the reason that RPI can not connect to MM2. In contrary, it seams that there is some connection between rpi and MM2, but it fails to collect data from MM2, but again in some rare ocasions (I don't know why and when) it succeed. I am very confused.

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 25, 2021 via email

@tzachi-dar
Copy link
Owner

tzachi-dar commented May 26, 2021 via email

@bordeb
Copy link
Author

bordeb commented May 26, 2021

Hi @tzachi-dar , tnx very very much for asking!
I still have no consistent conclusions to report. After experiencing the above mentioned situation with the 2nd RPI zero W, I have started a clean install from scratch on the 1st RPI again, but then stuck with errors while python3 setup.py build so I started again clean install from scractch... In the meanwhile on the 2nd RPI zero there is no changes = after some initial good readings from MM2 the rpi fails to successfully recive additional new data and in the log there are connection errors (btle.BTLEException Failed to connect to peripheral xx:xx:xx:xx:xx:xx, addr type: random) although it is obviously somehow connected with MM2 because during that time MM2 is not visible for phones.
I will report additional info as soon as new clean install on the 1st RPi is successfully finished

@bordeb
Copy link
Author

bordeb commented May 27, 2021

So, next step. Let's comment again the line #btle.Debugging = True On line 498, you have #print('total = ' ,binascii.b2a_hex(self.data_)) please enable it and run again (send me the logs after). Thanks Tzachi

On Mon, 24 May 2021 at 21:12, bordeb @.***> wrote: Sorry, I now seen what actually you were asking? Apologies! Yes, we are using Libre1 sensors! 100% — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#11 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB4TBZGE5J5HWHBPKU7TZ3DTPKJH3ANCNFSM45LNX2RQ .

After several clean installs and setups, the only thing consistent is that there is some connection between RPI Zero W and MM2 but the data received is not good. I have enabled print('total = ' ,binascii.b2a_hex(self.data_))
I am really not an expert but from the log it is obvious that something is happening but with plenty of errors. How could I send you the log file? Thank you in advance!!

@tzachi-dar
Copy link
Owner

I have just installed the system on the latest version of pi zero.
So far, after about one hour all is working well.
I'll let it run for a few more days, and let's see how things will work.

Thanks
Tzachi

@bordeb
Copy link
Author

bordeb commented May 28, 2021

Thank you for the info!!
Would you be so kind and let me know what firmware version is MM2 that you are testing with?
In addition, please let know what specific version of raspbian have you used, did you perform full apt/ apt-get upgrade or not after install (I am asking because I have also noticed some error during upgrade, decribed here also RPi-Distro/pi-bluetooth#25) , and finally what exact commands did you perform to install everything required - if you can maybe export history of your commands so I can try to exactly reproduce all here at my place.

@tzachi-dar
Copy link
Owner

mm2 firmware is 4.0
The rpi image that I have installed is: 2021-03-04-raspios-buster-armhf-full
After the install, I let it install all necessary updates.

On the install I have run the commands as written in the instructions and also did:
sudo cp ./bluepy/bluepy-helper /usr/local/lib/python3.7/dist-packages/bluepy/bluepy-helper

By the way, the python version that I have there is 3.7.3

If it will continue to work for a few more days without a problem, I'll create an image of the pi and upload it.

@bordeb
Copy link
Author

bordeb commented May 28, 2021

Tnx so much!

So, you did NOT need to perform:
sudo cp bluepy/*.py /usr/local/lib/python3.7/dist-packages/bluepy/
??

Yes, on buster the python is 3.7 while on stretch it is 3.5.

In the meanwhile, do you maybe want me to send you the log file after I enabled print('total = ' ,binascii.b2a_hex(self.data_)) ?

@tzachi-dar
Copy link
Owner

No, you should be running with the copy line above.
Can you try running this on the buster version (after applying all changes)?

So, far all is working for 24 hours on a test system. If things will continue to be well, I'll switch tomorrow to a real system.

If you have logs from such a buster system, please mail them to [email protected]

@bordeb
Copy link
Author

bordeb commented May 29, 2021

Thank you!
After several initial trials on stretch, I have than switched to buster but again without success. I have just sent you the log from the buster system on rpi zero w.

@tzachi-dar
Copy link
Owner

Looking at the logs that you have sent, me it seems that data is arriving correctly, however it is ariving too slowly.
Here is what you should try:
On line 456 you have the line:
if time.time() - self.lastReceiveTimestamp_ > 3:

Please replace it with:
if time.time() - self.lastReceiveTimestamp_ > 10:

This should sovle your problem.

If this will not help, please replace the line (498):
print('total = ' ,binascii.b2a_hex(self.data_))
with:
logging.info('total = ' ,binascii.b2a_hex(self.data_))
run it for about 30 minutes and send me the logs.

@bordeb
Copy link
Author

bordeb commented May 30, 2021

Thank you @tzachi-dar !! It works!
After changing the number in the 456 line from 3 to 10 it started to collect good data! I am now testing and will continue to run it for a day and report if everything will be ok. Is this change posses some potential risk for consistency, security, performance..? Should I be specially cautious? I suppose not, that this is just amouint of time to let it wait. Am I right?

In addition, for me it was also enough just to do sudo cp ./bluepy/bluepy-helper /usr/local/lib/python3.7/dist-packages/bluepy/bluepy-helper
I did NOT need to sudo cp bluepy/*.py /usr/local/lib/python3.7/dist-packages/bluepy/

Also, I would suggest the revision of the tutorial regarding the distro. - at the beginning to say "buster" raspbian

@tzachi-dar
Copy link
Owner

I hope things are still working well. My test system is still running.

Background:
mm2 sends the data in 3 packets, every 5 minutes.
In a case of a failure, there are up to 4 retries. Failures are very rare, but I did see them on MM1 (once every month or so). After 4 retries, the connection disconnects (which causes a reset to mm1). Although this were very rare, without the retry and disconnection, the jobs would stack, and I had to wake up and restart them.
As this retransmits are very rare, It is hard to be 100% sure that things did work for them.

The problem that I saw in your logs is that the 3 packets got mixed for some reason, that is it started with the second one, than the third, than the first one. This happened after the retransmit was done.

I thought that increasing the timeout should help things work better, but I'm not sure on it anymore.
The change should be safe since checksum is verified on the data, so we will not send bad data to xDrip.
If you can send me the logs again, I can try and understand what is going on there.

Thanks
Tzachi

@bordeb
Copy link
Author

bordeb commented Jun 1, 2021

I hope things are still working well. My test system is still running.

Dear Tzachi, thank you very much an all your support! It still works, two Rpi zeros and one Rpi 3B. It really is that this change from 3 to 10 was the solution in my case.

If you can send me the logs again, I can try and understand what is going on there.

Yes, I will gladly send you whatever you think is useful! Please let me know exactly what you want.

At the moment all rpis all clean install from scratch and then following the online tutorial. The only differences (three in total) from the tutorial is the use of "buster" insted of the older OS version, then skipping the step sudo cp bluepy/*.py /usr/local/lib/python3.7/dist-packages/bluepy/ which was not needed in my case, and most importantly changing the value from "3" to "10" in the main.py

Do you want me to enable:
print('total = ' ,binascii.b2a_hex(self.data_))
or replace it with
logging.info('total = ' ,binascii.b2a_hex(self.data_))
or...?

Regards!

@tzachi-dar
Copy link
Owner

tzachi-dar commented Jun 2, 2021 via email

@bordeb
Copy link
Author

bordeb commented Jun 6, 2021

Hi! I have just shared the log file with you on gdrive. Thank you so much!

@tzachi-dar
Copy link
Owner

Hi,
It seems that the line that I have asked you to write was wrong.
Please change it to:
logging.info('total = %s' ,binascii.b2a_hex(self.data_))
and run again.

Thanks
Tzachi

@bordeb
Copy link
Author

bordeb commented Jun 9, 2021

Hi!
I have just shared with you the new log after running for last two hours with enabled:
logging.info('total = %s' ,binascii.b2a_hex(self.data_))
Hope it will help this time. Tnx very very much!
Looking forward

@tzachi-dar
Copy link
Owner

Well, it seems that after a new connection there is some problem that I do not understand, but it seems that after 5 minutes things start to work well again.
So, if things seems to be working, I would not change anything here.

@bordeb
Copy link
Author

bordeb commented Jun 10, 2021

Interesting! Yes. As not an expert, I have noticed that there is some problem in the beginning but after a while it somehow starts to collect data and functioning is ok. The key point is that it is necessary to change the value from 3 to 10 in the 456 line of the main.py

When such an expert as you and after thorough examination thinks that a change is not necessary, I can easily fully agree and be happy continuing to use such a great software!

P.S. when you tested with your RPi Zero W, did you have to change from 3 to 10 or in your case it was operating even with default value of 3?
Maybe I could try to experiment with lowering the value as close as possible to 3 and try to detect what is minimal value that works in my case.

@bordeb bordeb closed this as completed Jun 10, 2021
@bordeb bordeb reopened this Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants