GrowNode
gn_commons.h File Reference

General structures and functions. More...

Data Structures

struct  gn_config_init_param_t
 
struct  gn_leaf_parameter_event_t
 
struct  gn_node_event_t
 
struct  gn_leaf_descriptor_t
 this represents the description and status informations of the leaf More...
 
union  gn_val_t
 holds the parameter value More...
 

Macros

#define GN_NODE_NAME_SIZE   32
 
#define GN_LEAF_NAME_SIZE   32
 
#define GN_LEAF_PARAM_NAME_SIZE   32
 
#define GN_LEAF_DATA_SIZE   512
 
#define GN_NODE_DATA_SIZE   512
 
#define GN_LEAF_DESC_TYPE_SIZE   32
 

Typedefs

typedef struct gn_config_init_param_tgn_config_init_param_handle_t
 
typedef void * gn_leaf_handle_t
 
typedef void * gn_node_handle_t
 
typedef void * gn_config_handle_t
 
typedef void * gn_display_container_t
 
typedef gn_leaf_parameter_event_tgn_leaf_parameter_event_handle_t
 
typedef gn_node_event_tgn_node_event_handle_t
 
typedef void(* gn_leaf_task_callback) (gn_leaf_handle_t leaf_config)
 
typedef gn_leaf_descriptor_tgn_leaf_descriptor_handle_t
 
typedef gn_leaf_descriptor_handle_t(* gn_leaf_config_callback) (gn_leaf_handle_t leaf_config)
 
typedef void * gn_leaf_param_handle_t
 

Enumerations

enum  gn_node_status_t {
  GN_NODE_STATUS_NOT_INITIALIZED = 0 , GN_NODE_STATUS_INITIALIZING = 1 , GN_NODE_STATUS_ERROR = 2 , GN_NODE_STATUS_NETWORK_ERROR = 3 ,
  GN_NODE_STATUS_SERVER_ERROR = 4 , GN_NODE_STATUS_READY_TO_START = 5 , GN_NODE_STATUS_STARTED = 6 , GN_NODE_STATUS_ERROR_MISSING_FIRMWARE_URL = 7 ,
  GN_NDOE_STATUS_ERROR_MISSING_PROVISIONING_PASSWORD = 8 , GN_NODE_STATUS_ERROR_MISSING_SERVER_BASE_TOPIC = 9 , GN_NODE_STATUS_ERROR_MISSING_SERVER_URL = 10 , GN_NODE_STATUS_ERROR_BAD_SERVER_KEEPALIVE_SEC = 11 ,
  GN_NODE_STATUS_ERROR_MISSING_SNTP_URL = 12 , GN_NODE_STATUS_ERROR_MISSING_SERVER_DISCOVERY_PREFIX = 13
}
 
enum  gn_server_status_t { GN_SERVER_CONNECTED , GN_SERVER_DISCONNECTED }
 
enum  gn_err_t {
  GN_RET_OK = 0 , GN_RET_ERR = -1 , GN_RET_ERR_INVALID_ARG = 0x201 , GN_RET_ERR_LEAF_NOT_STARTED = 0x202 ,
  GN_RET_ERR_NODE_NOT_STARTED = 0x203 , GN_RET_ERR_LEAF_PARAM_ACCESS_VIOLATION = 0x204 , GN_RET_ERR_EVENT_LOOP_ERROR = 0x205 , GN_RET_ERR_LEAF_NOT_FOUND = 0x206 ,
  GN_RET_ERR_EVENT_NOT_SENT = 0x207 , GN_RET_ERR_MQTT_SUBSCRIBE = 0x208 , GN_RET_ERR_MQTT_ERROR = 0x209
}
 error codes that the grownode functions can return. More...
 
enum  gn_leaf_param_validator_result_t {
  GN_LEAF_PARAM_VALIDATOR_PASSED = 0x000 , GN_LEAF_PARAM_VALIDATOR_ERROR_ABOVE_MAX = 0x001 , GN_LEAF_PARAM_VALIDATOR_ERROR_BELOW_MIN = 0x002 , GN_LEAF_PARAM_VALIDATOR_ERROR_NOT_ALLOWED = 0x100 ,
  GN_LEAF_PARAM_VALIDATOR_ERROR_GENERIC = 0x101 , GN_LEAF_PARAM_VALIDATOR_PASSED_CHANGED = 0x200
}
 result of a validation function run More...
 
enum  gn_log_level_t { GN_LOG_DEBUG = ESP_LOG_DEBUG , GN_LOG_INFO = ESP_LOG_INFO , GN_LOG_WARNING = ESP_LOG_WARN , GN_LOG_ERROR = ESP_LOG_ERROR }
 
