Bluetooth in OpenWrt.

Den Betrieb von Bluetooth betrachten wir anhand vom Beispiel der Verbindung eines Mobiltelefons mit dem Router über die Bluetooth-Schnittstelle. Ich verwende das Nokia 6230i, aber ich denke, dass Handymodell keine Rolle spielt und dass Verbindungsverfahren für alle Modelle identisch ist.

Auf der Stufe der Konfiguration sind folgende Module auszuwählen:
Utilities:
<M> bluez-utils
Kernel modules:
Other modules:
<M> kmod-bluetooth
Libraries:
<M> libusb
Filesystem:
<M> libfuse

Downloaden wir und installieren die Pakete:

root@OpenWrt:/# opkg install kmod-bluetooth bluez-utils
Installing kmod-bluetooth (2.6.36.4-1) to root...
Downloading ftp://ftp:ftp@192.168.0.9/kmod-bluetooth_2.6.36.4-1_brcm47xx.ipk.
Installing kmod-crc16 (2.6.36.4-1) to root...
Downloading ftp://ftp:ftp@192.168.0.9/kmod-crc16_2.6.36.4-1_brcm47xx.ipk.
Installing kmod-hid (2.6.36.4-1) to root...
Downloading ftp://ftp:ftp@192.168.0.9/kmod-hid_2.6.36.4-1_brcm47xx.ipk.
Installing kmod-input-core (2.6.36.4-1) to root...
Downloading ftp://ftp:ftp@192.168.0.9/kmod-input-core_2.6.36.4-1_brcm47xx.ipk.
Installing kmod-rfkill (2.6.36.4-1) to root...
Downloading ftp://ftp:ftp@192.168.0.9/kmod-rfkill_2.6.36.4-1_brcm47xx.ipk.
Installing bluez-utils (3.36-7) to root...
Downloading ftp://ftp:ftp@192.168.0.9/bluez-utils_3.36-7_brcm47xx.ipk.
Installing bluez-libs (3.36-3) to root...
Downloading ftp://ftp:ftp@192.168.0.9/bluez-libs_3.36-3_brcm47xx.ipk.
Installing libpthread (0.9.32-68) to root...
Downloading ftp://ftp:ftp@192.168.0.9/libpthread_0.9.32-68_brcm47xx.ipk.
Installing dbus (1.2.4.6permissive-2) to root...
Downloading ftp://ftp:ftp@192.168.0.9/dbus_1.2.4.6permissive-2_brcm47xx.ipk.
Installing libexpat (2.0.1-1) to root...
Downloading ftp://ftp:ftp@192.168.0.9/libexpat_2.0.1-1_brcm47xx.ipk.
Installing libdbus (1.2.4.6permissive-2) to root...
Downloading ftp://ftp:ftp@192.168.0.9/libdbus_1.2.4.6permissive-2_brcm47xx.ipk.
Configuring libpthread.
Configuring libdbus.
Configuring kmod-input-core.
Configuring bluez-libs.
Configuring libexpat.
Configuring dbus.
Configuring kmod-crc16.
Configuring kmod-hid.
Configuring kmod-rfkill.
Configuring kmod-bluetooth.
Configuring bluez-utils.

root@OpenWrt:/# opkg install libfuse
Installing libfuse (2.8.5-1) to root...
Downloading ftp://ftp:ftp@192.168.0.9/libfuse_2.8.5-1_brcm47xx.ipk.
Installing kmod-fuse (2.6.36.4-1) to root...
Downloading ftp://ftp:ftp@192.168.0.9/kmod-fuse_2.6.36.4-1_brcm47xx.ipk.
Configuring kmod-fuse.
Configuring libfuse.

root@OpenWrt:/# opkg install libusb
Installing libusb (0.1.12-2) to root...
Downloading ftp://ftp:ftp@192.168.0.9/libusb_0.1.12-2_brcm47xx.ipk.
Configuring libusb.

Um den Zugang zum Dateisystem des Mobiltelefons zu bekommen, verwendet man ublicherweise die Anwendungen openopbex, obexftp, obexfs. Zum Zeitpunkt des Verfassens dieses Artikels sind diese Anwendungen nicht in Openwrt enthalten. Also werden wir diese selbständig hinzufügen.

Es ist ganz einfach die neuen Pakete in Openwrt hinzufügen. Man soll ein Verzeichnis mit dem Namen des Pakets im Verzeichnis openwrt/package erstellen. Im neuen Verzeichnis ist die Datei Makefile zu erstellen. Es ist ganz einfach die Makefile zu erstellen, wenn wir als Basis eine ähnliche Datei aus dem Verzeichnis openwrt/package nehmen.

Wenn Sie daran interessiert sind, können Sie die Anwendungen openopbex, obexftp, obexfs in das openwrt selbständig hinzufügen. Oder verwenden meine Versionen aus dem Abschnitt «Herunterladen».

Nachdem wir die neuen Verzeichnisse in openwrt/package erstellt haben, starten wir make menuconfig und wählen diese für die nachfolgende Zusammenfassung aus.

Installieren wir die neuen Pakete weiter:

root@OpenWrt:/# opkg install openobex
Installing openobex (1.3-1) to root...
Downloading ftp://ftp:ftp@192.168.0.9/openobex_1.3-1_brcm47xx.ipk.
Configuring openobex.

root@OpenWrt:/# opkg install obexftp
Installing obexftp (0.22-1) to root...
Downloading ftp://ftp:ftp@192.168.0.9/obexftp_0.22-1_brcm47xx.ipk.
Configuring obexftp.

root@OpenWrt:/# opkg install obexfs
Installing obexfs (0.12-1) to root...
Downloading ftp://ftp:ftp@192.168.0.9/obexfs_0.12-1_brcm47xx.ipk.
Configuring obexfs.

