GrowNode
|
Macros | |
#define | GN_NODE_LEAVES_MAX_SIZE 64 |
Typedefs | |
typedef gn_leaf_param_validator_result_t(* | gn_validator_callback_t) (gn_leaf_param_handle_t param, void **value) |
typedef struct gn_config_init_param_t * | gn_config_init_param_handle_t |
Functions | |
gn_node_handle_t | gn_node_create (gn_config_handle_t config, const char *name) |
create a new node with specified configuration and name More... | |
gn_err_t | gn_node_destroy (gn_node_handle_t node) |
removes the node from the config More... | |
gn_err_t | gn_node_start (gn_node_handle_t node) |
starts the node by starting the leaves tasks More... | |
size_t | gn_node_get_size (gn_node_handle_t config) |
number of leaves into the node More... | |
gn_config_handle_t | gn_init (gn_config_init_param_t *config_init) |
performs the initialization workflow More... | |
gn_err_t | gn_firmware_update () |
send a message to the display More... | |
gn_err_t | gn_reset () |
reset the flash content and restart the board immediately More... | |
gn_err_t | gn_reboot () |
reboot the board More... | |
gn_leaf_handle_t | gn_leaf_create (gn_node_handle_t node_config, const char *name, gn_leaf_config_callback callback, size_t task_size) |
creates the leaf More... | |
gn_leaf_descriptor_handle_t | gn_leaf_get_descriptor (gn_leaf_handle_t leaf_config) |
QueueHandle_t | gn_leaf_get_event_queue (gn_leaf_handle_t leaf_config) |
gets the leaf queue handle More... | |
gn_err_t | gn_leaf_event_subscribe (gn_leaf_handle_t leaf_config, gn_event_id_t event_id) |
subscribe the leaf to the event id. More... | |
gn_err_t | gn_leaf_event_unsubscribe (gn_leaf_handle_t leaf_config, gn_event_id_t event_id) |
unsubscribe the leaf to the event id. More... | |
gn_leaf_param_handle_t | gn_leaf_param_create (gn_leaf_handle_t leaf_config, const char *name, const gn_val_type_t type, const gn_val_t val, gn_leaf_param_access_type_t access, gn_leaf_param_storage_t storage, gn_validator_callback_t validator) |
gn_err_t | gn_leaf_param_add_to_leaf (const gn_leaf_handle_t leaf, const gn_leaf_param_handle_t new_param) |
add a parameter to the leaf. More... | |
gn_leaf_param_handle_t | gn_leaf_param_get_param_handle (const gn_leaf_handle_t leaf, const char *param_name) |
returns the specific parameter associated to the leaf More... | |
gn_err_t | gn_leaf_param_get_value (const gn_leaf_param_handle_t param, void *val) |
gets the value pointed by the parameter More... | |
gn_err_t | gn_leaf_param_get_string (const gn_leaf_handle_t leaf_config, const char *name, char *val, size_t max_lenght) |
gets the parameter value More... | |
gn_err_t | gn_leaf_param_write_string (const gn_leaf_handle_t leaf, const char *name, char *val) |
updates the parameter with new value More... | |
gn_err_t | gn_leaf_param_init_string (const gn_leaf_handle_t leaf, const char *name, const char *val) |
init the parameter with new value and stores in NVS flash, overwriting previous values More... | |
gn_err_t | gn_leaf_param_get_bool (const gn_leaf_handle_t leaf_config, const char *name, bool *val) |
gn_err_t | gn_leaf_param_write_bool (const gn_leaf_handle_t leaf, const char *name, bool val) |
updates the parameter with new value More... | |
gn_err_t | gn_leaf_param_init_bool (const gn_leaf_handle_t leaf, const char *name, bool val) |
init the parameter with new value and stores in NVS flash, overwriting previous values More... | |
gn_err_t | gn_leaf_param_get_double (const gn_leaf_handle_t leaf_config, const char *name, double *val) |
gn_err_t | gn_leaf_param_write_double (const gn_leaf_handle_t leaf, const char *name, double val) |
updates the parameter with new value More... | |
gn_err_t | gn_leaf_param_init_double (const gn_leaf_handle_t leaf, const char *name, double val) |
init the parameter with new value and stores in NVS flash, overwriting previous values More... | |
gn_err_t | gn_leaf_param_write (const gn_leaf_handle_t leaf, const void *val) |
gn_err_t | gn_log (char *log_tag, gn_log_level_t level, const char *message,...) |
write ESP log, send log in the event queue and publish in network More... | |
gn_node_status_t | gn_get_status (gn_config_handle_t config) |
retrieves the configuration status More... | |
const char * | gn_get_status_description (gn_config_handle_t config) |
retrieves the configuration status description More... | |
esp_event_loop_handle_t | gn_get_event_loop (gn_config_handle_t config) |
retrieves the event loop starting from the config handle More... | |
esp_event_loop_handle_t | gn_leaf_get_event_loop (gn_config_handle_t config) |
retrieves the event loop starting from the leaf config handle More... | |
gn_err_t | gn_node_get_name (gn_node_handle_t node_config, char *name) |
gets the name of the node referenced by the handle More... | |
gn_err_t | gn_leaf_get_name (gn_leaf_handle_t leaf_config, char *name) |
gets the name of the leaf referenced by the handle More... | |
esp_event_loop_handle_t | gn_node_get_event_loop (gn_node_handle_t node) |
retrieves the event loop from the node More... | |
gn_leaf_handle_t | gn_leaf_get_config_handle (gn_node_handle_t node, const char *name) |
gn_node_handle_t | gn_leaf_get_node (gn_leaf_handle_t leaf_config) |
gn_err_t | gn_send_leaf_param_change_message (const char *leaf_name, const char *param_name, const void *message, size_t message_len) |
send a request to change a parameter name More... | |
gn_err_t | gn_send_node_leaf_param_status (const gn_node_handle_t _node_config) |
send parameter status per each parameter More... | |
gn_err_t | gn_leaf_param_set_bool (const gn_leaf_handle_t leaf_config, const char *name, bool val) |
generate a request to update the parameter to the leaf. More... | |
gn_err_t | gn_leaf_param_set_double (const gn_leaf_handle_t leaf_config, const char *name, double val) |
generate a request to update the parameter to the leaf. More... | |
gn_err_t | gn_leaf_param_set_string (const gn_leaf_handle_t leaf_config, const char *name, char *val) |
generate a request to update the parameter to the leaf. More... | |
gn_display_container_t | gn_display_setup_leaf (gn_leaf_handle_t leaf_config) |
BaseType_t | gn_display_leaf_refresh_start () |
BaseType_t | gn_display_leaf_refresh_end () |
gn_server_status_t | gn_mqtt_get_status () |
gn_err_t | gn_storage_set (const char *key, const void *value, size_t required_size) |
stores the key into the NVS flash More... | |
gn_err_t | gn_storage_get (const char *key, void **value) |
retrieves the key from the NVS flash More... | |
#define GN_NODE_LEAVES_MAX_SIZE 64 |
typedef struct gn_config_init_param_t* gn_config_init_param_handle_t |
typedef gn_leaf_param_validator_result_t(* gn_validator_callback_t) (gn_leaf_param_handle_t param, void **value) |
BaseType_t gn_display_leaf_refresh_end | ( | ) |
BaseType_t gn_display_leaf_refresh_start | ( | ) |
gn_display_container_t gn_display_setup_leaf | ( | gn_leaf_handle_t | leaf_config | ) |
gn_err_t gn_firmware_update | ( | ) |
send a message to the display
implemented by sending an internal GN_DISPLAY_LOG_EVENT event NOTE: data will be truncated depending on display size
message | the message to send (null terminated) |
starts the OTA firmware upgrade
it starts the OTA tasks so it returns immediately
esp_event_loop_handle_t gn_get_event_loop | ( | gn_config_handle_t | config | ) |
retrieves the event loop starting from the config handle
config | the config handle |
|
inline |
retrieves the configuration status
config | the configuration handle to check |
|
inline |
retrieves the configuration status description
config | the configuration handle to check |
gn_config_handle_t gn_init | ( | gn_config_init_param_t * | config_init | ) |
performs the initialization workflow
this is a process that will continue even after the function returns, eg for network/server connection
when everything is OK it sets the status of the config handle to GN_CONFIG_STATUS_ERROR
NOTE: if called several times, it returns always the same handle
gn_leaf_handle_t gn_leaf_create | ( | gn_node_handle_t | node_config, |
const char * | name, | ||
gn_leaf_config_callback | callback, | ||
size_t | task_size | ||
) |
creates the leaf
initializes the leaf structure. the returned handle is not active and need to be started by the gn_node_start() function
node_config | the configuration handle to create the leaf to |
name | the name of the leaf to be created |
callback | the callback to be called to configure the leaf |
task | callback function of the leaf task |
task_size | the size of the task to be memory allocated |
gn_err_t gn_leaf_event_subscribe | ( | gn_leaf_handle_t | leaf_config, |
gn_event_id_t | event_id | ||
) |
subscribe the leaf to the event id.
gn_err_t gn_leaf_event_unsubscribe | ( | gn_leaf_handle_t | leaf_config, |
gn_event_id_t | event_id | ||
) |
unsubscribe the leaf to the event id.
gn_leaf_handle_t gn_leaf_get_config_handle | ( | gn_node_handle_t | node, |
const char * | name | ||
) |
gn_leaf_descriptor_handle_t gn_leaf_get_descriptor | ( | gn_leaf_handle_t | leaf_config | ) |
returns the descriptor handle for the corresponding leaf
esp_event_loop_handle_t gn_leaf_get_event_loop | ( | gn_leaf_handle_t | leaf_config | ) |
retrieves the event loop starting from the leaf config handle
leaf_config | the leaf config handle |
QueueHandle_t gn_leaf_get_event_queue | ( | gn_leaf_handle_t | leaf_config | ) |
gets the leaf queue handle
leaf_config | the leaf to be queried |
gn_err_t gn_leaf_get_name | ( | gn_leaf_handle_t | leaf_config, |
char * | name | ||
) |
gets the name of the leaf referenced by the handle
leaf_config | the handle to be queried |
name | the pointer where the name will be set. set lenght to GN_LEAF_NAME_SIZE |
gn_node_handle_t gn_leaf_get_node | ( | gn_leaf_handle_t | leaf_config | ) |
gn_err_t gn_leaf_param_add_to_leaf | ( | const gn_leaf_handle_t | leaf, |
const gn_leaf_param_handle_t | param | ||
) |
add a parameter to the leaf.
the parameter will then listen to server changes
leaf | the leaf handle |
param | the param to add to the leaf. the leaf will point at it upon method return |
gn_leaf_param_handle_t gn_leaf_param_create | ( | gn_leaf_handle_t | leaf_config, |
const char * | name, | ||
const gn_val_type_t | type, | ||
gn_val_t | val, | ||
gn_leaf_param_access_type_t | access, | ||
gn_leaf_param_storage_t | storage, | ||
gn_validator_callback_t | validator | ||
) |
@brief creates a parameter on the leaf NOTE: if parameter is stored, the value is overridden
leaf_config | the leaf to be queried |
name | the name of the parameter (null terminated char array) |
type | the type of parameter |
val | the value of parameter |
access | access type of parameter |
storage | storage type of parameter |
validator | callback to validate |
gn_err_t gn_leaf_param_get_bool | ( | const gn_leaf_handle_t | leaf_config, |
const char * | name, | ||
bool * | val | ||
) |
gn_err_t gn_leaf_param_get_double | ( | const gn_leaf_handle_t | leaf_config, |
const char * | name, | ||
double * | val | ||
) |
gn_leaf_param_handle_t gn_leaf_param_get_param_handle | ( | const gn_leaf_handle_t | leaf_config, |
const char * | param_name | ||
) |
returns the specific parameter associated to the leaf
leaf_config | the leaf handle to search within |
param_name | the name of the parameter (null terminated) |
gn_err_t gn_leaf_param_get_string | ( | const gn_leaf_handle_t | leaf_config, |
const char * | name, | ||
char * | val, | ||
size_t | max_lenght | ||
) |
gets the parameter value
leaf_config | the leaf to get the parameter from |
name | the name of the parameter, null terminated |
val | pointer where the parameter is put |
max_lenght | the maximum lenght of the parameter value to be copied @return GN_RET_OK if the parameter is set @return GN_RET_ERR_INVALID_ARG if the parameter is not found |
gn_err_t gn_leaf_param_get_value | ( | const gn_leaf_param_handle_t | param, |
void * | val | ||
) |
gets the value pointed by the parameter
param | the parameter handle to look at |
val | the value returned @return GN_RET_OK if the parameter is set @return GN_RET_ERR_INVALID_ARG in case of input errors |
gn_err_t gn_leaf_param_init_bool | ( | const gn_leaf_handle_t | leaf_config, |
const char * | name, | ||
bool | val | ||
) |
init the parameter with new value and stores in NVS flash, overwriting previous values
the leaf must be not initialized to have an effect. the parameter value will be copied to the corresponding handle.
leaf_config | the leaf handle to be queried |
name | the name of the parameter (null terminated) |
val | the value to set |
gn_err_t gn_leaf_param_init_double | ( | const gn_leaf_handle_t | leaf_config, |
const char * | name, | ||
double | val | ||
) |
init the parameter with new value and stores in NVS flash, overwriting previous values
the leaf must be not initialized to have an effect. the parameter value will be copied to the corresponding handle.
leaf_config | the leaf handle to be queried |
name | the name of the parameter (null terminated) |
val | the value to set |
gn_err_t gn_leaf_param_init_string | ( | const gn_leaf_handle_t | leaf_config, |
const char * | name, | ||
const char * | val | ||
) |
init the parameter with new value and stores in NVS flash, overwriting previous values
the leaf must be not initialized to have an effect. the parameter value will be copied to the corresponding handle.
leaf_config | the leaf handle to be queried |
name | the name of the parameter (null terminated) |
val | the value to set |
gn_err_t gn_leaf_param_set_bool | ( | const gn_leaf_handle_t | leaf_config, |
const char * | name, | ||
bool | val | ||
) |
generate a request to update the parameter to the leaf.
It inform the leaf that a parameter should be changed. Think of it as it would be requested by the network. It is the basis of inter-leaves messaging.
leaf_config | the leaf to ask |
name | the parameter name to change |
val | the value to change @return GN_RET_ERR_LEAF_NOT_FOUND if the leaf is not found @return GN_RET_ERR_INVALID_ARG in case of input parameter error @return GN_RET_ERR_LEAF_PARAM_ACCESS_VIOLATION in case the parameter access is not write enable |
gn_err_t gn_leaf_param_set_double | ( | const gn_leaf_handle_t | leaf_config, |
const char * | name, | ||
double | val | ||
) |
generate a request to update the parameter to the leaf.
It inform the leaf that a parameter should be changed. Think of it as it would be requested by the network. It is the basis of inter-leaves messaging.
leaf_config | the leaf to ask |
name | the parameter name to change |
val | the value to change @return GN_RET_ERR_LEAF_NOT_FOUND if the leaf is not found @return GN_RET_ERR_INVALID_ARG in case of input parameter error @return GN_RET_ERR_LEAF_PARAM_ACCESS_VIOLATION in case the parameter access is not write enable |
gn_err_t gn_leaf_param_set_string | ( | const gn_leaf_handle_t | leaf_config, |
const char * | name, | ||
char * | val | ||
) |
generate a request to update the parameter to the leaf.
It inform the leaf that a parameter should be changed. Think of it as it would be requested by the network. It is the basis of inter-leaves messaging.
leaf_config | the leaf to ask |
name | the parameter name to change |
val | the value to change @return GN_RET_ERR_LEAF_NOT_FOUND if the leaf is not found @return GN_RET_ERR_INVALID_ARG in case of input parameter error @return GN_RET_ERR_LEAF_PARAM_ACCESS_VIOLATION in case the parameter access is not write enable |
gn_err_t gn_leaf_param_write | ( | const gn_leaf_param_handle_t | param_handle, |
const void * | value | ||
) |
@brief updates the parameter with new value
this is calling the gn_leaf_parameter_write_XXX depending on the param handle type, so be careful in order to avoid memory leaks
@param leaf_config the leaf handle to be queried @param value the pointer to value to set ( in case of string, null terminated) @return GN_RET_OK if the parameter is set @return GN_RET_ERR_INVALID_ARG in case of input errors
gn_err_t gn_leaf_param_write_bool | ( | const gn_leaf_handle_t | leaf_config, |
const char * | name, | ||
bool | val | ||
) |
updates the parameter with new value
the parameter value will be copied to the corresponding handle. after the change the parameter change will be propagated to the event system through a GN_LEAF_PARAM_CHANGED_EVENT and to the server.
leaf_config | the leaf handle to be queried |
name | the name of the parameter (null terminated) |
val | the value to set (null terminated) |
gn_err_t gn_leaf_param_write_double | ( | const gn_leaf_handle_t | leaf_config, |
const char * | name, | ||
double | val | ||
) |
updates the parameter with new value
the leaf must be already initialized to have an effect. the parameter value will be copied to the corresponding handle. after the change the parameter change will be propagated to the event system through a GN_LEAF_PARAM_CHANGED_EVENT and to the server.
leaf_config | the leaf handle to be queried |
name | the name of the parameter (null terminated) |
val | the value to set |
gn_err_t gn_leaf_param_write_string | ( | const gn_leaf_handle_t | leaf_config, |
const char * | name, | ||
char * | val | ||
) |
updates the parameter with new value
the parameter value will be copied to the corresponding handle. after the change the parameter change will be propagated to the event system through a GN_LEAF_PARAM_CHANGED_EVENT and to the server.
leaf_config | the leaf handle to be queried |
name | the name of the parameter (null terminated) |
val | the value to set (null terminated) |
gn_err_t gn_log | ( | char * | log_tag, |
gn_log_level_t | level, | ||
const char * | message, | ||
... | |||
) |
write ESP log, send log in the event queue and publish in network
log_tag | log level, will be the TAG in ESP logging framework |
level | grownode log level |
message | the null terminated message to log @return GN_RET_OK if event is dispatched @return GN_RET_ERR if the event dispatch encounters a problem @return GN_RET_ERR_INVALID_ARG if message is NULL or zero length |
gn_server_status_t gn_mqtt_get_status | ( | ) |
gn_node_handle_t gn_node_create | ( | gn_config_handle_t | config, |
const char * | name | ||
) |
create a new node with specified configuration and name
config | the config handle to use |
name | name of the node. MUST BE null terminated |
gn_err_t gn_node_destroy | ( | gn_node_handle_t | node | ) |
removes the node from the config
node | the node to be removed |
esp_event_loop_handle_t gn_node_get_event_loop | ( | gn_node_handle_t | node | ) |
retrieves the event loop from the node
node | the node handle |
gn_err_t gn_node_get_name | ( | gn_node_handle_t | node_config, |
char * | name | ||
) |
gets the name of the node referenced by the handle
node_config | the handle to be queried |
name | the pointer where the name will be set. set lenght to GN_LEAF_NAME_SIZE |
size_t gn_node_get_size | ( | gn_node_handle_t | node_config | ) |
number of leaves into the node
node_config | the node to be inspected |
gn_err_t gn_node_start | ( | gn_node_handle_t | node | ) |
starts the node by starting the leaves tasks
At the end of the process, it sets the node status to GN_CONFIG_STATUS_STARTED and sends a GN_NODE_STARTED_EVENT event
node | the node to be started |
gn_err_t gn_reboot | ( | ) |
reboot the board
gn_err_t gn_reset | ( | ) |
reset the flash content and restart the board immediately
gn_err_t gn_send_leaf_param_change_message | ( | const char * | leaf_name, |
const char * | param_name, | ||
const void * | message, | ||
size_t | message_len | ||
) |
send a request to change a parameter name
It sends a GN_LEAF_PARAM_CHANGE_REQUEST_EVENT to the leaf parameter, if the parameter is modifiable
leaf_name | the leaf name (null terminated) to send the request to |
param_name | the parameter name to change (null terminated) |
message | a pointer to the payload |
message_len | size of the payload |
gn_err_t gn_send_node_leaf_param_status | ( | const gn_node_handle_t | _node_config | ) |
send parameter status per each parameter
_node_config | the config |
gn_err_t gn_storage_get | ( | const char * | key, |
void ** | value | ||
) |
retrieves the key from the NVS flash
internally, this is implemented by retrieving raw bytes to the flash storage
key | name (null terminated) |
value | pointer where the pointer of the data acquired will be stored |
gn_err_t gn_storage_set | ( | const char * | key, |
const void * | value, | ||
size_t | required_size | ||
) |
stores the key into the NVS flash
internally, this is implemented by copying raw bytes to the flash storage
key | name (null terminated) |
value | pointer to data |
required_size | bytes to write |