Nov 22
Nokia N70 (S60 series), python and your PC
Here is a small briefing of how to connect your Nokia S60 series and your PC through bluetooth:
First of all, I installed some packages, for Ubuntu users:
sudo apt-get install ussp-push bluez-utils bluez-gnome gnome-bluetooth
1- Sending a file to your phone
The first thing to do, is to pair your mobile phone and your computer. So turn on the bluetooth on your box if its not already done, for Ubuntu users:
sudo /etc/init.d/bluetooth start
Now pair the two devices. : ) (no help here..)
Now we will scan the bluetooth neighborhood of your box:
ghantoos@mystation:~$ hcitool scan
Scanning ...
00:11:22:AA:BB:D1 ghantoos-phone
00:11:22:AA:BB:D2 someguysphone
00:11:22:AA:BB:D3 somegirlsphone
In order to get which channel is used for each application on your phone, use: (try to find the OBEX File Transfer channel number)
ghantoos@mystation:~$sdptool browse 00:11:22:AA:BB:D1
(...)
Service Name: OBEX File Transfer
Service RecHandle: 0x10002
Service Class ID List:
"OBEX File Transfer" (0x1106)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 10
"OBEX" (0x0008)
(...)
Now edit your /etc/bluetooth/rfcomm.conf configuration file, and add the MAC address of your phone & the channel number, to bind with an rfcomm device:
sudo vim /etc/bluetooth/rfcomm.conf
# and add:
rfcomm0 {
bind no;
device 00:11:22:AA:BB:D1;
channel 10;
comment "OBEX File Transfer";
}
Now let’s bind the phone’s file transfer channel to /dev/rfcomm0:
sudo rfcomm bind /dev/rfcomm0
This should a created the /dev/rfcomm0 device.
Now test a file transfer: (any file should be ok to send, but try sending a text file fast & fun.. )
sudo ussp-push /dev/rfcomm0 /path/to/file_name_on_PC name_on_phone # Careful to the space!
2- Your mobile python console on your box!
First of all, you have to install python on your phone.
Go to PyS60 project’s homepage on sourceforge.net and get the latest .SIS versions of PythonForS60 & PythonScriptShell.
The ones I got were:
wget http://garr.dl.sourceforge.net/sourceforge/pys60/PythonForS60_1_4_1_2ndEd.SIS wget http://garr.dl.sourceforge.net/sourceforge/pys60/PythonScriptShell_1_4_1_2ndEd.SIS
Now send the files to your Nokia, and install them. You can use the previous paragraph to send the files on your phone. : )
Once you have installed the python on your nokia, go to (on the phone my Own -> Python) and chose the “Bluetooth console”. Do not connect anything yet!
Now let’s configure the PC to listen the phone’s channel 10 on a certain local (PC) serial port (port 1 in the following example):
ghantoos@mystation:~$ sdptool add --channel=1 SP Serial Port service registered ghantoos@mystation:~$ sudo rfcomm listen /dev/rfcomm0 1 Waiting for connection on channel 1
Now, go back to your phone, and, through the “Bluetooth console” connect to your PC, this should add:
Discovered 00:11:22:AA:BB:D1, {u'Serial Port': 1}
Connecting to ('00:00:00:00:00:00',1)... OK
ghantoos@mystation:~$ sudo rfcomm listen /dev/rfcomm0 1 Waiting for connection on channel 1 Connection from 00:11:22:AA:BB:D1 to /dev/rfcomm0 Press CTRL-C for hangup
And now the magic appears! Connect to the rfcomm0 device to view what it wants to show you : )
ghantoos@mystation:~$ screen /dev/rfcomm0
Press “enter” to make shure it worked.. you should see the following magic:
>>> >>> print "Hello World!" Hello World! >>>
VoilĂ !
Hope this was useful!
cheers,
Ghantoos
