Sun SPOT API
Green Release  


com.sun.squawk.io.j2me.radiogram
Class Protocol

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

public class Protocol
extends RadioConnectionBase
implements RadiogramConnection

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

See Also:
RadioConnection

Field Summary
 
Fields inherited from class com.sun.spot.peripheral.RadioConnectionBase
DEFAULT_TIMEOUT
 
Constructor Summary
Protocol()
          Default constructor - normally not called by user code which should use the GCF framework instead.
 
Method Summary
 void close()
          Close
 long getMacAddress()
           
 int getMaximumLength()
          Get the maximum length a datagram can be.
 int getNominalLength()
          Get the nominal length of a datagram.
 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 protocolName, String name, int mode, boolean timeouts)
          Open a connection to a target.
 void receive(Datagram dgram)
          Receive a datagram.
 RadioPacket receivePacket()
           
 RadioPacket receivePacket(long timeout)
           
 void send(Datagram dgram)
          Send a datagram.
 void sendPacket(RadioPacket rp)
           
static void setPBPM(IPortBasedProtocolManager pbpm)
           
 
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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.spot.peripheral.ITimeoutableConnection
getTimeout, setTimeout
 

Constructor Detail

Protocol

public Protocol()
Default constructor - normally not called by user code which should use the GCF framework instead. See class comment for examples.

Method Detail

setPBPM

public static void setPBPM(IPortBasedProtocolManager pbpm)

open

public Connection open(String protocolName,
                       String name,
                       int mode,
                       boolean timeouts)
Description copied from class: ConnectionBase
Open a connection to a target.

Specified by:
open in class ConnectionBase
Parameters:
protocolName - The URL protocol
name - The URL for the connection
mode - The access mode
timeouts - A flag to indicate that the caller wants timeout exceptions
Returns:
A new Connection object

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
Description copied from interface: DatagramConnection
Send a datagram.

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

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.
InterruptedIOException - Timeout or upon closing the connection with outstanding I/O.

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()

sendPacket

public void sendPacket(RadioPacket rp)
                throws NoAckException,
                       ChannelBusyException
Throws:
NoAckException
ChannelBusyException

receivePacket

public RadioPacket receivePacket(long timeout)

receivePacket

public RadioPacket receivePacket()

Sun SPOT API
Green Release  


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