|
IoTivity-Lite
|
#include "oc_client_state.h"#include "oc_export.h"#include "oc_link.h"#include "oc_ri.h"#include "oc_session_events.h"#include "oc_uuid.h"#include "util/oc_compiler.h"#include "util/oc_endpoint_address.h"#include "util/oc_features.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 bool(* | oc_cloud_on_keepalive_response_cb_t) (bool response_received, uint64_t *next_ping, uint16_t *next_ping_timeout, void *user_data) |
| Callback invoked by the cloud manager when cloud change state to logged in or a keepalive response is received. More... | |
| typedef bool(* | oc_cloud_schedule_action_cb_t) (oc_cloud_action_t action, uint8_t retry_count, uint64_t *delay, uint16_t *timeout, void *user_data) |
| Callback invoked by the cloud manager when the cloud wants to schedule an action. More... | |
| typedef enum oc_cps_t | oc_cps_t |
Enumerations | |
| enum | oc_cloud_action_t { OC_CLOUD_ACTION_UNKNOWN = 0 , OC_CLOUD_ACTION_REGISTER = 1 , OC_CLOUD_ACTION_LOGIN = 2 , OC_CLOUD_ACTION_REFRESH_TOKEN = 3 } |
| Enumeration defining cloud actions. More... | |
| 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 | |
| const char * | oc_cloud_action_to_str (oc_cloud_action_t action) 1 |
| Convert cloud action to a string representation. More... | |
| int | oc_cloud_add_resource (oc_resource_t *resource) |
| Publish resource to cloud. More... | |
| oc_endpoint_address_t * | oc_cloud_add_server_address (oc_cloud_context_t *ctx, const char *uri, size_t uri_len, oc_uuid_t sid) |
| Allocate and add an endpoint address to the list of cloud server addresses. More... | |
| void | oc_cloud_context_clear (oc_cloud_context_t *ctx, bool dump_async) |
| Remove cloud context values, disconnect, and stop the cloud manager, without releasing the context. More... | |
| void | oc_cloud_delete_resource (oc_resource_t *resource) |
| Unpublish resource from cloud. More... | |
| int | oc_cloud_deregister (oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data) |
| Send request to deregister device from cloud. More... | |
| int | oc_cloud_discover_resources (const oc_cloud_context_t *ctx, oc_discovery_all_handler_t handler, void *user_data) |
| const oc_string_t * | oc_cloud_get_access_token (const oc_cloud_context_t *ctx) |
| Get the access token from cloud context. More... | |
| const oc_string_t * | oc_cloud_get_authorization_provider_name (const oc_cloud_context_t *ctx) |
| Get the authorization provider name from cloud context. More... | |
| oc_cloud_context_t * | oc_cloud_get_context (size_t device) |
| Get cloud context for device. More... | |
| size_t | oc_cloud_get_device (const oc_cloud_context_t *ctx) |
| Get device index from cloud context. More... | |
| int | oc_cloud_get_identity_cert_chain (const oc_cloud_context_t *ctx) |
| Get selected identity certificate chain to establish TLS connection. More... | |
| oc_cloud_on_status_change_t | oc_cloud_get_on_status_change (const oc_cloud_context_t *ctx) |
| Get the callback function invoked on status change. More... | |
| oc_cps_t | oc_cloud_get_provisioning_status (const oc_cloud_context_t *ctx) |
| Get current cloud provisiong status. More... | |
| const oc_string_t * | oc_cloud_get_refresh_token (const oc_cloud_context_t *ctx) |
| Get the refresh token from cloud context. More... | |
| const oc_endpoint_t * | oc_cloud_get_server (const oc_cloud_context_t *ctx) |
| Get the active OCF cloud server. More... | |
| const oc_uuid_t * | oc_cloud_get_server_id (const oc_cloud_context_t *ctx) |
| Get the identity of the OCF Cloud. More... | |
| oc_session_state_t | oc_cloud_get_server_session_state (const oc_cloud_context_t *ctx) |
| Get session state of the active cloud server. More... | |
| const oc_string_t * | oc_cloud_get_server_uri (const oc_cloud_context_t *ctx) |
| Get the URL of the OCF Cloud. More... | |
| uint8_t | oc_cloud_get_status (const oc_cloud_context_t *ctx) |
| Get current cloud status. More... | |
| int | oc_cloud_get_token_expiry (const oc_cloud_context_t *ctx) |
| Get access token expiration (in seconds). More... | |
| const oc_string_t * | oc_cloud_get_user_id (const oc_cloud_context_t *ctx) |
| Get the OCF Cloud User identifier. More... | |
| void | oc_cloud_iterate_server_addresses (const oc_cloud_context_t *ctx, oc_endpoint_addresses_iterate_fn_t fn, void *data) |
| Iterate over cloud server addresses. More... | |
| int | oc_cloud_login (oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data) |
| Send request to sign in the device to the cloud. More... | |
| int | oc_cloud_logout (oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data) |
| Send request to sign out the device to the cloud. More... | |
| bool | oc_cloud_manager_is_started (const oc_cloud_context_t *ctx) |
| Check if the cloud registration process is started. More... | |
| void | oc_cloud_manager_restart (oc_cloud_context_t *ctx) |
| Restart cloud registration process with the current configuration. More... | |
| int | oc_cloud_manager_start (oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data) |
| Start cloud registration process. More... | |
| int | oc_cloud_manager_stop (oc_cloud_context_t *ctx) |
| Stop cloud registration process, remove related pending delayed callbacks and clean-up data. More... | |
| void | oc_cloud_manager_stop_v1 (oc_cloud_context_t *ctx, bool resetConfiguration) |
| Stop cloud registration process, remove related pending delayed callbacks and clean-up data. More... | |
| 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) |
| Configure cloud properties. More... | |
| int | oc_cloud_publish_resources (size_t device) |
| Republish previously published devices. More... | |
| int | oc_cloud_refresh_token (oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data) |
| Send request to refresh the device access token to the cloud. More... | |
| int | oc_cloud_register (oc_cloud_context_t *ctx, oc_cloud_cb_t cb, void *data) |
| Send request to register device to cloud. More... | |
| bool | oc_cloud_remove_server_address (oc_cloud_context_t *ctx, const oc_endpoint_address_t *ea) |
| Remove an endpoint address from the list of cloud server addresses. More... | |
| bool | oc_cloud_select_server_address (oc_cloud_context_t *ctx, const oc_endpoint_address_t *ea) |
| Select an address from the list of cloud server addresses. More... | |
| const oc_endpoint_address_t * | oc_cloud_selected_server_address (const oc_cloud_context_t *ctx) |
| Get the selected cloud server address. More... | |
| 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... | |
| void | oc_cloud_set_keepalive (oc_cloud_context_t *ctx, oc_cloud_on_keepalive_response_cb_t on_keepalive_response, void *user_data) |
| Set keepalive parameters for the cloud manager. More... | |
| void | oc_cloud_set_on_status_change (oc_cloud_context_t *ctx, oc_cloud_on_status_change_t status_change) |
| Set the callback function invoked on status change. More... | |
| 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... | |
| void | oc_cloud_set_schedule_action (oc_cloud_context_t *ctx, oc_cloud_schedule_action_cb_t on_schedule_action, void *user_data) |
| Set a custom scheduler for actions in the cloud manager. More... | |
| 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.
| ctx | Cloud context (cannot be NULL) |
| status | Current status of the cloud. |
| user_data | User data |
| typedef bool(* oc_cloud_on_keepalive_response_cb_t) (bool response_received, uint64_t *next_ping, uint16_t *next_ping_timeout, void *user_data) |
Callback invoked by the cloud manager when cloud change state to logged in or a keepalive response is received.
| response_received | Keepalive response received, true if received, otherwise false |
| next_ping | Delay in milliseconds before next keepalive ping |
| next_ping_timeout | Timeout in seconds for next keepalive ping |
| user_data | User data passed from the caller |
| typedef bool(* oc_cloud_schedule_action_cb_t) (oc_cloud_action_t action, uint8_t retry_count, uint64_t *delay, uint16_t *timeout, void *user_data) |
Callback invoked by the cloud manager when the cloud wants to schedule an action.
| action | Cloud action to schedule. |
| retry_count | Retries count - 0 means the first attempt to perform the action. |
| delay | Delay the action in milliseconds before executing it. |
| timeout | Timeout in seconds for the action. |
| user_data | User data passed from the caller. |
| enum oc_cloud_action_t |
| enum oc_cloud_status_t |
Cloud connection status.
| const char* oc_cloud_action_to_str | ( | oc_cloud_action_t | action | ) |
Convert cloud action to a string representation.
| action | Cloud action to convert. |
| 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.
| resource | the resource to be published |
| void oc_cloud_context_clear | ( | oc_cloud_context_t * | ctx, |
| bool | dump_async | ||
| ) |
Remove cloud context values, disconnect, and stop the cloud manager, without releasing the context.
| ctx | Cloud context to clear, must not be NULL. |
| dump_async | If true, store the context to storage in an asynchronous manner; otherwise, perform the dump while executing this function. |
| void oc_cloud_delete_resource | ( | oc_resource_t * | resource | ) |
Unpublish resource from cloud.
| resource | the resource to be unpublished |
| int oc_cloud_deregister | ( | oc_cloud_context_t * | ctx, |
| oc_cloud_cb_t | cb, | ||
| void * | data | ||
| ) |
Send request to deregister device from cloud.
| ctx | cloud context |
| cb | callback function invoked on status change |
| data | user data provided to the status change function |
| const oc_string_t* oc_cloud_get_access_token | ( | const oc_cloud_context_t * | ctx | ) |
Get the access token from cloud context.
Access token is returned by an Authorisation Provider or an OCF Cloud.
| ctx | cloud context (cannot be NULL) |
at property in the cloud configuration resource | const oc_string_t* oc_cloud_get_authorization_provider_name | ( | const oc_cloud_context_t * | ctx | ) |
Get the authorization provider name from cloud context.
The name of the Authorization Provider through which access token was obtained.
| ctx | cloud context (cannot be NULL) |
apn property in the cloud configuration resource | oc_cloud_context_t* oc_cloud_get_context | ( | size_t | device | ) |
Get cloud context for device.
| size_t oc_cloud_get_device | ( | const oc_cloud_context_t * | ctx | ) |
Get device index from cloud context.
| ctx | cloud context (cannot be NULL) |
| int oc_cloud_get_identity_cert_chain | ( | const oc_cloud_context_t * | ctx | ) |
Get selected identity certificate chain to establish TLS connection.
| ctx | Cloud context to update, must not be NULL. |
| oc_cloud_on_status_change_t oc_cloud_get_on_status_change | ( | const oc_cloud_context_t * | ctx | ) |
Get the callback function invoked on status change.
| oc_cps_t oc_cloud_get_provisioning_status | ( | const oc_cloud_context_t * | ctx | ) |
Get current cloud provisiong status.
| ctx | cloud context (cannot be NULL) |
cps property in the cloud configuration resource | const oc_string_t* oc_cloud_get_refresh_token | ( | const oc_cloud_context_t * | ctx | ) |
Get the refresh token from cloud context.
Refresh token is used to obtain a new access token when the current access token expires.
| ctx | cloud context (cannot be NULL) |
| const oc_endpoint_t* oc_cloud_get_server | ( | const oc_cloud_context_t * | ctx | ) |
Get the active OCF cloud server.
| ctx | cloud context (cannot be NULL) |
| const oc_uuid_t* oc_cloud_get_server_id | ( | const oc_cloud_context_t * | ctx | ) |
Get the identity of the OCF Cloud.
| ctx | cloud context (cannot be NULL) |
sid property in the cloud configuration resource | oc_session_state_t oc_cloud_get_server_session_state | ( | const oc_cloud_context_t * | ctx | ) |
Get session state of the active cloud server.
| ctx | cloud context (cannot be NULL) |
| const oc_string_t* oc_cloud_get_server_uri | ( | const oc_cloud_context_t * | ctx | ) |
Get the URL of the OCF Cloud.
| ctx | cloud context (cannot be NULL) |
cis property in the cloud configuration resource | uint8_t oc_cloud_get_status | ( | const oc_cloud_context_t * | ctx | ) |
Get current cloud status.
| ctx | cloud context (cannot be NULL) |
| int oc_cloud_get_token_expiry | ( | const oc_cloud_context_t * | ctx | ) |
Get access token expiration (in seconds).
| const oc_string_t* oc_cloud_get_user_id | ( | const oc_cloud_context_t * | ctx | ) |
Get the OCF Cloud User identifier.
| ctx | cloud context (cannot be NULL) |
uid property in the cloud configuration resource | int oc_cloud_login | ( | oc_cloud_context_t * | ctx, |
| oc_cloud_cb_t | cb, | ||
| void * | data | ||
| ) |
Send request to sign in the device to the cloud.
| ctx | cloud context |
| cb | callback function invoked on status change |
| data | user data provided to the status change function |
| int oc_cloud_logout | ( | oc_cloud_context_t * | ctx, |
| oc_cloud_cb_t | cb, | ||
| void * | data | ||
| ) |
Send request to sign out the device to the cloud.
| ctx | cloud context |
| cb | callback function invoked on status change |
| data | user data provided to the status change function |
| bool oc_cloud_manager_is_started | ( | const oc_cloud_context_t * | ctx | ) |
Check if the cloud registration process is started.
| ctx | cloud context (cannot be NULL) |
| void oc_cloud_manager_restart | ( | oc_cloud_context_t * | ctx | ) |
Restart cloud registration process with the current configuration.
| ctx | cloud context (cannot be NULL) |
| int oc_cloud_manager_start | ( | oc_cloud_context_t * | ctx, |
| oc_cloud_cb_t | cb, | ||
| void * | data | ||
| ) |
Start cloud registration process.
| ctx | cloud context |
| cb | callback function invoked on status change |
| data | user data provided to the status change function |
| int oc_cloud_manager_stop | ( | oc_cloud_context_t * | ctx | ) |
Stop cloud registration process, remove related pending delayed callbacks and clean-up data.
| ctx | cloud context |
| void oc_cloud_manager_stop_v1 | ( | oc_cloud_context_t * | ctx, |
| bool | resetConfiguration | ||
| ) |
Stop cloud registration process, remove related pending delayed callbacks and clean-up data.
| ctx | cloud context (cannot be NULL) |
| resetConfiguration | if true, reset cloud configuration to default (cloud must be reconfigured by oc_cloud_provision_conf_resource or by updating the cloud resource); if false the previous cloud configuration is kept, but the cloud is reset to OC_CPS_REGISTERED state if it was registered or to OC_CPS_READYTOREGISTER otherwise |
| 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 | ||
| ) |
Configure cloud properties.
| ctx | Cloud context to update (cannot be be NULL) |
| server | Cloud server URL |
| access_token | Access token from an Authorisation Provider |
| server_id | Cloud server ID |
| auth_provider | Name of the Authorization Provider which provided the access token |
| int oc_cloud_publish_resources | ( | size_t | device | ) |
Republish previously published devices.
| device | the device index |
| int oc_cloud_refresh_token | ( | oc_cloud_context_t * | ctx, |
| oc_cloud_cb_t | cb, | ||
| void * | data | ||
| ) |
Send request to refresh the device access token to the cloud.
| ctx | cloud context |
| cb | callback function invoked on status change |
| data | user data provided to the status change function |
| int oc_cloud_register | ( | oc_cloud_context_t * | ctx, |
| oc_cloud_cb_t | cb, | ||
| void * | data | ||
| ) |
Send request to register device to cloud.
| ctx | cloud context |
| cb | callback function invoked on status change |
| data | user data provided to the status change function |
| 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.
| ctx | Cloud context to update, must not be NULL. |
| selected_identity_cred_id | Selected identity certificate chain id. -1(default) means any. |
| void oc_cloud_set_keepalive | ( | oc_cloud_context_t * | ctx, |
| oc_cloud_on_keepalive_response_cb_t | on_keepalive_response, | ||
| void * | user_data | ||
| ) |
Set keepalive parameters for the cloud manager.
| ctx | Cloud context to update, must not be NULL. |
| on_keepalive_response | Callback invoked by the cloud manager when cloud change state to logged in or a keepalive response is received. |
| user_data | User data passed from the caller |
| void oc_cloud_set_on_status_change | ( | oc_cloud_context_t * | ctx, |
| oc_cloud_on_status_change_t | status_change | ||
| ) |
Set the callback function invoked on status change.
| ctx | cloud context (cannot be NULL) |
| status_change | callback function invoked on status change with user data |
| 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.
| ctx | Cloud context to update, must not be NULL. |
| ttl | Time to live value in seconds. |
| void oc_cloud_set_schedule_action | ( | oc_cloud_context_t * | ctx, |
| oc_cloud_schedule_action_cb_t | on_schedule_action, | ||
| void * | user_data | ||
| ) |
Set a custom scheduler for actions in the cloud manager.
By default, the cloud manager uses its own scheduler.
This function allows you to set a custom scheduler to define delay and timeout for actions.
| ctx | Cloud context to update. Must not be NULL. |
| on_schedule_action | Callback invoked by the cloud manager when the cloud wants to schedule an action. |
| user_data | User data passed from the caller to be provided during the callback. |
ctx) must not be NULL.