This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SSH over Bluetooth (for real?)
#1
I've been scouring websites, blog posts, and gits for days now, and have yet to find an actual solution.

Can someone PLEASE point me to a WORKING setup for ssh over bluetooth?

I can pair the board with my phone, no problem. But that's ALL I can get it to do.

Running the Tinker (debian) OS version 2.01 if that helps.
Reply
#2
I've been planning on setting this up myself, so I had a quick look.

Digging around on google, there sure is a lot of outdated (and therefore misleading) information. https://blind.guru/tag/bluetooth-pan.html seems to be current, and provides a lot of clues.

sudo systemctl status bluetooth tells us that the TinkerOS kernel configuration left out the BNEP option, which makes it impossible to use Bluetooth networking functions, including PAN as a client or server. Maybe it doesn't work with the current bluetooth driver, or maybe they just thought nobody needed it. If you _need_ ssh over bluetooth, it looks like you'll have to build a custom kernel to see if it works.

Will a bluetooth serial console login do what you need? If yes, follow https://github.com/engn1931z/lab4 or https://hacks.mozilla.org/2017/02/headle...bluetooth/

I found I had to make a small change, moving the lines that say

ExecStartPost=/usr/bin/sdptool add SP
ExecStartPost=/bin/hciconfig hci0 piscan

to the rfcomm.service file and add a Type like so:

-------------------------------------------------------

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

[Service]
Type=oneshot
ExecStart=/usr/bin/sdptool add SP
ExecStartPost=/bin/hciconfig hci0 piscan
ExecStart=/usr/bin/rfcomm watch hci0 1 getty rfcomm0 115200 vt100

[Install]
WantedBy=multi-user.target

-------------------------------------------------------

I then had to un-pair and re-pair my Mac and Tinker. Then on my Mac I simply do a cu -l /dev/cu.tinkerboard-SerialPort -s 115200
Reply
#3
[quote pid='3233' dateline='1510733235']
Finally a coherent answer! Thank you for that!

(This forum software is set up so oddly!)

Couple of questions if you don't mind...

Where did you place the rfcomm.service file?

What is the "cu" command?

I'm using the ELAR Lxbuntu distro as I found the TinkerOS far too limiting for the packages I need installed.

I don't mind compiling a fresh kernel if absolutely necessary.

Basically, this board will eventually be installed in a robot. I'll be connecting from my phone to issue commands, and receive replies from the robot (Android has some great speech to text built in, so I cut out the overhead of needing that on-board). So a serial console may work. :Smile 

[/quote]

----------------------------------------------------------------------------------



I've been planning on setting this up myself, so I had a quick look.  

Digging around on google, there sure is a lot of outdated (and therefore misleading) information.  https://blind.guru/tag/bluetooth-pan.html seems to be current, and provides a lot of clues.  

sudo systemctl status bluetooth tells us that the TinkerOS kernel configuration left out the BNEP option, which makes it impossible to use Bluetooth networking functions, including PAN as a client or server.  Maybe it doesn't work with the current bluetooth driver, or maybe they just thought nobody needed it.   If you _need_ ssh over bluetooth, it looks like you'll have to build a custom kernel to see if it works.  

Will a bluetooth serial console login do what you need?  If yes, follow https://github.com/engn1931z/lab4 or https://hacks.mozilla.org/2017/02/headle...bluetooth/

I found I had to make a small change, moving the lines that say

ExecStartPost=/usr/bin/sdptool add SP
ExecStartPost=/bin/hciconfig hci0 piscan

to the rfcomm.service file and add a Type like so:

-------------------------------------------------------

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

[Service]
Type=oneshot
ExecStart=/usr/bin/sdptool add SP
ExecStartPost=/bin/hciconfig hci0 piscan
ExecStart=/usr/bin/rfcomm watch hci0 1 getty rfcomm0 115200 vt100

[Install]
WantedBy=multi-user.target

-------------------------------------------------------

I then had to un-pair and re-pair my Mac and Tinker.  Then on my Mac I simply do a cu -l /dev/cu.tinkerboard-SerialPort -s 115200
Reply
#4
I don't use ELAR so I can't help with specifics. My summary for serial bluetooth *should* still work, though, with both TinkerOS and ELAR being Debian/Ubuntu based. If you still can't get it working, you should probably talk to the ELAR people or their forum if they have one.

ON THE CLIENT MACHINE:

cu is a an old-school serial (i.e. modem) communications program that happens to be built-in on Macs. "cu -l /dev/device -s baud-rate" is like "screen /dev/device baud-rate". screen or cu or minicom should be installable on any linux box you are trying to connect to your Tinker from. putty does serial comms on Windows. There's a bunch of free apps for Android phones; I use one called "Serial Bluetooth Terminal".

On android, a BT Serial app will sort this out automatically, but on macos/linux/windows you will have to figure out which COM port or /dev device is created once you pair your Tinker. The name varies depending on your BT adapter. If you are connecting _from_ linux, you may need to do something like "sudo rfcomm bind 0 f2:13:8c:a1:5f:23" where the hex is the BT address of your Tinker, in order for /dev/rfcomm0 to appear so you can use that as your serial /dev/device.

ON THE TINKER:

The rfcomm.service goes into /lib/systemd/system, as described in that Mozilla.org link I provided, but he's made it a bit unclear by putting it into a script. Here are my files:

/lib/systemd/system/rfcomm.service :

--------------------------------------------------------------------------------

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

[Service]
Type=oneshot
ExecStart=/usr/bin/sdptool add SP
ExecStartPost=/bin/hciconfig hci0 piscan
ExecStart=/usr/bin/rfcomm watch hci0 1 getty rfcomm0 115200 vt100

[Install]
WantedBy=multi-user.target

--------------------------------------------------------------------------------

and /lib/systemd/system/bluetooth.service:

--------------------------------------------------------------------------------

[Unit]
Description=Bluetooth service
Documentation=man:bluetoothd(8)
ConditionPathIsDirectory=/sys/class/bluetooth

[Service]
Type=dbus
BusName=org.bluez
# ExecStart=/usr/lib/bluetooth/bluetoothd
ExecStart=/usr/lib/bluetooth/bluetoothd -C

NotifyAccess=main
#WatchdogSec=10
#Restart=on-failure
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
LimitNPROC=1
ProtectHome=true
ProtectSystem=full

[Install]
WantedBy=bluetooth.target
Alias=dbus-org.bluez.service

--------------------------------------------------------------------------------

Don't forget to "sudo systemctl enable rfcomm.service" and reboot.
Reply
#5
Success! I get a login prompt via Bluetooth now!

Now to figure out how to redirect it to a script instead...

Any ideas?
Reply
#6
That's something I haven't done in decades. You may want getty to autologin a user by changing

ExecStart=/usr/bin/rfcomm watch hci0 1 getty rfcomm0 115200 vt100

to

ExecStart=/usr/bin/rfcomm watch hci0 1 getty rfcomm0 115200 vt100 -a yourusername

or run something other than getty on the rfcomm0 virtual serial port to talk to.

You can use expect in bash shell scripts. Python has pySerial. Good luck!
Reply
#7
New to this kind of hardware and still sitting on the fence. Before deciding which way to go, I have done some digging and found that hciconfig and rfcomm are now deprecated - did not find any recommendations on what to use instead, except the advice to activate "compat" mode (is this supported with tinker board?) - see https://github.com/chrippa/ds4drv/issues/123

Without hciconfig, it will be difficult to find which bluetooth channel to use for serial communication, and without rfcomm difficult to bind that channel to a device in order to support serial communication. Sorry, slightly OT with respect to bluetooth ssh.
Reply
#8
For proper PAN which allows TCP/IP and SSH, I nearly got this working with a combination of information here:

github bablokb/pi-btnap
blind.guru/tag/bluetooth-pan.html
blog.fraggod.net/2015/03/28/bluetooth-pan-network-setup-with-bluez-5x.html

After trying lots of stuff I was connected via Bluetooth with no WiFi and saw that I was assigned an ip with 192.168.20.x range.
I was able to ssh to the host on 192.168.20.99.

Unfortunately I rebooted the device and now its no longer providing me with an IP when I connect via bluetooth.

I might re try after wiping the SD card and following the instructions again more carefully.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)