justforfun |
2011-09-11 16:04 |
How to make a 'Bluetooth serial port' between N900 and laptop(Linux)?
I did a trial to setup a 'Bluetooth serial port' between my N900 and my laptop(Ubuntu installed), but failed.
I record the process as below, please help to find the reason, thanks!
On the laptop side:
Code:
# hcitool scan
Scanning ...
C8:97:9F:E3:28:44 Nokia N900
# export N900='C8:97:9F:E3:28:44'
On N900 side:
Code:
# hcitool scan
Scanning ...
88:9F:FA:F3:F5:0A BlueZ (1)
# export LAPTOP='88:9F:FA:F3:F5:0A'
To add the Serial Port protol, I execute the command on both sides:
Code:
# sdptool add --channel=10 SP
Serial Port service registered
Then I searched the services on laptop side:
Code:
# sdptool records $N900
...
Service Name: Serial Port
Service Description: COM Port
Service Provider: BlueZ
Service RecHandle: 0x10005
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 10
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Serial Port" (0x1101)
Version: 0x0100
...
Then I searched the services on N900 side:
Code:
# sdptool records $LAPTOP
...
Service Name: Serial Port
Service Description: COM Port
Service Provider: BlueZ
Service RecHandle: 0x10006
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 10
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Serial Port" (0x1101)
Version: 0x0100
...
On laptop side:
Code:
# cat /etc/bluetooth/rfcomm.conf
#
# RFCOMM configuration file.
#
rfcomm0 {
# # Automatically bind the device at startup
bind yes;
#
# # Bluetooth address of the device
device C8:97:9F:E3:28:44;
#
# # RFCOMM channel for the connection
channel 10;
#
# # Description of the connection
comment "Example Bluetooth device";
}
On N900 side:
Code:
# cat /etc/bluetooth/rfcomm.conf
#
# RFCOMM configuration file.
#
rfcomm0 {
# # Automatically bind the device at startup
bind yes;
#
# # Bluetooth address of the device
device 88:9F:FA:F3:F5:0A;
# # RFCOMM channel for the connection
channel 10;
# # Description of the connection
comment "BT COM TEST";
}
Then create the rfcomm0 on both sides:
Code:
mknod /dev/rfcomm0 c 216 1
chmod 666 /dev/rfcomm0
Load the conf file on both sides:
Code:
rfcomm -f /etc/bluetooth/rfcomm.conf
Start to connect on N900 side, but failed:
Code:
# rfcomm connect /dev/rfcomm0
Can't connect RFCOMM socket: Connection refused
Some hints below:
On laptop side, I can connect to N900 via below command, but only for a few seconds:
Code:
# hcitool cc C8:97:9F:E3:28:44
root@maemo-desktop:/etc/bluetooth# hcitool con
Connections:
< ACL C8:97:9F:E3:28:44 handle 12 state 1 lm SLAVE
root@maemo-desktop:/etc/bluetooth# hcitool con
Connections:
And also on laptop side, I can l2ping the N900:
Code:
# l2ping C8:97:9F:E3:28:44
Ping: C8:97:9F:E3:28:44 from 88:9F:FA:F3:F5:0A (data size 44) ...
44 bytes from C8:97:9F:E3:28:44 id 0 time 18.97ms
44 bytes from C8:97:9F:E3:28:44 id 1 time 15.46ms
44 bytes from C8:97:9F:E3:28:44 id 2 time 27.80ms
44 bytes from C8:97:9F:E3:28:44 id 3 time 20.50ms
44 bytes from C8:97:9F:E3:28:44 id 4 time 20.78ms
44 bytes from C8:97:9F:E3:28:44 id 5 time 29.30ms
44 bytes from C8:97:9F:E3:28:44 id 6 time 8.01ms
44 bytes from C8:97:9F:E3:28:44 id 7 time 19.67ms
Send failed: Connection reset by peer
|