com.esf.device.bluetooth.serialportprofile.service
Interface IBluetoothSerialPortProfile


public interface IBluetoothSerialPortProfile

ESF bluetooth serial port profile agent interface. This interface is used to control the SPP agent.

Use the IBluetoothSppFactory.getSerialPortProfileAgent method to obtain a reference to a new SPP agent interface.


Method Summary
 boolean isConnected()
          Reports whether the ESF serial port profile agent is currently connected to a bluetooth device.
 void setCacheUrl(boolean cacheUrl)
          Instructs the serial port profile agent whether to re-scan for bluetooth devices when a connection is needed.
 void setConnectionRetrySeconds(int seconds)
          Sets the pause interval after a connection attempt fails.
 void setDeviceIdentifier(java.lang.String deviceIdentifier)
          Sets the identification string to be used for device scan matching.
 void setListener(IBluetoothSppListener listener)
          Sets the callback event handler for receiving notifications from the ESF serial port profile agent.
 void setPinCode(java.lang.String pinCode)
          Sets the Bluetooth pin code required by a bluetooth device.
 boolean startAgent()
          Instructs the ESF serial port profile agent to start the worker thread.
 void stopAgent()
          Instructs the ESF serial port profile agent to stop the worker thread.
 void writeBytes(byte[] data)
          If the serial port profile agent is connected to a bluetooth device, then this method will write an array of bytes to the Stream to the device.
 

Method Detail

setDeviceIdentifier

void setDeviceIdentifier(java.lang.String deviceIdentifier)
Sets the identification string to be used for device scan matching. The identification string may match either the device friendly name or the device bluetooth address.

Note: This setter should be called prior to starting the agent (startAgent).

Parameters:
deviceIdentifier - device identifier string.

setConnectionRetrySeconds

void setConnectionRetrySeconds(int seconds)
Sets the pause interval after a connection attempt fails. The number of seconds to wait before trying a new connection attempt.

Note: This setter should be called prior to starting the agent (startAgent).

Parameters:
seconds - Number of seconds to delay between connection attempts.

setCacheUrl

void setCacheUrl(boolean cacheUrl)
Instructs the serial port profile agent whether to re-scan for bluetooth devices when a connection is needed.

If this parameter is true, then the agent will perform device discovery until a matching device is located. For subsequent connections, the agent will reuse the last known device URL.

If this parameter is false, then the agent will never cache a last known bluetooth device URL. If a connection is lost, then the agent will perform a new device scan.

An application would use false in case various physical devices may come within range. In that case, the agent will connect to any device within range. The application would use false for the case where only a single device will ever be within connection range. In that case, the URL should never change, and reconnection may be faster since a rescan is not performed.

Note: This setter should be called prior to starting the agent (startAgent).

Parameters:
cacheUrl - true to use the last known good device URL for subsequent connections.

setPinCode

void setPinCode(java.lang.String pinCode)
Sets the Bluetooth pin code required by a bluetooth device.

Note: This setter should be called prior to starting the agent (startAgent).

Parameters:
pinCode - device pin code.

setListener

void setListener(IBluetoothSppListener listener)
Sets the callback event handler for receiving notifications from the ESF serial port profile agent. The events include receiving of data from the device, and change in state of connection to the bluetooth device.

Note: This setter should be called prior to starting the agent (startAgent).

Parameters:
listener - reference to class instance that implements the IBluetoothSppListener interface.

startAgent

boolean startAgent()
Instructs the ESF serial port profile agent to start the worker thread. This worker thread will attempt to connect to a bluetooth device, and maintain that connection.

Returns:
true if the worker thread was successfully started.

stopAgent

void stopAgent()
Instructs the ESF serial port profile agent to stop the worker thread.


isConnected

boolean isConnected()
Reports whether the ESF serial port profile agent is currently connected to a bluetooth device.

Returns:
boolean, true if connected.

writeBytes

void writeBytes(byte[] data)
If the serial port profile agent is connected to a bluetooth device, then this method will write an array of bytes to the Stream to the device.

Parameters:
data - data buffer to write to the bluetooth device.