|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.tinyos.message.MoteIF
MoteIF provides an application-level Java interface for receiving messages from, and sending messages to, a mote through a serial port, TCP connection, or some other means of connectivity. Generally this is used to write Java programs that connect over a TCP or serial port to communicate with a TOSBase or GenericBase mote. The default way to use MoteIF is to create an instance of this class and then register one or more MessageListener objects that will be invoked when messages arrive. For example:
MoteIF mif = new MoteIF();
mif.registerListener(new FooMsg(), this);
// Invoked when a message arrives
public void messageReceived(int toaddr, Message msg) { ... }
The default MoteIF constructor uses the MOTECOM environment
variable to determine how the Java application connects to the mote.
For example, a MOTECOM setting of "serial@COM1" connects to a base
station using the serial port on COM1.
You can also send messages through the base station mote using
MoteIF.send().
BuildSource| Field Summary | |
|---|---|
protected Receiver |
receiver
|
protected Sender |
sender
|
protected PhoenixSource |
source
|
static int |
TOS_BCAST_ADDR
The destination address for a broadcast. |
| Constructor Summary | |
|---|---|
MoteIF()
Create a new mote interface to packet source specified using the MOTECOM environment variable. |
|
MoteIF(Messenger messages)
Create a new mote interface to packet source specified using the MOTECOM environment variable. |
|
MoteIF(PhoenixSource source)
Create a new mote interface to an arbitrary packet source. |
|
| Method Summary | |
|---|---|
void |
deregisterListener(Message m,
MessageListener l)
Deregister a listener for a given message type. |
PhoenixSource |
getSource()
|
void |
registerListener(Message m,
MessageListener l)
Register a listener for given messages type. |
void |
send(int moteId,
Message m)
Send m to moteId via this mote interface |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int TOS_BCAST_ADDR
protected PhoenixSource source
protected Sender sender
protected Receiver receiver
| Constructor Detail |
public MoteIF()
public MoteIF(Messenger messages)
messages - where to send status messages (null means no messages)public MoteIF(PhoenixSource source)
source - packet source to use| Method Detail |
public PhoenixSource getSource()
public void send(int moteId,
Message m)
throws java.io.IOException
moteId - message destinationm - message
java.io.IOException - thrown if message could not be sent
public void registerListener(Message m,
MessageListener l)
m - message template specifying which message to receivel - listener to which received messages are dispatched
public void deregisterListener(Message m,
MessageListener l)
m - message template specifying which message to receivel - listener to which received messages are dispatched
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||