Create PC Bluetooth application easily with pybluez

October 23rd, 2007 Posted in Open Source, PDA, PocketPC, Tips, Tricks, Guide

pybluez is a python bindings for the bluez application which enables you to interface with bluetooth devices on your computer.

Combined with the power of python dynamic typing, you will be able to do Rapid Application Development and test mobile bluetooth application quickly on your computer

Here's a snippets which combines pyosd and pybluez which scans for nearby bluetooth devices and display the result on screen :

PYTHON:
  1. import bluetooth
  2. import pyosd
  3. from time import sleep
  4.  
  5. p = pyosd.osd()
  6.  
  7. p.set_pos(pyosd.POS_MID)
  8. p.set_align(pyosd.ALIGN_CENTER)
  9. p.set_colour("green")
  10.  
  11. p.display( "Scanning for bluetooth device")
  12.  
  13. nearby_devices = bluetooth.discover_devices(duration=20, lookup_names = True)
  14.  
  15. str= "found %d devices" % len(nearby_devices)
  16. print str
  17. p.display(str)
  18. sleep(2)
  19.  
  20. for name, addr in nearby_devices:
  21.    p.display( "  %s - %s" % (addr, name))
  22.    print (" %s - %s" % (addr,name))
  23.    sleep(2)

Python enables Rapid Application Development on your computer without much fuss. Coupled with pygtk and wxPython acting as GUI, you can create a lot of bluetooth application to interface with your mobile devices, limited only by your imagination.

[tags]python,pybluez,bluetooth,gtk,gnome,linux,mobile,pda,programming,development,RAD[/tags]

 

Random Posts

One Response to “Create PC Bluetooth application easily with pybluez”

  1. Luigi Fulk Says:

    Thankkkk you!



Leave a Reply