Microsoft Azure IoT Gateway SDK  1.0.8
The Microsoft Azure IoT Gateway SDK contains the infrastructure and modules to create IoT gateway solutions.
Data Structures | Macros | Typedefs | Enumerations | Functions
gateway.h File Reference

Library that allows a user to create and configure a gateway. More...

#include "azure_c_shared_utility/macro_utils.h"
#include "azure_c_shared_utility/vector.h"
#include "nanomsg/nn.h"
#include "module.h"
#include "module_loader.h"
#include "gateway_export.h"

Go to the source code of this file.

Data Structures

struct  GATEWAY_LINK_ENTRY_TAG
 Struct representing a single link for a gateway. More...
 
struct  GATEWAY_MODULE_LOADER_INFO_TAG
 Struct representing the loader and entrypoint to be used for a specific module. More...
 
struct  GATEWAY_MODULES_ENTRY_TAG
 Struct representing a single entry of the GATEWAY_PROPERTIES. More...
 
struct  GATEWAY_PROPERTIES_DATA_TAG
 Struct representing the properties that should be used when creating a module; each entry of the VECTOR_HANDLE being a GATEWAY_MODULES_ENTRY. More...
 

Macros

#define GATEWAY_CONNECTION_ID_MAX   NN_SOCKADDR_MAX
 
#define GATEWAY_MESSAGE_VERSION_1   0x01
 
#define GATEWAY_MESSAGE_VERSION_CURRENT   GATEWAY_MESSAGE_VERSION_1
 

Typedefs

typedef enum GATEWAY_ADD_LINK_RESULT_TAG GATEWAY_ADD_LINK_RESULT
 Enumeration describing the result of Gateway_AddLink.
 
typedef enum GATEWAY_START_RESULT_TAG GATEWAY_START_RESULT
 Enumeration describing the result of Gateway_Start.
 
typedef enum GATEWAY_UPDATE_FROM_JSON_RESULT_TAG GATEWAY_UPDATE_FROM_JSON_RESULT
 Enumeration describing the result of Gateway_UpdateFromJson.
 
typedef struct GATEWAY_LINK_ENTRY_TAG GATEWAY_LINK_ENTRY
 Struct representing a single link for a gateway.
 
typedef struct GATEWAY_HANDLE_DATA_TAG * GATEWAY_HANDLE
 Struct representing a particular gateway.
 
typedef struct GATEWAY_MODULE_LOADER_INFO_TAG GATEWAY_MODULE_LOADER_INFO
 Struct representing the loader and entrypoint to be used for a specific module.
 
typedef struct GATEWAY_MODULES_ENTRY_TAG GATEWAY_MODULES_ENTRY
 Struct representing a single entry of the GATEWAY_PROPERTIES.
 
typedef struct GATEWAY_PROPERTIES_DATA_TAG GATEWAY_PROPERTIES
 Struct representing the properties that should be used when creating a module; each entry of the VECTOR_HANDLE being a GATEWAY_MODULES_ENTRY.
 

Enumerations

enum  GATEWAY_ADD_LINK_RESULT_TAG { GATEWAY_ADD_LINK_SUCCESS, GATEWAY_ADD_LINK_ERROR, GATEWAY_ADD_LINK_INVALID_ARG }
 Enumeration describing the result of Gateway_AddLink.
 
enum  GATEWAY_START_RESULT_TAG { GATEWAY_START_SUCCESS, GATEWAY_START_INVALID_ARGS }
 Enumeration describing the result of Gateway_Start.
 
enum  GATEWAY_UPDATE_FROM_JSON_RESULT_TAG { GATEWAY_UPDATE_FROM_JSON_SUCCESS, GATEWAY_UPDATE_FROM_JSON_ERROR, GATEWAY_UPDATE_FROM_JSON_INVALID_ARG, GATEWAY_UPDATE_FROM_JSON_MEMORY }
 Enumeration describing the result of Gateway_UpdateFromJson.
 

Functions

const char * GATEWAY_UPDATE_FROM_JSON_RESULTStrings (GATEWAY_UPDATE_FROM_JSON_RESULT value)
 
