Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
Flow Based Programming

The flow system consists of a series of connected nodes that send packets to each other via ports. More...

Modules

 Flow Builder
 Flow-builder is a helper component that creates nodes and connections specs with a friendly API.
 
 Flow Inspector
 Soletta flow's runtime inspector.
 
 Flow Packet
 Flow packet is the fundamental data structure used to pass information between nodes in a flow.
 
 Flow Parser
 The Flow Parser is used to transform a textual description (either FBP or other metatypes) into node types that can be used in a flow.
 
 Flow's Simple C Type
 Helper to create a flow node type from a simple C function.
 
 Resolver
 A Resolver matches type names to an actual node_type and possibly a companion options.
 
 Single Flow
 Single flow is a parent node that creates a single children that works stand alone.
 
 Static Flow
 Static flow is a parent node that creates its children nodes and routes packets between them.
 

Data Structures

struct  sol_flow_node_container_type
 Structure of Container Node. More...
 
struct  sol_flow_node_named_options
 Named options is an intermediate structure to handle Node Options parsing. More...
 
struct  sol_flow_node_named_options_member
 Structure of a Options Member. More...
 
struct  sol_flow_node_options
 Node options are a set of attributes defined by the Node Type that can change the behavior of a Node. More...
 
struct  sol_flow_node_type
 The node type describes the capabilities and operations of a node. More...
 
struct  sol_flow_port_type_in
 Node's Input port structure. More...
 
struct  sol_flow_port_type_out
 Node's Output port structure. More...
 

Macros

#define sol_flow_get_node_type(_mod, _type, _var)   ({ (*(_var)) = &_type; 0; })
 Gets the specified node type, loading the necessary module if required. More...
 
#define sol_flow_get_packet_type(_mod, _type, _var)   ({ (*(_var)) = _type; 0; })
 Gets the specified packet type, loading the necessary module if required. More...
 
#define SOL_FLOW_NODE_PORT_ERROR_NAME   ("ERROR")
 Error port identifier. More...
 

Typedefs

typedef struct sol_flow_node sol_flow_node
 A node is an entity that has input/output ports. More...
 
typedef struct
sol_flow_node_container_type 
sol_flow_node_container_type
 Structure of Container Node. More...
 
typedef struct
sol_flow_node_named_options 
sol_flow_node_named_options
 Named options is an intermediate structure to handle Node Options parsing. More...
 
typedef struct
sol_flow_node_named_options_member 
sol_flow_node_named_options_member
 Structure of a Options Member. More...
 
typedef struct
sol_flow_node_options 
sol_flow_node_options
 Node options are a set of attributes defined by the Node Type that can change the behavior of a Node. More...
 
typedef struct sol_flow_node_type sol_flow_node_type
 The node type describes the capabilities and operations of a node. More...
 
typedef struct
sol_flow_port_type_in 
sol_flow_port_type_in
 Node's Input port structure. More...
 
typedef struct
sol_flow_port_type_out 
sol_flow_port_type_out
 Node's Output port structure. More...
 

Enumerations

enum  sol_flow_node_options_member_type {
  SOL_FLOW_NODE_OPTIONS_MEMBER_UNKNOWN, SOL_FLOW_NODE_OPTIONS_MEMBER_BOOL, SOL_FLOW_NODE_OPTIONS_MEMBER_BYTE, SOL_FLOW_NODE_OPTIONS_MEMBER_DIRECTION_VECTOR,
  SOL_FLOW_NODE_OPTIONS_MEMBER_DRANGE_SPEC, SOL_FLOW_NODE_OPTIONS_MEMBER_FLOAT, SOL_FLOW_NODE_OPTIONS_MEMBER_INT, SOL_FLOW_NODE_OPTIONS_MEMBER_IRANGE_SPEC,
  SOL_FLOW_NODE_OPTIONS_MEMBER_RGB, SOL_FLOW_NODE_OPTIONS_MEMBER_STRING
}
 Possible types for option attributes (or members). More...
 
enum  sol_flow_node_type_flags { SOL_FLOW_NODE_TYPE_FLAGS_CONTAINER = (1 << 0) }
 Flags used to set some sol_flow_node_type characteristics. More...
 

