Implements the basic sending and receiving capabilities on iostreams. More...

#include <MoteProtocol.h>

Collaboration diagram for mote::MoteProtocol:
Collaboration graph

Detailed Description

Implements the basic sending and receiving capabilities on iostreams.

This class can be used for debugging purpouses, as can be binded to any kind of input or output streams, easily sending the packets to cout and reading them from cin. For daily purpouses MoteIF should be used instead.

#include "MoteProtocol.h"
#define MY_TYPE 37
struct MyType {
uint8_t a;
uint16_t b;
}
int main() {
using namespace mote;
TOSMessage message;
MyType myType;
cin.unsetf( std::ios_base::skipws )
mote.bind( cin, cout );
try {
myType.a = 42;
myType.b = 4242;
message.compose( MY_TYPE, &myType, sizeof(myType));
mote.sendMessage( message, P_PACKET_NO_ACK );
} catch (...) {
// ...exception handling stuff
throw;
}
return 0;
}
Implements the basic sending and receiving capabilities on iostreams.
Definition MoteProtocol.h:147
TinyOS generic message.
Definition MoteProtocol.h:205

Public Member Functions

void bind (istream &is, ostream &os)
 
void getMessage (TOSMessage &message)
 
void sendMessage (TOSMessage &message, uint8_t type)
 
void setOS (int v)
 Set TinyOS version.
 
int getOS ()
 Get current TinyOS version.
 

Protected Types

enum  Status { ST_LOST , ST_SYNC }
 

Protected Member Functions

void sendPacket (Packet &packet)
 

Protected Attributes

Status status
 
char * bufferIn
 
char * bufferOut
 
istream * ins
 
ostream * outs
 
int os
 

Member Function Documentation

◆ getOS()

int mote::MoteProtocol::getOS ( )

Get current TinyOS version.

Returns
TinyOS version

◆ setOS()

void mote::MoteProtocol::setOS ( int v)

Set TinyOS version.

Parameters
TinyOSversion. It can be 1 or 2

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