Linux/Raspi - Bluetooth-Serial-Terminal

In dieser Linux-Ecke dürfen nur Themen rund um Linux geschrieben werden.
Beiträge, die plattformübergreifend sind, gehören ins 'Allgemein'-Forum.
ccode_new
Beiträge: 1214
Registriert: 27.11.2016 18:13
Wohnort: Erzgebirge

Linux/Raspi - Bluetooth-Serial-Terminal

Beitrag von ccode_new »

Hi!

Kennt jemand eine bessere/elegantere Lösung eine Bluetooth-Serial-Terminal-Verbindung zu ermöglichen.

Bisher:
  • Edit:
    sudo nano /etc/systemd/system/dbus-org.bluez.service

    Diese Zeile erweitern:
    ExecStart=/usr/lib/bluetooth/bluetoothd -C --noplugin=sap
    Diese Zeile danach einfügen:
    ExecStartPost=/usr/bin/sdptool add SP

    Speichern

    Erstellen eines neuen "rfcomm" - Ports:
    Edit:
    sudo nano /etc/systemd/system/rfcomm.service

    [Unit]
    Description=RFCOMM service
    After=bluetooth.service
    Requires=bluetooth.service

    [Service]
    ExecStart=/usr/bin/rfcomm watch hci0
    Restart=on-failure
    RestartSec=5s
    RemainAfterExit=yes

    Speichern

    sudo systemctl enable rfcomm

    sudo reboot
Danach:
Ein Serial-Port mit PureBasic öffnen.
Beispiel:

Code: Alles auswählen

IncludeFile "Serial.pbi" 

Global Text.s

UseModule Serial

MeinPort.Serial = new()

MeinPort\open("/dev/rfcomm0", 9600, #PB_SerialPort_NoParity, 8, 1, #PB_SerialPort_NoHandshake)

If MeinPort\isOpen()
  Debug "Das Port ist geoeffnet."

  MeinPort\sendData(Ascii(~"Hallo vom Raspi!!!\n"), 19)
  MeinPort\sendData(Ascii("Huhu!!!"), 7)

  Repeat
    Text = MeinPort\receiveString()
    Debug Text
  Until Text = "exit"
Else
  Debug "Geht nicht!"
EndIf

MeinPort\close()

MeinPort\free()

UnuseModule Serial
End
Betriebssysteme: div. Windows, Linux, Unix - Systeme

no Keyboard, press any key
no mouse, you need a cat