You Are Here:

Community: Developer Discussion Boards

#1 Old Bluetooth connection - 2007-02-09, 17:11

Join Date: Feb 2007
Posts: 10
jon83
Offline
Registered User
hi guys,
I have some problem with my program; I want to find all the BT devices and print for each of them the name, the mac address and other things.
I want also to create a menu with 3 buttons:
start - start searching the devices
stop - stop searching the devices
exit - exit to the program

I tried to use a while(): but it doesn't work because I cannot stop the search.
I have also some problems with how to free the cache because even if I turn off one device it is coming in the list of the active devices.

Someone has some ideas?

this is my code:

Code:
import aosocketnativenew
import appuifw
import e32
import socket
import location
from aosocket.symbian.bt_device_discoverer import *
from time import *
from pdis.lib.logging import *

path = "c:\\BT_scan1.txt"
BT = open(path,'w')
BT.write("")
BT.close()
	
  
def callback(error, devices, cb_param=None):	   	 
    	global name,address	
    	for address, name in devices:
		tim=strftime("%d %b %Y %H:%M:%S", localtime())
		tim=unicode(tim)
		loc1,loc2,loc3,loc4 = location.gsm_location()
        	l= str(loc1)+" "+str(loc2)+" "+str(loc3)+" "+str(loc4)
    		text1 =  '\n'  +" Location: " + l + '\n'
		print "Found: ", name, address, l, tim
		text = '\n'  +  " Name:  "  + name  + '\n'  +  " Address: "  +  address 
		text2 = " Date: " +  tim[0:11] +  '\n' + " Time: " +  tim[12:] + '\n' + '\n' 
		BT = open(path,'a') 
		BT.write(text + text1 + text2)
		BT.close()


def start():
	global a
	a = [1, 2, 3, 4, 5]
	print "discovering......"
	#for x in a:
	lister = BtDeviceLister() 
	lister.discover_all(callback, None)
		#e32.ao_sleep(4)
		
def stop():
        print "stop"
        #.........
	
def show():
	a = open(path,'r+')
	print a.read()
	a.close()


def exit_key_handler():	
    	app_lock.signal()
    	appuifw.app.set_exit()

appuifw.app.menu = [(u"START", start),(u"SHOW LOG", show),(u"EXIT", exit_key_handler)]
appuifw.app.exit_key_handler=exit_key_handler
app_lock=e32.Ao_lock()
app_lock.wait()
Reply With Quote

#2 Old Re: Bluetooth connection - 2007-02-12, 11:38

Join Date: Feb 2007
Posts: 10
jon83
Offline
Registered User
Hi guys,
I've found a function for cancel the cache and discover fresh bluetooth

bluetooth.discover_devices(lookup_names = True, flush_cache = True, duration = 20)

it's just necessary put flush_cache = True , now the problem is that this function need import bluetooth, but I don't have this module. in the web I found bluetooth.py and I copy it in the resource folder but doesn't work.
what I can do?
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Send SMS using a Bluetooth connection???? ankitshrivastav General Messaging 4 2006-10-11 16:52
Internet connection over Bluetooth (6600<->PC) cbruegg Bluetooth Technology 0 2003-11-12 20:28
Ipaq 5450 and Nokia 8910/i bluetooth connection ferceska Bluetooth Technology 0 2003-07-07 15:23
Connection Manager does not with 6310i over bluetooth with ACER USB Stick BT 500 haumi General Discussion 0 2003-07-06 12:58
GPRS Connection from Laptop over Bluetooth ChicMac Bluetooth Technology 1 2003-05-19 19:22

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d81449X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