473,728 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

bluetooth discover

1 New Member
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 2554
Curtis Rutland
3,256 Recognized Expert Specialist
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
2279
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 not the expensive SDK from WIDCOMM to use the bluetooth programming interfaces. But, as I know most pocket PCs with integrated bluetooth chips use the WIDCOMM bluetooth stack. So my questions are as follows: 1) Is it possible to...
3
8042
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
5891
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 transfer files from a symbian phone to a pc, but nothing about sending them in the oposite direction. would anybody point me to some resources on the topic?
2
5430
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 dongle, ive tried a another dongle with widicom software as I was having problems with the IVT bluesoleil software. that seems to have got rid of some other problems,
6
8509
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 bluetooth device and how to send files to the pc in vb.net? i would really really appreciate your help!!
1
2435
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 where it runs the bluetooth application as a hidden program to send the audio file. It is where when i click the button send, it will operate the file transfer wizard in the bluetooth application and when i click the bluetooth button it should operate...
1
6088
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 barcode scanner. After a lot of searching the Internet, I have come to the conclusion that something using RFCOMM would be best. Unfortunately, Bluetooth programming books are not exactly plentiful and finding a book on RFCOMM is almost...
2
7924
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 app both side mobile and pc are able to discover the devices but when i start sending data from pc to mobile a exception will be caught. if intelbth.dll is needed then where can i find it please provide me some link..
1
2276
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 micrososft will support only a few dongles, mine is broadcom bcm2045a, but is there any alternative than this i came to know that we can use serial communication, but i have a doubt that by using serial com can we able to discover the devices and also...
0
8891
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9409
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9263
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9188
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9121
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8110
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4787
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2642
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2159
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.