Bluetooth GPS einrichten: Unterschied zwischen den Versionen
K (1 Version importiert) |
(kein Unterschied)
|
Version vom 28. Dezember 2018, 18:34 Uhr
Tools installieren
sudo apt-get install bluez gpsd gpsd-clients
GPS Gerät suchen
hcitool inq
Ausgabe so in etwa
Inquiring ...
00:02:C7:54:6F:11 clock offset: 0x5493 class: 0x001f00 7C:2F:80:74:4E:0F clock offset: 0x0ecf class: 0x100208 das GPS Gerät ist "00:02:C7:54:6F:11" da ich nicht wusste welches das richtige Gerät ist GPS einfach ausschalten, das nicht mehr angezeigte Gerät ist das richtige ;-)
mehr Infos über das Gerät
sdptool search --bdaddr 00:02:C7:54:6F:11 SP
es folgt folgende Ausgabe
Searching for SP on 00:02:C7:54:6F:11 ... Service Name: Serial Port Service RecHandle: 0x10000 Service Class ID List: "Serial Port" (0x1101) Protocol Descriptor List: "L2CAP" (0x0100)00:02:C7:54:6F:11 "RFCOMM" (0x0003) Channel: 1 Language Base Attr List: code_ISO639: 0x656e encoding: 0x6a base_offset: 0x100
Please note the line with the property Channel: this is the channel where your GPS device listens for incoming connections (Bluetooth supports only one connection at a time) So, remember what the channel number is. The next bit is a bit more specific for the Pi than the Debian guide
# # RFCOMM configuration file. # rfcomm0 { bind yes; device 00:02:C7:54:6F:11; channel 1; comment "RoyalTek"; }
Now to start bluetooth services
/etc/init.d/bluetooth start
So, first I installed it with
sudo apt-get install blueman
dann ...
sudo reboot
nach Reboot
sudo hcitool inq
To bind it to rfcomm (with copied 00:02:C7:54:6F:11 and the channel number after it)
sudo rfcomm connect rfcomm0 00:02:C7:54:6F:11 1
Ausgabe
Connected /dev/rfcomm0 to 00:02:C7:54:6F:11 on channel 1 Press CTRL-C for hangup
crtl-C
sudo dpkg-reconfigure gpsd
Ausgabe
Warning: Stopping gpsd.service, but it can still be activated by: gpsd.socket Creating/updating gpsd user account...
gpsd starten
sudo /etc/init.d/gpsd start
[ ok ] Starting gpsd (via systemctl): gpsd.service.
noch etwas mehr Software installieren
sudo apt-get install minicom
Im zweiten Terminal folgendes starten (muss im Hintergund laufen)
sudo rfcomm connect rfcomm0 00:02:C7:54:6F:11 1
Verbindung testen
cat /dev/rfcomm0
Wenn jetzt lauter Zahlenkolonnen kommen, dann ist alles gut.
GPSD Daemon einrichten
Next is the “gpsd” daemon. This is a process that runs in the background and translates the NMEA messages for use by the clients.
gpsd -b /dev/rfcomm0
The b switch tells it to only read messages and not attempt to send anything back to the GPS receiver.
Step 6 – Terminal Client
At this stage your GPS module should be streaming data to the Pi over Bluetooth. To present this data in a more readable way we can use one of the clients that comes with the gpsd package. Try :
cgps -s
If everything has gone to plan you should see something a bit think this :
CGPS Client
Schritte oben waren nicht erfolgreich
Alternative von https://klenzel.de/4182
Anschließend binden wir, zunächst manuell, die GPS-Maus als Gerät in unser System ein:
rfcomm bind /dev/rfcomm0 00:02:C7:54:6F:11
Damit die Einbindung künftig automatisch beim Systemstart erfolgt, erstellen wir für die GPS-Maus einen neuen Dienst (ab Raspbian Wheezy mit systemd), indem wir die Datei „/etc/systemd/system/rfcomm.service“ mit folgendem Inhalt erstellen:
sudo nano /etc/systemd/system/rfcomm.service
[Unit] Description=RFCOMM service After=bluetooth.service Requires=bluetooth.service [Service] ExecStart=/usr/bin/rfcomm bind /dev/rfcomm0 00:02:C7:54:6F:11 Restart=on-failure RestartSec=5s RemainAfterExit=yes [Install] WantedBy=multi-user.target [Unit] Description=RFCOMM service After=bluetooth.service Requires=bluetooth.service [Service] ExecStart=/usr/bin/rfcomm bind /dev/rfcomm0 00:02:78:AA:BB:CC Restart=on-failure RestartSec=5s RemainAfterExit=yes [Install] WantedBy=multi-user.target
Dabei ist natürlich die MAC-Adresse an das eigene Gerät anzupassen.
Anschließend aktivieren wir den neuen Dienst mit
systemctl restart rfcomm.service
und prüfen mit einem Neustart, ob die GPS-Maus beim Systemstart automatisch unter „/dev/rfcomm0“ eingebunden wird:
rfcomm -a && ls -al /dev/rfcomm0
Die Ausgabe sollte in etwa so aussehen:
rfcomm0: 00:02:78:AA:BB:CC channel 1 closed crw-rw---- 1 root dialout 216, 0 Mai 31 08:32 /dev/rfcomm0 rfcomm0: 00:02:78:AA:BB:CC channel 1 closed crw-rw---- 1 root dialout 216, 0 Mai 31 08:32 /dev/rfcomm0
Quellen: