IoTivity-Lite
Device provisioning

A facitility to securely provision and preconfigure devices. More...

Modules

 Support for multiple DPS endpoint addresses
 

Macros

#define PLGD_DPS_URI   "/plgd/dps"
 Configuration resource. More...
 

Typedefs

typedef struct plgd_dps_context_t plgd_dps_context_t
 
typedef void(* plgd_dps_on_status_change_cb_t) (plgd_dps_context_t *ctx, plgd_dps_status_t status, void *data)
 A function pointer for handling the dps status. More...
 
typedef void(* plgd_dps_print_log_fn_t) (oc_log_level_t level, const char *file, int line, const char *func_name, const char *format,...)
 Custom logging function. More...
 
typedef bool(* plgd_dps_schedule_action_cb_t) (plgd_dps_context_t *ctx, plgd_dps_status_t action, uint8_t retry_count, uint64_t *delay, uint16_t *timeout, void *user_data)
 Callback invoked by the dps manager when the dps wants to schedule an action. More...
 

Enumerations

enum  { PLGD_DPS_MAX_RETRY_VALUES_SIZE = 8 }
 
enum  plgd_dps_dhcp_set_values_t { PLGD_DPS_DHCP_SET_VALUES_ERROR = -1 , PLGD_DPS_DHCP_SET_VALUES_NOT_CHANGED = 0 , PLGD_DPS_DHCP_SET_VALUES_UPDATED = 1 , PLGD_DPS_DHCP_SET_VALUES_NEED_REPROVISION }
 DPS dhcp plgd_dps_dhcp_set_values_from_vendor_encapsulated_options return values. More...
 
enum  plgd_dps_error_t {
  PLGD_DPS_OK = 0 , PLGD_DPS_ERROR_RESPONSE = 1 , PLGD_DPS_ERROR_CONNECT = 2 , PLGD_DPS_ERROR_GET_CREDENTIALS = 3 ,
  PLGD_DPS_ERROR_GET_ACLS = 4 , PLGD_DPS_ERROR_SET_CLOUD = 5 , PLGD_DPS_ERROR_START_CLOUD = 6 , PLGD_DPS_ERROR_GET_OWNER = 7 ,
  PLGD_DPS_ERROR_GET_TIME = 8
}
 DPS errors. More...
 
enum  plgd_dps_status_t {
  PLGD_DPS_INITIALIZED = 1 << 0 , PLGD_DPS_GET_CREDENTIALS = 1 << 1 , PLGD_DPS_HAS_CREDENTIALS = 1 << 2 , PLGD_DPS_GET_ACLS = 1 << 3 ,
  PLGD_DPS_HAS_ACLS = 1 << 4 , PLGD_DPS_GET_CLOUD = 1 << 6 , PLGD_DPS_HAS_CLOUD = 1 << 7 , PLGD_DPS_CLOUD_STARTED = 1 << 8 ,
  PLGD_DPS_RENEW_CREDENTIALS = 1 << 9 , PLGD_DPS_GET_OWNER = 1 << 10 , PLGD_DPS_HAS_OWNER = 1 << 11 , PLGD_DPS_GET_TIME = 1 << 12 ,
  PLGD_DPS_HAS_TIME = 1 << 13 , PLGD_DPS_TRANSIENT_FAILURE = 1 << 29 , PLGD_DPS_FAILURE = 1 << 30
}
 DPS provisioning status flags. More...
 

Functions

bool plgd_cloud_manager_start (const plgd_dps_context_t *ctx)
 Start cloud manager with previously set server and callbacks. More...
 
uint8_t plgd_dps_dhcp_get_vendor_encapsulated_option_code_dps_certificate_fingerprint (const plgd_dps_context_t *ctx)
 Get the vendor encapsulated option code for the DPS certificate fingerprint. More...
 
uint8_t plgd_dps_dhcp_get_vendor_encapsulated_option_code_dps_endpoint (const plgd_dps_context_t *ctx)
 Get the vendor encapsulated option code for the DPS endpoint. More...
 