int GATEWAY_UPDATE_FROM_JSON_RESULT_FromString (const char *enumAsString, GATEWAY_UPDATE_FROM_JSON_RESULT *destination)
 
GATEWAY_EXPORT GATEWAY_HANDLE Gateway_CreateFromJson (const char *file_path)
 Creates a gateway using a JSON configuration file as input which describes each module. Each module described in the configuration must support Module_CreateFromJson. More...
 
GATEWAY_EXPORT GATEWAY_UPDATE_FROM_JSON_RESULT Gateway_UpdateFromJson (GATEWAY_HANDLE gw, const char *json_content)
 Updates a gateway using a JSON configuration string as input which describes each module. More...
 
GATEWAY_EXPORT GATEWAY_HANDLE Gateway_Create (const GATEWAY_PROPERTIES *properties)
 Creates a new gateway using the provided GATEWAY_PROPERTIES. More...
 
GATEWAY_EXPORT GATEWAY_START_RESULT Gateway_Start (GATEWAY_HANDLE gw)
 Tell the Gateway it's ready to start. More...
 
GATEWAY_EXPORT void Gateway_Destroy (GATEWAY_HANDLE gw)
 Destroys the gateway and disposes of all associated data. More...
 
GATEWAY_EXPORT MODULE_HANDLE Gateway_AddModule (GATEWAY_HANDLE gw, const GATEWAY_MODULES_ENTRY *entry)
 Creates a new module based on the GATEWAY_MODULES_ENTRY*. More...
 
GATEWAY_EXPORT void Gateway_StartModule (GATEWAY_HANDLE gw, MODULE_HANDLE module)
 Tells a module that the gateway is ready for it to start. More...
 
GATEWAY_EXPORT void Gateway_RemoveModule (GATEWAY_HANDLE gw, MODULE_HANDLE module)
 Removes the provided module from the gateway and all links that involves this module. More...
 
GATEWAY_EXPORT int Gateway_RemoveModuleByName (GATEWAY_HANDLE gw, const char *module_name)
 Removes module by its unique name. More...
 
GATEWAY_EXPORT GATEWAY_ADD_LINK_RESULT Gateway_AddLink (GATEWAY_HANDLE gw, const GATEWAY_LINK_ENTRY *entryLink)
 Adds a link to a gateway message broker. More...
 
GATEWAY_EXPORT void Gateway_RemoveLink (GATEWAY_HANDLE gw, const GATEWAY_LINK_ENTRY *entryLink)
 Remove a link from a gateway message broker. More...
 

Detailed Description

Library that allows a user to create and configure a gateway.

The Gateway library provides a mechanism for creating and destroying a gateway, as well as adding and removing modules.

Function Documentation

◆ Gateway_AddLink()

GATEWAY_EXPORT GATEWAY_ADD_LINK_RESULT Gateway_AddLink ( GATEWAY_HANDLE  gw,
const GATEWAY_LINK_ENTRY entryLink 
)

Adds a link to a gateway message broker.

Parameters
gwPointer to a GATEWAY_HANDLE from which link is going to be added.
entryLinkPointer to a GATEWAY_LINK_ENTRY to be added.
Returns
A GATEWAY_ADD_LINK_RESULT with the operation result.

◆ Gateway_AddModule()

GATEWAY_EXPORT MODULE_HANDLE Gateway_AddModule ( GATEWAY_HANDLE  gw,
const GATEWAY_MODULES_ENTRY entry 
)

Creates a new module based on the GATEWAY_MODULES_ENTRY*.

Parameters
gwPointer to a GATEWAY_HANDLE to add the Module onto.
entryPointer to a GATEWAY_MODULES_ENTRY structure describing the module.
Returns
A non-NULL MODULE_HANDLE to the newly created and added Module, or NULL on failure.

◆ Gateway_Create()

GATEWAY_EXPORT GATEWAY_HANDLE Gateway_Create ( const GATEWAY_PROPERTIES properties)

