35#ifndef COMMANDER_API_SRC_COMMANDER_HPP_
36#define COMMANDER_API_SRC_COMMANDER_HPP_
38#define COMMANDER_API_VERSION (const char*)"2.1.0"
53#ifdef COMMANDER_USE_WIFI_CLIENT_RESPONSE
55 #include <ESP8266WiFi.h>
64#include <avr/pgmspace.h>
70#define apiElement( name, desc, func ) { 0, NULL, NULL, (const char*)name, (const char*)desc, func }
78#define apiElement_P( element, name, desc, func_arg ) { element.name_P = F( name ); element.desc_P = F( desc ); element.func = func_arg; }
86#define attachTree( name ) attachTreeFunction( name, sizeof( name ) / sizeof( name[ 0 ] ) )
185 void execute(
const char *cmd );
194 void execute(
char *cmd, Stream *resp );
203 void execute(
const char *cmd, Stream *resp );
347 void helpFunction(
bool description, Stream* out,
bool style =
false );
353 int32_t
hasChar(
char* str,
char c );
355 #ifdef COMMANDER_ENABLE_PIPE_MODULE
#define COMMANDER_MAX_COMMAND_SIZE
API_t * operator[](int i)
Array index operator overload for int type.
void swap_api_elements(uint16_t index, uint16_t place)
Swap two API elements in the tree.
memoryType_t memoryType
Flag for memory type.
void disableDebug()
Disables debug messages.
API_t * API_tree
Starting address of the API-tree.
int commander_strcmp_tree_ram_progmem(API_t *element1, char *element2)
Compare an API-tree element's name with a regular string.
uint32_t API_tree_size
Number of elements in the API-tree.
int(Commander::* commander_strcmp)(API_t *element1, API_t *element2)
Function pointer to an internal strcmp like function.
char tempBuff[COMMANDER_MAX_COMMAND_SIZE]
Internal command buffer.
void executeCommand(char *cmd)
Command execution.
commandResponse defaultResponse
Default response handler class.
uint32_t elementCounter
Internal variable for counting purpose.
commandResponse defaultDebugResponse
Default response handler for debug messages.
int(Commander::* commander_strcmp_tree_ram)(API_t *element1, char *element2)
Function pointer to an internal strcmp like function.
int commander_strcmp_progmem(API_t *element1, API_t *element2)
Compare two API-tree element's name.
Stream * response
Pointer to response class.
char progmemBuffer[COMMANDER_MAX_COMMAND_SIZE]
With the PROGMEM implementation we need to copy the data from the PROGMEM area to a buffer for comper...
static const char * version
Library version string.
void helpFunction(bool description=false)
Help function.
void printHelp(Stream *out)
Prints out the help string to the specified Stream.
int32_t hasChar(char *str, char c)
Search for a character in a string.
void recursive_optimizer(int32_t start_index, int32_t stop_index)
Recursive function optimize a section in the tree.
Stream * dbgResponse
Pointer to response class.
int commander_strcmp_tree_ram_regular(API_t *element1, char *element2)
Compare an API-tree element's name with a regular string.
char pipeArgBuffer[COMMANDER_MAX_COMMAND_SIZE]
If piping happenes the output of the first command will be copied to this buffer.
bool debugEnabled
Flag to enable or disable debug messages.
void attachDebugChannel(Stream *resp)
Debug channel for Serial.
void execute(char *cmd)
Default execution function.
int commander_strcmp_regular(API_t *element1, API_t *element2)
Compare two API-tree element's name.
void optimize_api_tree()
Optimizes the tree to make it balanced.
void enableDebug()
Enables debug messages.
uint16_t find_api_index_by_place(uint16_t place)
Find an API element in the tree by alphabetical place.
commanderPipeChannel pipeChannel
Channel for the internal piping.
void attachTreeFunction(API_t *API_tree_p, uint32_t API_tree_size_p)
Attach API-tree to the object.
@ MEMORY_PROGMEM
Progmem memory implementation.
@ MEMORY_REGULAR
Regular memory implementation.
Structure for command data.
__FlashStringHelper * name_P
__FlashStringHelper * desc_P
void(* func)(char *, Stream *response)