Functions

void sol_flow_node_del (struct sol_flow_node *node)
 Deletes a node. More...
 
const char * sol_flow_node_get_id (const struct sol_flow_node *node)
 Retrieves the node ID string. More...
 
const struct sol_flow_nodesol_flow_node_get_parent (const struct sol_flow_node *node)
 Gets the node's parent. More...
 
void * sol_flow_node_get_private_data (const struct sol_flow_node *node)
 Retrieves a node private data. More...
 
const struct sol_flow_node_typesol_flow_node_get_type (const struct sol_flow_node *node)
 Get a node's type. More...
 
void sol_flow_node_named_options_fini (struct sol_flow_node_named_options *named_opts)
 Finalize named options. More...
 
int sol_flow_node_named_options_init_from_strv (struct sol_flow_node_named_options *named_opts, const struct sol_flow_node_type *type, const char *const *strv)
 Initializes a Named options structure from a options string. More...
 
struct sol_flow_nodesol_flow_node_new (struct sol_flow_node *parent, const char *id, const struct sol_flow_node_type *type, const struct sol_flow_node_options *options)
 Creates a new node. More...
 
void sol_flow_node_options_del (const struct sol_flow_node_type *type, struct sol_flow_node_options *options)
 Delete an options handle. More...
 
enum
sol_flow_node_options_member_type 
sol_flow_node_options_member_type_from_string (const char *data_type)
 Returns the option member type which name is data_type. More...
 
const char * sol_flow_node_options_member_type_to_str (enum sol_flow_node_options_member_type type)
 Returns a string for the name of a given option member type. More...
 
int sol_flow_node_options_new (const struct sol_flow_node_type *type, const struct sol_flow_node_named_options *named_opts, struct sol_flow_node_options **out_opts)
 Creates a new Node Options. More...
 
void sol_flow_node_options_strv_del (char **opts_strv)
 Delete a key-value options array. More...
 
void sol_flow_node_type_del (struct sol_flow_node_type *type)
 Delete a node type. More...
 
const struct
sol_flow_port_type_in
sol_flow_node_type_get_port_in (const struct sol_flow_node_type *type, uint16_t port)
 Get a node type's input port definition struct, given a port index. More...
 
const struct
sol_flow_port_type_out
sol_flow_node_type_get_port_out (const struct sol_flow_node_type *type, uint16_t port)
 Get a node type's output port definition struct, given a port index. More...
 
int sol_flow_send_blob_packet (struct sol_flow_node *src, uint16_t src_port, const struct sol_blob *value)
 Convenience function to create and send a Blob packet. More...
 
int sol_flow_send_bool_packet (struct sol_flow_node *src, uint16_t src_port, unsigned char value)
 Convenience function to create and send a Boolean packet. More...
 
int sol_flow_send_byte_packet (struct sol_flow_node *src, uint16_t src_port, unsigned char value)
 Convenience function to create and send a Byte packet. More...
 
int sol_flow_send_composed_packet (struct sol_flow_node *src, uint16_t src_port, const struct sol_flow_packet_type *composed_type, struct sol_flow_packet **children)
 Convenience function to create and send a Composed packet. More...
 
int sol_flow_send_direction_vector_components_packet (struct sol_flow_node *src, uint16_t src_port, double x, double y, double z)
 Similar to sol_flow_send_direction_vector_packet(), but takes the vector components as arguments. More...
 
int sol_flow_send_direction_vector_packet (struct sol_flow_node *src, uint16_t src_port, const struct sol_direction_vector *value)
 Convenience function to create and send a Direction Vector packet. More...
 
int sol_flow_send_drange_packet (struct sol_flow_node *src, uint16_t src_port, const struct sol_drange *value)
 Convenience function to create and send a Drange packet. More...
 
int sol_flow_send_drange_value_packet (struct sol_flow_node *src, uint16_t src_port, double value)
 Convenience function to create and send a Drange packet of value value and default spec. More...
 
int sol_flow_send_empty_packet (struct sol_flow_node *src, uint16_t src_port)
 Convenience function to create and send an Empty packet. More...
 
int sol_flow_send_error_packet (struct sol_flow_node *src, int code, const char *msg_fmt,...) SOL_ATTR_PRINTF(3
 Convenience function to create and send an Error packet. More...
 
int int sol_flow_send_error_packet_errno (struct sol_flow_node *src, int code)
 Similar to sol_flow_send_error_packet, but uses a default error message based on code. More...
 
int sol_flow_send_error_packet_str (struct sol_flow_node *src, int code, const char *str)
 Similar to sol_flow_send_error_packet, but the error message is ready to be used. More...
 
int sol_flow_send_http_response_packet (struct sol_flow_node *src, uint16_t src_port, int response_code, const char *url, const char *content_type, const struct sol_blob *content, const struct sol_vector *cookies, const struct sol_vector *headers)
 Convenience function to create and send a HTTP Response packet. More...
 
int sol_flow_send_irange_packet (struct sol_flow_node *src, uint16_t src_port, const struct sol_irange *value)
 Convenience function to create and send an Irange packet. More...
 
int sol_flow_send_irange_value_packet (struct sol_flow_node *src, uint16_t src_port, int32_t value)
 Convenience function to create and send a Irange packet of value value and default spec. More...
 
int sol_flow_send_json_array_packet (struct sol_flow_node *src, uint16_t src_port, const struct sol_blob *value)
 Convenience function to create and send a JSON Array packet. More...
 
int sol_flow_send_json_object_packet (struct sol_flow_node *src, uint16_t src_port, const struct sol_blob *value)
 Convenience function to create and send a JSON Object packet. More...
 
int sol_flow_send_location_components_packet (struct sol_flow_node *src, uint16_t src_port, double lat, double lon, double alt)
 Similar to sol_flow_send_location_packet(), but takes the location components as arguments. More...
 
int sol_flow_send_location_packet (struct sol_flow_node *src, uint16_t src_port, const struct sol_location *value)
 Convenience function to create and send a Location packet. More...
 
int sol_flow_send_packet (struct sol_flow_node *src, uint16_t src_port, struct sol_flow_packet *packet)
 Send a packet from a given node to one of its output ports. More...
 
int sol_flow_send_rgb_components_packet (struct sol_flow_node *src, uint16_t src_port, uint32_t red, uint32_t green, uint32_t blue)
 Similar to sol_flow_send_rgb_packet(), but takes the RGB components as arguments. More...
 
int sol_flow_send_rgb_packet (struct sol_flow_node *src, uint16_t src_port, const struct sol_rgb *value)
 Convenience function to create and send a RGB packet. More...
 
int sol_flow_send_string_packet (struct sol_flow_node *src, uint16_t src_port, const char *value)
 Convenience function to create and send a String packet. More...
 
int sol_flow_send_string_slice_packet (struct sol_flow_node *src, uint16_t src_port, const struct sol_str_slice value)
 Convenience function to create and send a String packet from a string slice. More...
 
int sol_flow_send_string_take_packet (struct sol_flow_node *src, uint16_t src_port, char *value)
 Convenience function to create and send a String packet but takes ownership of value to use as the packet content. More...
 
int sol_flow_send_timestamp_packet (struct sol_flow_node *src, uint16_t src_port, const struct timespec *value)
 Convenience function to create and send a Timestamp packet. More...
 

Detailed Description

The flow system consists of a series of connected nodes that send packets to each other via ports.

Each node may have multiple input/output ports. It is responsibility of the parent (see sol_flow_node_container_type) node to deliver the packets sent by its children nodes (one thing the "static flow" node, returned by sol_flow_static_new(), already does).

Macro Definition Documentation

#define sol_flow_get_node_type (   _mod,
  _type,
  _var 
)    ({ (*(_var)) = &_type; 0; })

Gets the specified node type, loading the necessary module if required.

Checks if the node type _type is built-in, if not, it loads the module _mod and fetches the type's symbol there. The result is stored in _var.

Parameters
_modThe name of the module to load if the symbol is not built-in.
_typeThe node type's symbol.
_varVariable where to store the type.
Returns
0 on success, < 0 on error.
Examples:
/src/samples/flow/c-api/lowlevel.c, and /src/samples/flow/c-api/single-node.c.

