Music Album

Description:

This application triggers the BT devices and retrieves the gsm_location. In order to run the 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:
pdis.hiit.fi/pdis/download/pdis/
These sis files will install automatically the needed libraries to the correct folder on the phone

#Jan Nørgaard Thomsen
#Lars Christensen
#Tharaniharan Somasegaran
#Jonas Vejlin
###### Import modules
import appuifw
import e32
import time
import location
from graphics import *
import aosocketnativenew
from pdis.lib.logging import *
import httplib, urllib
from aosocket.symbian.bt_device_discoverer import *
from socket import * # for obex file send
def exit_key_handler():
app_lock.signal()
###### Path to store the log file
path = u"c:\\BT_scan.txt"
###### the argument is written to the logfile and printed to the body of the gui
def tell(string):
logwrite(string)
if e32.is_ui_thread():
output = unicode(string )
BT_search = appuifw.Text()
BT_search.add(output)
appuifw.app.body = BT_search
e32.ao_yield()
# -----------------------------------------------------------------------------
# this method was found from forum.nokia.com
def discovered(error, devices, cb_param):
if error == 0:
tell(" ")
for address, name in devices:
tell("Found: " + address + " | " + name)
for address, name in devices:
tell(" ")
try:
address2, services = bt_discover(address) #find services and port number
tell("Probing: " + address + " | " + name)
tell("RFCOMM Services: ")
tell(services)
tell(services.values()[0]) # port number of first RFCOMM service found
tell(" ")
except:
pass
for address, name in devices:
try:
address3, services2 = bt_obex_discover(address) #find obex service port number
tell("Probing: " + address + " | " + name)
tell("OBEX SERVICES: ")
tell(services2)
tell(services2.values()[0]) # port number of first OBEX service found
tell(" ")
except:
pass
else:
tell("device discovery failure: error %d" % error)
_discoverer.close()
# -----------------------------------------------------------------------------
###### The CallBack method
def Choice():
###### The the index nr. of what was initated of the list "menu"
index = View.current()
if index == 0:
###### Gets the Time
tid = time.asctime(time.localtime())
tid = unicode(tid)
appuifw.note(tid, "info")
if index == 1:
###### Gets the GSM location
gsm = location.gsm_location()
gsm = unicode(gsm)
appuifw.note(gsm, "info")
if index == 2:
###### init_logging writes to logfile, each time it's call the inital log is overwritten.
init_logging(FileLogger(path))
gsm = location.gsm_location()
gsm = unicode(gsm)
tell("GSM Location:" + gsm + "\n")
appuifw.body = None
while(1):
try:
_discoverer = BtDeviceLister()
_discoverer.discover_all(discovered, None)
tell("discovering")
e32.ao_sleep(30)
except:
tell("init failure")
appuifw.note(u"Fatal error.", "error")
if index == 3:
###### The Log file is opened and read, and added to the gui body.
Log_BT = open(path).read()
Log_BT = unicode(Log_BT)
Log_body = appuifw.Text()
Log_body.add(Log_BT)
appuifw.app.body = Log_body
e32.ao_yield()
# -----------------------------------------------------------------------------
###### The menu list
Menu = [(u"Time info"),
(u"GSM info"),
(u"Ping Bluetooth"),
(u"Show Log")
]
###### Show the menu as a listbox, and callback to Choice
View = appuifw.Listbox(Menu,Choice)
###### Set the inital body
appuifw.app.screen = 'normal'
appuifw.app.title = u'BlueTooth'
appuifw.app.body = View
app_lock = e32.Ao_lock()
appuifw.app.exit_key_handler = exit_key_handler
app_lock.wait()

Download:

open_guiBT3-1.py

Output:

The following screenshots are the outcome. Just click on the icons to enlarge them for a better view.

Output

Department of Electronic Systems | Aalborg University | Niels Jernes Vej 12 | DK-9220 Aalborg | Denmark
Phone: (+45) 9635 8695 | Fax (+45) 9815 1583 | E-mail ies(at)ies.aau.dk
Copyright © 2006 Department of Electronic Systems

Last update:20-10-2006