Creates a new gateway using the provided GATEWAY_PROPERTIES.

Parameters
propertiesGATEWAY_PROPERTIES structure containing specific module properties and information.
Returns
A non-NULL GATEWAY_HANDLE that can be used to manage the gateway or NULL on failure.

◆ Gateway_CreateFromJson()

GATEWAY_EXPORT GATEWAY_HANDLE Gateway_CreateFromJson ( const char *  file_path)

Creates a gateway using a JSON configuration file as input which describes each module. Each module described in the configuration must support Module_CreateFromJson.

Parameters
file_pathPath to the JSON configuration file for this gateway.

Sample JSON configuration file:

{ "modules" : [ { "name": "sensor", "loader": { "name": "dotnet", "entrypoint": { "class.name": "Microsoft.Azure.Gateway.SensorModule", "assembly.path": "./bin/Microsoft.Azure.Gateway.Modules.dll" } }, "args" : { "power.level": 5 } }, { "name": "logger", "loader": { "name": "native", "entrypoint": { "module.path": "./bin/liblogger.so" } }, "args": { "filename": "/var/logs/gateway-log.json" } } ], "links": [ { "source": "sensor", "sink": "logger" } ] }

Returns
A non-NULL GATEWAY_HANDLE that can be used to manage the gateway or NULL on failure.

◆ Gateway_Destroy()

GATEWAY_EXPORT void Gateway_Destroy ( GATEWAY_HANDLE  gw)

Destroys the gateway and disposes of all associated data.

Parameters
gwGATEWAY_HANDLE to be destroyed.

◆ Gateway_RemoveLink()

GATEWAY_EXPORT void Gateway_RemoveLink ( GATEWAY_HANDLE  gw,
const GATEWAY_LINK_ENTRY entryLink 
)

Remove a link from a gateway message broker.

Parameters
gwPointer to a GATEWAY_HANDLE from which link is going to be removed.
entryLinkPointer to a GATEWAY_LINK_ENTRY to be removed.

◆ Gateway_RemoveModule()

GATEWAY_EXPORT void Gateway_RemoveModule ( GATEWAY_HANDLE  gw,
MODULE_HANDLE  module 
)

Removes the provided module from the gateway and all links that involves this module.

Parameters
gwPointer to a GATEWAY_HANDLE from which to remove the Module.
modulePointer to a MODULE_HANDLE that needs to be removed.

◆ Gateway_RemoveModuleByName()

GATEWAY_EXPORT int Gateway_RemoveModuleByName ( GATEWAY_HANDLE  gw,
const char *  module_name 
)

Removes module by its unique name.

Parameters
gwPointer to a GATEWAY_HANDLE from which to remove the module.
module_nameA C string representing the name of module to be removed
Returns
0 on success and a non-zero value when an error occurs.

◆ Gateway_Start()

GATEWAY_EXPORT GATEWAY_START_RESULT Gateway_Start ( GATEWAY_HANDLE  gw)

Tell the Gateway it's ready to start.

Parameters
gwGATEWAY_HANDLE to be destroyed.
Returns
A GATEWAY_START_RESULT to report the result of the start

◆ Gateway_StartModule()

GATEWAY_EXPORT void Gateway_StartModule ( GATEWAY_HANDLE  gw,
MODULE_HANDLE  module 
)

Tells a module that the gateway is ready for it to start.

Parameters
gwPointer to a GATEWAY_HANDLE from which to remove the Module.
modulePointer to a MODULE_HANDLE that needs to be removed.

◆ Gateway_UpdateFromJson()

GATEWAY_EXPORT GATEWAY_UPDATE_FROM_JSON_RESULT Gateway_UpdateFromJson ( GATEWAY_HANDLE  gw,
const char *  json_content 
)

Updates a gateway using a JSON configuration string as input which describes each module.

Parameters
gwPointer to a GATEWAY_HANDLE from which to remove the module.
json_contentA JSON string with a list of Loaders, Modules and/or Links.
Returns
A GATEWAY_UPDATE_FROM_JSON_RESULT with the operation result.