IoTivity-Lite
Support for multiple DPS endpoint addresses

Functions

oc_endpoint_address_t * plgd_dps_add_endpoint_address (plgd_dps_context_t *ctx, const char *uri, size_t uri_len, const char *name, size_t name_len)
 Allocate and add an address to the list of DPS endpoint addresses. More...
 
bool plgd_dps_endpoint_is_empty (const plgd_dps_context_t *ctx)
 Check if no DPS service endpoint is set. More...
 
int plgd_dps_get_endpoint (const plgd_dps_context_t *ctx, char *buffer, size_t buffer_size)
 Copy the selected endpoint address of the DPS service to output buffer. More...
 
void plgd_dps_iterate_server_addresses (const plgd_dps_context_t *ctx, oc_endpoint_addresses_iterate_fn_t iterate_fn, void *iterate_fn_data)
 Iterate over DPS endpoint addresses. More...
 
bool plgd_dps_remove_endpoint_address (plgd_dps_context_t *ctx, const oc_endpoint_address_t *address)
 Remove an address from the list of DPS endpoint addresses. More...
 
bool plgd_dps_select_endpoint_address (plgd_dps_context_t *ctx, const oc_endpoint_address_t *address)
 Select an address from the list of DPS endpoint addresses. More...
 
const oc_endpoint_address_t * plgd_dps_selected_endpoint_address (const plgd_dps_context_t *ctx)
 Get the selected DPS endpoint address. More...
 
void plgd_dps_set_endpoint (plgd_dps_context_t *ctx, const char *endpoint)
 Set endpoint address of the DPS service. More...
 

Detailed Description

Function Documentation

◆ plgd_dps_add_endpoint_address()

oc_endpoint_address_t* plgd_dps_add_endpoint_address ( plgd_dps_context_t *  ctx,
const char *  uri,
size_t  uri_len,
const char *  name,
size_t  name_len 
)

Allocate and add an address to the list of DPS endpoint addresses.

Parameters
ctxdps 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
namename of the DPS endpoint
name_lenlength of name
Returns
oc_endpoint_address_t* pointer to the allocated DPS endpoint address
NULL on failure

◆ plgd_dps_endpoint_is_empty()

bool plgd_dps_endpoint_is_empty ( const plgd_dps_context_t *  ctx)

Check if no DPS service endpoint is set.

Parameters
ctxdps context (cannot be NULL)
Returns
true if no endpoint is set
false otherwise

◆ plgd_dps_get_endpoint()

int plgd_dps_get_endpoint ( const plgd_dps_context_t *  ctx,
char *  buffer,
size_t  buffer_size 
)

Copy the selected endpoint address of the DPS service to output buffer.

Parameters
ctxdps context (cannot be NULL)
[out]bufferoutput buffer (cannot be NULL and must be large enough to contain the endpoint in a string format)
buffer_sizesize of output buffer
Returns
>0 on success, number of copied bytes to buffer
0 endpoint is not set, thus nothing was copied
<0 on error

◆ plgd_dps_iterate_server_addresses()

void plgd_dps_iterate_server_addresses ( const plgd_dps_context_t *  ctx,
oc_endpoint_addresses_iterate_fn_t  iterate_fn,
void *  iterate_fn_data 
)

Iterate over DPS endpoint addresses.

Parameters
ctxdps context (cannot be NULL)
iterate_fncallback function invoked for each DPS endpoint address (cannot be NULL)
iterate_fn_datacustom user data provided to iterate_fn
Note
The callback function iterate_fn must not modify the list of DPS endpoint addresses.

◆ plgd_dps_remove_endpoint_address()

bool plgd_dps_remove_endpoint_address ( plgd_dps_context_t *  ctx,
const oc_endpoint_address_t *  address 
)

Remove an address from the list of DPS endpoint addresses.

Parameters
ctxdps context (cannot be NULL)
addressendpoint address to remove
Returns
true if the endpoint address was removed from the list of DPS endpoints
false on failure
Note
The endpoints 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 in the DPS context, so if you remove the selected endpoint address during provisioning then it might be necessary to restart the DPS manager for the change to take effect.
See also
plgd_dps_manager_restart

◆ plgd_dps_select_endpoint_address()

bool plgd_dps_select_endpoint_address ( plgd_dps_context_t *  ctx,
const oc_endpoint_address_t *  address 
)

Select an address from the list of DPS endpoint addresses.

Parameters
ctxdps context (cannot be NULL)
addressDPS endpoint address to select (cannot be NULL; must be in the list of DPS endpoints)
Returns
true if the address was selected
false on failure to select the address, because it is not in the list of DPS endpoint addresses
Note
The server is cached in the DPS context, so if you remove the selected endpoint address during provisioning then it might be necessary to restart the DPS manager for the change to take effect.
See also
plgd_dps_manager_restart

◆ plgd_dps_selected_endpoint_address()

const oc_endpoint_address_t* plgd_dps_selected_endpoint_address ( const plgd_dps_context_t *  ctx)

Get the selected DPS endpoint address.

Parameters
ctxdps context (cannot be NULL)
Returns
oc_endpoint_address_t* pointer to the selected DPS endpoint address
NULL if no DPS endpoint address is selected

◆ plgd_dps_set_endpoint()

void plgd_dps_set_endpoint ( plgd_dps_context_t *  ctx,
const char *  endpoint 
)

Set endpoint address of the DPS service.

Expected format of the endpoint is "coaps+tcp://${HOST}:${PORT}". For example: coaps+tcp://localhost:40030

If there are multiple endpoint addresses set then a successful call to this function will remove all other endpoint addresses and set the new endpoint address as the only one in the list of DPS endpoint addresses.

Parameters
ctxdps context (cannot be NULL)
endpointendpoint of the provisioning server (cannot be NULL)
Deprecated:
replaced by plgd_dps_add_endpoint_address in v2.2.5.15