1#ifndef COMMAND_PARSER_H
2#define COMMAND_PARSER_H 1
3#include <platform-header.h>
11#define MAX_SINGLE_ARG_SIZE 196
13#define PROTOCOL_VERSION_ASCII 1
15#define CLOUD_SERVER 0x00000001
17#define COMMAND_MAXARGS 17
20#define COM_LOCAL_FLAG_FORCE_DEVICE 1
26struct command *command_parse(
const byte *buf,
int size);
29struct command *command_add_byte(
int b);
41int command_add_encoded_arg(
struct command *
com,
byte *buf);
42byte command_calc_checksum(
struct command *
com);
char * command_get_source_name(byte sourcedev)
returns a human readable text identifying a source device
int namedarg_uint16(struct command *com, const char *name, uint16_t *value)
get a named arg (key-value pair), parsed as integer. result in "value". if return value == 0 ,...
int command_encode_ascii(struct command *com, int bufsize, char *buf)
encode a command to an ascii blob properly surrounded by '{' and '}' and escaped returns length if ok...
int get_arg_size_inmem(const struct command *com, int index)
given an argument by index [0..n], will returns the number in bytes this argument takes up in memory....
void command_add_arg(struct command *com, const char *format,...)
adds an arg to a partially initialised command structure
const char * namedarg(struct command *com, const char *name)
get a named arg (key-value pair) or NULL
void command_add_varg(struct command *com, const char *format, va_list args)
adds a varg list of parameters to a command
int namedarg_uint32(struct command *com, const char *name, uint32_t *value)
get a named arg (key-value pair), parsed as integer. result in "value". if return value == 0 ,...
const char * command_get_name(int num)
given a command number returns its name
void command_init(struct command *com)
initialize a command structure with default values
const byte * get_arg_new(const struct command *com, int index)
given an argument by index[0..n], will returns a pointer to it. This will include the fieldnumber and...
int get_arg_int_array(const struct command *com, const int index, int *result, const int arraysize)
given a command and argument index, will attempt to parse the arg as array and return it array syntax...
void command_print(struct command *com)
prints a command in human readable format to serial console
int command_add_binary_arg(struct command *com, const int len, const byte *srcbuf)
adds a binary parameter to command returns 0 if ok otherwise errorcode
const char * get_arg(const struct command *com, int index)
given an argument by index[0..n], will return a pointer to the bytearray (excluding the fieldtype) th...
int get_arg_size(const struct command *com, int index)
given an argument by index [0..n], will returns the size of the value in bytes. for a string/array it...
void command_start()
initialization for command parser