Connect BLE devices with Raspberry pi 3 B - raspberry-pi

I know this is not the first time this question was asked but after trying every thing I could during a week, I still have problems.
I'm trying to connect to my Raspberry pi to BLE devices. I can scan them but not connect to them.
The last explanation I have followed was this github issue: https://github.com/ukBaz/python-bluezero/issues/30
And here is all the commands I have done to try to update bluez and make this connection works.
###Install RASPBIAN JESSIE LITE
2017-01-11-raspbian-jessie-lite.img
###Updates
$ sudo apt-get update
$ sudo apt-get upgrade
###Add libs
$ sudo apt-get install bluetooth bluez-tools build-essential autoconf glib2.0 libglib2.0-dev libdbus-1-dev libudev-dev libical-dev libreadline-dev git
###Get bluez-5.43
$ wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.43.tar.xz
$ tar xf bluez-5.43.tar.xz
$ cd bluez-5.43
###Patch bluez
$ wget https://gist.github.com/pelwell/c8230c48ea24698527cd/archive/3b07a1eb296862da889609a84f8e10b299b7442d.zip
$ unzip 3b07a1eb296862da889609a84f8e10b299b7442d.zip
$ git apply -v c8230c48ea24698527cd-3b07a1eb296862da889609a84f8e10b299b7442d/*
###Install bluez
$ ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-experimental --enable-maintainer-mode
$ make -j 4 && sudo make install
### Add to /etc/dbus-1/system.d/bluetooth.conf
<!-- allow users of bluetooth group to communicate -->
<policy group="bluetooth">
<allow send_destination="org.bluez"/>
</policy>
$ sudo usermod -G bluetooth -a $USER
$ sudo sed -i '/^ExecStart.*bluetoothd\s*$/ s/$/ --experimental/' /lib/systemd/system/bluetooth.service
$ sudo systemctl daemon-reload
$ sudo service bluetooth restart
$ service bluetooth status
$ sudo reboot
$ sudo hcitool lescan
LE Scan ...
XX:XX:XX:XX:XX:XX (name)
$ gatttool -b XX:XX:XX:XX:XX:XX -I
[XX:XX:XX:XX:XX:XX][LE]> connect
Attempting to connect to XX:XX:XX:XX:XX:XX
Error: connect error: Transport endpoint is not connected (107)
$ gatttool -b XX:XX:XX:XX:XX:XX -t random -I
[XX:XX:XX:XX:XX:XX][LE]> connect
Attempting to connect to XX:XX:XX:XX:XX:XX
Error: connect error: Connection refused (111)
Thank you for your help
Edit for Constantin Chabirand's answer
$ systemctl status bluetooth
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled)
Active: active (running) since Tue 2017-01-17 21:17:07 UTC; 1min 51s ago
Docs: man:bluetoothd(8)
Main PID: 587 (bluetoothd)
Status: "Running"
CGroup: /system.slice/bluetooth.service
└─587 /usr/libexec/bluetooth/bluetoothd --experimental
$ bluetoothctl
[NEW] Controller B8:27:EB:FD:93:2B raspberrypi [default]
[bluetooth]# scan on
Discovery started
....
[bluetooth]# scan off
[bluetooth]# connect XX:XX:XX:XX:XX:XX
Attempting to connect to XX:XX:XX:XX:XX:XX
Failed to connect: org.bluez.Error.Failed
Edit 2
After reinstalling with the simple solution:
$ bluetoothctl -v
5.43
$ systemctl status bluetooth
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled)
Active: active (running) since Wed 2017-01-18 15:46:53 UTC; 3min 37s ago
Docs: man:bluetoothd(8)
Main PID: 586 (bluetoothd)
Status: "Running"
CGroup: /system.slice/bluetooth.service
└─586 /usr/local/libexec/bluetooth/bluetoothd --experimental
$ sudo bluetoothctl
[bluetooth]# connect XX:XX:XX:XX:XX:XX
Attempting to connect to XX:XX:XX:XX:XX:XX
Failed to connect: org.bluez.Error.Failed

Thank's to Constantin Chabirand, I made it work. I needed a few more command lines to make it work and I needed to change the advertising frequency of my BLE device (I still need to do some tests on that).
Here is the exact commands I used to install bluez on my rpi3 and connect to BLE devices:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install -y libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.43.tar.xz
tar xf bluez-5.43.tar.xz
cd bluez-5.43/
./configure
make
sudo make install
sudo reboot
# check version
bluetoothctl -v
sudo nano /lib/systemd/system/bluetooth.service
# Add --experimental to this lane
ExecStart=/usr/local/libexec/bluetooth/bluetoothd --experimental
sudo systemctl daemon-reload
sudo systemctl restart bluetooth
sudo hciconfig hci0 up
sudo reboot
sudo usermod -G bluetooth -a pi
sudo reboot
That's it. Thank's again for your help.

What is the result of the bash command systemctl status bluetooth ?
Can you start bluetoothctl (just type it in your shell) ?
I also use a raspberry pi 3 to connect to BLE devices and I don't need a patch. Start a fresh install with bluez5.43 and post the results of the two commands I've written
UPDATE
For the installation I did it the simplest way I could. I followed the "The simplest way to compile this package is:" section in the INSTALL file which is :
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.43.tar.xz
tar xf bluez-5.43.tar.xz
cd bluez-5.43.tar.xz
./configure
make
make install
Did you succesfully connect to your BLE device using something else ? Like a smartphone ? There are applications out there that can read gatt atrributes.
UPDATE 2
I did not remove a thing. Merely installed bluez5.43 on top of the rest. When I run
bluetoothctl -v it returns : 5.43.
When I run apt list --installed is can see the following packages installed automatically :
bluez/stable,now 5.23-2+rpi2 armhf [installed,automatic]
bluez-firmware/stable,now 1.2-3+rpi1 all [installed,automatic]
bluez-obexd/stable,now 5.23-2+rpi2 armhf [installed,automatic]
bluez-tools/stable,now 0.2.0~20140808-3 armhf [installed]
As you can see I still have the old version installed.

I needed to install the bluez-5.43 to get around bugs in the default bluez-5.23 when using bluetoothctl from scripts.
You could probably install the binary version from stretch, but my experience is that you often run into other dependencies.
I had the same problem under Ubuntu-16.04 and used the deb-src package from Ubuntu-Zesty, to fix that. Since this is just a debian package I used this on the Raspberry pi too, worked fine when using a USB-bluetooth dongle. To make this work on the RPI-3, which has its bluetooth controller attached via a serial line, you need to install the ../issue/30 patches too.
The advantage of doing it this way, is that once your Raspbian will contain a newer bluez version it will replace what we do here, and if you got more raspbian system you of course only need to install the generated .deb packages
This is what I did (handsfree):
#!/bin/bash
sudo apt-get install devscripts debhelper dh-autoreconf flex bison libdbus-glib-1-dev libglib2.0-dev libcap-ng-dev libudev-dev l
ibreadline-dev libical-dev check dh-systemd libebook1.2-dev
wget https://launchpad.net/ubuntu/+archive/primary/+files/bluez_5.43.orig.tar.xz
wget https://launchpad.net/ubuntu/+archive/primary/+files/bluez_5.43-0ubuntu1.debian.tar.xz
wget https://launchpad.net/ubuntu/+archive/primary/+files/bluez_5.43-0ubuntu1.dsc
tar xf bluez_5.43.orig.tar.xz
cd bluez-5.43
tar xf ../bluez_5.43-0ubuntu1.debian.tar.xz
# install patches relevant for rpi-3 bluetooth
. /etc/os-release
if [ $ID = raspbian ]; then
wget https://gist.github.com/pelwell/c8230c48ea24698527cd/archive/3b07a1eb296862da889609a84f8e10b299b7442d.zip
cd debian/patches
unzip ../../3b07a1eb296862da889609a84f8e10b299b7442d.zip
for i in c8230c48ea24698527cd-3b07a1eb296862da889609a84f8e10b299b7442d/*;do
mv $i .
basename $i >> series
done
rmdir c8230c48ea24698527cd-3b07a1eb296862da889609a84f8e10b299b7442d
cd ../..
fi
# end of Raspian related patches
debchange --local=~lorenzen 'Backport to Xenial'
debuild -b -j4
cd ..
sudo dpkg -i *.deb
This would should work under other Debian derived systems too,
https://askubuntu.com/a/884062/655086

I faced the same problem that connecting and playing BLE devices with Raspberry Pi 3 built-in Bluetooth. First of all, I learned how to play and control a tool of bluetoothctl in virtue of below webpage.
[https://mcuoneclipse.com/2016/12/19/tutorial-ble-pairing-the-raspberry-pi-3-model-b-with-hexiwear/][1]
In this tutorial, after successful connection with your BLE devices, you can work with an attribute that you want to play with.
For example, if you want to work with the attribute of Bluetooth UART TX or RX, you just need to input commands below, then read or write a value of that attribute of characteristic.
list-attributes 00:34:40:0A:00:4E
select-attribute /org/bluez/hci0/dev_00_32_40_08_00_12/service0026/char0027
read
write
If there is anyone who is fully aware of creating bluetooth connecting between Raspberry Pi 3 built-in BLE with Arduino Ble, Please share your knowledge. ;)

Related

MongoDB failed (result: core-dump)?

I'm attempting to setup MongoDB on Ubuntu 20.04.02 LTS by following the documentation. I have ensured this is a fresh install. However an error persists when I verify if the MongoDB install started succesfully by typing in:
sudo systemctl status mongod
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor prese>
Active: failed (Result: core-dump) since Wed 2021-08-11 12:59:20 UTC; 49s >
Docs: https://docs.mongodb.org/manual
Process: 3190 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=dum> Main PID: 3190 (code=dumped, signal=ILL)
Aug 11 12:59:19 discorddomagoj systemd1: Started MongoDB Database
Server. Aug 11 12:59:20 discorddomagoj systemd1: mongod.service:
Main process exited,> Aug 11 12:59:20 discorddomagoj systemd1:
mongod.service: Failed with result '>
Picture of problem for clarity:
1.Stop the mongod process by issuing the following command:-
sudo service mongod stop
2.Remove any MongoDB packages that you had previously installed:-
sudo apt-get purge mongodb-org*
3.Remove MongoDB databases and log files:-
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
4.Then reinstall mangodb 4.4.8
5.Import the public key used by the package management system:-
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
6.The following instruction is for Ubuntu 20.04 (Focal):-
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
7.Update Apt
sudo apt-get update
8.Install mongodb
sudo apt-get install mongodb-org=4.4.8 mongodb-org-server=4.4.8 mongodb-org-shell=4.4.8 mongodb-org-mongos=4.4.8 mongodb-org-tools=4.4.8
9.Use mongod --version to check its succesfully installed
10.If u encounter any error while using mongod
sudo mkdir /data
cd /data
sudo mkdir db
sudo pkill -f mongod
11.Then use sudo mongod command.
This error show CPU incompatibly with mongodb. if use proxmox set cpu mode to "HOST".
stop the db
sudo service mongod stop
uninstall it:
sudo apt-get purge mongodb-org*
Import the public key used by the package management system
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
Create a list file for MongoDB.
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
Reload local package database
sudo apt-get update
Install a specific release of the MongoDB packages(this was the reason I had that similar error for not specifying the package)
sudo apt-get install -y mongodb-org=5.0.7 mongodb-org-database=5.0.7 mongodb-org-server=5.0.7 mongodb-org-shell=5.0.7 mongodb-org-mongos=5.0.7 mongodb-org-tools=5.0.7
lastly, on one tab of the terminal run:
sudo mongod
on another open the db:
mongo
I have same issue when installing mongodb on virtual machine with proxmox.
Changing processor from kvm to host or sandybridge(my actual pc) solved this problem. Reference link
This is an addition to #AbdulWahhab 's answer. I have recently seen many questions of same type: 'can't start mongodb#5.0.x server on ubuntu#20.0.4'. Having faced this issue myself, I found installing mongodb#4.4.8 version only way out. In addition consider that sudo apt-get update updates all packages including mongodb. Newer version of mongodb gets installed and server does not work anymore(as of 10th december 2021). To prevent unintended upgrades, you can pin the package at the currently installed version:
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-database hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
A possible reason for the dump is a change in the microarchitecture requirements of MongoDB introduced with version 5.0. This causes this exact issue on a Raspberry Pi for instance (see: MongoDB Forum).
This issue might be mitigated by building from source as described in the forum post. I haven't tried this though personally. Installing versions prior to 5.0 (as described by Abdul Wahhab) will solve the problem as well.
If you have tried all of the above solutions, and still can't help, please try to reboot the VM.
I am using 18.04 and initially installed 6.0 mongoDB and it just showed the core-dump error after issuing "sudo systemctl status mongod".
After doing some research, I tried to uninstall the 6.0 and then re-install 4.4, it still couldn't help.
Then I tried to re-install 4.2, it still couldn't help.
Finally, I tried to reboot the VM, then it works..
For MongoDB 5.0+
If you are running on VirtualBox with a Windows host, disable Hyper-V. The issue is a lack of AVX support and to get it you need to disable Hyper-V and be using VirtualBox 5.03 or later.
Using CMD as Administrator
bcdedit /set hypervisorlaunchtype off
DISM /Online /Disable-Feature:Microsoft-Hyper-V
Then hard shutdown and restart the host. After that, starting the guest from cold boot should work.
sudo systemctl start mongodb
sudo systemctl status mongodb
Source: https://forums.virtualbox.org/viewtopic.php?f=25&t=99390
I had the same problem on Ubuntu 22.10 and MongoDB 6.0.
I solved it by put it AVX to AUTO in BIOS.
Just for future help in case of someone else need help.
check if you have the java runtime environment (JRE), if not then install it:
sudo apt install default-jre
That' s all =)

Update dbus on Raspberry Pi

I need to update DBus on my Raspberry Pi, in order to upgrade to the latest Bluez version (and I hope for performance benefits). I can't use a package install, as the latest packaged version is old, so I "configure/make/make install".
The problem with this is that it appears to install alongside the old version, but in a different directory. So, if I run dbus-daemon --version, I see the old version number following the install.
The original version (and launch path) is /usr/bin, whereas my install is going to /usr/arm-linux-gnueabi/bin. I did try editing the path for launch in /lib/systemd/system/dbus.service, but after this, Linux failed to start.
So now I have two versions of dbus on my Pi, with the old one booting.
Any help would be greatly appreciated.
Here is what I did to successfully have D-Bus 1.10.18 on my Raspberry Pi 3 with Raspbian Jessie Lite Fresh (release 2017-04-10) :
[I use aptitude instead of apt-get. You can substitute one by another.]
sudo aptitude install -y libapparmor1
cd ~
wget http://ftp.fr.debian.org/debian/pool/main/d/dbus/libdbus-1-3_1.10.18-1_armhf.deb
sudo dpkg --auto-deconfigure -i libdbus-1-3_1.10.18-1_armhf.deb
wget http://ftp.fr.debian.org/debian/pool/main/d/dbus/dbus_1.10.18-1_armhf.deb
sudo dpkg -i dbus_1.10.18-1_armhf.deb
sudo reboot
and after reboot :
pi#RasPi3-Tests:~ $ dpkg -l dbus
Souhait=inconnU/Installé/suppRimé/Purgé/H=à garder
| État=Non/Installé/fichier-Config/dépaqUeté/échec-conFig/H=semi-installé/W=attend-traitement-déclenchements
|/ Err?=(aucune)/besoin Réinstallation (État,Err: majuscule=mauvais)
||/ Nom Version Architecture Description
+++-=======================-================-================-===================================================
ii dbus 1.10.18-1 armhf simple interprocess messaging system (daemon and ...
and :
pi#RasPi3-Tests:~ $ dbus-daemon --version
D-Bus Message Bus Daemon 1.10.18
Copyright (C) 2002, 2003 Red Hat, Inc., CodeFactory AB, and others
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Before answering your question, share the failure log from "journalctl -xe" or "systemctl status dbus". Following might solve your problem,
Make sure to stop the dbus before update it. "systemctl stop dbus"
systemctl daemon-reload (Needs to run after changing service file of any daemon)
Start dbus again, systemctl start dbus.
check the binary path available in "echo $PATH", if not, export it. In your case, export PATH=/usr/arm-linux-gnueabi/bin:$PATH should help
Note: Many applications will stop working when you stop dbus.
sudo apt-get install python3-dbus

How to upgrade psql on Amazon ec2?

I'm aware of how one can upgrade the PostgreSQL version on an RDS instance by using the management console's point-and-click. However, doing so leaves me with mismatched client and server psql versions. I want to upgrade the psql client on my ec2 instance. How does one do so?
You can also use amazon-linux-extras command to install new major versions of postgresql, for example:
$ sudo amazon-linux-extras install postgresql13
$ psql --version
psql (PostgreSQL) 13.3
Note that previous versions will remain enabled, but you can explicitly disable them (even though there's no uninstall, try yum to get rid of packages):
$ sudo amazon-linux-extras disable postgresql11
Tested on:
$ hostnamectl | grep -E -w 'Operating|Kernel|Architecture'
Operating System: Amazon Linux 2
Kernel: Linux 4.14.243-185.433.amzn2.aarch64
Architecture: arm64
The exact solution is going to vary depending on your AMI, but here's what worked for me on Amazon Linux:
sudo yum erase postgresql92 -y
sudo yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-ami201503-96-9.6-2.noarch.rpm -y
sudo yum install postgresql96 postgresql96-devel -y
sudo ln -sf /usr/pgsql-9.6/bin/pg_config /usr/bin/
You might not need the last step unless you're trying to get the pg gem working in Ruby on Rails.

CouchDB won't start badmatch error bad_return CentOS7

I've been trying to install CouchDB on a fresh centos7 in digital ocean droplet. I get no errors trying to install with the following steps:
yum -y update
yum -y groupinstall "Development Tools"
yum -y install libicu-devel curl-devel ncurses-devel libtool libxslt fop java-1.6.0-openjdk java-1.6.0-openjdk-devel unixODBC unixODBC-devel openssl-devel
Step 2 - Installing Erlang
wget http://www.erlang.org/download/otp_src_R16B02.tar.gz
tar -zxvf otp_src_R16B02.tar.gz
cd otp_src_R16B02
./configure && make
make install
Step 3 - Installing the SpiderMonkey JS Engine
wget http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
tar -zxvf js185-1.0.0.tar.gz
cd js-1.8.5/js/src
./configure && make
make install
Step 4 - Installing CouchDB
wget http://mirror.olnevhost.net/pub/apache/couchdb/source/1.6.1/apache-couchdb-1.6.1.tar.gz
tar -xvf apache-couchdb-1.6.1.tar.gz
cd apache-couchdb-1.6.1
./configure && make
make install
Step 5 - Setting up CouchDB
adduser --no-create-home couchdb
chown -R couchdb:couchdb /usr/local/var/lib/couchdb /usr/local/var/log/couchdb /usr/local/var/run/couchdb
ln -sf /usr/local/etc/rc.d/couchdb /etc/init.d/couchdb
chkconfig --add couchdb
chkconfig couchdb on
vi /usr/local/etc/couchdb/local.ini
Should you need to access couchdb from the web, in the [httpd] section, look for a setting called bind_address and change it to 0.0.0.0 - this will make CouchDB bind all available addresses.
[httpd]
port = 5984
bind_address = 0.0.0.0
service couchdb start
/etc/init.d/couchdb status (this has no output)
And i get the following when i try to run:
/usr/local/bin/couchdb
Apache CouchDB 1.6.1 (LogLevel=info) is starting.
{"init terminating in do_boot",{{badmatch,{error,{bad_return,{{couch_app,start,[normal,["/usr/local/etc/couchdb/default.ini","/usr/local/etc/couchdb/local.ini"]]},{'EXIT',{{badmatch,{error,{shutdown,{failed_to_start_child,couch_secondary_services,{shutdown,{",[]},{couch_uuids,new_prefix,0,[{file,"couch_uuids.erl"},{line,84}]},{couch_uuids,state,0,[{file,"couch_uuids.erl"},{line,100}]},{couch_uuids,init,1,[{file,"couch_uuids.erl"},{line,50}]},{gen_server,init_it,6,[{file,"gen_server.erl"},{line,304}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]}}}}}}},[{couch_server_sup,start_server,1,[{file,"couch_server_sup.erl"},{line,98}]},{application_master,start_it_old,4,[{file,"application_master.erl"},{line,269}]}]}}}}}},[{couch,start,0,[{file,"couch.erl"},{line,18}]},{init,start_it,1,[]},{init,start_em,1,[]}]}}
Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
Does anyone know how to get past this?
Note I get no such file or directory when trying the answer from here
Can you check if erlang-crypto is a separate module that is maybe not installed?
CouchDB doesn’t (imho rightfully) doesn’t account for distributions splitting up the monolithically released Erlang installation.
Your error is raised in the UUID module and the only thing I can think of immediately is the crypto dependency that might be missing.

GitLab reconfigure exists on Raspberry Pi

Just did a fresh install of GitLib on a raspberry pi (original) running Raspbian.
wget https://s3-eu-west-1.amazonaws.com/downloads-packages/raspberry-pi/gitlab_7.9.0-omnibus.pi-1_armhf.deb
sudo dpkg -i gitlab_7.9.0-omnibus.pi-1_armhf.deb
When I try and run sudo gitlab-ctl reconfigure it runs for maybe 5 seconds, then just exists with status code 1. No error message or output.
Any ideas?