SunSPOT API V3.0


com.sun.spot.io.j2me.radiogram
Class RadiogramConnImpl

java.lang.Object
  extended by com.sun.squawk.io.ConnectionBase
      extended by com.sun.spot.peripheral.RadioConnectionBase
          extended by com.sun.spot.io.j2me.radiogram.RadiogramConnImpl
All Implemented Interfaces:
RadiogramConnection, IMultipleHopConnection, IRadioControl, ITimeoutableConnection, Connection, DatagramConnection

public class RadiogramConnImpl
extends RadioConnectionBase
implements RadiogramConnection

This class provides the "radiogram" protocol for accessing the SPOT radio using datagrams. It is an implementor of RadiostreamConnection

See Also:
RadiostreamConnection

Field Summary
 
Fields inherited from class com.sun.spot.peripheral.RadioConnectionBase
DEFAULT_TIMEOUT
 
Constructor Summary
RadiogramConnImpl()
          DO NOT USE THIS CONSTRUCTOR - connections should be created using Connector.open(...)
RadiogramConnImpl(String addr, byte portNo, boolean isServer, boolean timeouts)
          DO NOT USE THIS CONSTRUCTOR - connections should be created using Connector.open(...)
 
Method Summary
 void close()
          Close
 byte getLocalPort()
          Answer the port number for this connection
 long getMacAddress()
           
 int getMaxBroadcastHops()
          returns the maximum number of mesh hops broadcasts sent on this connection will traverse
 int getMaximumLength()
          Get the maximum length a datagram can be.
 int getNominalLength()
          Get the nominal length of a datagram.
static IRadioPolicyManager getRadioPolicyManager()
           
 boolean isBroadcast()
           
 boolean isPointToPoint()
           
 boolean isServer()
           
 Datagram newDatagram(byte[] buf, int size)
          Make a new datagram object.
 Datagram newDatagram(byte[] buf, int size, String addr)
          Make a new datagram object.
 Datagram newDatagram(int size)
          Make a new datagram object automatically allocating a buffer.
 Datagram newDatagram(int size, String addr)
          Make a new datagram object.
 Connection open(String arg0, String arg1, int arg2, boolean arg3)
          Open a connection to a target.
 boolean packetsAvailable()
          determines whether there are radiograms that can be read from this connection
 void receive(Datagram dgram)
          Receive a datagram.
 IncomingData receivePacket()
           
 void send(Datagram dgram)
          Send a datagram.
 void setMaxBroadcastHops(int hops)
          change the number of mesh hops a broadcast packet may take
static void setProtocolManager(IRadiogramProtocolManager protocolManager)
           
 void setRadioPolicy(RadioPolicy policy)
          Set the radio policy for this connection
static void setRadioPolicyManager(IRadioPolicyManager manager)
           
 
Methods inherited from class com.sun.spot.peripheral.RadioConnectionBase
getTimeout, setTimeout
 
Methods inherited from class com.sun.squawk.io.ConnectionBase
openDataInputStream, openDataOutputStream, openInputStream, openOutputStream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.spot.peripheral.ITimeoutableConnection
getTimeout, setTimeout
 

Constructor Detail

RadiogramConnImpl

public RadiogramConnImpl(String addr,
                         byte portNo,
                         boolean isServer,
                         boolean timeouts)
DO NOT USE THIS CONSTRUCTOR - connections should be created using Connector.open(...)


RadiogramConnImpl

public RadiogramConnImpl()
DO NOT USE THIS CONSTRUCTOR - connections should be created using Connector.open(...)

Method Detail

setProtocolManager

public static void setProtocolManager(IRadiogramProtocolManager protocolManager)

getRadioPolicyManager

public static IRadioPolicyManager getRadioPolicyManager()

setRadioPolicyManager

public static void setRadioPolicyManager(IRadioPolicyManager manager)

close

public void close()
           throws IOException
Description copied from class: ConnectionBase
Close

Specified by:
close in interface Connection
Overrides:
close in class ConnectionBase
Throws:
IOException - If an I/O error occurs

getMaximumLength

public int getMaximumLength()
Description copied from interface: DatagramConnection
Get the maximum length a datagram can be.

Specified by:
getMaximumLength in interface DatagramConnection
Returns:
The maximum length a datagram can be.

getNominalLength

public int getNominalLength()
Description copied from interface: DatagramConnection
Get the nominal length of a datagram.

Specified by:
getNominalLength in interface DatagramConnection
Returns:
The nominal length a datagram can be.

send

public void send(Datagram dgram)
          throws NoAckException,
                 ChannelBusyException,
                 NoRouteException,
                 NoMeshLayerAckException
Description copied from interface: DatagramConnection
Send a datagram.

Specified by:
send in interface DatagramConnection
Parameters:
dgram - A datagram.
Throws:
NoAckException
ChannelBusyException
NoRouteException
NoMeshLayerAckException

receive

public void receive(Datagram dgram)
             throws IOException
Description copied from interface: DatagramConnection
Receive a datagram.

Specified by:
receive in interface DatagramConnection
Parameters:
dgram - A datagram.
Throws:
IOException - If an I/O error occurs.

newDatagram

public Datagram newDatagram(int size)
Description copied from interface: DatagramConnection
Make a new datagram object automatically allocating a buffer.

Specified by:
newDatagram in interface DatagramConnection
Parameters:
size - The length of the buffer to be allocated for the datagram
Returns:
A new datagram

newDatagram

public Datagram newDatagram(int size,
                            String addr)
Description copied from interface: DatagramConnection
Make a new datagram object.

Specified by:
newDatagram in interface DatagramConnection
Parameters:
size - The length of the buffer to be used
addr - The I/O address to which the datagram will be sent
Returns:
A new datagram

newDatagram

public Datagram newDatagram(byte[] buf,
                            int size)
Description copied from interface: DatagramConnection
Make a new datagram object.

Specified by:
newDatagram in interface DatagramConnection
Parameters:
buf - The buffer to be used in the datagram
size - The length of the buffer to be allocated for the datagram
Returns:
A new datagram

newDatagram

public Datagram newDatagram(byte[] buf,
                            int size,
                            String addr)
Description copied from interface: DatagramConnection
Make a new datagram object.

Specified by:
newDatagram in interface DatagramConnection
Parameters:
buf - The buffer to be used in the datagram
size - The length of the buffer to be used
addr - The I/O address to which the datagram will be sent
Returns:
A new datagram

isBroadcast

public boolean isBroadcast()

isPointToPoint

public boolean isPointToPoint()

isServer

public boolean isServer()

getMacAddress

public long getMacAddress()

setRadioPolicy

public void setRadioPolicy(RadioPolicy policy)
Description copied from interface: IRadioControl
Set the radio policy for this connection

Specified by:
setRadioPolicy in interface IRadioControl
Parameters:
policy - the policy required

open

public Connection open(String arg0,
                       String arg1,
                       int arg2,
                       boolean arg3)
                throws IOException
Description copied from class: ConnectionBase
Open a connection to a target.

Specified by:
open in class ConnectionBase
Parameters:
arg0 - The URL protocol
arg1 - The URL for the connection
arg2 - The access mode
arg3 - A flag to indicate that the caller wants timeout exceptions
Returns:
A new Connection object
Throws:
IOException - If some other kind of I/O error occurs.

receivePacket

public IncomingData receivePacket()

getLocalPort

public byte getLocalPort()
Description copied from interface: IRadioControl
Answer the port number for this connection

Specified by:
getLocalPort in interface IRadioControl
Returns:
the port number

packetsAvailable

public boolean packetsAvailable()
Description copied from interface: RadiogramConnection
determines whether there are radiograms that can be read from this connection

Specified by:
packetsAvailable in interface RadiogramConnection
Returns:
true if there are packets that can be read from the connection

setMaxBroadcastHops

public void setMaxBroadcastHops(int hops)
Description copied from interface: IMultipleHopConnection
change the number of mesh hops a broadcast packet may take

Specified by:
setMaxBroadcastHops in interface IMultipleHopConnection
Parameters:
hops - the new number of mesh hops a packet will traverse

getMaxBroadcastHops

public int getMaxBroadcastHops()
Description copied from interface: IMultipleHopConnection
returns the maximum number of mesh hops broadcasts sent on this connection will traverse

Specified by:
getMaxBroadcastHops in interface IMultipleHopConnection
Returns:
the number of mesh hops a packet will traverse

SunSPOT API V3.0


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