Design

The BCExchanger MIDlet allows you to exchange business cards over Bluetooth using the OBEX API.

The following figure shows the main BCExchanger process flow: When the MIDlet is started for the first time, the user selects his or her own business card and proceeds to the main menu. If the card has already been selected during previous runs, the MIDlet starts directly from the main menu. From the main menu, the user can select another card, initiate a card exchange, accept a card exchange, or exit the MIDlet.

Figure: BCExchanger process

When the user initiates the card exchange from the main menu, the MIDlet starts a series of Bluetooth procedures: inquiry, service discovery, sending own card, and receiving and saving the remote business card. If several Bluetooth services declared by the BCExchanger MIDlet are discovered, the MIDlet displays the list of found services and asks the user to select one. Each procedure can be canceled or can end in an error, in which case the execution of the card exchange process ends and the MIDlet returns to the main menu.

Figure: BCExchanger card exchange initiation process

When another user has initiated a card exchange process with you, the MIDlet acts as an accepting peer. It simply receives the card, saves it, and sends your card. Each procedure can be canceled or can end in an error. The user who initiated the exchange operation receives a notification on whether the exchange operation proceeds successfully or fails.

Figure: BCExchanger card exchange acceptance process

The BCExchanger architecture can be divided into the following elements:

  • MIDlet—The central architecture element, which represents the application execution and owns and manages the other architecture components.

  • UI module—The element responsible for the user interface. It contains classes implementing various MIDlet screens and screen transitions.

  • Comm module—The element responsible for communication, that is, all operations related to Bluetooth OBEX.

  • Address Book module—The element providing access to the phone book of the device.

  • Storage module—The element responsible for saving information about the card chosen as the own card.

The UI and Comm modules are the most complicated part of the MIDlet, and contain the classes that implement a state machine. The design pattern state has been used to implement both the UI and Comm modules (see Design Patterns: Elements of Reusable Object-Oriented Software by Gamma et al., Addison-Wesley, 1995).

For instructions on how to implement the MIDlet, see section Implementation.