plgd_dps_dhcp_set_values_t plgd_dps_dhcp_set_values_from_vendor_encapsulated_options (plgd_dps_context_t *ctx, const uint8_t *vendor_encapsulated_options, size_t vendor_encapsulated_options_size)
 Set DPS endpoint and certificate fingerprint that will be used in establishment of secure connection. More...
 
void plgd_dps_dhcp_set_vendor_encapsulated_option_code_dps_certificate_fingerprint (plgd_dps_context_t *ctx, uint8_t code)
 Set the vendor encapsulated option code for the DPS certificate fingerprint. More...
 
void plgd_dps_dhcp_set_vendor_encapsulated_option_code_dps_endpoint (plgd_dps_context_t *ctx, uint8_t code)
 Set the vendor encapsulated option code for the DPS endpoint. More...
 
void plgd_dps_force_reprovision (plgd_dps_context_t *ctx)
 Force all steps of the provisioning process to be executed. More...
 
int plgd_dps_get_certificate_fingerprint (const plgd_dps_context_t *ctx, mbedtls_md_type_t *md_type, uint8_t *buffer, size_t buffer_size)
 Copy certificate fingerprint of the DPS service to output buffer. More...
 
plgd_cloud_status_observer_configuration_t plgd_dps_get_cloud_observer_configuration (const plgd_dps_context_t *ctx)
 Get cloud observer configuration. More...
 
plgd_dps_context_t * plgd_dps_get_context (size_t device)
 Get context for given device. More...
 
size_t plgd_dps_get_device (const plgd_dps_context_t *ctx)
 Get device from context. More...
 
plgd_dps_error_t plgd_dps_get_last_error (const plgd_dps_context_t *ctx)
 Get last provisioning error. More...
 
plgd_dps_print_log_fn_t plgd_dps_get_log_fn (void) 1
 Get global logging function. More...
 
uint32_t plgd_dps_get_provision_status (const plgd_dps_context_t *ctx)
 Get provision status. More...
 
bool plgd_dps_get_skip_verify (const plgd_dps_context_t *ctx)
 Get skip verify value from context. More...
 
bool plgd_dps_has_been_provisioned_since_reset (const plgd_dps_context_t *ctx)
 Check whether the device has been provisioned at least once since the last DPS reset initiated by a factory reset or by setting the endpoint to an empty value in the DPS resource. More...
 
bool plgd_dps_has_forced_reprovision (const plgd_dps_context_t *ctx)
 Check if force reprovision flag is set. More...
 
ssize_t plgd_dps_hex_string_to_bytes (const char *hex_string, size_t hex_string_size, uint8_t *buffer, size_t buffer_size)
 Convert isc-dhcp leases file vendor encapsulated options to byte array. More...
 
int plgd_dps_init (void)
 Allocate and initialize data. More...
 
oc_log_level_t plgd_dps_log_get_level (void)
 Get log level of the global logger. More...
 
void plgd_dps_log_set_level (oc_log_level_t level)
 Set log level of the global logger, logs with lower importance will be ignored. More...
 
bool plgd_dps_manager_is_started (const plgd_dps_context_t *ctx)
 Check whether DPS manager has been started. More...
 
int plgd_dps_manager_restart (plgd_dps_context_t *ctx)
 Restart DPS manager to provision device by given server. More...
 
int plgd_dps_manager_start (plgd_dps_context_t *ctx)
 Start DPS manager to provision device. More...
 
void plgd_dps_manager_stop (plgd_dps_context_t *ctx)
 Stop DPS manager. More...
 
int plgd_dps_on_factory_reset (plgd_dps_context_t *ctx)
 Clean-up of DPS provisioning on factory reset. More...
 
uint16_t plgd_dps_pki_get_expiring_limit (const plgd_dps_context_t *ctx)
 Get expiring-in limit of DPS certificates. More...
 
void plgd_dps_pki_set_expiring_limit (plgd_dps_context_t *ctx, uint16_t expiring_limit)
 Set expiring-in limit of DPS certificates. More...
 
bool plgd_dps_set_certificate_fingerprint (plgd_dps_context_t *ctx, mbedtls_md_type_t md_type, const uint8_t *fingerprint, size_t size)
 Set certificate fingerprint of the provisioning server. More...
 
