error bluetooth

L

Luca Sanna

the code is output the error of the ubuntu

from bluetooth import *

target_name = "My Phone"
target_address = None

nearby_devices = discover_devices()

for address in nearby_devices:
if target_name == lookup_name( address ):
target_address = address
break

if target_address is not None:
print "found target bluetooth device with address", target_address
else:
print "could not find target bluetooth device nearby"

the error

luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py
Traceback (most recent call last):
File "bluetooth.py", line 14, in <module>
from bluetooth import *
File "/home/luca/py-temperature/py-temperature/bluetooth.py", line 19, in <module>
nearby_devices = discover_devices()
NameError: name 'discover_devices' is not defined
luca@luca-XPS-M1330:~/py-temperature/py-temperature$

it's a bug of the module? thanks
 
U

Ulrich Eckhardt

Am 05.10.2012 10:51, schrieb Luca Sanna:
the code is output the error of the ubuntu

from bluetooth import *
[...]

nearby_devices = discover_devices()
[...]

the error

luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py
Traceback (most recent call last):
File "bluetooth.py", line 14, in <module>
from bluetooth import *
File "/home/luca/py-temperature/py-temperature/bluetooth.py", line 19, in <module>
nearby_devices = discover_devices()
NameError: name 'discover_devices' is not defined

The module "bluetooth" doesn't export any function called
discover_devices(). You could try "dir(bluetooth)" or "help(bluetooth)"
(do that from an interactive prompt) to find out what is in there. I
don't know why you expect such a function there, if it is mentioned in
the documentation or example code that would be a bug.

Uli
 
D

Dave Angel

the code is output the error of the ubuntu

from bluetooth import *

target_name = "My Phone"
target_address = None

nearby_devices = discover_devices()

for address in nearby_devices:
if target_name == lookup_name( address ):
target_address = address
break

if target_address is not None:
print "found target bluetooth device with address", target_address
else:
print "could not find target bluetooth device nearby"

the error

luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py
Traceback (most recent call last):
File "bluetooth.py", line 14, in <module>
from bluetooth import *
File "/home/luca/py-temperature/py-temperature/bluetooth.py", line 19, in <module>
nearby_devices = discover_devices()
NameError: name 'discover_devices' is not defined
luca@luca-XPS-M1330:~/py-temperature/py-temperature$

it's a bug of the module? thanks

Perhaps you named your script bluetooth.py, and thus masked the module
bluetooth.py. Pick a different name for your own sources.
 
H

Hans Mulder

from bluetooth import *
[......]

luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py

When you say "from bluetooth import *", Python will find a file
name "bluetooth.py" and import stuff from that file. Since your
script happens to be named "bluetooth.py", Python will import
your script, thinking it is a module.
it's a bug of the module?

You've chosen the wrong file name. Rename your script.


Hope this helps,

-- HansM
 
L

Luca Sanna

Il giorno venerdì 5 ottobre 2012 13:33:14 UTC+2, Hans Mulder ha scritto:
from bluetooth import *


[......]



luca@luca-XPS-M1330:~/py-temperature/py-temperature$ python bluetooth.py



When you say "from bluetooth import *", Python will find a file

name "bluetooth.py" and import stuff from that file. Since your

script happens to be named "bluetooth.py", Python will import

your script, thinking it is a module.


it's a bug of the module?



You've chosen the wrong file name. Rename your script.





Hope this helps,



-- HansM



i'm sorry, it's ok the rename file in bt.py

how do I send a ping in bluetooth?
because android phones are not always visible.
I can not find the ping command
thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,149
Members
46,695
Latest member
StanleyDri

Latest Threads

Top