IoTivity-Lite
oc_cloud.h File Reference
#include "oc_client_state.h"
#include "oc_export.h"
#include "oc_ri.h"
#include "oc_session_events.h"

Typedefs

typedef void(* oc_cloud_cb_t) (struct oc_cloud_context_t *ctx, oc_cloud_status_t status, void *user_data)
 A function pointer for handling the cloud status. More...
 
typedef struct oc_cloud_context_t oc_cloud_context_t
 
typedef struct oc_cloud_store_t oc_cloud_store_t
 
typedef enum oc_cps_t oc_cps_t
 

Enumerations

enum  oc_cloud_error_t {
  CLOUD_OK = 0 , CLOUD_ERROR_RESPONSE = 1 , CLOUD_ERROR_CONNECT = 2 , CLOUD_ERROR_REFRESH_ACCESS_TOKEN = 3 ,
  CLOUD_ERROR_UNAUTHORIZED = 4
}
 
enum  oc_cloud_status_t {
  OC_CLOUD_INITIALIZED = 0 , OC_CLOUD_REGISTERED = 1 << 0 , OC_CLOUD_LOGGED_IN = 1 << 1 , OC_CLOUD_TOKEN_EXPIRY = 1 << 2 ,
  OC_CLOUD_REFRESHED_TOKEN = 1 << 3 , OC_CLOUD_LOGGED_OUT = 1 << 4 , OC_CLOUD_FAILURE = 1 << 5 , OC_CLOUD_DEREGISTERED = 1 << 6
}
 Cloud connection status. More...
 
enum  oc_cps_t {
  OC_CPS_UNINITIALIZED = 0 , OC_CPS_READYTOREGISTER , OC_CPS_REGISTERING , OC_CPS_REGISTERED ,
  OC_CPS_FAILED , OC_CPS_DEREGISTERING
}
 

Functions

OC_API int oc_cloud_add_resource (oc_resource_t *resource)
 Publish resource to cloud. More...
 
OC_API void oc_cloud_delete_resource (oc_resource_t *resource)
 Unpublish resource from cloud. More...
 
OC_API int oc_cloud_deregister (oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data)
 
OC_API int oc_cloud_discover_resources (oc_cloud_context_t *ctx, oc_discovery_all_handler_t handler, void *user_data)
 
OC_API oc_cloud_context_t * oc_cloud_get_context (size_t device)
 Get cloud context for device. More...
 
OC_API int oc_cloud_get_identity_cert_chain (oc_cloud_context_t *ctx)
 Get selected identity certificate chain to establish TLS connection. More...
 
OC_API int oc_cloud_get_token_expiry (oc_cloud_context_t *ctx)
 
OC_API int oc_cloud_login (oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data)
 
OC_API int oc_cloud_logout (oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data)
 
OC_API void oc_cloud_manager_restart (oc_cloud_context_t *ctx)
 Restart cloud registration process with the current configuration. More...
 
OC_API int oc_cloud_manager_start (oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data)
 Start cloud registration process. More...
 
OC_API int oc_cloud_manager_stop (oc_cloud_context_t *ctx)
 Stop cloud registration process, remove related pending delayed callbacks and clean-up data. More...
 
OC_API int oc_cloud_provision_conf_resource (oc_cloud_context_t *ctx, const char *server, const char *access_token, const char *server_id, const char *auth_provider)
 
OC_API int oc_cloud_publish_resources (size_t device)
 Republish previously published devices. More...
 
OC_API int oc_cloud_refresh_token (oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data)
 
OC_API int oc_cloud_register (oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data)
 
OC_API void oc_cloud_set_identity_cert_chain (oc_cloud_context_t *ctx, int selected_identity_cred_id)
 Set identity certificate chain to establish TLS connection. More...
 
OC_API void oc_cloud_set_published_resources_ttl (oc_cloud_context_t *ctx, uint32_t ttl)
 Set Time to Live value in the provided cloud context. More...
 

Typedef Documentation

◆ oc_cloud_cb_t

typedef void(* oc_cloud_cb_t) (struct oc_cloud_context_t *ctx, oc_cloud_status_t status, void *user_data)

A function pointer for handling the cloud status.

Parameters
ctxCloud context (cannot be NULL)
statusCurrent status of the cloud.
user_dataUser data

Enumeration Type Documentation

◆ oc_cloud_status_t

Cloud connection status.

Function Documentation

◆ oc_cloud_add_resource()

OC_API int oc_cloud_add_resource ( oc_resource_t resource)

Publish resource to cloud.

Function checks that resource is contained in list of published or to-be published resources. If it is, the function does nothing. If it is not, then the resource is added to the to-be published resources list and a publish request with this list is sent to the cloud server.

Parameters
resourcethe resource to be published

◆ oc_cloud_delete_resource()

OC_API void oc_cloud_delete_resource ( oc_resource_t resource)

Unpublish resource from cloud.

Parameters
resourcethe resource to be unpublished

◆ oc_cloud_get_context()

OC_API oc_cloud_context_t* oc_cloud_get_context ( size_t  device)

Get cloud context for device.

◆ oc_cloud_get_identity_cert_chain()

OC_API int oc_cloud_get_identity_cert_chain ( oc_cloud_context_t *  ctx)

Get selected identity certificate chain to establish TLS connection.

Parameters
ctxCloud context to update, must not be NULL.
Returns
Selected identity certificate chain id. -1 means any.

◆ oc_cloud_manager_restart()

OC_API void oc_cloud_manager_restart ( oc_cloud_context_t *  ctx)

Restart cloud registration process with the current configuration.

Parameters
ctxcloud context (cannot be NULL)

◆ oc_cloud_manager_start()

OC_API int oc_cloud_manager_start ( oc_cloud_context_t *  ctx,
oc_cloud_cb_t  cb,
void *  data 
)

Start cloud registration process.

Parameters
ctxcloud context (cannot be NULL)
cbcallback function invoked on status change
datauser data provided to the status change function
Returns
int 0 on success
int -1 on error

◆ oc_cloud_manager_stop()

OC_API int oc_cloud_manager_stop ( oc_cloud_context_t *  ctx)

Stop cloud registration process, remove related pending delayed callbacks and clean-up data.

Parameters
ctxcloud context (cannot be NULL)
Returns
int 0 on success
int -1 on error

◆ oc_cloud_publish_resources()

OC_API int oc_cloud_publish_resources ( size_t  device)

Republish previously published devices.

Parameters
devicethe device index

◆ oc_cloud_set_identity_cert_chain()

OC_API void oc_cloud_set_identity_cert_chain ( oc_cloud_context_t *  ctx,
int  selected_identity_cred_id 
)

Set identity certificate chain to establish TLS connection.

Parameters
ctxCloud context to update, must not be NULL.
selected_identity_cred_idSelected identity certificate chain id. -1(default) means any.

◆ oc_cloud_set_published_resources_ttl()

OC_API void oc_cloud_set_published_resources_ttl ( oc_cloud_context_t *  ctx,
uint32_t  ttl 
)

Set Time to Live value in the provided cloud context.

Parameters
ctxCloud context to update, must not be NULL.
ttlTime to live value in seconds.