[BlueZ] 1、Download install and use the BlueZ and hcitool on PI 3B+

星期日, 02. 九月 2018 11:58下午 – beautifulzzzz

The version compatibility across the OS and these packages is a
nightmare for every new person who tries to use Tensorflow.  In here, I
record the successful procedure to install everything listed in the
title of this note.

图片 1

First of all, make sure that you have the exact same version of
software in every steps, or it may not work.  To install Tensorflow at
Ubuntu, you will need to install Ubuntu 16.04.  Run 

1. Introduction

Bluez is the default Bluetooth protocol stack on Linux. It should be
present and installed on your Linux distribution. If not, building and
installing from source is not too difficult:

  • Download the latest stable source release of Bluez from here. Unzip
    the compressed file you downloaded.
  • Install the headers and libraries required for Bluez compilation:

图片 2

lsb_release -a 

2. Download And Install

I follow the blog (Installing Bluez 5.44 onto
Raspbian?)
to install bluez-5.50.

Download the most recent version from the official
page:.

For example, at the time of writing it was 5.50, so I used(on my pi):

wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.50.tar.xz

Then I extracted it and built it:

tar -xf bluez-5.50.tar.xz
cd bluez-5.50

Read the README! It lists the dependencies and the configure
switches:

Install the dependencies first: (glib, dbus, libdbus, udev, etc.)

sudo apt install libdbus-1-dev libudev-dev libical-dev libreadline-dev

note: If you do not install the libdbus-1-dev, you will later get
this strange error:

configure: error: D-Bus >= 1.6 is required

once you’ve installed dependencies, you can configure switches:

./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var  --enable-experimental

then do:

make
sudo make install

It takes maybe 10 minutes to compile. After installing, you should find
bluetoothd in /usr/libexec/bluetooth. You should also see bluetoothd
in /usr/lib/bluetooth.

Go to each of these directories and type

./bluetoothd --version

You’ll note that the one in libexec is new and the one in lib is old.

In order to make sure that d-bus is talking to you new BlueZ 5.50
and not your old BlueZ 5.43, you need to tell systemd to use the new
bluetooth daemon:

sudo vim /lib/systemd/system/bluetooth.service

Make sure the exec.start line points to your new daemon in
/usr/libexec/bluetooth.

For me, that wasn’t enough. No matter what, upon restart I always got
bluetoothd 5.43… So I just created a symlink from the old one to the
new.

First rename the old file:

sudo mv /usr/lib/bluetooth/bluetoothd /usr/lib/bluetooth/bluetoothd-543.orig

Create the symlink:

sudo ln -s /usr/libexec/bluetooth/bluetoothd /usr/lib/bluetooth/bluetoothd
sudo systemctl daemon-reload

That should do it.

图片 3

to check the version of your Ubuntu.  If you want to dual-boost OS from
window10, like what I did, there is another note teach you how to do the
dual-boost.  The following passages assume you have already had your
Ubuntu 16.04 installed correctly.

3. How to use the bluez and hcitool


3.1 setup bluetooth service

Start the bluetooth service and enable automatic startup, assuming
you’re using systemd as the init daemon:

sudo systemctl start bluetooth.service
sudo systemctl enable bluetooth.service

Install pycharm

ref: https://itsfoss.com/install-pycharm-ubuntu/

Open a terminal and use the following commands:

sudo add-apt-repository ppa:mystic-mirage/pycharmsudo apt-get update

To install the community edition of PyCharm, use the command below. It
will download data of around 120 MB.

sudo apt-get install pycharm-community

To install the professional edition of PyCharm, use the command below.
It will download data of around 160 MB.

sudo apt-get install pycharm

3.2 hcitool scan for bluetooth devices

Before start scanning make sure that your bluetooth device is turned on
and not blocked, you can check that with the rfkill command:

sudo rfkill list

If the bluetooth device is blocked (soft or hard blocked), unblock it
with the rfkill command again:

sudo rfkill unblock bluetooth

Bring up the bluetooth device with hciconfig command and start scanning,
make sure the target device’s bluetooth is on and It’s discoverable:

sudo hciconfig hci0 up
hcitool scan

Wait few moment to complete the hcitool scan or hcitool lescan, the
results will be something like bellow:

图片 4

图片 5

Here 00:1A:7D:DA:71:0A is the bluetooth MAC address and SHEN-PC is the
name of the bluetooth device, i.e. an PC.

note: use hcitool lescan will forever scan ble devices, if use
ctrl+c stop it, it will show error(ref to LINKS
4
to solve):

hcitool lescan
Set scan parameters failed: Input/output error

Remove PyCharm

To uninstall PyCharm installed by the above described method, use the
command below to uninstall the community edition of PyCharm:

sudo apt-get remove pycharm-community

To remove the professional version, use the command below:

sudo apt-get remove pycharm

Afterward, use the command below to remove the PPA from the sources
list:

sudo add-apt-repository –remove ppa:mystic-mirage/pycharm

That’s all you need to do. I hope this tutorial helped you toinstall
PyCharm in Ubuntu Linux. Any questions or suggestions are always
welcomed.


Install Python2.7

ref:

sudo add-apt-repository ppa:fkrull/deadsnakes

sudo apt-get update

sudo apt-get install python2.7


发表评论

电子邮件地址不会被公开。 必填项已用*标注