473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

bluetooth discover

Im doing project which connect a bluetooth module to development board. unfortunely, my python code couldn't discover bluetooth devices. Can anyone help me to check my code ? thx you


Expand|Select|Wrap|Line Numbers
  1. import socket,appuifw,e32
  2.  
  3.  
  4. def bt_socket_connect(target=''):
  5. address, services= socket.bt_discover()
  6.  
  7. if len(services) > 1:
  8. choices = services.keys()
  9. choices.port()
  10. choice = appuifw.popup_menu([unicode(services[x])+": "+x for x in choices], u'Choose port:')
  11. target = (address, services[choices[choice]])
  12. else:
  13. target = (address, services.values()[0])
  14. sock = socket.socket(socket.AF_BT,socket.SOCK_STREAM)
  15. sock.connect(target)
  16. return sock
  17.  
  18. def recieve():
  19.     global sock
  20.     data=sock.recv(1)
  21.     if data=="1":
  22.         appuifw.note(u"LED on","info")
  23.     elif data=="0":
  24.     appuifw.note(u"LED off","info")
  25.  
  26. def recieve():
  27.     global sock
  28.     data=sock.recv(2)
  29.     if data=="1":
  30.         appuifw.note(u"Light on","info")
  31.     elif data=="0":
  32.     appuifw.note(u"Light off","info")
  33.  
  34.  
  35. def bt_send_data1():
  36.     global sock
  37.     sock.send("1")
  38.     receive()
  39.  
  40. def bt_send_data2():
  41.     global sock
  42.     sock.send("0")
  43.     receive()
  44.  
  45. def bt_send_data3():
  46.     global sock
  47.     sock.send("1")
  48.     receive()
  49.  
  50. def bt_send_data4():
  51.     global sock
  52.     sock.send("0")
  53.     receive()
  54.  
  55.  
  56. def exit_key_handler():
  57.     print"socket closed"
  58.     sock.close()
  59.     app_lock.signal()
  60.  
  61. app_lock=e32.Ao_lock()
  62.  
  63.  
  64. devices = [u"LED", u"Light"]  
  65. index = appuifw.selection_list(devices, 0)
  66.  
  67.  
  68. appuifw.app.exit_key_handler=exit_key_handler
  69. app_lock.wait()
Nov 24 '08 #1
1 2542
Curtis Rutland
3,256 Expert 2GB
Please enclose your posted code in [CODE] [/CODE] tags (See How to Ask a Question). Code tags preserve indention and uses a monospaced font.

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [CODE] [/CODE] tags in future.

MODERATOR
Nov 25 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Thomas_Germany | last post by:
I would like to develop a smart device bluetooth application for pocket PC 2003. As I know, Pocket PC 2003 includes the microsoft bluetooth stack. My intention is to use the SDK from mircrosoft and...
3
by: Tor Erik Sønvisen | last post by:
Hi I'm making a server-side solution in Python and need to be able to communicate through bluetooth. Is there any bluetooth-packages out there for python? regards tores
9
by: Drex | last post by:
Hi, I have been looking on the internet for some info about sending files from PC to a mobile phone (I have a nokia 6288) but I was not able to find anything. there is a lot of info how to...
2
by: colin | last post by:
Hi, Im having a tiresome amount of trouble with using a bluetooth serial link. The receiving end is a bluetooth-rs232 module conected to my embeded system. The PC has a little usb bluetooth...
6
by: jabslim | last post by:
excuse me, im a newbie programmer and i need a code on how to to be able to send files from a mobile phone to a pc through bluetooth in vb.net can anyone post a code here on how to detect a...
1
by: gringgos | last post by:
hi, friends... Currently i am doing a project based on bluetooth and Visual Basic 6.0. But i am unable to find any solution regarding bluetooth. But my supervisor gave her idea about do a code...
1
by: Z.K. | last post by:
I know this is probably not the correct newsgroup, but I can't find anywhere else that is appropriate to post it in. I need to figure out how to write a bluetooth program to access a bluetooth...
2
by: lakshmiRam | last post by:
hi iam doing an project where i need to send data in and out between pc and mobile using bluetooth and i red some where that we need intelbth.dll in system for this communication is it true. coz my...
1
by: lakshmiRam | last post by:
hi i have a bluetooth dongle and a program to serach all the devices using bluetooth, but the problem is findFirstDevice() function always returns null so it fails in searching but, i know that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.