example.bluetooth.demo
Class BTImageClient

java.lang.Object
  extended by example.bluetooth.demo.BTImageClient
All Implemented Interfaces:
java.lang.Runnable, javax.bluetooth.DiscoveryListener

final class BTImageClient
extends java.lang.Object
implements java.lang.Runnable, javax.bluetooth.DiscoveryListener

Initialize BT device, search for BT services, presents them to user and picks his/her choice, finally download the choosen image and present it to user.


Field Summary
 
Fields inherited from interface javax.bluetooth.DiscoveryListener
INQUIRY_COMPLETED, INQUIRY_ERROR, INQUIRY_TERMINATED, SERVICE_SEARCH_COMPLETED, SERVICE_SEARCH_DEVICE_NOT_REACHABLE, SERVICE_SEARCH_ERROR, SERVICE_SEARCH_NO_RECORDS, SERVICE_SEARCH_TERMINATED
 
Constructor Summary
BTImageClient(GUIImageClient parent)
          Constructs the bluetooth server, but it is initialized in the different thread to "avoid dead lock".
 
Method Summary
(package private)  void cancelLoad()
          Cancel's the image download.
(package private)  void cancelSearch()
          Cancel's the devices/services search.
(package private)  void destroy()
          Destroy a work with bluetooth - exits the accepting thread and close notifier.
 void deviceDiscovered(javax.bluetooth.RemoteDevice btDevice, javax.bluetooth.DeviceClass cod)
          Invoked by system when a new remote device is found - remember the found device.
 void inquiryCompleted(int discType)
          Invoked by system when device discovery is done.
(package private)  void requestLoad(java.lang.String name)
          Sets the request to load the specified image.
(package private)  void requestSearch()
          Sets the request to search the devices/services.
 void run()
          Process the search/download requests.
 void servicesDiscovered(int transID, javax.bluetooth.ServiceRecord[] servRecord)
           
 void serviceSearchCompleted(int transID, int respCode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BTImageClient

BTImageClient(GUIImageClient parent)
Constructs the bluetooth server, but it is initialized in the different thread to "avoid dead lock".

Method Detail

run

public void run()
Process the search/download requests.

Specified by:
run in interface java.lang.Runnable

deviceDiscovered

public void deviceDiscovered(javax.bluetooth.RemoteDevice btDevice,
                             javax.bluetooth.DeviceClass cod)
Invoked by system when a new remote device is found - remember the found device.

Specified by:
deviceDiscovered in interface javax.bluetooth.DiscoveryListener

inquiryCompleted

public void inquiryCompleted(int discType)
Invoked by system when device discovery is done.

Use a trick here - just remember the discType and process its evaluation in another thread.

Specified by:
inquiryCompleted in interface javax.bluetooth.DiscoveryListener

servicesDiscovered

public void servicesDiscovered(int transID,
                               javax.bluetooth.ServiceRecord[] servRecord)
Specified by:
servicesDiscovered in interface javax.bluetooth.DiscoveryListener

serviceSearchCompleted

public void serviceSearchCompleted(int transID,
                                   int respCode)
Specified by:
serviceSearchCompleted in interface javax.bluetooth.DiscoveryListener

requestSearch

void requestSearch()
Sets the request to search the devices/services.


cancelSearch

void cancelSearch()
Cancel's the devices/services search.


requestLoad

void requestLoad(java.lang.String name)
Sets the request to load the specified image.


cancelLoad

void cancelLoad()
Cancel's the image download.


destroy

void destroy()
Destroy a work with bluetooth - exits the accepting thread and close notifier.