SHETSourceClient Class Reference

#include <SHETSource.h>

List of all members.

Public Member Functions

 SHETSourceClient (const char *name, int address, int status_pin=DEFAULT_STATUS_PIN)
const client_status_t getStatus ()
const void displayStatus ()
void outputNotify (int port)
void bindOutputPort (int port, char *name, bool(*func)())
void bindOutputPort (int port, char *name, int8(*func)())
void bindOutputPort (int port, char *name, int16(*func)())
void onReceive (int length)
void onRequest (void)

Detailed Description

An API for really easily creating clients on the SHETSource network. Handles responding to pings, hiding away (where possible) the polling-oriented nature of I2C and other relevent restrictions to make the whole thing a bit more RPC-ish.


Constructor & Destructor Documentation

SHETSourceClient::SHETSourceClient ( const char *  name,
int  address,
int  status_pin = DEFAULT_STATUS_PIN 
)

Set up the current device as a SHETSourceClient and a I2C slave. Note: Because of some restrictions involving the Wire module, you can only create one instance of this class (not that you should ever want more).

Parameters:
name A string representing a human readable name for the client.
address The numeric I2C address the device should occupy.
status_pin A pin on the arduino which may be used by the client to display status.

Member Function Documentation

void SHETSourceClient::bindOutputPort ( int  port,
char *  name,
int16(*)()  func 
)

Bind a function to the read event for a specified port. The specified function will be executed whenever a read event is recieved for that port. Note that the type of the value is determined by the return value of the function you provide.

Parameters:
port The output port number for this value.
name A human-readable string naming the port's data.
func A function pointer to be executed on a read request.
void SHETSourceClient::bindOutputPort ( int  port,
char *  name,
int8(*)()  func 
)

Bind a function to the read event for a specified port. The specified function will be executed whenever a read event is recieved for that port. Note that the type of the value is determined by the return value of the function you provide.

Parameters:
port The output port number for this value.
name A human-readable string naming the port's data.
func A function pointer to be executed on a read request.
void SHETSourceClient::bindOutputPort ( int  port,
char *  name,
bool(*)()  func 
)

Bind a function to the read event for a specified port. The specified function will be executed whenever a read event is recieved for that port. Note that the type of the value is determined by the return value of the function you provide.

Parameters:
port The output port number for this value.
name A human-readable string naming the port's data.
func A function pointer to be executed on a read request.
const void SHETSourceClient::displayStatus (  ) 

Flash the status LED with the current status code. Note that this function will block during the flashing.

Status codes are:

OK Solid-On
Not Connected Short-On, Long-Off
Error Fast blinking
const client_status_t SHETSourceClient::getStatus ( void   ) 

Get the current status of the client. Find out if there is an error or if the client simply hasn't been polled by a master yet.

Returns:
The current status of the client.
void SHETSourceClient::onReceive ( int  length  ) 

For internal use as part of a work-around: DO NOT USE. Unfortunately this has to be public for the workaround it is involved with. Please ignore.

Handle incoming data from the server

void SHETSourceClient::onRequest ( void   ) 

For internal use as part of a work-around: DO NOT USE. Unfortunately this has to be public for the workaround it is involved with. Please ignore.

Send back a previously designated value if requested.

void SHETSourceClient::outputNotify ( int  port  ) 

Set the notify bit for the specifed output port.

Parameters:
port The output port port number to set the bit for.

The documentation for this class was generated from the following files:
 All Classes Functions Variables
Generated on Thu Jun 3 15:50:50 2010 by  doxygen 1.6.3