Data Delivery C API Library Reference  2.0
Data Structures | Defines | Functions
ddca_device_adapter.h File Reference

Data Structures

struct  ddca_devadpt_context_t
 Device Adapter context variable type for DDCA Device Adapter API. More...

Functions

int ddca_devadpt_context_create (ddca_devadpt_context_t **context)
 create connection for device adapter
int ddca_devadpt_init (const ddca_devadpt_context_t *context, const char *devadpt_profile_name)
 initialize connection for device adapter
int ddca_devadpt_emit (const ddca_event_t *evt)
 emit given event data to Edge Delivery Core
int ddca_devadpt_emit_with_data_type (const ddca_event_t *evt)
 emit given event data with data_type to Edge Delivery Core
int ddca_devadpt_destroy ()
 destroy the context
int ddca_devadpt_register_device (const char *device_profile_name, char **device_id)
 register device to the system
int ddca_devadpt_register_multi_devices (const char *device_profile_name, int device_number, char ***device_ids)
 register devices to the system
int ddca_devadpt_register_event_cb (int(*EVENT_CB)(const ddca_event_t *event))
 register the event callback function
int ddca_devadpt_register_operation_cb (int(*AP_OPERATION_CB)(ddca_event_t *event))
 register the operation callback function
int ddca_devadpt_register_notification_cb (int(*NOTIFICATION_CB)(const ddca_event_t *event))
 register the notification callback function
int ddca_devadpt_respond (const char *op_id, const ddca_bool_t success, const char *device_id)
 send an acknowledgement of the message from REST API to the backend
int ddca_devadpt_start ()
 start to receive the event callback request
int ddca_devadpt_stop ()
 stop to receive the event callback request
int ddca_devadpt_join ()
 join the event callback receive thread
int ddca_devadpt_get_profile (const char *device_id, ddca_conf_profile_t **profile)
 get a registered profile
int ddca_devadpt_update_profile (const char *device_id)
 update profile

Detailed Description


Function Documentation

create connection for device adapter

This function creates the connection context for a given device adapter to Edge delivery core.

Parameters:
[in,out]*contextconnection context
Return values:
ADPT_SUCCESSoperation success
othersoperation failure

destroy the context

This function destroys the context of connection. The function must be called before the end of the program to exit cleanly.

Return values:
ADPT_SUCCESSoperation success
othersoperation failure
int ddca_devadpt_emit ( const ddca_event_t evt)

emit given event data to Edge Delivery Core

This function emits the given evt data to Edge Delivery Core indicated by the context.

Parameters:
[in]*evtdata to be emitted
Return values:
ADPT_SUCCESSoperation success
othersoperation failure

emit given event data with data_type to Edge Delivery Core

This function emits the given evt data with data_type to Edge Delivery Core indicated by the context.

Parameters:
[in]*evtdata to be emitted
Return values:
ADPT_SUCCESSoperation success
othersoperation failure
int ddca_devadpt_get_profile ( const char *  device_id,
ddca_conf_profile_t **  profile 
)

get a registered profile

This function returns a pointer to a registered profile. If device_id is "", the return value is profile of device adapter.

Parameters:
[in]*device_iddevice_id strings assigned to the device
[out]**profilea regitered profile
Return values:
DDCA_SUCCESSoperation success
othersoperation failure
int ddca_devadpt_init ( const ddca_devadpt_context_t context,
const char *  devadpt_profile_name 
)

initialize connection for device adapter

This function initializes the connection for a given device adapter to Edge delivery core using a context given as a parameter.

Parameters:
[in]*contextconnection context
[in]*ddca_devadpt_profiledevice adapter profile
Return values:
ADPT_SUCCESSoperation success
othersoperation failure

join the event callback receive thread

This function waits to join to the event callback receive thread. The function must be called between the call of ddca_devadpt_start and ddca_devadpt_destroy to terminate the program cleanly.

Return values:
DDCA_SUCCESSoperation success
othersoperation failure
int ddca_devadpt_register_device ( const char *  device_profile_name,
char **  device_id 
)