bool plgd_dps_set_cloud_observer_configuration (plgd_dps_context_t *ctx, uint8_t max_retry_count, uint8_t retry_interval_s)
 Configure cloud observer. More...
 
void plgd_dps_set_configuration_resource (plgd_dps_context_t *ctx, bool create)
 Controls whether a dps client creates configuration resource for managing dps client via COAPs API. More...
 
void plgd_dps_set_log_fn (plgd_dps_print_log_fn_t log_fn)
 Set global logging function. More...
 
void plgd_dps_set_manager_callbacks (plgd_dps_context_t *ctx, plgd_dps_manager_callbacks_t callbacks)
 Set DPS manager callbacks. More...
 
bool plgd_dps_set_retry_configuration (plgd_dps_context_t *ctx, const uint8_t cfg[], size_t cfg_size)
 Configure retry counter. More...
 
void plgd_dps_set_schedule_action (plgd_dps_context_t *ctx, plgd_dps_schedule_action_cb_t on_schedule_action, void *user_data)
 Set a custom scheduler for actions in the cloud manager. More...
 
void plgd_dps_set_skip_verify (plgd_dps_context_t *ctx, bool skip_verify)
 Controls whether a dps client verifies the device provision service's certificate chain against trust anchor in the device. More...
 
void plgd_dps_shutdown (void)
 Stop all devices and deallocate data. More...
 
int plgs_dps_get_retry_configuration (const plgd_dps_context_t *ctx, uint8_t *buffer, size_t buffer_size)
 Get retry counter configuration. More...
 

Detailed Description

A facitility to securely provision and preconfigure devices.

Macro Definition Documentation

◆ PLGD_DPS_URI

#define PLGD_DPS_URI   "/plgd/dps"

Configuration resource.

Description:

  • Resource type: x.plgd.dps.conf
  • Resource structure in json format: { endpoint: string; lastErrorCode: int; provisionStatus: string; forceReprovision: bool; }

Typedef Documentation

◆ plgd_dps_on_status_change_cb_t

typedef void(* plgd_dps_on_status_change_cb_t) (plgd_dps_context_t *ctx, plgd_dps_status_t status, void *data)

A function pointer for handling the dps status.

Parameters
ctxdps context
statusCurrent status of the dps.
datauser data provided to the callback

◆ plgd_dps_print_log_fn_t

typedef void(* plgd_dps_print_log_fn_t) (oc_log_level_t level, const char *file, int line, const char *func_name, const char *format,...)

Custom logging function.

Parameters
levellog level of the message
filefile of the log message call
lineline of the log message call in file
func_namefunction name in which the log message call is invoked
formatformat of the log message

◆ plgd_dps_schedule_action_cb_t

typedef bool(* plgd_dps_schedule_action_cb_t) (plgd_dps_context_t *ctx, plgd_dps_status_t action, uint8_t retry_count, uint64_t *delay, uint16_t *timeout, void *user_data)

Callback invoked by the dps manager when the dps wants to schedule an action.

Parameters
ctxdps context
actionOne of PLGD_DPS_GET actions or PLGD_DPS_RENEW_CREDENTIALS to schedule, or 0 for reinitialization.
retry_countRetries count - 0 means the first attempt to perform the action.
delayDelay the action in milliseconds before executing it.
timeoutTimeout in seconds for the action.
user_dataUser data passed from the caller.
Returns
true if the dps manager should continue to schedule the action, false if the dps manager should restarts from the beginning.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PLGD_DPS_MAX_RETRY_VALUES_SIZE 

Maximal size of the retry configuration array.

◆ plgd_dps_dhcp_set_values_t

DPS dhcp plgd_dps_dhcp_set_values_from_vendor_encapsulated_options return values.

◆ plgd_dps_error_t

DPS errors.

◆ plgd_dps_status_t

DPS provisioning status flags.

Function Documentation

◆ plgd_cloud_manager_start()

bool plgd_cloud_manager_start ( const plgd_dps_context_t *  ctx)

Start cloud manager with previously set server and callbacks.

Parameters
ctxdps context (cannot be NULL)
Returns
true on success
false otherwise

◆ plgd_dps_dhcp_get_vendor_encapsulated_option_code_dps_certificate_fingerprint()

uint8_t plgd_dps_dhcp_get_vendor_encapsulated_option_code_dps_certificate_fingerprint ( const plgd_dps_context_t *  ctx)

Get the vendor encapsulated option code for the DPS certificate fingerprint.

Used during call plgd_dps_set_dhcp_vendor_encapsulated_option_code_dps_certificate_fingerprint.

Parameters
ctxdps context (cannot be NULL)
Returns
uint8_t vendor encapsulated option code for the DPS certificate fingerprint.

◆ plgd_dps_dhcp_get_vendor_encapsulated_option_code_dps_endpoint()

uint8_t plgd_dps_dhcp_get_vendor_encapsulated_option_code_dps_endpoint ( const plgd_dps_context_t *  ctx)

Get the vendor encapsulated option code for the DPS endpoint.

Used during call plgd_dps_set_dhcp_vendor_encapsulated_option_code_dps_certificate_fingerprint.

Parameters
ctxdps context (cannot be NULL)
Returns
uint8_t vendor encapsulated option code for the DPS endpoint

◆ plgd_dps_dhcp_set_values_from_vendor_encapsulated_options()

plgd_dps_dhcp_set_values_t plgd_dps_dhcp_set_values_from_vendor_encapsulated_options ( plgd_dps_context_t *  ctx,
const uint8_t *  vendor_encapsulated_options,
size_t  vendor_encapsulated_options_size 
)

Set DPS endpoint and certificate fingerprint that will be used in establishment of secure connection.

Parameters
ctxdps context (cannot be NULL)
vendor_encapsulated_optionsvendor encapsulated options in byte array
vendor_encapsulated_options_sizevendor encapsulated options size in byte array
Returns
one of plgd_dps_dhcp_set_values_t

◆ plgd_dps_dhcp_set_vendor_encapsulated_option_code_dps_certificate_fingerprint()

void plgd_dps_dhcp_set_vendor_encapsulated_option_code_dps_certificate_fingerprint ( plgd_dps_context_t *  ctx,
uint8_t  code 
)

Set the vendor encapsulated option code for the DPS certificate fingerprint.

Used during call plgd_dps_set_dhcp_vendor_encapsulated_option_code_dps_certificate_fingerprint.

Parameters
ctxdps context (cannot be NULL)
codevendor encapsulated option code for the DPS certificate fingerprint.

◆ plgd_dps_dhcp_set_vendor_encapsulated_option_code_dps_endpoint()

void plgd_dps_dhcp_set_vendor_encapsulated_option_code_dps_endpoint ( plgd_dps_context_t *  ctx,
uint8_t  code 
)

Set the vendor encapsulated option code for the DPS endpoint.

Used during call plgd_dps_set_dhcp_vendor_encapsulated_option_code_dps_certificate_fingerprint.

Parameters
ctxdps context (cannot be NULL)
codevendor encapsulated option code for the DPS endpoint

◆ plgd_dps_force_reprovision()

void plgd_dps_force_reprovision ( plgd_dps_context_t *  ctx)

Force all steps of the provisioning process to be executed.

A step that was successfully executed stores data in the storage and on the next start this data is still valid the step would be automatically skipped.

Parameters
ctxdps context (cannot be NULL)
See also
plgd_dps_manager_start

◆ plgd_dps_get_certificate_fingerprint()

int plgd_dps_get_certificate_fingerprint ( const plgd_dps_context_t *  ctx,
mbedtls_md_type_t *  md_type,
uint8_t *  buffer,
size_t  buffer_size 
)

Copy certificate fingerprint of the DPS service to output buffer.

Parameters
ctxdps context (cannot be NULL)
[out]md_typehash algorithm used for fingerprint
[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_get_cloud_observer_configuration()

plgd_cloud_status_observer_configuration_t plgd_dps_get_cloud_observer_configuration ( const plgd_dps_context_t *  ctx)

Get cloud observer configuration.

Parameters
ctxdps context (cannot be NULL)
Returns
plgd_cloud_status_observer_configuration_t current cloud observer configuration

◆ plgd_dps_get_context()

plgd_dps_context_t* plgd_dps_get_context ( size_t  device)

Get context for given device.

◆ plgd_dps_get_device()

size_t plgd_dps_get_device ( const plgd_dps_context_t *  ctx)

Get device from context.

Parameters
ctxdps context (cannot be NULL)
Returns
size_t index of device

◆ plgd_dps_get_last_error()

plgd_dps_error_t plgd_dps_get_last_error ( const plgd_dps_context_t *  ctx)

Get last provisioning error.

Parameters
ctxdps context (cannot be NULL)
Returns
plgd_dps_error_t last provisioning error

◆ plgd_dps_get_log_fn()

plgd_dps_print_log_fn_t plgd_dps_get_log_fn ( void  )

Get global logging function.

◆ plgd_dps_get_provision_status()

uint32_t plgd_dps_get_provision_status ( const plgd_dps_context_t *  ctx)

Get provision status.

Parameters
ctxdps context (cannot be NULL)
Returns
uint16_t current provision status

◆ plgd_dps_get_skip_verify()

bool plgd_dps_get_skip_verify ( const plgd_dps_context_t *  ctx)

Get skip verify value from context.

Parameters
ctxdps context (cannot be NULL)
Returns
true skip verify is enabled
false skip verify is disabled
See also
plgd_dps_set_skip_verify

◆ plgd_dps_has_been_provisioned_since_reset()

bool plgd_dps_has_been_provisioned_since_reset ( const plgd_dps_context_t *  ctx)

Check whether the device has been provisioned at least once since the last DPS reset initiated by a factory reset or by setting the endpoint to an empty value in the DPS resource.

Parameters
ctxdps context (cannot be NULL)
Returns
true if DPS has been successfully provisioned at least once since the DPS context reset.
false for otherwise

◆ plgd_dps_has_forced_reprovision()

bool plgd_dps_has_forced_reprovision ( const plgd_dps_context_t *  ctx)

Check if force reprovision flag is set.

Parameters
ctxdps context (cannot be NULL)
Returns
true force reprovision is set
false force reprovision is not set

◆ plgd_dps_hex_string_to_bytes()

ssize_t plgd_dps_hex_string_to_bytes ( const char *  hex_string,
size_t  hex_string_size,
uint8_t *  buffer,
size_t  buffer_size 
)

Convert isc-dhcp leases file vendor encapsulated options to byte array.

Parameters
hex_stringinput hex string (cannot be NULL) in format "01:a:3:14" or "010a0314"
hex_string_sizevendor encapsulated options size in dhcp leases file.
bufferoutput buffer into which the byte array will be copied or NULL to get the needed size
buffer_sizesize of the output buffer
Returns
>0 the size of used or needed to copy to buffer, -1 on error

◆ plgd_dps_init()

int plgd_dps_init ( void  )

Allocate and initialize data.

Returns
int 0 on success <0 on failure

◆ plgd_dps_log_get_level()

oc_log_level_t plgd_dps_log_get_level ( void  )

Get log level of the global logger.

It is thread safe.

Returns
Log level

◆ plgd_dps_log_set_level()

void plgd_dps_log_set_level ( oc_log_level_t  level)

Set log level of the global logger, logs with lower importance will be ignored.

It is thread safe.

Parameters
levelLog level
Note
If log level is not set, the default log level is OC_LOG_LEVEL_INFO.

◆ plgd_dps_manager_is_started()

bool plgd_dps_manager_is_started ( const plgd_dps_context_t *  ctx)

Check whether DPS manager has been started.

Parameters
ctxdps context (cannot be NULL)
Returns
true DPS manager has been started
false DPS manager has not been started
See also
plgd_dps_manager_start

◆ plgd_dps_manager_restart()

int plgd_dps_manager_restart ( plgd_dps_context_t *  ctx)

Restart DPS manager to provision device by given server.

A convenience function equivalent to calling plgd_dps_manager_stop and plgd_dps_manager_start.

Parameters
ctxdps context (cannot be NULL)
Returns
0 on success
-1 on failure
See also
plgd_dps_manager_start
plgd_dps_manager_stop

◆ plgd_dps_manager_start()

int plgd_dps_manager_start ( plgd_dps_context_t *  ctx)

Start DPS manager to provision device.

Setup context, global session handlers and start DPS manager.

Starting DPS also starts the retry mechanism, which will remain active until the device is successfully provisioned. If a provisioning step fails, it will be tried again after a time interval. The time interval depends on the retry counter (which is incremented on each retry) and uses the following values [ 10, 20, 40, 80, 120 ] in seconds. Meaning that the first retry is scheduled after 10 seconds after a failure, the second retry after 20 seconds, etc. After the interval reaches the maximal value (120 seconds) it resets back to the first value (10 seconds).

Note
Before starting the DPS manager, an endpoint must be added by plgd_dps_add_endpoint_address (if you add multiple endpoints then use plgd_dps_select_endpoint_address to select the endpoint that will be used to provision). Without an endpoint selected the provisioning will not start.
The function examines the state of storage and some provisioning steps might be skipped if the stored data is evaluated as still valid. To force full reprovisioning call plgd_force_reprovision before this function. At the end of this call forced reprovisioning is disabled.
See also
plgd_force_reprovision
Parameters
ctxdps context (cannot be NULL)
Returns
0 on success
-1 on failure

◆ plgd_dps_manager_stop()

void plgd_dps_manager_stop ( plgd_dps_context_t *  ctx)

Stop DPS manager.

Deregister handlers, clear context, stop DPS manager, close connection to DPS endpoint and remove identity certificates retrieved from DPS endpoint.

Parameters
ctxdps context (cannot be NULL)

◆ plgd_dps_on_factory_reset()

int plgd_dps_on_factory_reset ( plgd_dps_context_t *  ctx)

Clean-up of DPS provisioning on factory reset.

The function must be called from the factory reset handler to clean-up data that has been invalidated by a factory reset. The clean-up includes:

  • stopping of DPS provisioning and resetting the provisioning status
  • disconnecting from DPS endpoint and resetting the endpoint address
  • resetting data in storage and committing the empty data to storage files
  • removing identifiers of identity certificates that have been deleted by factory reset
Parameters
ctxdps context (cannot be NULL)
Returns
0 on success
-1 on failure

◆ plgd_dps_pki_get_expiring_limit()

uint16_t plgd_dps_pki_get_expiring_limit ( const plgd_dps_context_t *  ctx)

Get expiring-in limit of DPS certificates.

Parameters
ctxdps context (cannot be NULL)
Returns
expiring-in limit in seconds

◆ plgd_dps_pki_set_expiring_limit()

void plgd_dps_pki_set_expiring_limit ( plgd_dps_context_t *  ctx,
uint16_t  expiring_limit 
)

Set expiring-in limit of DPS certificates.

If a certificate's valid-to timestamp is within the expiring-in limit (current time < valid_to and current time + expiring-in limit > valid_to) then the certificate is considered as expiring. Expiring certificates are not accepted during the get credentials step of DPS provisioning. If a expiring certificates is received then the step is retried to receive a newer certificate with longer expiration.

Parameters
ctxdps context (cannot be NULL)
expiring_limitlimit value in seconds

◆ plgd_dps_set_certificate_fingerprint()

bool plgd_dps_set_certificate_fingerprint ( plgd_dps_context_t *  ctx,
mbedtls_md_type_t  md_type,
const uint8_t *  fingerprint,
size_t  size 
)

Set certificate fingerprint of the provisioning server.

If the fingerprint is set then the DPS client will verify the fingerprint of the provisioning server certificate during the TLS handshake. If any certificate matching the fingerprint in the chain is found then the handshake is successful.

Parameters
ctxdps context (cannot be NULL)
md_typehash algorithm used for fingerprint
fingerprintfingerprint of the provisioning server certificate
sizesize of the fingerprint
Returns
true on success

◆ plgd_dps_set_cloud_observer_configuration()

bool plgd_dps_set_cloud_observer_configuration ( plgd_dps_context_t *  ctx,
uint8_t  max_retry_count,
uint8_t  retry_interval_s 
)

Configure cloud observer.

Parameters
ctxdps context (cannot be NULL)
max_retry_countmaximal number of retries, set to 0 to disable cloud status observer
retry_interval_sretry interval in seconds (must be >0)
Returns
true on success
false on error caused by invalid parameters

◆ plgd_dps_set_configuration_resource()

void plgd_dps_set_configuration_resource ( plgd_dps_context_t *  ctx,
bool  create 
)

Controls whether a dps client creates configuration resource for managing dps client via COAPs API.

Parameters
ctxdps context (cannot be NULL)
createset true for creating resource. set false to free memory of created resource.

◆ plgd_dps_set_log_fn()

void plgd_dps_set_log_fn ( plgd_dps_print_log_fn_t  log_fn)

Set global logging function.

◆ plgd_dps_set_manager_callbacks()

void plgd_dps_set_manager_callbacks ( plgd_dps_context_t *  ctx,
plgd_dps_manager_callbacks_t  callbacks 
)

Set DPS manager callbacks.

Parameters
ctxdps context (cannot be NULL)
callbackscallbacks with data

Example of plgd_dps_on_status_change_cb_t function:

static void
on_change_cb(plgd_dps_context_t *ctx, plgd_dps_status_t status, void
*on_change_data) { printf("DPS Manager Status:\n"); if (status &
PLGD_DPS_INITIALIZED) { printf("\t-Initialized\n");
}
...
}
plgd_dps_status_t
DPS provisioning status flags.
Definition: plgd_dps.h:122

Example of oc_cloud_cb_t function:

static void
on_cloud_change_cb(oc_cloud_context_t *ctx, oc_cloud_status_t status, void
*on_cloud_change_data) { printf("Cloud Manager Status:\n"); if (status &
OC_CLOUD_REGISTERED) { printf("\t-Registered\n");
}
...
}
oc_cloud_status_t
Cloud connection status.
Definition: oc_cloud.h:43

◆ plgd_dps_set_retry_configuration()

bool plgd_dps_set_retry_configuration ( plgd_dps_context_t *  ctx,
const uint8_t  cfg[],
size_t  cfg_size 
)

Configure retry counter.

Parameters
ctxdps context (cannot be NULL)
cfgarray with new timeout values (must have [1, PLGD_DPS_MAX_RETRY_VALUES_SIZE> number of non-zero values)
cfg_sizesize of the array with timeout values
Returns
true on success
false on failure

◆ plgd_dps_set_schedule_action()

void plgd_dps_set_schedule_action ( plgd_dps_context_t *  ctx,
plgd_dps_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.

Parameters
ctxCloud context to update. Must not be NULL.
on_schedule_actionCallback invoked by the cloud manager when the cloud wants to schedule an action.
user_dataUser data passed from the caller to be provided during the callback.
Note
The provided cloud context (ctx) must not be NULL.
See also
oc_cloud_schedule_action_cb_t

◆ plgd_dps_set_skip_verify()

void plgd_dps_set_skip_verify ( plgd_dps_context_t *  ctx,
bool  skip_verify 
)

Controls whether a dps client verifies the device provision service's certificate chain against trust anchor in the device.

To set skip verify, it must be called before plgd_dps_manager_start.

Parameters
ctxdps context (cannot be NULL)
skip_verifyskip verification of the DPS service

◆ plgd_dps_shutdown()

void plgd_dps_shutdown ( void  )

Stop all devices and deallocate data.

◆ plgs_dps_get_retry_configuration()

int plgs_dps_get_retry_configuration ( const plgd_dps_context_t *  ctx,
uint8_t *  buffer,
size_t  buffer_size 
)

Get retry counter configuration.

Parameters
ctxdps context (cannot be NULL)
[out]bufferoutput buffer into which the configuration will be copied (cannot be NULL, and must be large enough to contain the current configuration)
buffer_sizesize of the output buffer
Returns
>0 the size of the configuration array copied to buffer
<0 on failure