Gateway C ABI
Loading...
Searching...
No Matches
abi.h File Reference
#include "datapoint_value.h"
#include "json.h"
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  sGCPluginInfo
 Plugin version information The information that the core uses to register a new plugin. Every plugin must provide this information. More...
 
struct  sGCEthernetInterface
 Ethernet interface configuration. More...
 
struct  sGCSerialInterface
 Serial interface configuration. More...
 
struct  sGCDatapoint
 Datapoint information The information about a datapoint, each DatapointValue will belong to a specific Datapoint which can be verified by it's ID which is unique for the entire Gateway/plugins. More...
 
struct  sPluginConfig
 Holds the configuration and related functions. More...
 
struct  sGCPluginInterface
 The plugin interface. More...
 

Macros

#define GC_INTERFACE_NAME_MAX   50
 Maximum length for interface names (including null terminator)
 

Typedefs

typedef enum eGCLogLevel GCLogLevel
 
typedef const struct sGCPluginInfoGCPluginInfo
 
typedef struct sGCEthernetInterfaceGCEthernetInterface
 
typedef struct sGCSerialInterfaceGCSerialInterface
 
typedef const struct sGCDatapoint GCDatapoint
 
typedef void * GCCoreCtx
 
typedef void * GCInstanceHandle
 The handle to the plugin instance.
 
typedef bool(* tPublishDatapointValue) (GCCoreCtx, GCDatapointValue)
 
typedef void(* tStoreDatapointValue) (GCCoreCtx, GCDatapointValue)
 
typedef GCDatapointValue(* tGetLastDatapointValue) (GCCoreCtx, GCDatapointIdentifier)
 
typedef void(* tSystemLog) (GCCoreCtx, GCLogLevel, const char *)
 
typedef void(* tAuditLog) (GCCoreCtx, const char *)
 
typedef bool(* tReleaseDatapointValue) (GCDatapointValue)
 
typedef bool(* tGetEthernetInterface) (GCCoreCtx, const char *name, GCEthernetInterface out)
 
typedef bool(* tGetSerialInterface) (GCCoreCtx, const char *name, GCSerialInterface out)
 
typedef const struct sPluginConfig GCPluginConfig
 
typedef const struct sGCPluginInterfaceGCPluginInterface
 

Enumerations

enum  eGCLogLevel {
  CRITICAL , ERROR , WARNING , INFO ,
  DEBUG
}
 The log levels available. More...
 
enum  GCStopBits { GC_STOP_BITS_ONE = 1 , GC_STOP_BITS_TWO = 2 }
 Serial port stop bits configuration. More...
 
enum  GCParity { GC_PARITY_NONE = 0 , GC_PARITY_ODD = 1 , GC_PARITY_EVEN = 2 }
 Serial port parity configuration. More...
 
enum  GCDataBits { GC_DATA_BITS_FIVE = 5 , GC_DATA_BITS_SIX = 6 , GC_DATA_BITS_SEVEN = 7 , GC_DATA_BITS_EIGHT = 8 }
 Serial port data bits configuration. More...
 

Functions

GCInstanceHandle gc_plugin_init (GCPluginInterface interface)
 Initializes the plugin.
 
void gc_plugin_shutdown (GCInstanceHandle instance)
 Safely shuts down the plugin instance.
 
GCPluginInfo gc_plugin_get_info ()
 Retrieves the plugin information.
 
bool gc_plugin_receive_datapoint (GCInstanceHandle instance, const GCDatapointValue dataValue)
 Receives a datapoint value.
 
void gcSystemLog (GCPluginInterface interface, GCLogLevel level, const char *message,...)
 Logs a message to the system log.
 
void gcAuditLog (GCPluginInterface interface, const char *message,...)
 Logs a message to the audit log.
 
void gcReleaseDatapointValue (GCPluginInterface interface, GCDatapointValue dataValue)
 Releases a datapoint value This function is a wrapper around the releaseDatapointValueCallback callback provided by the core. It is used to release a datapoint value that was previously returned by the core.
 
bool gcPublishDatapointValue (GCPluginInterface interface, GCDatapointValue dataValue)
 Publishes a datapoint value This function is a wrapper around the publishDatapointValueCallback callback provided by the core. It is used to publish a new datapoint value to the core.
 
bool gcGetEthernetInterface (GCPluginInterface interface, const char *name, GCEthernetInterface out)
 Retrieves an Ethernet interface configuration by name.
 