register device to the system

This function registers the information of given device to the system. Devices which is going to emit the data to the system must be registered beforehand.

Parameters:
[in]*device_profile_namename of device profile to be registered
[out]**device_iddevice_id strings assigned by the registration
Return values:
ADPT_SUCCESSoperation success
othersoperation failure
int ddca_devadpt_register_event_cb ( int(*)(const ddca_event_t *event)  EVENT_CB)

register the event callback function

This function marks the given function as the event callback function. This event callback function will be called when the new event is notified to this Deivce Adapter.

Parameters:
[in]*EVENT_CBfunction pointer to be marked as the event callback function
Return values:
DDCA_SUCCESSoperation success
othersoperation failure
int ddca_devadpt_register_multi_devices ( const char *  device_profile_name,
int  device_number,
char ***  device_ids 
)

register devices to the system

This function registers the information of given multi devices to the system. Devices which is going to emit the data to the system must be registered beforehand.

Parameters:
[in]*device_profile_namename of multi devices profile to be registered
[in]device_numberthe number of devices to be registered by this function call
[out]***device_idsan array of device_id strings assigned by the registration
Return values:
ADPT_SUCCESSoperation success
othersoperation failure
int ddca_devadpt_register_notification_cb ( int(*)(const ddca_event_t *event)  NOTIFICATION_CB)

register the notification callback function

This function marks the given function as the notification callback function. This notification callback function will be called when the notification message is delivered from ICE Core. This notification callback function is used to receive the ddca_event_t variable as the command from ICE Core and expected to act following to its context.

Parameters:
[in]*NOTIFICATION_CBthe pointer which indicates the notifiaction callback function
Return values:
DDCA_SUCCESSoperation success
othersoperation failure
int ddca_devadpt_register_operation_cb ( int(*)(ddca_event_t *event)  AP_OPERATION_CB)

register the operation callback function

This function marks the given function as the operation callback function. This operation callback function will be called when the operation message is delivered from REST API to this device adapter or one of devices managed by this device adapter via ICE Core(the sink variable of the given event variable stands for the target device id if the target of the message is the device; it is empty string if the target is device adapter itself). This operation callback function is used to receive the ddca_event_t variable as the command from REST and expected to act following to its context. ddca_devadpt_respond API is available to respond an acknowledgement to the backend in the callback function.

Parameters:
[in]*AP_OPERATION_CBthe pointer which indicates the operation callback function
Return values:
DDCA_SUCCESSoperation success
othersoperation failure
int ddca_devadpt_respond ( const char *  op_id,
const ddca_bool_t  success,
const char *  device_id 
)

send an acknowledgement of the message from REST API to the backend

This function sends an acknowledgement of the message from REST API to the backend. The response can be associated with the message with an op_id and accumulated to the database on the backend. This function is intended to use to the case that to tell the REST API operator the published message is delivered to the application properly which do not return any result, or which return the result after a while. This functoin can be called only once by an operation. If device_id is "", the sender of this response is set to the device adapter.

Parameters:
[in]*op_idoperation id to be reported with the result
[in]successresult to be reported
[in]*device_iddevice_id strings assigned to the device
Return values:
DDCA_SUCCESSoperation success
othersoperation failure

start to receive the event callback request

This function starts to receive the event callback request. The event callback request will be delivered after this function is called.

Return values:
DDCA_SUCCESSoperation success
othersoperation failure

stop to receive the event callback request

This function stops to receive the event callback request. The event callback request will not be delivered after this function is called.

Return values:
DDCA_SUCCESSoperation success
othersoperation failure
int ddca_devadpt_update_profile ( const char *  device_id)

update profile

This function notifies C API of renewing a profile. A profile is read in C API, and it's re-registered. If device_id is "", the profile of device adapter is updated.

Parameters:
[in]*device_iddevice_id strings assigned to the device
Return values:
DDCA_SUCCESSoperation success
othersoperation failure
 All Data Structures Files Functions Variables Typedefs Defines