Public Member Functions | List of all members
VizBlock Class Reference

The main VizBlock class. More...

#include <VizBlocks.h>

Public Member Functions

void add (Behaviour *b)
 
void announce (String doc)
 
void announce_capabilities ()
 
void generateCapabilitiesJSON ()
 
char * getId ()
 
void init ()
 
void mqtt_command ()
 
void MQTT_connect ()
 
String process (String input)
 
String process_command (String command, String args)
 
void run ()
 
void serial_command ()
 
void set_wifi (boolean v)
 
void setID (char *id)
 
 VizBlock (char *id, char *ssid="VizBlockNet", char *wifi_pass="VizBlocksAP", char *server="172.20.10.8", int port=1883)
 

Detailed Description

The main VizBlock class.

This class contains all of the connection information for the WiFi network and Node-RED. It checks for commands recieved via serial/mqtt and executes behaviours in reponse.

Constructor & Destructor Documentation

◆ VizBlock()

VizBlock::VizBlock ( char *  id,
char *  ssid = "VizBlockNet",
char *  wifi_pass = "VizBlocksAP",
char *  server = "172.20.10.8",
int  port = 1883 
)

Member Function Documentation

◆ add()

void VizBlock::add ( Behaviour b)

Add a behaviour to the list of possible behaviours.

◆ announce()

void VizBlock::announce ( String  doc)

Publishes a message to the block's mqtt announcement channel.

◆ announce_capabilities()

void VizBlock::announce_capabilities ( )

Loops through the block's behaviours and announces each one over mqtt/

◆ generateCapabilitiesJSON()

void VizBlock::generateCapabilitiesJSON ( )

Generates an array json formatted string containing information about each of the behaviours the block can perform.

◆ getId()

char* VizBlock::getId ( )

Returns the ID of the block.

◆ init()

void VizBlock::init ( )

Set up the block's WiFi and MQTT.

◆ mqtt_command()

void VizBlock::mqtt_command ( )

Read a command from the serial input and process it. It only waits for 50ms to allow other behaviours to continue.

◆ MQTT_connect()

void VizBlock::MQTT_connect ( )

Function to connect and reconnect as necessary to the MQTT server.

◆ process()

String VizBlock::process ( String  input)

Process a command. This means:

  • split the command name from the arguments
  • call process_command with the separated command and argument string

◆ process_command()

String VizBlock::process_command ( String  command,
String  args 
)

Process a command and its arguments. This means:

  • look for a Behaviour with the right name
  • if found, then call that behaviour with the arguments (which are still a single string)

◆ run()

void VizBlock::run ( )

This is the main loop. It should be called from within loop() - really this function is the only thing you should need to call. It will manage it's own delay, so you can call as often as possible.

◆ serial_command()

void VizBlock::serial_command ( )

Read a command from the serial input and process it

◆ set_wifi()

void VizBlock::set_wifi ( boolean  v)

Turns the block's wifi on or off.

◆ setID()

void VizBlock::setID ( char *  id)

Sets the ID of the block.


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