raspberry pi-3 setup with blue tooth GKARTHIK
Now that it has been a few weeks since the release of the
Raspberry Pi 3, support for the WiFi and Bluetooth chip has settled and you can use it with Raspbian. Support with
Windows 10 IoT Core will be available in the early days via the
Insider Program before it is pushed through to the full release.
As
usual, with Raspbian ensure that you have your distribution up to date,
with this guide we will be using Raspbian Jessie, at present it is
still the ARMv7 32bit kernel. Connect your Raspberry Pi to the internet
either via WiFi or Ethernet and run the following commands:
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo rpi-update
Installing the Software
From
a console terminal, either from within your desktop environment, which
at the time of writing the window manager is still LXDE. This will
ensure your system is up to date.
Now you have a few options, you can install the following package:
sudo apt-get install pi-bluetooth
Which
should install what you need to use the bluetooth portion of the chip,
this installs the following packages which you can, if you want, install
instead of pi-bluetooth:
sudo apt-get install bluez bluez-firmware
As
the chip requires a firmware blob to work along with the driver. Bluez
also installs a suite of tools. These will work from the console
terminal. Should you wish to manage your bluetooth devices from your X
environment, aka your windows manager, aka your desktop then you can
install the following package:
sudo apt-get install blueman
After
installing the software and drivers, reboot your Raspberry Pi. Unless
you know otherwise, to load the driver for the adapter.
Terminal / Console
Bluez
comes with a tool called 'bluetoothctl' which you can run from the
console terminal, typing 'man bluetoothctl' does not give you a great
deal of detail, so you have to type 'help' from within the software:
pi@raspberrypi:~ $ bluetoothctl
[bluetooth]# help
Available commands:
list List available controllers
show [ctrl] Controller information
select <ctrl> Select default controller
devices List available devices
paired-devices List paired devices
power <on/off> Set controller power
pairable <on/off> Set controller pairable mode
discoverable <on/off> Set controller discoverable mode
agent <on/off/capability> Enable/disable agent with given capability
default-agent Set agent as the default one
scan <on/off> Scan for devices
info <dev> Device information
pair <dev> Pair with device
trust <dev> Trust device
untrust <dev> Untrust device
block <dev> Block device
unblock <dev> Unblock device
remove <dev> Remove device
connect <dev> Connect device
disconnect <dev> Disconnect device
version Display version
quit Quit program
Now we are in bluetoothctl we can run the commands, first lets make sure that bluetooth is on, running and discovering devices:
With the commands 'power on', 'agent on' and 'scan on'. Though we likely only need 'power on' and 'scan on'.
Devices!
and while the software is running we will see devices appear, change,
delete, etc. We can then connect to a device using its MAC address.
Basically, we are talking to the devices directly at the hardware layer,
usually on your typical WiFi or Ethernet network this is done
transparently to you and we only work with IP addresses. However with
Bluetooth at this point, no.
We can also then pair and trust the device and do all the fun features of Bluetooth, provided these are successful.
GUI
Some
consider the blueman package and software to be unstable, though the
sources saying so are a bit dated by now and it may be somewhat more
stable.
When
you have the blueman package installed, you should have a nice
Bluetooth icon in your system tray. If you left-click with a mouse
connected to your Raspberry Pi you should get a menu with all of the,
hopefully, self explanatory options for you to play with, which for some
reason I could not capture with scrot/imagemagick, so you get a nice
photograph:
Yum,
pixelated (it was an old Dell monitor). If we want to scan for devices,
similarly to using the 'scan' command for bluetoothctl then we select
'Devices' on the menu:
And
from here we can see what is available in the vicinity, you may be
surprised at suddenly finding your neighbours smart television or phone,
you will find out how thin your walls really are. It can be more fun in
the office at work.
However, let us select "setup a new device":
Add New Device
Choose a pairing code
×
3 / 3
However,
what I discovered is that the passkey method is practically deprecated
or ignored, it may be applicable for older Bluetooth software or
devices, but these days you will get a prompt appear (and for myself,
then hide) on Raspbian, next to the icon for blueman, there will be a
message, and in this message it will display a message like:
This device wants to pair with this machine, with this code xxxxxxxx, do you want to permit or deny?
This
likely happens with new devices such as smart phones and televisions,
as a security measure that you are physically holding or looking at the
device in question. Of course you then 'permit' on either the device or
Raspbian and the two will be paired. Allowing you to then setup drivers
for your Bluetooth device functionality, to use it as a modem, in the
case of a phone, share its internet access or simply send files to and
from it. Potentially, you can even use it as an audio device!
Attaching
to devices such as headsets tends to be easier, and usually does not
use a pairing code. A standard is usually four zeroes (0000) with most
consumer devices.
No comments:
Post a Comment