Referenced by create_minutes(), create_seconds(), and startup().

#define sol_flow_get_packet_type (   _mod,
  _type,
  _var 
)    ({ (*(_var)) = _type; 0; })

Gets the specified packet type, loading the necessary module if required.

Checks if the node type _type is built-in, if not, it loads the module _mod and fetches the packet's symbol there. The result is stored in _var.

Parameters
_modThe name of the module to load if the packet is not built-in.
_typeThe packet type's symbol.
_varVariable where to store the type.
Returns
0 on success, < 0 on error.
#define SOL_FLOW_NODE_PORT_ERROR_NAME   ("ERROR")

Error port identifier.

Typedef Documentation

A node is an entity that has input/output ports.

Its operations are described by a node type, so that the node can be seen as a class instance, being the node type the class.

Nodes receive packets in their input ports and can send packets to their output ports.

Structure of Container Node.

When a node type is a container (i.e. may act as parent of other nodes), it should provide extra operations. This is the case of the "static flow" node.

Named options is an intermediate structure to handle Node Options parsing.

Used to help the options parser to parse an options string.

Structure of a Options Member.

Node options are a set of attributes defined by the Node Type that can change the behavior of a Node.

The node type describes the capabilities and operations of a node.

So a node can be seen as a class instance, being the node type the class.

This description is usually defined as const static and shared by many different nodes.

Node's Input port structure.

Node's Output port structure.

Enumeration Type Documentation

Possible types for option attributes (or members).

Enumerator
SOL_FLOW_NODE_OPTIONS_MEMBER_UNKNOWN 
SOL_FLOW_NODE_OPTIONS_MEMBER_BOOL 
SOL_FLOW_NODE_OPTIONS_MEMBER_BYTE 
SOL_FLOW_NODE_OPTIONS_MEMBER_DIRECTION_VECTOR 
SOL_FLOW_NODE_OPTIONS_MEMBER_DRANGE_SPEC 
SOL_FLOW_NODE_OPTIONS_MEMBER_FLOAT 
SOL_FLOW_NODE_OPTIONS_MEMBER_INT 
SOL_FLOW_NODE_OPTIONS_MEMBER_IRANGE_SPEC 
SOL_FLOW_NODE_OPTIONS_MEMBER_RGB 
SOL_FLOW_NODE_OPTIONS_MEMBER_STRING 

Flags used to set some sol_flow_node_type characteristics.

Enumerator
SOL_FLOW_NODE_TYPE_FLAGS_CONTAINER 

Flag to set the node as Container (a "static flow" node is an example)

Function Documentation

void sol_flow_node_del ( struct sol_flow_node node)

Deletes a node.

The root node should be deleted in the sol_main_callbacks::shutdown function – it will take care of recursively deleting its children nodes.

Parameters
nodeThe node to be deleted
Examples:
/src/samples/flow/c-api/highlevel.c, /src/samples/flow/c-api/lowlevel.c, /src/samples/flow/c-api/simple-c-type.c, and /src/samples/flow/c-api/single-node.c.

Referenced by shutdown().

const char* sol_flow_node_get_id ( const struct sol_flow_node node)

Retrieves the node ID string.

As given to the node on sol_flow_node_new()

Parameters
nodeThe Node
Returns
The Node ID on success, NULL otherwise.
const struct sol_flow_node* sol_flow_node_get_parent ( const struct sol_flow_node node)

Gets the node's parent.

Parameters
nodeThe node to get the parent from
Returns
The parent node of node, NULL if node is the top/root node.
void* sol_flow_node_get_private_data ( const struct sol_flow_node node)

Retrieves a node private data.

Private data is the data allocated by the system for each node, whose size is described by data_size attribute of the node's type.

Parameters
nodeThe Node
Examples:
/src/samples/flow/c-api/custom-node-types.c, and /src/samples/flow/c-api/simple-c-type.c.

Referenced by on_timeout(), and reader_on_timeout().

const struct sol_flow_node_type* sol_flow_node_get_type ( const struct sol_flow_node node)

Get a node's type.

Parameters
nodeThe node get the type from
Returns
The node type of node or NULL, on errors
Examples:
/src/samples/flow/c-api/single-node.c.

Referenced by get_int32_packet_and_log().

void sol_flow_node_named_options_fini ( struct sol_flow_node_named_options named_opts)

Finalize named options.

Parameters
named_optsNamed options to be finalized
Examples:
/src/samples/flow/c-api/find-type.c, and /src/samples/flow/c-api/single-node.c.

Referenced by create_minutes(), create_seconds(), and show_resolved_type().

int sol_flow_node_named_options_init_from_strv ( struct sol_flow_node_named_options named_opts,
const struct sol_flow_node_type type,
const char *const *  strv 
)

Initializes a Named options structure from a options string.

Parameters
named_optsNamed Options to be initialized
typeThe Node Type
strvOptions string used to initialize the Named Options
Returns
0 on success, a negative error code on errors
Examples:
/src/samples/flow/c-api/single-node.c.

Referenced by create_minutes(), and create_seconds().

struct sol_flow_node* sol_flow_node_new ( struct sol_flow_node parent,
const char *  id,
const struct sol_flow_node_type type,
const struct sol_flow_node_options options 
)

Creates a new node.

Nodes should be created in the sol_main_callbacks::startup function, and at least the root one must be a "static flow" node. (

See Also
sol_flow_static_new(), sol_flow_builder_get_node_type() and sol_flow_static_new_type()).
Parameters
parentThe parent node. Pass NULL if you're creating the root node of the flow.
idA string to identify the node
typeThe type of the node
optionsOptions to individually parametrize the type instance (
See Also
sol_flow_node_options_new())
Returns
A new node instance on success, otherwise NULL
Examples:
/src/samples/flow/c-api/highlevel.c, and /src/samples/flow/c-api/simple-c-type.c.

Referenced by startup().

void sol_flow_node_options_del ( const struct sol_flow_node_type type,
struct sol_flow_node_options options 
)

Delete an options handle.

Parameters
typeThe node type
optionsThe node options
Examples:
/src/samples/flow/c-api/single-node.c.

Referenced by create_minutes(), and create_seconds().

enum sol_flow_node_options_member_type sol_flow_node_options_member_type_from_string ( const char *  data_type)

Returns the option member type which name is data_type.

Parameters
data_typeName of the option member type
Returns
Option member type which name is data_type or SOL_FLOW_NODE_OPTIONS_MEMBER_UNKNOWN if not found
const char* sol_flow_node_options_member_type_to_str ( enum sol_flow_node_options_member_type  type)

Returns a string for the name of a given option member type.

Parameters
typeType to be named
Returns
String of the type's name, NULL on errors
int sol_flow_node_options_new ( const struct sol_flow_node_type type,
const struct sol_flow_node_named_options named_opts,
struct sol_flow_node_options **  out_opts 
)

Creates a new Node Options.

Parameters
typeThe Node Type
named_optsNamed Options to parse
out_optsThe final Node Options
Returns
0 on success, a negative error code on errors
Examples:
/src/samples/flow/c-api/single-node.c.

Referenced by create_minutes(), and create_seconds().

void sol_flow_node_options_strv_del ( char **  opts_strv)

Delete a key-value options array.

Parameters
opts_strvOptions array to be deleted
See Also
sol_flow_resolve_strv
void sol_flow_node_type_del ( struct sol_flow_node_type type)

Delete a node type.

It should be used only for types dynamically created and returned by functions like sol_flow_static_new_type().

Parameters
typeThe node type to be deleted
Examples:
/src/samples/flow/c-api/highlevel.c, and /src/samples/flow/c-api/simple-c-type.c.

Referenced by shutdown().

const struct sol_flow_port_type_in* sol_flow_node_type_get_port_in ( const struct sol_flow_node_type type,
uint16_t  port 
)

Get a node type's input port definition struct, given a port index.

Parameters
typeThe node type to get a port definition from
portThe port's index to retrieve
Returns
The input port's definition struct or NULL, on errors.
const struct sol_flow_port_type_out* sol_flow_node_type_get_port_out ( const struct sol_flow_node_type type,
uint16_t  port 
)

Get a node type's output port definition struct, given a port index.

