Home arrow Python arrow Page 2 - Bluetooth Programming using Python

Bluetooth and Python: the Whys and Wherefores - Python

Bluetooth is a way to connect devices wirelessly. This technology has a variety of uses. Python is an easy to learn scripting language that has been growing in popularity. The two can work well together, as will be explained in this article.

TABLE OF CONTENTS:
  1. Bluetooth Programming using Python
  2. Bluetooth and Python: the Whys and Wherefores
  3. Bluetooth Programming, Step by Step
  4. Bluetooth Programming in the Real World
By: A.P.Rajshekhar
Rating: starstarstarstarstar / 16
September 10, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

According to its definition, Bluetooth is "a radio standard and communications protocol primarily designed for low power consumption, with a short range (power-class-dependent: 1 meter, 10 meters, 100 m) based on low-cost transceiver microchips in each device." In other words, Bluetooth is a standard and protocol that uses short-range frequencies to create a wireless connection between two compatible (Bluetooth enabled) devices. Since a radio communication system is used, there is no "line of sight" problem that is common with infrared-based devices. As long as the devices are in range, they can communicate with each other even if one device is in one room and the other device is in a separate room. Bluetooth-enabled devices are categorized into three classes, which are:

  1. Class 1
  2. Class 2
  3. Class 3

The classification is based on the range in which the devices can communicate. The ordering is from the longest range to the shortest one.

Class 1 devices have the longest range. The range is up to 100 meters, approximately. Devices of this class consume the highest amount of power of all three classes. They consume 100 mW of power.

Class 2 devices can be considered medium range. The range in which they can communicate is up to 10 meters. With respect to power consumption, they require 2.5 mW.

Class 3 devices cannot communicate beyond one meter. The power requirement also is the least for devices of this class. They require only 1 mW.

If you observe closely the power requirement decreases with the decrease in communication range. That was a bird's eye view of Bluetooth. Next we will look at how a device provides services to other devices using Bluetooth. Each device provides certain services based on a specification known as the Wireless Interface Specification. A set of such services forms a profile. Sometimes the profile contains only one service, such as streaming of sound from an audio file, or it can contain a set of different services such as capturing a live video and streaming it. There are 27 standard profiles that are currently used by different devices. Some of the common profiles are:

  1. Basic Imaging Profile - for sending, receiving and resizing images.
  2. Basic Printing Profile - for using certain vCards, text, e-mail etc. to send to the printer from the device.
  3. File Transfer Profile - for accessing the file system of another device.
  4. Headset Profile - provides support for Bluetooth headsets to work with Bluetooth-enabled mobile phones for wireless audio; one of the most common profiles.
  5. Serial Port Profile - emulates serial cable connectivity and communication. It uses RFCOMM protocol.

Writing a program for a Bluetooth device, in reality, means programming for the profiles or accessing the functionalities of the profile. For programming, the BlueZ library is commonly used. It provides access to the Bluetooth stack in an object-oriented and modular manner. The Python wrapper for the BlueZ is PyBlueZ.

The wrapper targets the Microsoft Bluetooth stack on Windows and BlueZ stack on GNU/Linux. Using PyBlueZ, one can easily create a connection between traditional systems such as laptops, desktops and mobile devices and program the basic profiles such as File Transfer, network communication, and so forth. Now that the library that supports programming for Bluetooth has been introduced, we can look at the steps required to program Bluetooth devices using Python.



 
 
>>> More Python Articles          >>> More By A.P.Rajshekhar
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PYTHON ARTICLES

- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: