Miniware logo
Articles / Serial port communication between linux and mobile phone over bluetooth

Serial port communication between linux and mobile phone over bluetooth

This article descibes how to communicate with your phone through a com port using bluetooth in Ubuntu linux. In this article I am using Nokia 6230i but hopefully it will be the same with other phones.

First of all, be sure that you have the following librariees installed in your system: bluez-pin, bluez-utils. If not you can install them easily by using the Synaptic package manager.

Now we are going to detect the phone frm hour linux box. Assure that you have enabled the bluetooth in your phone.Then in a terminal window fire the following command:

>hcitool scan

In my case I receive the following result: 00:13:FD:94:B8:4F Nokia 6230i. This is the bluetooth id of your phone as well the frendly name you have given to it.

Our next step will be to view the services that our phone offers. In order to to do that we have to fire the following command:

>sdptool browse (in my case sdptool browse 00:13:FD:94:B8:4F)

The result will be something like that:

Browsing 00:13:FD:94:B8:4F ...
Service Name: Dial-up networking
Service RecHandle: 0x10000
Service Class ID List:
"Dialup Networking" (0x1103)
"Generic Networking" (0x1201)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 1
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Dialup Networking" (0x1103)
Version: 0x0100

Service Name: Nokia PC Suite
Service RecHandle: 0x10001
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 15
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100

Service Name: COM 1
Service RecHandle: 0x10002
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 3
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
.....

It will be a good advice to same the result of this command into a file as we will need in the next steps. Now we will modify the rfcomm.conf file. This file binds the bluetooth services to sepcifi com port. This file usually located nder /etc/bluetooth

In this article we are intrested in binding the com 1 service into the rfcomm0. So our fcomm.conf file will have the following form:

rfcomm0 {
bind yes;
# Bluetooth address of the device
device 00:13:FD:94:B8:4F;
# RFCOMM channel for the connection, can be found of the output
#of dptool browse
channel 3;
# Description of the connection
comment "Example Bluetooth device";
}

if we want to bind another service to another port we can append similar records to the file. We can test if we were successful by typing

> rfcomm connect 0

if everything went OK you will see a prompt for a pin in your phone. After you enter this prompt another prompt will appear in your computer requesting the same pin. If not try to restart blueetooth services by typing:

>/etc/init.d/bluez-utils restart



The content of this page can be reproduced as long as the author and the source are mentioned. For questions please use the forum. Nikos Fotiou
Comments
(Post new comment)