enum  gn_leaf_status_t { GN_LEAF_STATUS_NOT_INITIALIZED = 0 , GN_LEAF_STATUS_INITIALIZED = 1 , GN_LEAF_STATUS_ERROR = 2 }
 status of the leaf More...
 
enum  gn_val_type_t { GN_VAL_TYPE_STRING , GN_VAL_TYPE_BOOLEAN , GN_VAL_TYPE_DOUBLE }
 type of parameters available More...
 
enum  gn_leaf_param_access_type_t { GN_LEAF_PARAM_ACCESS_ALL = 0x01 , GN_LEAF_PARAM_ACCESS_NETWORK = 0x02 , GN_LEAF_PARAM_ACCESS_NODE = 0x03 , GN_LEAF_PARAM_ACCESS_NODE_INTERNAL = 0x04 }
 
enum  gn_leaf_param_storage_t { GN_LEAF_PARAM_STORAGE_PERSISTED , GN_LEAF_PARAM_STORAGE_VOLATILE }
 

Functions

size_t gn_leaf_event_mask_param (gn_leaf_parameter_event_handle_t evt, gn_leaf_param_handle_t param)
 
uint64_t gn_hash (const char *key)
 
void gn_hash_str (const char *key, char *buf, size_t len)
 
gn_leaf_param_validator_result_t gn_validator_double_positive (gn_leaf_param_handle_t param, void **param_value)
 
gn_leaf_param_validator_result_t gn_validator_double (gn_leaf_param_handle_t param, void **param_value)
 
gn_leaf_param_validator_result_t gn_validator_boolean (gn_leaf_param_handle_t param, void **param_value)
 

Variables

static const int16_t GN_CONFIG_MAX_SERVER_KEEPALIVE_SEC = 3600
 maximum time between two keepalive messages More...
 
const char * gn_config_status_descriptions [14]
 

Detailed Description

General structures and functions.

Macro Definition Documentation

◆ GN_LEAF_DATA_SIZE

#define GN_LEAF_DATA_SIZE   512

◆ GN_LEAF_DESC_TYPE_SIZE

#define GN_LEAF_DESC_TYPE_SIZE   32

◆ GN_LEAF_NAME_SIZE

#define GN_LEAF_NAME_SIZE   32

◆ GN_LEAF_PARAM_NAME_SIZE

#define GN_LEAF_PARAM_NAME_SIZE   32

◆ GN_NODE_DATA_SIZE

#define GN_NODE_DATA_SIZE   512

◆ GN_NODE_NAME_SIZE

#define GN_NODE_NAME_SIZE   32

Typedef Documentation

◆ gn_config_handle_t

typedef void* gn_config_handle_t

◆ gn_config_init_param_handle_t

◆ gn_display_container_t

typedef void* gn_display_container_t

◆ gn_leaf_config_callback

typedef gn_leaf_descriptor_handle_t(* gn_leaf_config_callback) (gn_leaf_handle_t leaf_config)

this is the leaf configuration callback. every leaf must implement one. it configures internal parameters and returns a leaf config

◆ gn_leaf_descriptor_handle_t

◆ gn_leaf_handle_t

typedef void* gn_leaf_handle_t

◆ gn_leaf_param_handle_t

typedef void* gn_leaf_param_handle_t

◆ gn_leaf_parameter_event_handle_t

◆ gn_leaf_task_callback

typedef void(* gn_leaf_task_callback) (gn_leaf_handle_t leaf_config)

◆ gn_node_event_handle_t

◆ gn_node_handle_t

typedef void* gn_node_handle_t

Enumeration Type Documentation

◆ gn_err_t

enum gn_err_t

error codes that the grownode functions can return.

The GN_RET_OK and GN_RET_ERR are mapped like ESP_OK and ESP_FAIL for compatibility across platforms

Enumerator
GN_RET_OK 

Everything went OK

GN_RET_ERR 

General error

GN_RET_ERR_INVALID_ARG 
GN_RET_ERR_LEAF_NOT_STARTED 

Not possible to start leaf

GN_RET_ERR_NODE_NOT_STARTED 
GN_RET_ERR_LEAF_PARAM_ACCESS_VIOLATION 

eg. parameter had no write access

GN_RET_ERR_EVENT_LOOP_ERROR 

impossible to send message to event loop

GN_RET_ERR_LEAF_NOT_FOUND 
GN_RET_ERR_EVENT_NOT_SENT 
GN_RET_ERR_MQTT_SUBSCRIBE 
GN_RET_ERR_MQTT_ERROR 

◆ gn_leaf_param_access_type_t