Schließen wir das Bluetooth Modul an und prüfen die Ausgabe dmesg:

root@OpenWrt:/# dmesg
Bluetooth: Core ver 2.15
NET: Registered protocol family 31
Bluetooth: HCI device and connection manager initialized
Bluetooth: HCI socket layer initialized
Bluetooth: L2CAP ver 2.15
Bluetooth: L2CAP socket layer initialized
Bluetooth: SCO (Voice Link) ver 0.6
Bluetooth: SCO socket layer initialized
Bluetooth: RFCOMM TTY layer initialized
Bluetooth: RFCOMM socket layer initialized
Bluetooth: RFCOMM ver 1.11
Bluetooth: BNEP (Ethernet Emulation) ver 1.3
Bluetooth: BNEP filters: protocol multicast
Bluetooth: HIDP (Human Interface Emulation) ver 1.2
Bluetooth: HCI UART driver ver 2.2
Bluetooth: HCI H4 protocol initialized
Bluetooth: HCI BCSP protocol initialized
Bluetooth: Generic Bluetooth USB driver ver 0.6
usbcore: registered new interface driver btusb
usb 1-1.4.3: new full speed USB device using ohci_hcd and address 5

Für den Betrieb von Bluetooth gibt es eigene Dienstprogramme. Treten wir einigen von denen näher. Das Dienstprogramm hciconfig ist etwas dem Dienstprogramm ifconfig ähnlich.

Starten wir dieses Dienstprogramm:

root@OpenWrt:/# hciconfig

hci0: Type: USB

BD Address: 00:00:00:00:00:00 ACL MTU: 0:0 SCO MTU: 0:0

DOWN

RX bytes:0 acl:0 sco:0 events:0 errors:0

TX bytes:0 acl:0 sco:0 commands:0 errors:0

Es wurde ein Gerät hci0 initialisiert, welches im Status down ist. Analogisch zum ifconfig starten wir hciconfig hci0 up.

root@OpenWrt:/# hciconfig hci0 up
root@OpenWrt:/# hciconfig
hci0: Type: USB
BD Address: 00:0A:3A:5C:88:60 ACL MTU: 192:8 SCO MTU: 64:8
UP RUNNING
RX bytes:340 acl:0 sco:0 events:11 errors:0
TX bytes:38 acl:0 sco:0 commands:11 errors:0

Es gibt noch ein nützliches Dienstprogramm, das ist hcitool. Aktivieren wir das Bluetooth am Mobiltelefon und führen Folgendes aus:

root@OpenWrt:/# hcitool scan
Scanning ...
00:13:FD:80:F9:F5 Nokia6230i

Jetzt wenn wir die Adresse des Telefons kennen, versuchen wir den Zugang zu seinem Dateisystem bekommen. Verwenden wir das Dienstprogramm obexfs. Beim Aufruf ist die Telefonadresse und das Dienstprogramm, wo das Dateisystem des Handys zu montieren ist, anzugeben:

root@OpenWrt:/# obexfs -b00:13:FD:80:F9:F5 /mnt/nokia/

Nach Ausführung dieses Befehls im Handy werden Sie vorgeschlagen eine Verbindung zu erstellen und dann ist die Pin-Code einzugeben. Nach der Eingabe der PIN-Code in Ihrem Handy, haben Sie die gleiche Code im Router einzugeben . . . . Wie dies zu machen ist, weiß ich nicht)))

Dieses Problem umzugehen ist sehr einfach. Prüfen wir den Inhalt des folgenden Verzeichnisses:

root@OpenWrt:/# ls -l /var/lib/bluetooth/00\:0A\:3A\:5C\:88\:60/
-rw-r--r-- 1 root root 27 Jan 1 00:04 classes
-rw-r--r-- 1 root root 26 Jan 1 01:40 config
-rw-r--r-- 1 root root 38 Jan 1 00:02 did
-rw-r--r-- 1 root root 35 Jan 1 00:02 features
-rw-r--r-- 1 root root 42 Jan 1 00:10 lastseen
-rw-r--r-- 1 root root 42 Jan 1 01:41 lastused
-rw------- 1 root root 55 Jan 1 00:11 linkkeys
-rw-r--r-- 1 root root 27 Jan 1 00:02 manufacturers
-rw-r--r-- 1 root root 37 Jan 1 00:02 names
-rw-r--r-- 1 root root 499 Jan 1 00:02 profiles
-rw-r--r-- 1 root root 2658 Jan 1 00:02 sdp

In diesem Verzeichnis befinden die Systemdateien, welche für die Bluetooth Verbindung verantwortlich sind. Ergänzen wir das Verzeichnis mit der Datei pincodes, wo wir die Adresse und die entsprechende PIN-Code eingeben. Bei mir sieht es wie folgt aus: 00:13:FD:80:F9:F5 1

Nach der Erstellung von dieser Datei brauchen wir die PIN-Code im Router nicht mehr. Versuchen wir es noch einmal:

root@OpenWrt:/# obexfs -b00:13:FD:80:F9:F5 /mnt/nokia/
root@OpenWrt:/# ls -l /mnt/nokia/
GETDIR:Mem. card
GETDIR:Фото
GETDIR:Клипы
GETDIR:Музыка
GETDIR:Темы
GETDIR:Графика
GETDIR:Мелодии
GETDIR:Аудиозаписи
GETDIR:Ww
GETDIR:0017.GIF

Wir können das Dateisystem wie folgt unmounten:

root@OpenWrt:/# umount /mnt/nokia/



Bestellen ein Bluetooth Modul bei uns:

Bluetooth Modul