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
Functions | Variables
single-node.c File Reference

Example how to create and use a single node without an associated flow. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "sol-flow-single.h"
#include "sol-log.h"
#include "sol-util.h"
#include "soletta.h"

Functions

static void create_minutes (void)
 
static void create_seconds (void)
 
static int32_t get_int32_packet_and_log (const struct sol_flow_node *n, uint16_t port, const struct sol_flow_packet *packet)
 
static void on_minutes_packet (void *data, struct sol_flow_node *n, uint16_t port, const struct sol_flow_packet *packet)
 
static void on_seconds_packet (void *data, struct sol_flow_node *n, uint16_t port, const struct sol_flow_packet *packet)
 
static void shutdown (void)
 
 SOL_MAIN_DEFAULT (startup, shutdown)
 
static void startup (void)
 

Variables

static struct sol_flow_nodeminutes
 
static uint16_t minutes_port_enabled
 
static uint16_t minutes_port_out
 
static struct sol_flow_nodeseconds
 
static uint16_t seconds_port_enabled
 
static uint16_t seconds_port_out
 

Detailed Description

Example how to create and use a single node without an associated flow.

This is useful when you need to access a component, send packets to its input ports manually and be notified when it's sending packets on its output ports.

To showcase it we use "wallclock/minute" and "wallclock/second" node types, they use both input and output ports as well as options. Although simple, this is a realistic example since to properly tick at every minute one needs to calculate the expire time to the next minute (not just start a 60s timer) and handle monitoring the system clock for changes.

Function Documentation

static void create_minutes ( void  )
static
static void create_seconds ( void  )
static
static int32_t get_int32_packet_and_log ( const struct sol_flow_node n,
uint16_t  port,
const struct sol_flow_packet packet 
)
static
static void on_minutes_packet ( void *  data,
struct sol_flow_node n,
uint16_t  port,
const struct sol_flow_packet packet 
)
static
static void on_seconds_packet ( void *  data,
struct sol_flow_node n,
uint16_t  port,
const struct sol_flow_packet packet 
)
static
static void shutdown ( void  )
static

References minutes, seconds, and sol_flow_node_del().

SOL_MAIN_DEFAULT ( startup  ,
shutdown   
)
static void startup ( void  )
static

Variable Documentation

struct sol_flow_node* minutes
static
uint16_t minutes_port_enabled
static
uint16_t minutes_port_out
static
struct sol_flow_node * seconds
static
uint16_t seconds_port_enabled
static
uint16_t seconds_port_out
static