Parameters
typeThe node type to get a port definition from
portThe port's index to retrieve
Returns
The output port's definition struct or NULL, on errors.
int sol_flow_send_blob_packet ( struct sol_flow_node src,
uint16_t  src_port,
const struct sol_blob value 
)

Convenience function to create and send a Blob packet.

Similar to sol_flow_send_packet(), but specific for Blob packets. It will create a new Blob packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the Blob packet
src_portThe port where the packet will be output
valueBlob packet content
Returns
0 on success, a negative error code on errors.
int sol_flow_send_bool_packet ( struct sol_flow_node src,
uint16_t  src_port,
unsigned char  value 
)

Convenience function to create and send a Boolean packet.

Similar to sol_flow_send_packet(), but specific for Boolean packets. It will create a new Boolean packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the Boolean packet
src_portThe port where the packet will be output
valueBoolean packet content
Returns
0 on success, a negative error code on errors.
Examples:
/src/samples/flow/c-api/custom-node-types.c, /src/samples/flow/c-api/simple-c-type.c, and /src/samples/flow/c-api/single-node.c.

Referenced by isodd(), logic_process(), and on_minutes_packet().

int sol_flow_send_byte_packet ( struct sol_flow_node src,
uint16_t  src_port,
unsigned char  value 
)

Convenience function to create and send a Byte packet.

Similar to sol_flow_send_packet(), but specific for Byte packets. It will create a new Byte packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the Byte packet
src_portThe port where the packet will be output
valueByte packet content
Returns
0 on success, a negative error code on errors.
int sol_flow_send_composed_packet ( struct sol_flow_node src,
uint16_t  src_port,
const struct sol_flow_packet_type composed_type,
struct sol_flow_packet **  children 
)

Convenience function to create and send a Composed packet.

Similar to sol_flow_send_packet(), but specific for Composed packets. It will create a new Composed packet from the composed_type and children and send it through src node at src_port port.

Parameters
srcThe node that is to output the Blob packet
src_portThe port where the packet will be output
composed_typeThe composed packet type
childrenList of children packets
Returns
0 on success, a negative error code on errors.
int sol_flow_send_direction_vector_components_packet ( struct sol_flow_node src,
uint16_t  src_port,
double  x,
double  y,
double  z 
)

Similar to sol_flow_send_direction_vector_packet(), but takes the vector components as arguments.

Parameters
srcThe node that is to output the Direction Vector packet
src_portThe port where the packet will be output
xX value
yY value
zZ value
Returns
0 on success, a negative error code on errors.
See Also
sol_flow_send_direction_vector_packet
int sol_flow_send_direction_vector_packet ( struct sol_flow_node src,
uint16_t  src_port,
const struct sol_direction_vector value 
)

Convenience function to create and send a Direction Vector packet.

Similar to sol_flow_send_packet(), but specific for Direction Vector packets. It will create a new Direction Vector packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the Direction Vector packet
src_portThe port where the packet will be output
valueDirection Vector packet content
Returns
0 on success, a negative error code on errors.
See Also
sol_flow_send_direction_vector_components_packet
int sol_flow_send_drange_packet ( struct sol_flow_node src,
uint16_t  src_port,
const struct sol_drange value 
)

Convenience function to create and send a Drange packet.

Similar to sol_flow_send_packet(), but specific for Drange packets. It will create a new Drange packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the Drange packet
src_portThe port where the packet will be output
valueDrange packet content
Returns
0 on success, a negative error code on errors.
See Also
sol_flow_send_drange_value_packet
int sol_flow_send_drange_value_packet ( struct sol_flow_node src,
uint16_t  src_port,
double  value 
)

Convenience function to create and send a Drange packet of value value and default spec.

Similar to sol_flow_send_drange_packet(), but creates a Drange struct from value and set the default spec to it.

Parameters
srcThe node that is to output the Drange packet
src_portThe port where the packet will be output
valueDesired Drange value
Returns
0 on success, a negative error code on errors.
See Also
sol_flow_send_drange_packet
Examples:
/src/samples/flow/tilt-angle/arctan-node.c.

Referenced by logic_process().

int sol_flow_send_empty_packet ( struct sol_flow_node src,
uint16_t  src_port 
)

