IoTivity-Lite
Support for multiple cloud server addresses

Functions

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_iterate_server_addresses (const oc_cloud_context_t *ctx, oc_endpoint_addresses_iterate_fn_t fn, void *data)
 Iterate over cloud server addresses. 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...
 

Detailed Description

Function Documentation

◆ oc_cloud_add_server_address()

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.

Parameters
ctxcloud context (cannot be NULL)
uriendpoint address (cannot be NULL; the uri must be at least 1 character long and less than OC_ENDPOINT_MAX_ENDPOINT_URI_LENGTH characters long, otherwise the call will fail)
uri_lenlength of uri
sididentity of the cloud server
Returns
oc_endpoint_address_t* pointer to the allocated cloud address
NULL on failure

◆ oc_cloud_iterate_server_addresses()

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.

Parameters
ctxcloud context (cannot be NULL)
fncallback function invoked for each cloud server address (cannot be NULL)
datacustom user data provided to fn
Note
The callback function fn must not modify the list of cloud server addresses.

◆ oc_cloud_remove_server_address()

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.

Parameters
ctxcloud context (cannot be NULL)
eaendpoint address to remove
Returns
true if the endpoint address was removed from the list of cloud servers
false on failure
Note
The servers are stored in a list. If the selected server address is removed, then next server address in the list will be selected. If the selected server address is the last item in the list, then the first server address in the list will be selected (if it exists).
The server is cached by the cloud, so if you remove the selected server address during cloud provisioning then it might be necessary to restart the cloud manager for the change to take effect.
See also
oc_cloud_manager_restart

◆ oc_cloud_select_server_address()

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.

Parameters
ctxcloud context (cannot be NULL)
eacloud server address to select (cannot be NULL; must be in the list of cloud servers)
Returns
true if the address was selected
false on failure to select the address, because it is not in the list of cloud server addresses
Note
The uri of the selected server address will be returned as the cis value and the identity of the selected server address will be returned as the sid value.
The server is cached by the cloud, so if you change the selected server address during cloud provisioning then it might be necessary to restart the cloud manager for the change to take effect.
See also
oc_cloud_remove_server_address
oc_cloud_get_server_uri
oc_cloud_get_server_id
oc_cloud_manager_restart

◆ oc_cloud_selected_server_address()

const oc_endpoint_address_t* oc_cloud_selected_server_address ( const oc_cloud_context_t *  ctx)

Get the selected cloud server address.

Parameters
ctxcloud context (cannot be NULL)
Returns
oc_endpoint_address_t* pointer to the selected cloud server address
NULL if no cloud server address is selected