bool gcGetSerialInterface (GCPluginInterface interface, const char *name, GCSerialInterface out)
 Retrieves a serial interface configuration by name.
 
void gcStoreDatapointValue (GCPluginInterface interface, GCDatapointValue dataValue)
 Stores a datapoint value This function us a wrapper around the StoreDatapointValueCallback callback provided by the core. It is used to store a new datapoint to the timeseries database.
 

Macro Definition Documentation

◆ GC_INTERFACE_NAME_MAX

#define GC_INTERFACE_NAME_MAX   50

Maximum length for interface names (including null terminator)

Typedef Documentation

◆ GCCoreCtx

typedef void* GCCoreCtx

◆ GCDatapoint

typedef const struct sGCDatapoint GCDatapoint

◆ GCEthernetInterface

◆ GCInstanceHandle

typedef void* GCInstanceHandle

The handle to the plugin instance.

The handle that the core provides to the plugin, this is for stateful plugins so they can keep track of their own state. It is meant to be casted to the plugin instance struct defined by it.

◆ GCLogLevel

typedef enum eGCLogLevel GCLogLevel

◆ GCPluginConfig

typedef const struct sPluginConfig GCPluginConfig

◆ GCPluginInfo

typedef const struct sGCPluginInfo* GCPluginInfo

◆ GCPluginInterface

typedef const struct sGCPluginInterface* GCPluginInterface

◆ GCSerialInterface

◆ tAuditLog

typedef void(* tAuditLog) (GCCoreCtx, const char *)

◆ tGetEthernetInterface

typedef bool(* tGetEthernetInterface) (GCCoreCtx, const char *name, GCEthernetInterface out)

◆ tGetLastDatapointValue

typedef GCDatapointValue(* tGetLastDatapointValue) (GCCoreCtx, GCDatapointIdentifier)

◆ tGetSerialInterface

typedef bool(* tGetSerialInterface) (GCCoreCtx, const char *name, GCSerialInterface out)

◆ tPublishDatapointValue

typedef bool(* tPublishDatapointValue) (GCCoreCtx, GCDatapointValue)

◆ tReleaseDatapointValue

typedef bool(* tReleaseDatapointValue) (GCDatapointValue)

◆ tStoreDatapointValue

typedef void(* tStoreDatapointValue) (GCCoreCtx, GCDatapointValue)

◆ tSystemLog

typedef void(* tSystemLog) (GCCoreCtx, GCLogLevel, const char *)

Enumeration Type Documentation

◆ eGCLogLevel

The log levels available.

Enumerator
CRITICAL 
ERROR 
WARNING 
INFO 
DEBUG 

◆ GCDataBits

enum GCDataBits

Serial port data bits configuration.

Enumerator
GC_DATA_BITS_FIVE 
GC_DATA_BITS_SIX 

5 data bits

GC_DATA_BITS_SEVEN 

6 data bits

GC_DATA_BITS_EIGHT 

7 data bits

◆ GCParity

enum GCParity

Serial port parity configuration.

Enumerator
GC_PARITY_NONE 
GC_PARITY_ODD 

No parity.

GC_PARITY_EVEN 

Odd parity.

◆ GCStopBits

enum GCStopBits

Serial port stop bits configuration.

Enumerator
GC_STOP_BITS_ONE 
GC_STOP_BITS_TWO 

1 stop bit

Function Documentation

◆ gc_plugin_get_info()

GCPluginInfo gc_plugin_get_info ( )
extern

Retrieves the plugin information.

This is the only exported function that does not require a plugin instance handle since every plugin instance will have the same information.

Returns
GCPluginInfo The information about the plugin

◆ gc_plugin_init()

GCInstanceHandle gc_plugin_init ( GCPluginInterface interface)
extern

Initializes the plugin.

This function is called by the core to initialize the plugin. This is the entrypoint of the plugin, and it will be called once for every plugin instance. It may also be called multiple times for the same plugin instance in the case of a restart for example, but in this case it is guaranteed that the plugin instance will be shutdown before (when the core issues a shutdown command). The core will only call other plugin exported functions after this function returns.

Parameters
interfaceThe interface that the core provides to the plugin
Returns
The handle to the plugin instance, this maybe any pointer to memory and can be use to keep track of the instance state as it will be forwarded to all other plugin exported functions.

◆ gc_plugin_receive_datapoint()

bool gc_plugin_receive_datapoint ( GCInstanceHandle instance,
const GCDatapointValue dataValue )
extern