Convenience function to create and send an Empty packet.

Similar to sol_flow_send_packet(), but specific for Empty packets. It will create a new Empty packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the Empty packet
src_portThe port where the packet will be output
Returns
0 on success, a negative error code on errors.
int sol_flow_send_error_packet ( struct sol_flow_node src,
int  code,
const char *  msg_fmt,
  ... 
)

Convenience function to create and send an Error packet.

Similar to sol_flow_send_packet(), but specific for Error packets. It will create a new Error packet and send it through src node.

Parameters
srcThe node that is to output the error packet
codeError code
msg_fmtA standard 'printf()' format string. Used to create the error message.
...Arguments to msg_fmt
Returns
0 on success, a negative error code on errors.
int int sol_flow_send_error_packet_errno ( struct sol_flow_node src,
int  code 
)

Similar to sol_flow_send_error_packet, but uses a default error message based on code.

Parameters
srcThe node that is to output the error packet
codeError code
Returns
0 on success, a negative error code on errors.
int sol_flow_send_error_packet_str ( struct sol_flow_node src,
int  code,
const char *  str 
)

Similar to sol_flow_send_error_packet, but the error message is ready to be used.

Parameters
srcThe node that is to output the error packet
codeError code
strError message
Returns
0 on success, a negative error code on errors.
int sol_flow_send_http_response_packet ( struct sol_flow_node src,
uint16_t  src_port,
int  response_code,
const char *  url,
const char *  content_type,
const struct sol_blob content,
const struct sol_vector cookies,
const struct sol_vector headers 
)

Convenience function to create and send a HTTP Response packet.

Similar to sol_flow_send_packet(), but specific for HTTP Response packets. It will create a new HTTP Response packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the HTTP Response packet
src_portThe port where the packet will be output
response_codeThe response code
urlResponse URL
content_typeThe response content type
contentThe response content
cookiesResponse cookies
headersResponse headers
Returns
0 on success, a negative error code on errors.
int sol_flow_send_irange_packet ( struct sol_flow_node src,
uint16_t  src_port,
const struct sol_irange value 
)

Convenience function to create and send an Irange packet.

Similar to sol_flow_send_packet(), but specific for Irange packets. It will create a new Irange packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the Irange packet
src_portThe port where the packet will be output
valueIrange packet content
Returns
0 on success, a negative error code on errors.
See Also
sol_flow_send_irange_value_packet
int sol_flow_send_irange_value_packet ( struct sol_flow_node src,
uint16_t  src_port,
int32_t  value 
)

Convenience function to create and send a Irange packet of value value and default spec.

Similar to sol_flow_send_irange_packet(), but creates a Irange struct from value and set the default spec to it.

Parameters
srcThe node that is to output the Irange packet
src_portThe port where the packet will be output
valueDesired Irange value
Returns
0 on success, a negative error code on errors.
See Also
sol_flow_send_irange_packet
Examples:
/src/samples/flow/c-api/custom-node-types.c.

Referenced by reader_on_timeout(), and reader_open().

int sol_flow_send_json_array_packet ( struct sol_flow_node src,
uint16_t  src_port,
const struct sol_blob value 
)

Convenience function to create and send a JSON Array packet.

Similar to sol_flow_send_packet(), but specific for JSON Array packets. It will create a new JSON Array packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the JSON Array packet
src_portThe port where the packet will be output
valueJSON Array packet content
Returns
0 on success, a negative error code on errors.
int sol_flow_send_json_object_packet ( struct sol_flow_node src,
uint16_t  src_port,
const struct sol_blob value 
)

Convenience function to create and send a JSON Object packet.

Similar to sol_flow_send_packet(), but specific for JSON Object packets. It will create a new JSON Object packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the JSON Object packet
src_portThe port where the packet will be output
valueJSON Object packet content
Returns
0 on success, a negative error code on errors.
int sol_flow_send_location_components_packet ( struct sol_flow_node src,
uint16_t  src_port,
double  lat,
double  lon,
double  alt 
)

Similar to sol_flow_send_location_packet(), but takes the location components as arguments.