Enumerator
GN_LEAF_PARAM_ACCESS_ALL 

param can be modified both by the node and network (eg. local configuration settings)

GN_LEAF_PARAM_ACCESS_NETWORK 

param can be modified only by network (eg. configuration settings from environment)

GN_LEAF_PARAM_ACCESS_NODE 

param can be modified only by the node (eg. sensor data)

GN_LEAF_PARAM_ACCESS_NODE_INTERNAL 

param can be modified only by the node (eg. sensor data) and it is not shown externally

◆ gn_leaf_param_storage_t

Enumerator
GN_LEAF_PARAM_STORAGE_PERSISTED 

param is stored in NVS flash every time it changes

GN_LEAF_PARAM_STORAGE_VOLATILE 

◆ gn_leaf_param_validator_result_t

result of a validation function run

Enumerator
GN_LEAF_PARAM_VALIDATOR_PASSED 

value is compliant

GN_LEAF_PARAM_VALIDATOR_ERROR_ABOVE_MAX 

value is over the maximum limit

GN_LEAF_PARAM_VALIDATOR_ERROR_BELOW_MIN 

value is below the minimum limit

GN_LEAF_PARAM_VALIDATOR_ERROR_NOT_ALLOWED 

value is not allowed for other reasons

GN_LEAF_PARAM_VALIDATOR_ERROR_GENERIC 

algorithm has returned an error

GN_LEAF_PARAM_VALIDATOR_PASSED_CHANGED 

value was not allowed but has been modified by the validator to be compliant

◆ gn_leaf_status_t

status of the leaf

Enumerator
GN_LEAF_STATUS_NOT_INITIALIZED 
GN_LEAF_STATUS_INITIALIZED 
GN_LEAF_STATUS_ERROR 

◆ gn_log_level_t

Enumerator
GN_LOG_DEBUG 
GN_LOG_INFO 
GN_LOG_WARNING 
GN_LOG_ERROR 

◆ gn_node_status_t

Enumerator
GN_NODE_STATUS_NOT_INITIALIZED 
GN_NODE_STATUS_INITIALIZING 
GN_NODE_STATUS_ERROR 
GN_NODE_STATUS_NETWORK_ERROR 
GN_NODE_STATUS_SERVER_ERROR 
GN_NODE_STATUS_READY_TO_START 
GN_NODE_STATUS_STARTED 
GN_NODE_STATUS_ERROR_MISSING_FIRMWARE_URL 
GN_NDOE_STATUS_ERROR_MISSING_PROVISIONING_PASSWORD 
GN_NODE_STATUS_ERROR_MISSING_SERVER_BASE_TOPIC 
GN_NODE_STATUS_ERROR_MISSING_SERVER_URL 
GN_NODE_STATUS_ERROR_BAD_SERVER_KEEPALIVE_SEC 
GN_NODE_STATUS_ERROR_MISSING_SNTP_URL 
GN_NODE_STATUS_ERROR_MISSING_SERVER_DISCOVERY_PREFIX 

◆ gn_server_status_t

Enumerator
GN_SERVER_CONNECTED 
GN_SERVER_DISCONNECTED 

◆ gn_val_type_t

type of parameters available

Enumerator
GN_VAL_TYPE_STRING 

character array, user defined dimension

GN_VAL_TYPE_BOOLEAN 

true/false

GN_VAL_TYPE_DOUBLE 

floating point with sign

Function Documentation

◆ gn_hash()

uint64_t gn_hash ( const char *  key)
inline

◆ gn_hash_str()

void gn_hash_str ( const char *  key,
char *  buf,
size_t  len 
)
inline

◆ gn_leaf_event_mask_param()

size_t gn_leaf_event_mask_param ( gn_leaf_parameter_event_handle_t  evt,
gn_leaf_param_handle_t  param 
)
inline

◆ gn_validator_boolean()

gn_leaf_param_validator_result_t gn_validator_boolean ( gn_leaf_param_handle_t  param,
void **  param_value 
)

◆ gn_validator_double()

gn_leaf_param_validator_result_t gn_validator_double ( gn_leaf_param_handle_t  param,
void **  param_value 
)

◆ gn_validator_double_positive()

gn_leaf_param_validator_result_t gn_validator_double_positive ( gn_leaf_param_handle_t  param,
void **  param_value 
)

Variable Documentation

◆ GN_CONFIG_MAX_SERVER_KEEPALIVE_SEC

const int16_t GN_CONFIG_MAX_SERVER_KEEPALIVE_SEC = 3600
static

maximum time between two keepalive messages

◆ gn_config_status_descriptions

const char* gn_config_status_descriptions[14]