Receives a datapoint value.

This function is called by the core to deliver a new datapoint value to the plugin via the subscription system. The plugin should process the value and return true if the value was successfully processed, false otherwise.

It is very important that the plugin releases the datapoint passed as an argument after it is done with it. This is done by calling the releaseDatapointValue callback. Failing to do so will result in a memory leak.

Parameters
instanceThe handle to the plugin instance
dataValueA shared reference to a datapoint value
Returns
true if the value was successfully processed, false otherwise

◆ gc_plugin_shutdown()

void gc_plugin_shutdown ( GCInstanceHandle instance)
extern

Safely shuts down the plugin instance.

This function is invoked by the core to terminate the plugin instance. The following points should be taken into consideration regarding concurrency:

  • After this function completes, no other functions exported by the plugin will be called for this instance.
  • During the execution of gc_plugin_shutdown, other plugin functions may still be running concurrently if their calls were initiated before gc_plugin_shutdown was invoked. It is therefore the plugin's responsibility to handle any potential race conditions while releasing resources.
  • All resources allocated by the plugin should be released by the time this function returns.
Parameters
instanceA pointer to the plugin instance being shut down.

◆ gcAuditLog()

void gcAuditLog ( GCPluginInterface interface,
const char * message,
... )

Logs a message to the audit log.

This function is a wrapper around the logAuditCallback callback provided by the core. It is used to log messages to the audit log. It works similarly to the printf function. It has a maximum buffer size of 1000 bytes, any message exceeding this size will be truncated.

Parameters
interfaceThe interface that the core provides to the plugin
messageThe message to be logged

◆ gcGetEthernetInterface()

bool gcGetEthernetInterface ( GCPluginInterface interface,
const char * name,
GCEthernetInterface out )

Retrieves an Ethernet interface configuration by name.

This function is used to retrieve the configuration of an Ethernet interface by its logical name.

Parameters
interfaceThe interface that the core provides to the plugin
nameThe logical name of the Ethernet interface (e.g., "primary_eth")
outPointer to the output structure (allocated by the plugin)
Returns
true if the interface was found and the output structure was filled, false otherwise

◆ gcGetSerialInterface()

bool gcGetSerialInterface ( GCPluginInterface interface,
const char * name,
GCSerialInterface out )

Retrieves a serial interface configuration by name.

This function is used to retrieve the configuration of a serial interface by its logical name.

Parameters
interfaceThe interface that the core provides to the plugin
nameThe logical name of the serial interface (e.g., "moxa_port_1")
outPointer to the output structure (allocated by the plugin)
Returns
true if the interface was found and the output structure was filled, false otherwise

◆ gcPublishDatapointValue()

bool gcPublishDatapointValue ( GCPluginInterface interface,
GCDatapointValue dataValue )

Publishes a datapoint value This function is a wrapper around the publishDatapointValueCallback callback provided by the core. It is used to publish a new datapoint value to the core.

Parameters
interfaceThe interface that the core provides to the plugin
dataValueThe datapoint value to be published
Returns
true if the value was published successfully, false if an error occurred while publishing the value

◆ gcReleaseDatapointValue()

void gcReleaseDatapointValue ( GCPluginInterface interface,
GCDatapointValue dataValue )

Releases a datapoint value This function is a wrapper around the releaseDatapointValueCallback callback provided by the core. It is used to release a datapoint value that was previously returned by the core.

Parameters
interfaceThe interface that the core provides to the plugin
dataValueThe datapoint value to be released

◆ gcStoreDatapointValue()

void gcStoreDatapointValue ( GCPluginInterface interface,
GCDatapointValue dataValue )

Stores a datapoint value This function us a wrapper around the StoreDatapointValueCallback callback provided by the core. It is used to store a new datapoint to the timeseries database.

Parameters
interfaceThe interface that the core provides to the plugin
dataValuethe datapoint value to be stored

◆ gcSystemLog()

void gcSystemLog ( GCPluginInterface interface,
GCLogLevel level,
const char * message,
... )

Logs a message to the system log.

This function is a wrapper around the logSystemCallback callback provided by the core. It is used to log messages to the system log. It works similarly to the printf function. It has a maximum buffer size of 1000 bytes, any message exceeding this size will be truncated.

Parameters
interfaceThe interface that the core provides to the plugin
levelThe log level of the message from the GCLogLevel enum
messageThe message to be logged