Sun SPOT API
Green Release  


com.sun.spot.io.j2me.radio
Class RadioInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.sun.spot.io.j2me.radio.RadioInputStream

public class RadioInputStream
extends InputStream

Helper class for "radio:" connections. This class provides an InputStream over the data received from another Spot. It also provides a small set of accessors to get information about the quality of the link. You should NOT normally instantiate this class directly, but rather via the GCF framework: see the first reference below for more details.

See Also:
RadioConnection

Constructor Summary
RadioInputStream(IPortBasedProtocolManager dispatcher, ConnectionID cid, long timeout)
          Construct a RadioInputStream
 
Method Summary
 int available()
          Return the number of bytes available to be read from the stream without blocking.
 void close()
          Closes this input stream and releases any system resources associated with the stream.
 int getCorr()
          CORR measures the average correlation value of the first 4 bytes of the packet header.
 int getLinkQuality()
          Link Quality Indication (LQI) is a characterization of the quality of a received packet.
 int getRssi()
          RSSI (received signal strength indicator) measures the strength (power) of the signal for the packet.
 int read()
          Reads the next byte of data from the input stream.
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RadioInputStream

public RadioInputStream(IPortBasedProtocolManager dispatcher,
                        ConnectionID cid,
                        long timeout)
Construct a RadioInputStream

Parameters:
dispatcher - the PortBasedProtocolManager that will dispatch radio packets
cid - the ConnectionID object being used
timeout - the timeout to use when waiting for input
Method Detail

read

public int read()
         throws IOException
Description copied from class: InputStream
Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

A subclass must provide an implementation of this method.

Specified by:
read in class InputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
IOException - if an I/O error occurs.

available

public int available()
              throws IOException
Return the number of bytes available to be read from the stream without blocking. Returns the number of bytes available in the current underlying radio packet - more packets might be coming but we just don't know.

Overrides:
available in class InputStream
Returns:
the number of bytes available right now
Throws:
IOException - if an I/O error occurs.

getLinkQuality

public int getLinkQuality()
Link Quality Indication (LQI) is a characterization of the quality of a received packet. Its value is computed from the CORR, correlation value. The LQI ranges from 0 (bad) to 255 (good).

Returns:
linkQuality - range 0 to 0xFF
See Also:
RadioPacket.getLinkQuality()

getCorr

public int getCorr()
CORR measures the average correlation value of the first 4 bytes of the packet header. A correlation value of ~110 indicates a maximum quality packet while a value of ~50 is typically the lowest quality packet detectable by the SPOT's receiver.

Returns:
- correlation value
See Also:
RadioPacket.getCorr()

getRssi

public int getRssi()
RSSI (received signal strength indicator) measures the strength (power) of the signal for the packet. It ranges from +60 (strong) to -60 (weak). To convert it to decibels relative to 1 mW (= 0 dBm) subtract 45 from it, e.g. for an RSSI of -20 the RF input power is approximately -65 dBm.

Returns:
- RSSI value
See Also:
RadioPacket.getRssi()

close

public void close()
           throws IOException
Description copied from class: InputStream
Closes this input stream and releases any system resources associated with the stream.

The close method of InputStream does nothing.

Overrides:
close in class InputStream
Throws:
IOException - if an I/O error occurs.

Sun SPOT API
Green Release  


Copyright © 2006 Sun Microsystems, Inc. All Rights Reserved.