菜单

[BlueZ] 一、Download install and use the BlueZ and hcitool on PI 三B+

2019年4月27日 - LINUX

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

This how-to will explain how to download rpm packages from a yum
repository without installing them. This will work on Redhat Enterprise
Linux 5.x, Fedora and CentOS 5.x. 

图片 1

You need to install yum plugin called yum-downloadonly. This plugin adds
a –downloadonly flag to yum so that yum can download the packages
without installing/updating them. Following options supported by this
plugin:

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:

图片 2

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:http://www.bluez.org/download/.

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

Install the yum-downloadonly plugin:

3. How to use the bluez and hcitool

Type the following command to install plugin, enter:

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

        # yum install yum-downloadonly

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

Now for downloading rpm packages from an already configured yum
repository use the following command:

3.3 bluetooth service discovery

Now we have the bluetooth MAC address of the target device, use the
sdptool command to know which services (like DUN, Handsfree audio) are
available on that target device.

sdptool browse 28:ED:6A:A0:26:B7

You can also use the interactive bluetoothctl tool for this purpose.

If the target device is present, you can ping it with l2ping command,
requires root privilege:

➜  bluez-5.50  sudo l2ping 94:87:E0:B3:AC:6F
Ping: 94:87:E0:B3:AC:6F from B8:27:EB:8E:CC:51 (data size 44) ...
44 bytes from 94:87:E0:B3:AC:6F id 0 time 53.94ms
44 bytes from 94:87:E0:B3:AC:6F id 1 time 77.12ms
44 bytes from 94:87:E0:B3:AC:6F id 2 time 38.63ms
44 bytes from 94:87:E0:B3:AC:6F id 3 time 46.13ms
44 bytes from 94:87:E0:B3:AC:6F id 4 time 59.96ms
5 sent, 5 received, 0% loss

So, bluetooth service discovery is useful to determine the type of the
device, like if it’s a bluetooth mp3 player or it’s a keyboard.

图片 6

      # yum update httpd -y –downloadonly
By default package will by downloaded and stored in /var/cache/yum/
directory. But, you can specifies an alternate directory to store
packages such as /opt, enter:

LINKS

图片 7

@beautifulzzzz
智能硬件、物联网,热爱技术,关注产品
博客:http://blog.beautifulzzzz.com
园友交流群:414948975

      # yum update httpd -y –downloadonly –downloaddir=/opt

Method 2: yum-utils.noarch
Package

Downloading rpm packages from a yum repository can be accomplished by
the below described method also!!!

yum-utils is a collection of utilities and examples for the yum package
manager. It includes utilities by different authors that make yum easier
and more powerful to use. These tools include: debuginfo-install,
package-cleanup, repoclosure, repodiff, repo-graph, repomanage,
repoquery, repo-rss, reposync, repotrack, verifytree, yum-builddep,
yum-complete-transaction, yumdownloader, yum-debug-dump and
yum-groups-manager.

     # yum -y install yum-utils.noarch

Now use the yumdownloader command which is a program for downloading
RPMs from Yum repositories. Type the following command to download httpd
rpm file:

     # yumdownloader httpd

Sample output:

Loaded plugins: rhnplugin
httpd-2.2.3-31.el5_4.2.x86_64.rpm       1.2 MB 00:00

 

相关文章

发表评论

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

网站地图xml地图