Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Developing Bluetooth Mobile Applications (Mobile Module)

LabVIEW 8.6 Mobile Module Help
June 2008

NI Part Number:
372508A-01

»View Product Info

The Mobile Module supports Bluetooth communication on Mobile devices running Pocket PC 2003 or Windows Mobile 5.0 with the WIDCOMM Bluetooth DLLs version 1.4 or later or the Microsoft Bluetooth driver. Bluetooth communication has low-power consumption with a range of about 30 feet (approximately 10 meters) and is designed for battery-operated devices. Bluetooth is supported for the following:

  • (Windows XP on Host Computer) LabVIEW supports Bluetooth devices that use the Microsoft Bluetooth driver on Windows XP Service Pack 1 or later only. Refer to the Microsoft Web site for Bluetooth devices that use the Microsoft Bluetooth driver. Most devices use a proprietary Bluetooth driver by default. You must switch to the Microsoft Bluetooth driver to use it with a Mobile application you build with the Mobile Module. (Windows XP SP 1) Obtain the Microsoft Bluetooth driver from the Bluetooth device manufacturer. (Windows XP SP 2) The Microsoft Bluetooth driver is included in Windows XP.
  • (Pocket PC) The Mobile Module supports Pocket PC devices using WIDCOMM BTW-CE 1.4 or later or the Microsoft Bluetooth driver. You must install the WIDCOMM Bluetooth DLLs on the Mobile device.
Note  Do not install the WIDCOMM Bluetooth DLLs if you have the Microsoft Bluetooth driver or you receive an error when you use the Bluetooth VIs and functions. If your device uses the Broadcom Bluetooth driver, install the LabVIEW WIDCOMM Bluetooth driver by manually copying LVBtw.dll from the labview\PDA\Utilities\Bluetooth directory to the Windows directory. Do not run Setup.exe and do not copy BtCoreIf.dll and BtSdkCE30.dll if they already exist on the device.

Creating a Bluetooth Mobile application involves creating a Bluetooth server application and creating a Bluetooth client application. Creating Bluetooth server and client applications in LabVIEW is similar to creating TCP server and client applications. A Bluetooth server application can use the Service Discovery Protocol (SDP) to broadcast the availability of services and listen for inbound connections. A client application creates an outbound RFCOMM connection to a server application. After the client and server connect to each other, they exchange data until the client or server terminates the connection or the connection is lost.

Note  The Bluetooth protocol does not have inherent security, although many devices include settings that require clients to log in before accessing Bluetooth services.

Creating a Bluetooth Server Application

A typical Bluetooth server application involves the following:

  1. Creating a service.
  2. Waiting for an incoming connection.
  3. Exchanging data with the client application.
  4. Closing the connection.

1. Creating a Service

Use the Bluetooth Create Listener function to create a service for a Bluetooth server. This function returns a listener ID refnum, which you use to refer to the Bluetooth server in the Mobile application, and a channel, which you use to listen for inbound connections. A Bluetooth channel is a global resource with only 30 channels available on any Bluetooth device. You receive an error if there are no available server channels.

2. Waiting for an Incoming Connection

Use the Bluetooth Wait On Listener function to wait for an incoming request from a client.

3. Exchanging Data with the Client Application

Use the Bluetooth Read function and the Bluetooth Write function to exchange data with the client. You can specify the behavior, or mode, of the read operation.

4. Closing the Connection

Use the Bluetooth Close Connection function to stop listening for incoming connections and close the connection to the client.

Creating a Bluetooth Client Application

A typical Bluetooth client application involves the following:

  1. Opening a connection to the server application.
  2. Exchanging data with the server application.
  3. Closing the connection.

1. Opening a Connection to the Server Application

Use the Bluetooth Open Connection function to connect to a Bluetooth server application. You can identify the Bluetooth server by channel or unique identifier. Set the channel input to 0 to use the Bluetooth unique identifier, which is the uuid input, to identify the service you want to connect to.

2. Exchanging Data with the Server Application

Use the Bluetooth Read function and the Bluetooth Write function to exchange data with the server. You can specify the behavior, or mode, of the read operation.

3. Closing the Connection

Use the Bluetooth Close Connection function to close the connection to the server.


Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit