Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debian: Forward login console over bluetooth

Some time ago, I've got a new single board computer running Debian which will eventually be the "heart" of a project at school.

Right now, I'm accessing the on-board distro using wired network and ssh. This is fine as long as the thing lies on my desktop, but not when it is built into the robot to where it is targeted. I managed to establish a bluetooth connection using a cheap USB-BT adapter, but now I'm stuck with an rfcomm device and no clue on how to proceed.

What I would like most would be to have the virtual serial port provided by the bluetooth connection to behave just like the real serial port. So that I can log in using minicom (or something similar) and get full access to everything on the board.

When searching the web, all I could find were guides about how to set up dial-up networking with mobiles and similar topics, but nothing about a bluetooth console. Maybe I've just tried the wrong keywords.

I'd really much appreciate any hint on how to do this.

Thanks, Philipp

like image 661
Philipp Burch Avatar asked Apr 01 '12 19:04

Philipp Burch


2 Answers

I suppose I've found a feasible solution. The missing keyword was "getty" and some glue logic in a shell script:

#!/bin/sh

# Make sure to have rfcomm loaded
modprobe rfcomm

# Turn on and reset bluetooth dongle
hciconfig hci0 up
hciconfig hci0 reset

# Accept incoming connections (in background)
rfcomm watch 0 1 &

# Loop forever
while true
do
  # Wait for our socket to pop in
  while [ ! -c /dev/rfcomm0 ]
  do
    sleep 5
  done

  # Present a login shell
  getty -n -l /bin/bash 115200 /dev/rfcomm0 vt102
done

I'm not very confident about it, since it does not seem to be very stable (Sometimes it is not possible to connect after boot...), but it works fast and is relatively easy. So I'm happy with it :)

Regards, Philipp

like image 116
Philipp Burch Avatar answered Oct 14 '22 07:10

Philipp Burch


I have a bluetooth serial link between my PC and my robot(beaglebone black). I'm very happy because I don't need anything more than a cheap Bluetooth USB dongle on the robot side to get a remote terminal. My PC also has its bluetooth.

The steps bellow worked for me:

Firstly you have to pair the devices. Pairing is relatively easy. I will call client(who starts talking - robot) and server(who reply)

You have to setup the server before: Server side(as root):

sdptool add --channel=3 SP
mknod -m 666 /dev/rfcomm0 c 216 0
rfcomm watch /dev/rfcomm0 3 /sbin/agetty rfcomm0 115200 linux

Client side(as root):

sdptool add --channel=3 SP
rfcomm connect /dev/rfcomm0 [SERVER_ADDR] 3

Now to open a serial terminal on the client:

screen /dev/rfcomm0 115200

Comments:

When you call the last command rfcomm connect... in the client, a device /dev/rfcomm0 will be created and associated to the server /dev/recomm0. This represents the serial link between both

The last server command: rfcomm watch.... will 'listen' for incoming connections. In connection lost, the command will restart a new 'listen' state.

like image 27
ismaia Avatar answered Oct 14 '22 07:10

ismaia