Info: Bluetooth: RFCOMM, OBEX, Background scanning

Data exchange form Mobile 1 to Mobile 2 with RFCOMM:

Mobile 1 script (server) : rfcomm_server.py

Mobile 2 script (client) : rfcomm_client.py

 

Instruction for using the scripts:

Start to run first the rfcomm_server.py on mobile 1. This will advertise a Bluetooth RFCOMM service called "jurgen". (Will be seen by the other phone)

Start to run then the rfcomm_client.py on mobile 2. This script will scan for bluetooth devices. Select the nickname of mobile 1. After that you should get a list of available RFCOMM services that mobile 1 offers inlcuding "jurgen". Select "jurgen". Now mobile 1 is connected to mobile 2 and data can be exchanged.

Note: Possibly you need to do 2 things beforehand:

1. pair up your 2 mobile devices beforehand: On the main desktop of your phone press the icon Connect, then Bluetooth, then switch to the right TAB by using the right navigation key, then press the options key and select new paired devices, then select More devices and scan for the other mobile to pair up with. Select the nickname of the other device, then type 2 as key code and also 2 as key code on the other phone, and then you are paired up.

2. Set each phone to "authorized": On the main desktop of your phone press the icon Connect, then Bluetooth, then switch to the right TAB by using the right navigation key, then press the options key and select Set as authorized.

 

File exchange form Mobile 1 to Mobile 2 with OBEX:

Mobile 1 script (server) : obex_server.py

Mobile 2 script (client) : obex_client.py

 

Instruction for using the scripts:

Start to run first the obex_server.py on mobile 1. This will advertise a Bluetooth OBEX service called "test". (Will be seen by the other phone)

Start to run then the obex_client.py on mobile 2. This script will scan for bluetooth devices. Select the nickname of mobile 1. After that you should get a list of available OBEX services that mobile 1 offers inlcuding "jurgen". Select "jurgen". Now mobile 1 is connected to mobile 2 and the file can be exchanged. In this case the file called test.txt (located on the c drive of mobile 2) will be pushed from mobile 2 to mobile 1.

Imoportant: modify the obex_client.py file before you run the sript. Replace test.txt with a name of an exiting file on your c drive or e.g. in the image folder (if from image folder, then include the complete path e.g. e:\\images\0001.jpg ).

Note: Possibly you need to do 2 things beforehand:

1. pair up your 2 mobile devices beforehand: On the main desktop of your phone press the icon Connect, then Bluetooth, then switch to the right TAB by using the right navigation key, then press the options key and select new paired devices, then select More devices and scan for the other mobile to pair up with. Select the nickname of the other device, then type 2 as key code and also 2 as key code on the other phone, and then you are paired up.

2. Set each phone to "authorized": On the main desktop of your phone press the icon Connect, then Bluetooth, then switch to the right TAB by using the right navigation key, then press the options key and select Set as authorized.

 

 

 

 

 

 

 

 

 

 

Background scanning of Bluetooth devices

Once the following script is run, a file called bt_probing.txt on the c drive contains the nicknames and the BT addresses of scanned devices. Scanning happens every 30 sec.

Example script: bt_background_scan.py

Description:
With this script you can scan for nearby bluetooth devices while you run other script activities at the same time. A file called bt_probing.txt that is located on the c drive of your phone ("c:\\bt_probing.txt") gets updated every 30 seconds. It contains the nicknames, the BT address and OBEX as well as RFCOMM services of phones that are nearby and have their bluetooth switched on.

IMPORTANT:
In order to run the bt_background_scan.py script you need to install first the following .sis files to your phone to get additional libraries installed that are not included in the original Nokia Python for 60 package:


1. aosocket-series60_v20.sis
2. pdis.sis

Both files are originally found from: http://pdis.hiit.fi/pdis/download/pdis/

These sis files will install automatically the needed libraries to the correct folder on the phone.

Running a script in the background: ( not allowed to have a UI component in it)

e32.start_server('c:\\system\\apps\\Python\\my\\script.py')

Note: you need to quit the background script somehow. Therefore it is good to have also a controller script. Use e.g. listening to a local tcp port or to look if a certain file exists.
Send commands to the TCP port by the controller script or create a file with it.


 

 

 

Running a script in the background: ( not allowed to have a UI component in it)

e32.start_server('c:\\system\\apps\\Python\\my\\script.py')

Note: you need to quit the background script somehow. Therefore it is good to have also a controller script. Use e.g. listening to a local tcp port or look if a certain file exists.
Send commands to the TCP port by the controller script or create a file with it.


 

 

 

Previous|Next | Menu         Copyright (c) 2006 Jurgen Scheible