HOW-to: Bluetooth serial comms SP/SPP bluez5

Here you'll find a place for solutions and hints.

Please use one of the support subforums below for questions or if you have any issues and need support.

HOW-to: Bluetooth serial comms SP/SPP bluez5

Postby waferhead » May 9th, '15, 08:05

Rather than just complain, I figured i'd post this mini-how-to for using a SPP device on bluetooth (bluez5) AKA SP once I figured it out again.

This is primarily used for network tethering to a phone, but in this case i need to use a BT rs232 serial port device--- works the same, I could stick it on a modem (or PLC, or ECU) from ~100 yards and connect. To hook up to an actual modem/get online you would also have to configure ppp.

When all the distros switched to bluez5, dropping bluez4, there were zero user space gui config tools that fully supported all the features of Bluez5. Several years later, this is still the case.

Fortunately, SPP or SP mode (serial port protocol) is a core bluetooth protocol (not optional if you are supposedly Bluetooth compliant), so it turns out works just fine used manually.

It gets better--- The traditional /etc/bluetooth/rfcomm.conf file is now ignored completely, so there is no undocumented config file to set up.

This actually makes life simpler, as all you need are a few very trivial one line commands that one can call or setup as services if so inclined.

Note: To release/destroy /dev/rfcomm0 if things get crossed up, one simply commands:
Code: Select all
rfcomm release 0


First, plug in your device and look for it (this is all very trivial commands)
Code: Select all
[root@spaz greg]# hcitool scan
Scanning ...
        00:18:DB:00:C4:B1       MS2extra

Then we see what channel it wants, you can also use this to find the device that supports SP mode if you have a house full of BT toys:
Code: Select all
[root@spaz greg]# sdptool search SP
Inquiring ...
Searching for SP on 00:18:DB:00:C4:B1 ...
Service Name: Dev BService RecHandle: 0x10001
Service Class ID List:
  "Serial Port" (0x1101)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 1
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:    0x6a
  base_offset: 0x100

Then we simply bind or connect:
Which method depends on the particular software you are using, bind is typically correct.
("AES" arg turns on authentication, encryption and security, "r" for raw tty mode)
Code: Select all
[root@spaz greg]# rfcomm -AESr connect  0 00:18:DB:00:C4:B1 1
(PIN dialog pops up, insert PIN and apply)
Connected /dev/rfcomm0 to 00:18:DB:00:C4:B1 on channel 1
Press CTRL-C for hangup

The "1" after the device address is the specified channel.

Here, we demonstrate the bind mode, and open/close the socket (which automagically connects/disconnects. the "r' option is raw mode and doesn't work for bind per the man page)
Code: Select all
[root@spaz greg]# rfcomm -AES bind 0 00:18:DB:00:C4:B1 1
[root@spaz greg]# cat /dev/rfcomm0
(/dev/rfcomm0 is created on first command, BT connects/disconnects when even cat accesses it/stops)


The most hilarious thing is that KDEs bluedevil will pop up the PIN prompt the first time you try to connect, and saves it, even though it has never had any clue of how to set up an SP device.
(blueman worked properly on MGA3, bluedevil never had the capability)
waferhead
 
Posts: 170
Joined: Jun 11th, '11, 06:36

Re: HOW-to: Bluetooth serial comms SP/SPP bluez5

Postby doktor5000 » May 25th, '15, 19:50

FWIW, newer blueman releases as the one we recently gained in cauldron (>= 1.99.alpha3) do offer nearly full bluez5 support, and it also includes a profile for SP/SPP.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17629
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: HOW-to: Bluetooth serial comms SP/SPP bluez5

Postby waferhead » May 26th, '15, 01:49

doktor5000 wrote:FWIW, newer blueman releases as the one we recently gained in cauldron (>= 1.99.alpha3) do offer nearly full bluez5 support, and it also includes a profile for SP/SPP.



I'll test it out!
(time passes)
Cool, seems to work well except it doesn't automagically reconnect, you must rerun setup each time.
It does remember the PIN, so only minor annoyance, the defaults are proper so its a two click job.

In order to disable the still broken bluedevil one simply has to turn off kde bluetooth integration in system settings, and leave bluetooth-manager running in the session when you log out.
(assuming you are set to preserve session status, it will open each time in the system tray)

The previous info is still useful for attaching the BT serial device from a script w/o having to deal with setting things up each time.
waferhead
 
Posts: 170
Joined: Jun 11th, '11, 06:36


Return to The magician suggests...

Who is online

Users browsing this forum: No registered users and 1 guest

cron