How-to to install bluetooth and run huawei-lpv2 on the Rapsberry Pi 3B (v1.2).
Read the whole guide before proceeding.
Follow this guide to install Arch on a SDCard.
To install it on a USB stick, you need to :
- install ArchLinux ARM on a SDCard
- install ArchLinux ARM on the stick the same way
- boot with the SDCard but do not follow step #10 of the guide
- enable USB boot mode ; write
program_usb_boot_mode=1in/boot/config.txt - reboot the Pi with the SDCard
- check the USB boot mode ; type
vcgencmd otp_dump | grep 17:result should be17:3020000a - remove
program_usb_boot_mode=1in/boot/config.txt - reboot without the SDCard
- follow step #10 of the guide
pacman -Syu to update the system.
Since firmware 5.4.50, bluetooth is integrated in the system. We do not need extra packages.
Add dtparam=krnbt=on to /boot/config.txt and ensure enable_uart=0 in /boot/config.txt.
Also ensure that /dev/ttyAMA0 is not used in /boot/cmdline.txt.
Install bluez and bluez-utils.
Automatic start and launch of the service :
systemctl enable bluetooth.service
systemctl start bluetooth.service
Reboot the Pi and bluetooth is started.
Install python.
Install bleak and cryptography modules the way you want, pacman or pip.
For the pacman version, bleak package is in AUR so one may install yay, then python-bleak and python-cryptography.
Get huawei-lpv2 from official git : https://github.com/zyv/huawei-lpv2
or more advanced git (feature/parse_log branch ) : https://github.com/psolyca/huawei-lpv2.git
One need to enable bluetooth on the Pi and have a first pairing with the band/watch
with bluez utils cause huawei-lpv2 is implemented around bluez framework.
bluetoothctl
power on
scan.transport le
scan on
pair MAC_BT_Band
disconnect MAC_BT_Band
exit
Then it is possible to connect to the band/watch.
On first launch python band_lpv2.py a file band.ini is created.
Fill this file with the MAC of :
- the Pi (client_mac) obtained with
bluetoothctl - the band (device_mac) obtained on the band
Relaunch python band_lpv2.py and voilà.
It is just a test script.