26.3.08

Bluetooth Again - For my Records

First of all, make sure you have all the BlueZ stuff installed. On this Ubuntu, using the Synaptic Package Manager, just search for Bluetooth and install anything that shows up.

Also have a look at the BlueZ site.

Find your bluetooth devicce address;

owen@Ubuntu-7:~$ hcitool dev
Devices:
hci0 00:11:67:5F:89:47

Now find the address of your (Mobile phone) device;

owen@Ubuntu-7:~$ hcitool scan
Scanning ...
00:16:20:9D:8A:7C John V600i

owen@Ubuntu-7:~$ hciconfig
hci0: Type: USB BD Address: 00:11:67:5F:89:47 ACL MTU: 678:8 SCO MTU: 48:10
UP RUNNING PSCAN ISCAN
RX bytes:3882 acl:14 sco:0 events:52 errors:0
TX bytes:674 acl:12 sco:0 commands:28 errors:0


Now have a look at what it can do;

owen@Ubuntu-7:~$ sdptool browse 00:16:20:9D:8A:7C
Browsing 00:16:20:9D:8A:7C ...
Service Description: Sony Ericsson V600i
Service RecHandle: 0x10000
Service Class ID List:
"PnP Information" (0x1200)


Then all this spews out

Service Name: Dial-up Networking
Service RecHandle: 0x10001
Service Class ID List:
"Dialup Networking" (0x1103)
"Generic Networking" (0x1201)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 1
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100

Service Name: Serial Port
Service RecHandle: 0x10002
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 2




I am only interested in the serial port. It is Channel 2, AND, I have paired my computer to the phone.



Well after saying to install everything with bluetooth in it, I curiously examined my menu items, and Lo!, there was something called Bluetooth Chat. Started that and it just connected to the phone and it all took about 5 seconds.

All the below is wasted effort, and if the chat client is written in Python, matbe I will find out how they made it so simple, by comparison anyway.







owen@Ubuntu-7:~$ sudo rfcomm connect 0 00:16:20:9D:8A:7C 2
Connected /dev/rfcomm0 to 00:16:20:9D:8A:7C on channel 2
Press CTRL-C for hangup

I now have a device rfcomm0

owen@Ubuntu-7:~$ ls -l /dev/rf*
crw-rw---- 1 root dialout 216, 0 2008-03-26 12:01 /dev/rfcomm0

You need to know this device when configuring minicom

=========================================================
Start minicom;

Welcome to minicom 2.2

OPTIONS: I18n
Compiled on Mar 7 2007, 15:10:03.
Port /dev/rfcomm0

Press CTRL-A Z for help on special keys

AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0
OK
atz+cops
ERROR
atz +cops?
+COPS: 1,0,"Telstra Mobile"

OK


=========================================================

Unfortunately the above is not 100% repeatable, but with enough fiddling and trying, including using the bind option to rfcomm, it will suddenly work.

Also I have been starting minicom in sudo mode, but don't know if that is necessary.

For the atz commands, see ETSI.

Acouple of other interesting commands, for the record.

owen@Ubuntu-7:~$hcitool con
Connections:
< ACL 00:16:20:9D:8A:7C handle 1 state 1 lm MASTER ENCRYPT

owen@Ubuntu-7:~$ rfcomm
rfcomm0: 00:11:67:75:48:32 -> 00:16:20:9D:8A:7C channel 2 connected [reuse-dlc release-on-hup tty-attached]

No comments: