-
Notifications
You must be signed in to change notification settings - Fork 7
Home
Commander API:
setDelimiters(String myDelims)
These methods can be used to query and extract items from the payload. The payload is anything that is found in the buffer after a command has been identified. The command will always be at the start of the buffer and the payload comes after it. The payload can be processed as discrete 'items' and each item is defined as a group of characters that have a delimiter at each end, or a delimiter at the start and an end of line at the end. The exception is when characters are enclosed with quote marks.
Here is an example payload:
Hi my name is bill
It contains five items, so the method countItems() will return 5.
Here is another payload example:
Hi my "name is bill"
This contains three items because the last three words are enclosed in quotes, so countItems() will return 3.
Commander has several methods for extracting payload items and it uses an internal variable to keep track of where it is in the buffer so that repeated calls to these methods can be used to extract items in sequence.
chain()
unchain()
Commander has a set of print methods which, when called, invoke the same methods for whatever outgoing Stream object is attached to the Commander object. These print methods should always be used within command handler functions to ensure that the command list and its handlers can work transparently with any Stream object. This way the same command list can serve a USB serial port, a Bluetooth SSP connection, and a hardware UART serial port, and all responses to commands sent from any of those streams will be sent back to the stream that the command came from.
Commander also uses some internal checks to apply prefix and postfix formatting where user sp0ecified tect is applied at the start and end of any line. It relies on the user of its own print methods to correctly apply formatting.
print(printType printableVariable)
print(printType printableVariable, int fmt)
println(printType printableVariable)
println(printType printableVariable, int fmt)
write(printType printableVariable)
write(printType printableVariable, int length)
Commander can be locked and unlocked. If an optional passphrase is set then it must be used to unlock the command system.
There are two lock levels, soft or hard. A soft lock allows internal commands to be used and will print help data. A hard lock prevents all internal commands except the unlock command. HARD_LOCK and SOFT_LOCK are defined as macros for true and false.
attachCommands(const commandList_t *commands, uint32_t size)
transferTo(const commandList_t *commands, uint32_t size, String newName)
transferBack(const commandList_t *commands, uint32_t size, String newName)
attachSpecialHandler(cmdHandler handler)
attachOutputPort(Stream *oPort)
attachInputPort(Stream *iPort)
attachDefaultHandler(cmdHandler handler)
setStreamType(streamType_t newType)
quickSet(String cmd, int& var)
quickSet(String cmd, float& var)
quickSet(String cmd, double& var)
quickGet(String cmd, float var)
getCommandItem(uint16_t commandItem)