Flow Integration API

This page describes various classes and variables that are used to ease the integration of FlowCloud with Arduino.

XML Manipulation

class XMLNode

A simple, writable node in an XML document.

XMLNode.h
  XMLNode (char *_name)
  Construct a XML node with the specified name.
 
XMLNode addChild (char *childName)
  Create and add a new XMLNode as a child.
 
void  addAttribute (char *name, char *value)
  Add an attribute with the specified name and value.
 
void  addAttribute (char *name, int value)
  Add an attribute with the specified name and integer value.
 
void  addAttribute (char *name, double value, int places)
  Add an attribute with the specified name and decimal value, truncated to the specified number of decimal places.
 
void  setContent (char *content)
  Set the content to the specified content.
 
void  setContent (int content)
  Set the content to the specified content.
 
void  setContent (double content, int places)
  Set the content to the specified content.
 
StringBuilder  appendTo (StringBuilder builder)
  Append the string representation of this XML node with all attributes, contents and children to the specified StringBuilder.

class ReadableXMLNode

A simple, readable node in an XML document.

XMLNode.h
  ReadableXMLNode (char *_name)
  Construct a readable XML node with the specified name.
 
  ReadableXMLNode (TreeNode _wrap)
  Construct a readable XML node wrapping access to the FlowCloud TreeNode type.
 
ReadableXMLNode getChild (char *path)
  Retrieve a ReadableXMLNode from the specified path. A single name (e.g. "foo") look for a child of this node named foo. Alternatively '/' can be used to specify multiple levels of children - "foo/bar/baz" looks for a child named baz that this the child of a node named bar, which is a child of this node named foo.
 
const char * getName ()
  Return the name of this node.
 
const char * getValue ()
  Get the string value of this node.
 
int  getIntegerValue ()
  Get the value of this node, parsed as an int (%d).
 
double  getFloatValue ()
  Get the value of this node, parsed as a floating-point number (double - %lf).

Command Handler

class FlowCommandHandler

A mapping of command strings to callback functions.

FlowCommandHandler.h
bool attach (char *command, CommandCallbackFunction callback)
Register a new callback for the specified command string
  • char *command  the string to trigger the callback
  • CommandCallbackFunction callback  the function to call when the command string is encountered
 
bool handleCommand (char *command, ReadableXMLNode &params, XMLNode &response)
Handle the command, by passing it to a mapped command handler, or returning false if there is no mapped command handler.
  • char *command  the command to handle
  • ReadableXMLNode params  the function to call when the command string is encountered
  • XMLNode response  the function to call when the command string is encountered

function CommandCallbackFunction

A function to be called to handle a specific command.

FlowCommandHandler.h
typedef CommandCallbackFunction
void (ReadableXMLNode &, XMLNode &)

Control variables

global variables

global
bool g_EnableConsole
Enable the FlowCloud library console. This will print status messages and logging over the default serial port.
 
bool g_EnableConsoleInput
Enable console input to the FlowCloud library. This will allow input to the FlowCloud CLI. This should only be enabled when Arduino code is not using console input (e.g. Serial.read etc.)
 
bool g_EnableUIControlLED
Enable access to the 4 LEDs from the FlowCloud library. The FlowCloud library uses the LEDs to show the status, but in doing so it will override state set by the Arduino code.

FlowCloud variables

global variables

global
char * g_ClientID
The FlowCloud unique identification for this device.
 
char * g_OwnerID
The FlowCloud unique identification for the owner (user) of this device.