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)