Keyboardbluetooth

De Slacam_Wiki
Ir para: navegação, pesquisa

Installing the Raspberry Pi Nano Bluetooth Dongle

Introduction

Bluetooth is a useful tool for getting devices communicating wirelessly. If you want your Raspberry Pi interacting with anything, from a printer, to a mobile phone, to setting up media streaming, bluetooth is the way to go! The nano dongle available from ModMyPi is the perfect low cost solution, and this guide will show you how to install it.

This guide is completed on Raspian, so the first step is to make sure you have the latest Raspbian Operating System (OS) installed on your Raspberry Pi. You can download the latest version here: http://www.raspberrypi.org/downloads

Step 1. Update and Install A. There's a few updates we need to run to make sure that our Raspberry Pi's software packages are all spiffy before we can proceed to installing the software we need for the bluetooth dongle. Skip this step if you're happy that your Pi's packages are already OK! Make sure you have a decent internet connection on your Pi before proceeding!

We'll need to make sure we've got the latest firmware drivers by running the following commands:

sudo apt-get update

(This updates the list of available packages and their versions, but it does not install or upgrade any packages.)

sudo apt-get upgrade

(This actually installs newer versions of the packages you have. After updating the lists, the package manager knows about available updates for the software you have installed.)

sudo apt-get autoremove

(This will then remove all of the reduntant packages after the latest upgrade)

B. We're now ready to install the software we need to interact with the bluetooth dongle!

sudo apt-get install bluetooth bluez-utils blueman

Easy :)

I usually turn off my Pi before proceeding with any hardware changes. So switch your Pi off, plug the nano dongle in, and switch the Pi back on.

Step 2. Plug and Play Command Line Access

This part is for people who feel like having a play from the command line, so ignore it if you're happy with access via the GUI - which to be honest will allow for the majority of connections!

A. You can run a quick check on the command line to see if the bluetooth device has been successfully registered:

lsusb

(This will list the currently connected USB devices)

This should yield the following connected device:

Bus 001 Device 005: 1D 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HC1 mode)

B. You can also check to see whether the bluetooth is live by running the following command:

/etc/init.d/bluetooth status

(This command will give you basic functionality, by replacing 'status' with the following - 'start', 'stop', 'restart', 'force-reload')

Running 'status' should yield the following status message:

[ ok ] bluetooth is running

C. Next we need to scan for devices:

hcitool scan 

This will show any devices in range of the dongle, for example my mobile phone.

68:69:7C:31:9A:75 JAKE-IPHONE

D. If you want, you can then ping your devices and make sure they're communicating OK! Please note the l2ping command this is the letter L2ping NOT 12ping (twelveping) - I went around in circles with this one for a while :D

sudo l2ping -c 1 68:69:7C:31:9A:75

Make sure you put in your MAC address - don't just copy the one above :) This pings the device via bluetooth and will yield the following if successful:

Ping 68:69:7C:31:9A:75 from 00:1B:10:00:ZA:EC (data size 44) . . .
44 bytes from 68:69:7C:31:9A:75 id 0 time 26.88ms
1 sent, 1 recieved, 0% loss

That's probably enough playing for now on the command line, so we'll pick this up via the GUI.

Step 3. GUI Access

A. Boot to the GUI

startx

Then all you need to navigate to 'start >> preferences >> bluetooth manager' which will bring up the bluetooth device manager. From here you can search for and pair with devices, send files, and generally access bits and pieces via bluetooth!

or by command line

Step 4 – Connect to the keyboard

Turn your keyboard on using the switch on the back and use the following command to tell your Pi to scan for the keyboard :

hcitool scan Here is some example output :

pi@raspberrypi ~ $ hcitool scan Scanning ...

       90:7F:61:91:66:67       KT-1263 BT Keyboard

If your Pi can’t find the keyboard you may need to turn the keyboard off. Turn it back on. The blue light on F12 should blink. Run the hcitool command again. If the keyboard has already been on for a few minutes press the little rubber switch on the back of the keyboard with a pen tip. Run the hcitool command again.

Make a note of your keyboard’s MAC address. In my example it is 90:7F:61:91:66:67. Run this command using your MAC address :

sudo bluez-simple-agent hci0 90:7F:61:91:66:67 You will be asked to enter a PIN colde. Enter your choice of number and press “Return”.

Carefully type the same number on your bluetooth keyboard and press “Return”.

Your Pi should display the following text :

Release New device (/org/bluez/2808/hci0/dev_90_7F_61_91_66_67) If you get a “Creating device failed: org.bluez.Error.AlreadyExists: Already Exists” error use the following command to remove the current settings and try the “bluez-simple-agent” command again :

sudo bluez-test-device remove 90:7F:61:91:66:67 Now make the device trusted using :

sudo bluez-test-device trusted 90:7F:61:91:66:67 yes Finally connect to the keyboard :

sudo bluez-test-input connect 90:7F:61:91:66:67 Your keyboard should be working! Horray!