This class provides serial-port-ready access to the mote. More...

#include <MoteIF.h>

Collaboration diagram for mote::MoteIF:
Collaboration graph

Detailed Description

This class provides serial-port-ready access to the mote.

This class is a wrapper for MoteProtocol, and includes a SerialStream for serial port handling. It makes very easy to receive a message of any kind via serial port.

// myType is an instance of the struct MyType, for example.
TOSMessage message;
MoteIF mote;
mote.open();
mote.getMessage( message );
if (message.type == MY_TYPE ) {
message.getData( &myType, sizeof( myType ));
}
mote.close();
This class provides serial-port-ready access to the mote.
Definition MoteIF.h:64
void open(const char *tty="/dev/ttyUSB0", SerialStreamBuf::BaudRateEnum baud_rate=SerialStreamBuf::BAUD_115200)
Configures and opens the serial port connection.
Definition MoteIF.cpp:44
TinyOS generic message.
Definition MoteProtocol.h:205

Public Member Functions

void open (const char *tty="/dev/ttyUSB0", SerialStreamBuf::BaudRateEnum baud_rate=SerialStreamBuf::BAUD_115200)
 Configures and opens the serial port connection.
 
void close ()
 
void getMessage (TOSMessage &message)
 
void sendMessage (TOSMessage &message, uint8_t type=0)
 Encapsulates a TinyOS message in a packet and sends it to the mote.
 
bool setTiming (short vmin, short vtime)
 
void setOS (int v)
 
int getOS ()
 

Protected Attributes

int os
 
MoteProtocol protocol
 
SerialStream serial
 

Member Function Documentation

◆ open()

void mote::MoteIF::open ( const char * tty = "/dev/ttyUSB0",
SerialStreamBuf::BaudRateEnum baud_rate = SerialStreamBuf::BAUD_115200 )

Configures and opens the serial port connection.

The required configuration is 115200 bps, parity none, flow control none, 8bits per byte and 1 stop bit.

Parameters
ttyDevice to open. If none is specified, /dev/ttyUSB0 is used by default.

◆ sendMessage()

void mote::MoteIF::sendMessage ( TOSMessage & message,
uint8_t type = 0 )
inline

Encapsulates a TinyOS message in a packet and sends it to the mote.

Parameters
messageMessage to be sent as payload in the packet.
typeType of the packet. Should be { P_PACKET_NO_ACK, P_PACKET_ACK }. The default value is P_PACKET_NO_ACK, i.e, acknownledgement not required.

The documentation for this class was generated from the following files: