org.bluemelon.bluesense
Class RouterDevice

java.lang.Object
  extended by org.bluemelon.bluesense.Device
      extended by org.bluemelon.bluesense.RouterDevice

public class RouterDevice
extends Device

Interface to the wireless router device BM7502. BlueSense routers acts as a portal between the PC and the BlueSense network. Some BlueSense routers are wireless. You can use the get and set channel methods to set the communcation channel BlueSense routers have a serial port which can be used for standard rs232 communication. Use the supplied metohods to set serial connection options.


Field Summary
static int MAX_CHANNEL
           
static int PROXY_ID
           
static java.lang.String PROXY_TITLE
           
static int[] SUPPORTS
           
 
Constructor Summary
RouterDevice(Master master, int deviceId)
          Creates a 'software' adcinput device with a given id.
 
Method Summary
 int bsRouterDevice_getSerialWriteBufferPendingData()
           
 int bsRouterDevice_writeSerialData(int[] data)
          Writes serial data into the writebuffer which will be copied to the serial extension board.
 boolean configPending()
          Checks if a configuration is being currently being set or being retrieved
 int getCurrentChannel()
          Obtain the last retrieved wireless channel settings.
 int getCurrentSerialBaudRate()
           
 int getCurrentSerialDataBits()
           
 int getCurrentSerialParity()
           
 int getCurrentSerialStopBits()
           
 boolean getRequestGetConfigDone()
          Checks if the configuration request is finished
 boolean getRequestSetConfigDone()
          Checks if the configuration set request is finished
 boolean getSerialReceiveAsciiMode()
          Returns the serial receive mode.
 long getTimeOutUs()
          Returns the current set time out delay.
 int popReceivedSerialData(int[] receiveArray)
          Retrieves received buffered data from the serial extension board.
 void requestGetConfiguration()
          Request to obtain the configuration settings from a adcInput Device.
 void requestSetChannel(int channel)
          Request the router device to set a new wireless channel
 void requestSetSerialConfiguration(int baudrate, int stopbits, int parity, int databits)
          Sets the configuration parameters for the serial extension board.
 void setSerialBufferSizes(int receiveSize, int writeSize)
          Sets buffer sizes to be used for receiving and writing data from/to the serial extension board
 void setSerialReceiveAsciiMode(boolean asciiMode)
          Set serial receive mode.
 void setTimeOutUs(int timeOutUs)
          Sets the time out value which is used to check if a request was acknowledged in the set time.
 
Methods inherited from class org.bluemelon.bluesense.Device
addDeviceEventListener, detect, getFirmwareVersion, getId, getType, getTypeName, isAccessible, removeDeviceEventListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROXY_TITLE

public static final java.lang.String PROXY_TITLE

PROXY_ID

public static final int PROXY_ID

SUPPORTS

public static final int[] SUPPORTS

MAX_CHANNEL

public static final int MAX_CHANNEL
Constructor Detail

RouterDevice

public RouterDevice(Master master,
                    int deviceId)
Creates a 'software' adcinput device with a given id. The device will inacessible until a physical device with the same id is detected.

Parameters:
master -
deviceId -
Method Detail

getCurrentChannel

public int getCurrentChannel()
Obtain the last retrieved wireless channel settings.

Returns:
the last retrieved channel settings

configPending

public boolean configPending()
Checks if a configuration is being currently being set or being retrieved

Returns:
1 if busy, 0 if done

getRequestGetConfigDone

public boolean getRequestGetConfigDone()
Checks if the configuration request is finished

Returns:
1 if configuration was retrieved, 0 if still busy

getRequestSetConfigDone

public boolean getRequestSetConfigDone()
Checks if the configuration set request is finished

Returns:
1 if request finished, 0 if request still busy

requestGetConfiguration

public void requestGetConfiguration()
Request to obtain the configuration settings from a adcInput Device.


requestSetChannel

public void requestSetChannel(int channel)
Request the router device to set a new wireless channel

Parameters:
channel - the new channel, should lie between 0 and BLUESENSE_WRTR_MAX_CHANNEL. @see BLUESENSE_WRTR_MAX_CHANNEL

requestSetSerialConfiguration

public void requestSetSerialConfiguration(int baudrate,
                                          int stopbits,
                                          int parity,
                                          int databits)
Sets the configuration parameters for the serial extension board. Note that not all options are available on all devices.

Parameters:
baudrate - the speed of serial communication default is 38400
stopbits - number of stopbits, choose 2 or 1
parity - parity bits: 4 = even, 3 = odd, 2 = mark, 1 = space, 0 = none
databits - number of databits: 5,6,7 or 8

getCurrentSerialBaudRate

public int getCurrentSerialBaudRate()
Returns:
Returns the configured baudrate for serial communication (when using the serial extension board)

getCurrentSerialDataBits

public int getCurrentSerialDataBits()
Returns:
Returns the configured number of databits for serial communication (when using the serial extension board)

getCurrentSerialStopBits

public int getCurrentSerialStopBits()
Returns:
the configured number of stopbits for serial communication (when using the serial extenstion board)

getCurrentSerialParity

public int getCurrentSerialParity()
Returns:
the configured parity mode 4 = even, 3 = odd, 2 = mark, 1 = space, 0 = none, for serial communication (when using the serial extension board).

setSerialBufferSizes

public void setSerialBufferSizes(int receiveSize,
                                 int writeSize)
Sets buffer sizes to be used for receiving and writing data from/to the serial extension board


popReceivedSerialData

public int popReceivedSerialData(int[] receiveArray)
Retrieves received buffered data from the serial extension board. Data is received into a receive buffer in each bsmaster yield call. If serial communication is in ascii mode the data will be returned delimited by ascii code 13, otherwise all pending data is returned.

Parameters:
receiveArray - an array which will be filled with the received data
Returns:
the number of received bytes

bsRouterDevice_writeSerialData

public int bsRouterDevice_writeSerialData(int[] data)
Writes serial data into the writebuffer which will be copied to the serial extension board. Data is written at each bsmaster yield call.

Parameters:
data - an array of data bytes (values between 0-255).
Returns:
number of bytes actually written.

bsRouterDevice_getSerialWriteBufferPendingData

public int bsRouterDevice_getSerialWriteBufferPendingData()

setSerialReceiveAsciiMode

public void setSerialReceiveAsciiMode(boolean asciiMode)
Set serial receive mode. When set to '1' data will be received line oriented (delimited by character 13). When set to '0' no interpretation is done of the data.

Parameters:
asciiMode - true to set line oriented mode, false for no interpretation.

getSerialReceiveAsciiMode

public boolean getSerialReceiveAsciiMode()
Returns the serial receive mode. true depicts line oriented ASCII mode, false binary mode.


getTimeOutUs

public long getTimeOutUs()
Returns the current set time out delay. The time out delay is used to check if a request was acknowledged in the set time. If an answer to a request is not received within the set time, the request is resent.

Returns:
the time out value in microseconds.

setTimeOutUs

public void setTimeOutUs(int timeOutUs)
Sets the time out value which is used to check if a request was acknowledged in the set time. If an answer to a request is not received within the set time, the request is resent.

Parameters:
timeOutUs - the value in microseconds which is the maximum duraion between a request and its answer.