Connectivity processor module implementation file. More...
#include "connectivity_processor.h"
#include "multipart.h"
#include "store.h"
#include "event.h"
#include "data_source_configuration.h"
#include "timeseries.h"
#include "file.h"
#include "custom_data.h"
#include "json.h"
#include "mcl_core/mcl_memory.h"
#include "mcl_core/mcl_string_util.h"
#include "mcl_core/mcl_file_util.h"
#include "mcl_core/mcl_json_util.h"
#include "mcl_core/mcl_random.h"
Go to the source code of this file.
Data Structures | |
struct | custom_data_callback_user_context |
Macros | |
#define | CORRELATION_ID_BYTE_LENGTH 16 |
#define | CORRELATION_ID_BUFFER_LENGTH ((CORRELATION_ID_BYTE_LENGTH * 2) + MCL_NULL_CHAR_SIZE) |
Variables | |
static const char * | content_type_values [CONTENT_TYPE_VALUES_END] |
Connectivity processor module implementation file.
Definition in file connectivity_processor.c.
#define CORRELATION_ID_BUFFER_LENGTH ((CORRELATION_ID_BYTE_LENGTH * 2) + MCL_NULL_CHAR_SIZE) |
Definition at line 100 of file connectivity_processor.c.
Referenced by connectivity_processor_create_mapping(), and connectivity_processor_exchange().
#define CORRELATION_ID_BYTE_LENGTH 16 |
Definition at line 99 of file connectivity_processor.c.
Referenced by _generate_correlation_id_string().
Content types.
This is used with content_type_values array to get the related string. ex: content_type_values[CONTENT_TYPE_APPLICATION_OCTET_STREAM] returns the string of "application/octet-stream".
Definition at line 30 of file connectivity_processor.c.
|
static |
Definition at line 561 of file connectivity_processor.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FREE, mcl_http_request_add_header(), MCL_NULL, MCL_OK, and mcl_string_util_concatenate().
Referenced by _add_http_headers_for_exchange(), connectivity_processor_create_mapping(), and connectivity_processor_get_data_source_configuration().
|
static |
Definition at line 997 of file connectivity_processor.c.
References _custom_data_payload_callback(), custom_data_payload_t::content_type, custom_data_callback_user_context::custom_data, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, multipart_add_tuple_with_callback(), custom_data_callback_user_context::offset, and custom_data_t::payload.
Referenced by _add_item_to_buffer().
|
static |
Definition at line 499 of file connectivity_processor.c.
References _add_authorization_header(), _add_multipart_mixed_content_type_header(), connectivity_processor_t::access_token, CONTENT_TYPE_APPLICATION_JSON, content_type_values, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, mcl_http_request_add_header(), and MCL_OK.
Referenced by connectivity_processor_exchange().
|
static |
Definition at line 663 of file connectivity_processor.c.
References _add_custom_data_to_buffer(), _file_payload_callback(), CONTENT_TYPE_APPLICATION_OCTET_STREAM, content_type_values, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FAIL, mcl_file_util_rewind(), MCL_ITEM_TYPE_CUSTOM_DATA, MCL_ITEM_TYPE_DATA_SOURCE_CONFIGURATION, MCL_ITEM_TYPE_EVENT, MCL_ITEM_TYPE_FILE, MCL_ITEM_TYPE_TIMESERIES, multipart_add_tuple(), multipart_add_tuple_with_callback(), and mcl_item_t::type.
Referenced by _prepare_body(), and _prepare_body_for_store().
|
static |
Definition at line 523 of file connectivity_processor.c.
References CONTENT_TYPE_MULTIPART_MIXED, content_type_values, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_STRING, MCL_FREE, mcl_http_request_add_header(), MCL_MALLOC, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, mcl_string_util_snprintf(), and mcl_string_util_strlen().
Referenced by _add_http_headers_for_exchange().
|
static |
Definition at line 727 of file connectivity_processor.c.
References _get_item_size(), mcl_list_t::count, mcl_list_node_t::data, store_item_t::item, store_t::item_list, store_item_t::item_size, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FALSE, MCL_ITEM_EXCEEDS_MAX_HTTP_REQUEST_SIZE, mcl_list_next(), mcl_list_reset(), MCL_NULL, MCL_OK, MCL_STORE_IS_EMPTY, MCL_TRUE, multipart_get_overhead_size(), store_item_t::status, and STORE_ITEM_STATUS_IGNORED.
Referenced by connectivity_processor_exchange().
|
static |
Definition at line 640 of file connectivity_processor.c.
References custom_data_payload_t::buffer, custom_data_callback_user_context::custom_data, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, mcl_string_util_memcpy(), custom_data_t::payload, and custom_data_payload_t::size.
Referenced by _add_custom_data_to_buffer().
|
static |
Definition at line 582 of file connectivity_processor.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR, mcl_http_response_get_status(), MCL_HTTP_STATUS_CODE_SUCCESS, MCL_INFO, MCL_NULL, MCL_OK, mcl_http_response_t::payload, mcl_http_response_t::payload_size, and mcl_http_response_t::status_code.
Referenced by connectivity_processor_exchange().
|
static |
Definition at line 628 of file connectivity_processor.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and mcl_file_util_fread().
Referenced by _add_item_to_buffer().
|
static |
Definition at line 609 of file connectivity_processor.c.
References CORRELATION_ID_BYTE_LENGTH, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_OK, mcl_random_generate_bytes(), and mcl_string_util_snprintf().
Referenced by connectivity_processor_create_mapping(), and connectivity_processor_exchange().
|
static |
Definition at line 697 of file connectivity_processor.c.
References CONTENT_TYPE_APPLICATION_JSON, CONTENT_TYPE_APPLICATION_OCTET_STREAM, content_type_values, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ITEM_TYPE_CUSTOM_DATA, MCL_ITEM_TYPE_DATA_SOURCE_CONFIGURATION, MCL_ITEM_TYPE_EVENT, MCL_ITEM_TYPE_FILE, MCL_ITEM_TYPE_TIMESERIES, multipart_get_tuple_size(), and mcl_item_t::type.
Referenced by _check_store_size(), and _prepare_body().
|
static |
Definition at line 799 of file connectivity_processor.c.
References mcl_list_node_t::data, store_t::item_list, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, mcl_list_next(), MCL_NULL, MCL_OK, store_item_t::status, and STORE_ITEM_STATUS_SELECTED.
Referenced by _prepare_body_for_store().
|
static |
Definition at line 879 of file connectivity_processor.c.
References _add_item_to_buffer(), _get_item_size(), _prepare_body_for_store(), MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FREE, MCL_ITEM_EXCEEDS_MAX_HTTP_REQUEST_SIZE, MCL_ITEM_TYPE_STORE, MCL_MALLOC, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, multipart_close(), multipart_get_overhead_size(), and mcl_item_t::type.
Referenced by connectivity_processor_exchange().
|
static |
Definition at line 821 of file connectivity_processor.c.
References _add_item_to_buffer(), _get_next_selected_store_item(), _select_store_items_to_exchange(), store_item_t::item, MCL_CONNECTIVITY_CODE_TO_STRING, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR, MCL_FAIL, MCL_FREE, MCL_MALLOC, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, multipart_close(), store_item_t::status, and STORE_ITEM_STATUS_PROCESSED.
Referenced by _prepare_body().
|
static |
Definition at line 1017 of file connectivity_processor.c.
References mapping_t::data_point_id, mapping_t::entity_id, mapping_t::keep_mapping, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_JSON_OBJECT, mcl_json_util_add_bool(), mcl_json_util_add_string(), mcl_json_util_destroy(), mcl_json_util_initialize(), mcl_json_util_to_string(), MCL_NULL, MCL_OK, mapping_t::property_name, and mapping_t::property_set_name.
Referenced by connectivity_processor_create_mapping().
|
static |
Definition at line 957 of file connectivity_processor.c.
References mcl_list_t::count, mcl_list_node_t::data, store_t::item_list, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FALSE, mcl_list_next(), mcl_list_remove_with_content(), mcl_list_reset(), MCL_NULL, MCL_TRUE, store_item_destroy(), STORE_ITEM_STATUS_PROCESSED, STORE_ITEM_STATUS_READY, and STORE_ITEM_STATUS_SELECTED.
Referenced by _scan_store_after_exchange().
|
static |
Definition at line 937 of file connectivity_processor.c.
References mcl_list_t::count, mcl_list_node_t::data, store_t::item_list, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, mcl_list_next(), mcl_list_reset(), MCL_NULL, and STORE_ITEM_STATUS_READY.
Referenced by _scan_store_after_exchange().
|
static |
Definition at line 472 of file connectivity_processor.c.
References _remove_uploaded_store_items(), _revert_store_item_status(), mcl_list_t::count, store_t::item_list, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ITEM_EXCEEDS_MAX_HTTP_REQUEST_SIZE, MCL_OK, and MCL_TRUE.
Referenced by connectivity_processor_exchange().
|
static |
Definition at line 770 of file connectivity_processor.c.
References mcl_list_node_t::data, store_t::item_list, store_item_t::item_size, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, mcl_list_next(), mcl_list_reset(), MCL_NULL, MCL_OK, multipart_get_overhead_size(), store_item_t::status, and STORE_ITEM_STATUS_SELECTED.
Referenced by _prepare_body_for_store().
mcl_error_t connectivity_processor_create_mapping | ( | connectivity_processor_t * | connectivity_processor, |
mapping_t * | mapping | ||
) |
This function creates a data point mapping.
[in] | connectivity_processor | Connectivity Processor handle to be used. |
[in] | mapping | Mapping handle. |
Definition at line 256 of file connectivity_processor.c.
References _add_authorization_header(), _generate_correlation_id_string(), _prepare_mapping_json(), connectivity_processor_t::access_token, connectivity_processor_t::agent_id, CONTENT_TYPE_APPLICATION_JSON, content_type_values, CORRELATION_ID_BUFFER_LENGTH, connectivity_processor_t::http_client, connectivity_processor_t::mapping_url, mapping_validate(), MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR, MCL_FREE, mcl_http_client_send(), MCL_HTTP_POST, mcl_http_request_add_header(), mcl_http_request_destroy(), mcl_http_request_initialize(), MCL_HTTP_REQUEST_PARAMETER_BODY, MCL_HTTP_REQUEST_PARAMETER_BODY_SIZE, MCL_HTTP_REQUEST_PARAMETER_METHOD, MCL_HTTP_REQUEST_PARAMETER_URL, mcl_http_request_set_parameter(), mcl_http_response_destroy(), mcl_http_response_get_status(), MCL_HTTP_STATUS_CODE_CREATED, MCL_INFO, MCL_NULL, MCL_OK, mcl_string_util_strlen(), MCL_UNEXPECTED_RESULT_CODE, mcl_http_response_t::payload, mcl_http_response_t::payload_size, and mcl_http_response_t::status_code.
Referenced by mcl_connectivity_create_mapping().
mcl_error_t connectivity_processor_exchange | ( | connectivity_processor_t * | connectivity_processor, |
mcl_item_t * | item | ||
) |
This function exchanges data with MindSphere.
[in] | connectivity_processor | Connectivity Processor handle to be used. |
[in] | item | Data to be exchanged. |
store
has no data. Definition at line 111 of file connectivity_processor.c.
References _add_http_headers_for_exchange(), _check_store_size(), _evaluate_response_for_exchange(), _generate_correlation_id_string(), _prepare_body(), _scan_store_after_exchange(), CORRELATION_ID_BUFFER_LENGTH, custom_data_validate(), data_source_configuration_validate(), event_validate(), connectivity_processor_t::exchange_url, file_validate(), connectivity_processor_t::http_client, connectivity_processor_t::max_http_payload_size, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FAIL, MCL_FALSE, MCL_FREE, mcl_http_client_send(), MCL_HTTP_POST, mcl_http_request_add_header(), mcl_http_request_destroy(), mcl_http_request_initialize(), MCL_HTTP_REQUEST_PARAMETER_BODY, MCL_HTTP_REQUEST_PARAMETER_BODY_SIZE, MCL_HTTP_REQUEST_PARAMETER_METHOD, MCL_HTTP_REQUEST_PARAMETER_URL, mcl_http_request_set_parameter(), mcl_http_response_destroy(), MCL_INVALID_PARAMETER, MCL_ITEM_PREAMBLE, MCL_ITEM_TYPE_CUSTOM_DATA, MCL_ITEM_TYPE_DATA_SOURCE_CONFIGURATION, MCL_ITEM_TYPE_EVENT, MCL_ITEM_TYPE_FILE, MCL_ITEM_TYPE_STORE, MCL_ITEM_TYPE_TIMESERIES, MCL_NULL, MCL_OK, MCL_TRUE, multipart_generate_boundary(), and timeseries_validate().
Referenced by mcl_connectivity_exchange().
mcl_error_t connectivity_processor_get_data_source_configuration | ( | connectivity_processor_t * | connectivity_processor, |
data_source_configuration_t ** | configuration | ||
) |
This function gets data source configuration.
[in] | connectivity_processor | Connectivity Processor handle to be used. |
[out] | configuration | Data source configuration. |
Definition at line 371 of file connectivity_processor.c.
References _add_authorization_header(), connectivity_processor_t::access_token, connectivity_processor_t::agent_id, CONTENT_TYPE_APPLICATION_JSON, content_type_values, connectivity_processor_t::hostname, connectivity_processor_t::http_client, json_parse_item(), MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FREE, mcl_http_client_send(), MCL_HTTP_GET, mcl_http_request_add_header(), mcl_http_request_destroy(), mcl_http_request_initialize(), MCL_HTTP_REQUEST_PARAMETER_METHOD, MCL_HTTP_REQUEST_PARAMETER_URL, mcl_http_request_set_parameter(), mcl_http_response_destroy(), mcl_http_response_get_status(), MCL_HTTP_STATUS_CODE_SUCCESS, MCL_MALLOC, MCL_NULL, MCL_NULL_CHAR_SIZE, MCL_OK, MCL_OUT_OF_MEMORY, mcl_string_util_memcpy(), mcl_string_util_strlen(), mcl_http_response_t::payload, mcl_http_response_t::payload_size, and mcl_http_response_t::status_code.
Referenced by mcl_connectivity_get_data_source_configuration().
|
static |
Content type values.
Definition at line 44 of file connectivity_processor.c.
Referenced by _add_http_headers_for_exchange(), _add_item_to_buffer(), _add_multipart_mixed_content_type_header(), _get_item_size(), connectivity_processor_create_mapping(), and connectivity_processor_get_data_source_configuration().