|
IoT managed integrations End Device SDK
|
#include <stdint.h>#include <stdio.h>#include <iotmi_device_agent.h>#include <iotmi_device_types.h>Go to the source code of this file.
Classes | |
| struct | iotmiDev_DataModelHandler_AttrMapping |
| struct | iotmiDev_DataModelHandler_CommandMapping |
| struct | iotmiDev_DataModelHandler_EventMapping |
| struct | iotmiDev_DataModelHandler_CustomSchemaMapping |
| struct | iotmiDev_DataModelHandler_Config |
| The struct to hold the configuration of data model handler. More... | |
This file defines the API for data model handler.
| void iotmiDev_DataModelHandler_initDefaultConfig | ( | struct iotmiDev_DataModelHandler_Config * | config | ) |
This API initializes a default Data Model Handler config.
This function fills the config with default reasonable values. We suggest to use the function to get the default values and then tweak values if necessary.
| [in] | config | Pointer to the config |
| iotmiDev_DMStatus iotmiDev_DataModelHandler_postAttrChange | ( | struct iotmiDev_Agent * | agent, |
| const iotmiDev_AttributeMetaData * | meta, | ||
| const void * | newValue, | ||
| size_t | newValueSize, | ||
| bool | immediate | ||
| ) |
The function to post an attribute change.
The function post an attribute change into the sending message queue of the data model handler. Note that the caller should know the exact type of the value, iotmiDev_DMStatusInvalidArg will be returned if the size of the value does not match.
| [in] | agent | The agent passed in iotmiDev_DataModelHandler_ThreadLoop() |
| [in] | meta | The metadata to identify an attribute. |
| [in] | newValue | A pointer to the new value. |
| [in] | newValueSize | the size of the newValue, used to check if the caller used the right type |
| [in] | immediate | A hint to tell data model handler to send the message immediately or not. |
| iotmiDev_DMStatusInvalidArg | if the size of the value does not match. |
| iotmiDev_DMStatusUnsupported | if the attribute is not supported. |
| iotmiDev_DMStatusInvalidInState | if the data model handler is not currently alive. |
| iotmiDev_DMStatusOk | on successes. |
| iotmiDev_DMStatus iotmiDev_DataModelHandler_postEvent | ( | struct iotmiDev_Agent * | agent, |
| const iotmiDev_EventMetaData * | meta, | ||
| const void * | event, | ||
| size_t | eventSize, | ||
| bool | immediate | ||
| ) |
The function to post an event.
The function post an event into the sending message queue of the data model handler. Note that the caller should know the exact type of the event, iotmiDev_DMStatusInvalidArg will be returned if the size of the event does not match.
| [in] | agent | The agent passed in iotmiDev_DataModelHandler_ThreadLoop() |
| [in] | meta | The metadata to identify an attribute. |
| [in] | event | A pointer to the event. |
| [in] | eventSize | the size of the event, used to check if the caller used the right type |
| [in] | immediate | A hint to tell data model handler to send the message immediately or not. |
| iotmiDev_DMStatusInvalidArg | if the size of the event does not match. |
| iotmiDev_DMStatusUnsupported | if the event is not supported. |
| iotmiDev_DMStatusInvalidInState | if the data model handler is not currently alive. |
| iotmiDev_DMStatusOk | on successes. |
| iotmiDev_DMStatus iotmiDev_DataModelHandler_registerAttrMappings | ( | const iotmiDev_DataModelHandler_AttrMapping * | mappings, |
| size_t | len | ||
| ) |
This API registers attribute mappings for attributes.
This function currently assumes all attributes for a cluster will be registered altogether at the same time. We might loosen this limitation later.
| [in] | mappings | Pointer to an array of mappings |
| [in] | len | Number of elements in mappings |
| iotmiDev_DMStatus iotmiDev_DataModelHandler_registerCommandMappings | ( | const iotmiDev_DataModelHandler_CommandMapping * | mappings, |
| size_t | len | ||
| ) |
This API registers command mappings for commands.
This function currently assumes all commands for a cluster will be registered altogether at the same time. We might loosen this limitation later.
| [in] | mappings | Pointer to an array of mappings |
| [in] | len | Number of elements in mappings |
| iotmiDev_DMStatus iotmiDev_DataModelHandler_registerCustomSchemaMappings | ( | const iotmiDev_DataModelHandler_CustomSchemaMapping * | mappings, |
| size_t | len | ||
| ) |
This API registers custom schema mappings for clusters.
This function handles registration of new custom schema mappings. Unlike other mapping types, custom schema mappings are identified only by clusterId without a secondary entity ID. The function checks for duplicate cluster IDs to avoid re-registration.
| [in] | mappings | Pointer to an array of custom schema mappings |
| [in] | len | Number of elements in mappings |
| iotmiDev_DMStatus iotmiDev_DataModelHandler_registerEventMappings | ( | const iotmiDev_DataModelHandler_EventMapping * | mappings, |
| size_t | len | ||
| ) |
This API registers event mappings for events.
This function currently assumes all events for a cluster will be registered altogether at the same time. We might loosen this limitation later.
| [in] | mappings | Pointer to an array of mappings |
| [in] | len | Number of elements in mappings |
| iotmiDev_DMStatus iotmiDev_DataModelHandler_stop | ( | ) |
This stops the data model handler loop.
| iotmiDev_DMStatusOk | if the data model handler loop is running and now being stopped. |
| iotmiDev_DMStatusInvalidInState | if the data model handler loop is not running |
| iotmiDev_DMStatus iotmiDev_DataModelHandler_threadLoop | ( | const struct iotmiDev_DataModelHandler_Config * | config | ) |
The thread loop function for the Data Model Handler task.
It is responsible for handling incoming cloud messages. It is basically an endless loop, only stop by iotmiDev_DataModelHandler_stop() or fatal error occurs.
| [in] | config | The configuration for the data model handler |