Parameters
srcThe node that is to output the Location packet
src_portThe port where the packet will be output
latLatitude value
lonLongitude value
altAltitude value
Returns
0 on success, a negative error code otherwise.
See Also
sol_flow_send_location_packet
int sol_flow_send_location_packet ( struct sol_flow_node src,
uint16_t  src_port,
const struct sol_location value 
)

Convenience function to create and send a Location packet.

Similar to sol_flow_send_packet(), but specific for Location packets. It will create a new Location packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the Location packet
src_portThe port where the packet will be output
valueLocation packet content
Returns
0 on success, a negative error code on errors.
int sol_flow_send_packet ( struct sol_flow_node src,
uint16_t  src_port,
struct sol_flow_packet packet 
)

Send a packet from a given node to one of its output ports.

The parent node of src will take care of routing the packet to the appropriated input ports of connected nodes.

Note
This function takes the ownership of the packet, becoming responsible to release its memory.
There are helper functions that already create a packet of a given type and send it, e. g. sol_flow_send_bool_packet().
Parameters
srcThe node that is to output a packet
src_portThe port where the packet will be output
packetThe packet to output
Returns
0 on success, a negative error code on errors.
int sol_flow_send_rgb_components_packet ( struct sol_flow_node src,
uint16_t  src_port,
uint32_t  red,
uint32_t  green,
uint32_t  blue 
)

Similar to sol_flow_send_rgb_packet(), but takes the RGB components as arguments.

Parameters
srcThe node that is to output the RGB packet
src_portThe port where the packet will be output
redRed value
greenGreen value
blueBlue value
Returns
0 on success, a negative error code on errors.
See Also
sol_flow_send_rgb_packet
int sol_flow_send_rgb_packet ( struct sol_flow_node src,
uint16_t  src_port,
const struct sol_rgb value 
)

Convenience function to create and send a RGB packet.

Similar to sol_flow_send_packet(), but specific for RGB packets. It will create a new RGB packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the RGB packet
src_portThe port where the packet will be output
valueRGB packet content
Returns
0 on success, a negative error code on errors.
See Also
sol_flow_send_rgb_components_packet
int sol_flow_send_string_packet ( struct sol_flow_node src,
uint16_t  src_port,
const char *  value 
)

Convenience function to create and send a String packet.

Similar to sol_flow_send_packet(), but specific for String packets. It will create a new String packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the String packet
src_portThe port where the packet will be output
valueString packet content
Returns
0 on success, a negative error code on errors.
See Also
sol_flow_send_string_slice_packet()
sol_flow_send_string_take_packet()
Examples:
/src/samples/flow/c-api/simple-c-type.c.

Referenced by on_timeout().

int sol_flow_send_string_slice_packet ( struct sol_flow_node src,
uint16_t  src_port,
const struct sol_str_slice  value 
)

Convenience function to create and send a String packet from a string slice.

Similar to sol_flow_send_string_packet(), but takes a sol_str_slice instead of a C string.

Parameters
srcThe node that is to output the String packet
src_portThe port where the packet will be output
valueString slice to create the packet content
Returns
0 on success, a negative error code on errors.
See Also
sol_flow_send_string_packet()
sol_flow_send_string_take_packet()
int sol_flow_send_string_take_packet ( struct sol_flow_node src,
uint16_t  src_port,
char *  value 
)

Convenience function to create and send a String packet but takes ownership of value to use as the packet content.

Instead of copying the initial string to the packets content, takes ownership of value memory.

Warning
The caller should not free value anymore.
Parameters
srcThe node that is to output the String packet
src_portThe port where the packet will be output
valueString packet content
Returns
0 on success, a negative error code on errors.
See Also
sol_flow_send_string_packet()
sol_flow_send_string_slice_packet()
int sol_flow_send_timestamp_packet ( struct sol_flow_node src,
uint16_t  src_port,
const struct timespec *  value 
)

Convenience function to create and send a Timestamp packet.

Similar to sol_flow_send_packet(), but specific for Timestamp packets. It will create a new Timestamp packet and send it through src node at src_port port.

Parameters
srcThe node that is to output the Timestamp packet
src_portThe port where the packet will be output
valueTimestamp packet content
Returns
0 on success, a negative error code on errors.