Skip Headers
Oracle® Java Micro Edition Software Development Kit Developer's Guide
Release 3.4 for NetBeans on Windows
E24265-06
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

17 JSR 82: Bluetooth and OBEX Support

This chapter describes how the Oracle Java ME SDK implements the Bluetooth and OBEX APIs.

The Oracle Java ME SDK emulator supports JSR 82, the Java APIs for Bluetooth. The emulator is fully compliant with version 1.1 of the specification, which describes integration with the push registry. JSR 82 includes two independent APIs:

17.1 Setting OBEX and Bluetooth Properties

The Oracle Java ME SDK enables you to configure the Bluetooth and OBEX simulation environment. Because the simulation requires a sender and receiver, Bluetooth settings are configured separately for each device. Follow these steps to set device properties:

  1. In the device selector, right-click a CLDC device and select Properties.

    The device properties are displayed in the Properties window. If you do not see this window, click the Window menu and select Properties from the NetBeans Toolbar.

  2. Scroll down to see the Bluetooth and OBEX properties. When you click a property a description is shown in the description area. If you can not see this area, right click a property and select Show Description Area.

The System Properties can be retrieved in an application using the getProperty() method in javax.bluetooth.LocalDevice. The Bluetooth properties are fully described in the JSR 82 specification.

17.2 Running the Bluetooth Demo

This application contains MIDlets that demonstrate the use of JSR 82's Bluetooth API. It shows how images can be transferred between devices using Bluetooth.

You must run two emulator instances to see this process, and each device must have a different phone number.

  1. Use JavaMEPhone1 to launch Bluetooth Demo, then launch Bluetooth Demo on JavaMEPhone2.

  2. The demo gives you a choice of Server or Client.

  3. On the first emulator, highlight Server and use the right softbutton to select OK.

    The server starts and displays a list of images. At the beginning, none of the images are available on the Bluetooth network.

    Select the image you want to make available.

    Press Publish image (the right soft button). The icon color changes from purple to green, indicating it is published.

  4. On the second emulator running the Bluetooth Demo, highlight Client and click OK. The MIDlet displays "Ready for images search." Click the Find soft button. The MIDlet finds the other emulator and gets a list of published images. Select one from the list and select Load.

    • If you are running the demonstration in a trusted protection domain, the image is transferred using simulated Bluetooth and is shown on the client emulator.

    • If you are not running in a trusted protection domain, the first emulator (the server) displays a prompt asking if you want to authorize the connection from the client. Select Yes. The image is displayed in the client emulator.

17.3 Running the OBEX Demo

This application shows how to transfer image files between emulator instances using the OBEX API. This demonstration shows the use of OBEX over a simulated infrared connection.

  1. Launch two instances of the emulator. One listens for incoming connections, while the other attempts to send an image.

    For example, right-click ObexDemo, select Run With... and select the device JavaMEPhone1. Repeat and select JavaMEPhone2.

  2. In the first emulator, select Receive Image. (Depending on your security level, the application warns that an OBEX connection allows other devices to talk to yours and asks, "Is it OK to make the connection?" Select Yes.) Click Start to run the application. The listener emulator displays a screen reading "Waiting for connection."

  3. In the second emulator (the sender), select Send Image and press the Start soft key. Select an image from the list and select Send. (Depending on your security level, the application warns that the demo wants to make an outgoing client connection, and asks if it is OK. Select Yes.) The Send Image utility uploads the image.

  4. In the listening emulator, the utility displays information about the incoming image and asks "Would you like to receive it?" Select Yes.

    The image you selected is transferred over the simulated infrared link and displayed on the first emulator.