com.sentilla.platform.cmote
Class ClientRadioProtocol

java.lang.Object
  extended by com.sentilla.system.DriverAdapter
      extended by com.sentilla.platform.cmote.Protocol
          extended by com.sentilla.platform.cmote.ClientRadioProtocol
All Implemented Interfaces:
Driver

public class ClientRadioProtocol
extends Protocol

Provides a protocol wrapper to the host-side communication interface. Used to send and receive from the radio firmware and provides metadata to set radio parameters.

See Also:
Protocol, Dispatcher

Nested Class Summary
static class ClientRadioProtocol.Receiver
          Provides receiver class for the client to receive from the host server.
static class ClientRadioProtocol.Sender
          Provides sender class for the simulated radio.
 
Field Summary
 
Fields inherited from class com.sentilla.system.DriverAdapter
m_nextDriver
 
Constructor Summary
ClientRadioProtocol()
           
 
Method Summary
 boolean connect(String host, int port, int timeout)
          Connects the server at the given host and port.
 void disconnect()
           
 boolean doesInstanceMatch(Object obj)
          Returns true if obj is an instanceof RadioMacAddressMessage.
static int getDebug()
          Get debug logging level
 String getDriverName(int n)
          Returns the strings "local" and "default".
 String getHost()
          Server host address.
 int getPacketsRead()
          Returns the number packets read from the server since instantiation, or the last reset.
 int getPacketsWritten()
          Returns the number packets written to the server since instantiation, or the last reset.
 int getPort()
          Server port.
 int getTimeout()
          The number of seconds to wait for server communication
 boolean isConnected()
           
 ClientRadioProtocol.Receiver newReceiver()
          Returns a new receiver for the client application to receive from the host server.
 ClientRadioProtocol.Receiver newReceiver(Class<ByteBufferMessage> name)
           
 ClientRadioProtocol.Sender newSender()
          Returns a new sender for the client application to communicate with the host server.
 void resetPacketCounters()
          Resets packact counters.
static void setDebug(int level)
          Set debug logging level
 void stackReceive(Receiver rcvr)
          Needed by client applications to snoop on other client communications.
 void stackSend(Sender ds)
          Sends a message to the host server.
 void startReceiving()
          Start receiving mote network traffic.
 void stopReceiving()
          Stop receiving mote network traffic.
 
Methods inherited from class com.sentilla.system.DriverAdapter
getNextDriver, setNextDriver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientRadioProtocol

public ClientRadioProtocol()
Method Detail

connect

public boolean connect(String host,
                       int port,
                       int timeout)
                throws UnknownHostException,
                       IOException
Connects the server at the given host and port.

Parameters:
host - the host address
port - the host port
timeout - the max number of milliseconds to wait for server communication
Returns:
boolean true if the connection attempt is successful, false otherwise
Throws:
IOException
UnknownHostException

disconnect

public void disconnect()

isConnected

public boolean isConnected()

getHost

public String getHost()
Server host address.

Returns:
String server host address as a String

getPort

public int getPort()
Server port.

Returns:
int integer port of the server

getTimeout

public int getTimeout()
The number of seconds to wait for server communication

Returns:
int the server communication timeout

setDebug

public static void setDebug(int level)
Set debug logging level


getDebug

public static int getDebug()
Get debug logging level


stackReceive

public void stackReceive(Receiver rcvr)
Needed by client applications to snoop on other client communications.

Specified by:
stackReceive in class Protocol
Parameters:
rcvr - Receiver object containing received object
See Also:
Protocol

stackSend

public void stackSend(Sender ds)
Sends a message to the host server. This method is only called by the Dispatcher and should never be called by any outside application.

Specified by:
stackSend in class Protocol
Parameters:
ds - sender object containing the data to be sent
See Also:
Protocol, ClientRadioProtocol.Sender, Dispatcher

newSender

public ClientRadioProtocol.Sender newSender()
Returns a new sender for the client application to communicate with the host server.

Specified by:
newSender in class Protocol
Returns:
new Sender object.
See Also:
ClientRadioProtocol.Sender, Dispatcher

newReceiver

public ClientRadioProtocol.Receiver newReceiver()
Returns a new receiver for the client application to receive from the host server. Should only be called by the Dispatcher.

Specified by:
newReceiver in class Protocol
Returns:
new Receiver object
See Also:
Receiver, Dispatcher

newReceiver

public ClientRadioProtocol.Receiver newReceiver(Class<ByteBufferMessage> name)

doesInstanceMatch

public boolean doesInstanceMatch(Object obj)
Returns true if obj is an instanceof RadioMacAddressMessage. This is required for client apps to snoop on addressed messages.

Specified by:
doesInstanceMatch in class Protocol
Parameters:
obj - Object to match
Returns:
true if this receiver is receiving for the same class as obj.
See Also:
Protocol

getDriverName

public String getDriverName(int n)
Returns the strings "local" and "default". Should only be called by the Drivers class.

Specified by:
getDriverName in interface Driver
Specified by:
getDriverName in class DriverAdapter
Parameters:
n - index of string to get
Returns:
the string "local" or "default"
See Also:
Protocol, Driver, Drivers

resetPacketCounters

public void resetPacketCounters()
Resets packact counters.


getPacketsRead

public int getPacketsRead()
Returns the number packets read from the server since instantiation, or the last reset.

Returns:
int the number of packets read from the server

getPacketsWritten

public int getPacketsWritten()
Returns the number packets written to the server since instantiation, or the last reset.

Returns:
int the number of packets written to the server

startReceiving

public void startReceiving()
                    throws IOException,
                           ClassNotFoundException
Start receiving mote network traffic.

Throws:
IOException
ClassNotFoundException

stopReceiving

public void stopReceiving()
                   throws IOException,
                          ClassNotFoundException
Stop receiving mote network traffic.

Throws:
IOException
ClassNotFoundException


Copyright © 2007 Sentilla Corporation. All Rights Reserved.