IoTivity-Lite
oc_api.h File Reference

Main API of IoTivity-Lite for client and server. More...

#include "messaging/coap/oc_coap.h"
#include "oc_buffer_settings.h"
#include "oc_cloud.h"
#include "oc_rep.h"
#include "oc_ri.h"
#include "oc_signal_event_loop.h"
#include "port/oc_storage.h"
#include "oc_client_state.h"

Data Structures

struct  oc_handler_t
 Call back handlers that are invoked in response to oc_main_init() More...
 

Macros

#define oc_activate_interrupt_handler(name)   (oc_process_start(&(name##_interrupt_x), 0))
 
#define oc_define_interrupt_handler(name)
 
#define oc_set_custom_device_property(prop, value)   oc_rep_set_text_string(root, prop, value)
 Set custom device property. More...
 
#define oc_set_custom_platform_property(prop, value)   oc_rep_set_text_string(root, prop, value)
 Set custom platform property. More...
 
#define oc_signal_interrupt_handler(name)
 API for setting handlers for interrupts. More...
 

Typedefs

typedef void(* oc_add_device_cb_t) (void *data)
 Callback invoked during oc_add_device(). More...
 
typedef void(* oc_con_write_cb_t) (size_t device_index, oc_rep_t *rep)
 Callback for change notifications from the oic.wk.con resource. More...
 
typedef void(* oc_factory_presets_cb_t) (size_t device, void *data)
 Callback invoked by the stack initialization to perform any "factory settings", e.g., this may be used to load a manufacturer certificate. More...
 
typedef void(* oc_init_platform_cb_t) (void *data)
 Callback invoked during oc_init_platform(). More...
 
typedef void(* oc_ownership_status_cb_t) (const oc_uuid_t *device_uuid, size_t device_index, bool owned, void *user_data)
 Callback invoked when the "owned" property of the doxm is changed. More...
 
typedef void(* oc_random_pin_cb_t) (const unsigned char *pin, size_t pin_len, void *data)
 Callback invoked when an onboarding client requests device ownership via the Random PIN Ownership Transfer Method (OTM). More...
 
typedef void(* oc_resource_free_instance_t) (oc_resource_t *)
 
typedef oc_resource_t *(* oc_resource_get_instance_t) (const char *, oc_string_array_t *, oc_resource_properties_t, oc_interface_mask_t, size_t)
 
typedef struct oc_role_t oc_role_t
 

Functions

void oc_add_collection (oc_resource_t *collection)
 Adds a collection to the list of collections. More...
 
int oc_add_device (const char *uri, const char *rt, const char *name, const char *spec_version, const char *data_model_version, oc_add_device_cb_t add_device_cb, void *data)
 Add an ocf device to the the stack. More...
 
void oc_add_ownership_status_cb (oc_ownership_status_cb_t cb, void *user_data)
 Add callback that is invoked when the doxm "owned" property is changed. More...
 
bool oc_add_resource (oc_resource_t *resource)
 Add a resource to the IoTivity stack. More...
 
void oc_assert_all_roles (oc_endpoint_t *endpoint, oc_response_handler_t handler, void *user_data)
 
bool oc_assert_role (const char *role, const char *authority, oc_endpoint_t *endpoint, oc_response_handler_t handler, void *user_data)
 
void oc_auto_assert_roles (bool auto_assert)
 
void oc_close_session (oc_endpoint_t *endpoint)
 
void oc_collection_add_link (oc_resource_t *collection, oc_link_t *link)
 Adds the link to the collection. More...
 
bool oc_collection_add_mandatory_rt (oc_resource_t *collection, const char *rt)
 Add a mandatory Resource Type to a collection. More...
 
bool oc_collection_add_supported_rt (oc_resource_t *collection, const char *rt)
 Add a supported Resource Type to a collection. More...
 
oc_resource_t * oc_collection_get_collections (void)
 Gets all known collections. More...
 
oc_link_t * oc_collection_get_links (oc_resource_t *collection)
 Returns the list of links belonging to this collection. More...
 
void oc_collection_remove_link (oc_resource_t *collection, oc_link_t *link)
 Removes a link from the collection. More...
 
bool oc_collections_add_rt_factory (const char *rt, oc_resource_get_instance_t get_instance, oc_resource_free_instance_t free_instance)
 
void oc_delete_collection (oc_resource_t *collection)
 Deletes the specified collection. More...
 
void oc_delete_link (oc_link_t *link)
 Deletes the link. More...
 
bool oc_delete_resource (oc_resource_t *resource)
 Remove a resource from the IoTivity stack and delete the resource. More...
 
void oc_device_bind_resource_type (size_t device, const char *type)
 Add a Resource Type "rt" property to the an /oic/d resource. More...
 
bool oc_do_delete (const char *uri, oc_endpoint_t *endpoint, const char *query, oc_response_handler_t handler, oc_qos_t qos, void *user_data)
 Issue a DELETE request to delete a resource. More...
 
bool oc_do_get (const char *uri, oc_endpoint_t *endpoint, const char *query, oc_response_handler_t handler, oc_qos_t qos, void *user_data)
 Issue a GET request to obtain the current value of all properties a resource. More...
 
bool oc_do_ip_discovery (const char *rt, oc_discovery_handler_t handler, void *user_data)
 Discover all servers that have a resource type. More...
 
bool oc_do_ip_discovery_all (oc_discovery_all_handler_t handler, void *user_data)
 Discover all servers. More...
 
bool oc_do_ip_discovery_all_at_endpoint (oc_discovery_all_handler_t handler, oc_endpoint_t *endpoint, void *user_data)
 Discover all resources in a specific endpoint. More...
 
bool oc_do_ip_discovery_at_endpoint (const char *rt, oc_discovery_handler_t handler, oc_endpoint_t *endpoint, void *user_data)
 Discover resources in a specific endpoint. More...
 
bool oc_do_ip_multicast (const char *uri, const char *query, oc_response_handler_t handler, void *user_data)
 
bool oc_do_observe (const char *uri, oc_endpoint_t *endpoint, const char *query, oc_response_handler_t handler, oc_qos_t qos, void *user_data)
 Dispatch a GET request with the CoAP Observe option to subscribe for notifications from a resource. More...
 
bool oc_do_post (void)
 Dispatch the CoAP POST request. More...
 
bool oc_do_put (void)
 Dispatch the CoAP PUT request. More...
 
bool oc_do_realm_local_ipv6_discovery (const char *rt, oc_discovery_handler_t handler, void *user_data)
 Discover all servers that have a resource type using the realm-local scope. More...
 
bool oc_do_realm_local_ipv6_discovery_all (oc_discovery_all_handler_t handler, void *user_data)
 Discover all servers using the realm-local scope. More...
 
bool oc_do_realm_local_ipv6_multicast (const char *uri, const char *query, oc_response_handler_t handler, void *user_data)
 
bool oc_do_site_local_ipv6_discovery (const char *rt, oc_discovery_handler_t handler, void *user_data)
 Discover all servers that have a resource type using the site-local scope. More...
 
bool oc_do_site_local_ipv6_discovery_all (oc_discovery_all_handler_t handler, void *user_data)
 Discover all servers using the realm-local scope. More...
 
bool oc_do_site_local_ipv6_multicast (const char *uri, const char *query, oc_response_handler_t handler, void *user_data)
 
void oc_free_server_endpoints (oc_endpoint_t *endpoint)
 Free a list of endpoints from the oc_endpoint_t. More...
 
oc_role_t * oc_get_all_roles (void)
 
bool oc_get_con_res_announced (void)
 Returns whether the oic.wk.con resource is advertised. More...
 
int oc_get_query_value (oc_request_t *request, const char *key, char **value)
 Get a pointer to the start of the value in a URL query parameter key=value pair. More...
 
void oc_ignore_request (oc_request_t *request)
 Ignore the request. More...
 
void oc_indicate_separate_response (oc_request_t *request, oc_separate_response_t *response)
 Respond to an incoming request asynchronously. More...
 
int oc_init_platform (const char *mfg_name, oc_init_platform_cb_t init_platform_cb, void *data)
 Initialize the platform. More...
 
bool oc_init_post (const char *uri, oc_endpoint_t *endpoint, const char *query, oc_response_handler_t handler, oc_qos_t qos, void *user_data)
 Prepare the stack to issue a POST request. More...
 
bool oc_init_put (const char *uri, oc_endpoint_t *endpoint, const char *query, oc_response_handler_t handler, oc_qos_t qos, void *user_data)
 Prepare the stack to issue a PUT request. More...
 
void oc_init_query_iterator (void)
 This resets the query iterator to the start of the URI query parameter. More...
 
bool oc_is_owned_device (size_t device_index)
 Get the ownership status of the logical device this is the value of the doxm "owned" property. More...
 
int oc_iterate_query (oc_request_t *request, char **key, size_t *key_len, char **value, size_t *value_len)
 Iterate through the URI query parameters and get each key=value pair. More...
 
bool oc_iterate_query_get_values (oc_request_t *request, const char *key, char **value, int *value_len)
 Iterate though the URI query parameters for a specific key. More...
 
void oc_link_add_link_param (oc_link_t *link, const char *key, const char *value)
 Adds a link parameter with specified key and value. More...
 
void oc_link_add_rel (oc_link_t *link, const char *rel)
 Adds a relation to the link. More...
 
int oc_main_init (const oc_handler_t *handler)
 Register and call handler functions responsible for controlling the IoTivity-lite stack. More...
 
oc_clock_time_t oc_main_poll (void)
 
void oc_main_shutdown (void)
 Shutdown and free all stack related resources. More...
 
oc_resource_t * oc_new_collection (const char *name, const char *uri, uint8_t num_resource_types, size_t device)
 Creates a new empty collection. More...
 
oc_link_t * oc_new_link (oc_resource_t *resource)
 Creates a new link for collections with the specified resource. More...
 
oc_resource_t * oc_new_resource (const char *name, const char *uri, uint8_t num_resource_types, size_t device)
 Allocate and populate a new oc_resource_t. More...
 
int oc_notify_observers (oc_resource_t *resource)
 Notify all observers of a change to a given resource's property. More...
 
void oc_process_baseline_interface (oc_resource_t *resource)
 Helper function used when responding to a GET request to add Common Properties to a GET response. More...
 
void oc_remove_delayed_callback (void *cb_data, oc_trigger_t callback)
 used to cancel a delayed callback More...
 
void oc_remove_ownership_status_cb (oc_ownership_status_cb_t cb, void *user_data)
 Remove the ownership changed callback. More...
 
void oc_reset ()
 Reset all logical devices to the RFOTM state. More...
 
void oc_reset_device (size_t device)
 Reset logical device to the RFOTM state. More...
 
void oc_resource_bind_resource_interface (oc_resource_t *resource, oc_interface_mask_t iface_mask)
 Add the supported interface(s) to the resource. More...
 
void oc_resource_bind_resource_type (oc_resource_t *resource, const char *type)
 Add a Resource Type "rt" property to the resource. More...
 
void oc_resource_make_public (oc_resource_t *resource)
 Expose unsecured coap:// endpoints (in addition to secured coaps:// endpoints) for this resource in /oic/res. More...
 
void oc_resource_set_default_interface (oc_resource_t *resource, oc_interface_mask_t iface_mask)
 Select the default interface. More...
 
void oc_resource_set_discoverable (oc_resource_t *resource, bool state)
 Specify if a resource can be found using OCF discover mechanisms. More...
 
void oc_resource_set_observable (oc_resource_t *resource, bool state)
 Specify that a resource should notify clients when a property has been modified. More...
 
void oc_resource_set_periodic_observable (oc_resource_t *resource, uint16_t seconds)
 The resource will periodically notify observing clients of is property values. More...
 
void oc_resource_set_properties_cbs (oc_resource_t *resource, oc_get_properties_cb_t get_properties, void *get_propr_user_data, oc_set_properties_cb_t set_properties, void *set_props_user_data)
 
void oc_resource_set_request_handler (oc_resource_t *resource, oc_method_t method, oc_request_callback_t callback, void *user_data)
 Specify a request_callback for GET, PUT, POST, and DELETE methods. More...
 
bool oc_send_ping (bool custody, oc_endpoint_t *endpoint, uint16_t timeout_seconds, oc_response_handler_t handler, void *user_data)
 
void oc_send_response (oc_request_t *request, oc_status_t response_code)
 Called after the response to a GET, PUT, POST or DELETE call has been prepared completed. More...
 
void oc_send_separate_response (oc_separate_response_t *handle, oc_status_t response_code)
 Called to send the deferred response to a GET, PUT, POST or DELETE request. More...
 
void oc_set_con_res_announced (bool announce)
 Sets whether the oic.wk.con resource is announced. More...
 
void oc_set_con_write_cb (oc_con_write_cb_t callback)
 Sets the callback to receive change notifications for the oic.wk.con resource. More...
 
void oc_set_delayed_callback (void *cb_data, oc_trigger_t callback, uint16_t seconds)
 Schedule a callback to be invoked after a set number of seconds. More...
 
void oc_set_factory_presets_cb (oc_factory_presets_cb_t cb, void *data)
 Set the factory presets callback. More...
 
void oc_set_immutable_device_identifier (size_t device, oc_uuid_t *piid)
 Set the immutable device identifier. More...
 
void oc_set_random_pin_callback (oc_random_pin_cb_t cb, void *data)
 Set the random pin callback for Random PIN Ownership Transfer Method (OTM) More...
 
void oc_set_separate_response_buffer (oc_separate_response_t *handle)
 Set a response buffer for holding the response payload. More...
 
void oc_stop_multicast (oc_client_response_t *response)
 
bool oc_stop_observe (const char *uri, oc_endpoint_t *endpoint)
 Unsubscribe for notifications from a resource. More...
 

Detailed Description

Main API of IoTivity-Lite for client and server.

Macro Definition Documentation

◆ oc_set_custom_device_property

#define oc_set_custom_device_property (   prop,
  value 
)    oc_rep_set_text_string(root, prop, value)

Set custom device property.

The purpose is to add additional device properties that are not supplied to oc_add_device() function call. This function will likely only be used inside the oc_add_device_cb_t().

Parameters
[in]propthe name of the custom property being added to the device
[in]valuethe value of the custom property being added to the device
See also
oc_add_device_cb_t for example code using this function
oc_add_device

◆ oc_set_custom_platform_property

#define oc_set_custom_platform_property (   prop,
  value 
)    oc_rep_set_text_string(root, prop, value)

Set custom platform property.

The purpose is to add additional platfrom properties that are not supplied to oc_init_platform() function call. This function will likely only be used inside the oc_init_platform_cb_t().

Parameters
[in]propthe name of the custom property being added to the platform
[in]valuethe value of the custom property being added to the platform
See also
oc_init_platform_cb_t for example code using this function
oc_init_platform

Typedef Documentation

◆ oc_add_device_cb_t

typedef void(* oc_add_device_cb_t) (void *data)

Callback invoked during oc_add_device().

The purpose is to add any additional device properties that are not supplied to oc_add_device() function call.

Example:

static void set_device_custom_property(void *data)
{
(void)data;
oc_set_custom_device_property(purpose, "desk lamp");
}
static int app_init(void)
{
int ret = oc_init_platform("My Platform", NULL, NULL);
ret |= oc_add_device("/oic/d", "oic.d.light", "My light", "ocf.1.0.0",
"ocf.res.1.0.0", set_device_custom_property, NULL);
return ret;
}
Parameters
[in]datacontext pointer that comes from the oc_init_platform() function
See also
oc_add_device
oc_set_custom_device_property

◆ oc_factory_presets_cb_t

typedef void(* oc_factory_presets_cb_t) (size_t device, void *data)

Callback invoked by the stack initialization to perform any "factory settings", e.g., this may be used to load a manufacturer certificate.

The following example illustrates the method of loading a manufacturer certificate chain (end-entity certificate, intermediate CA certificate, and root CA certificate) using oc_pki_xxx APIs.

Example:

void factory_presets_cb(size_t device, void *data)
{
(void)device;
(void)data;
#if defined(OC_SECURITY) && defined(OC_PKI)
char cert[8192];
size_t cert_len = 8192;
if (read_pem("pki_certs/ee.pem", cert, &cert_len) < 0) {
PRINT("ERROR: unable to read certificates\n");
return;
}
char key[4096];
size_t key_len = 4096;
if (read_pem("pki_certs/key.pem", key, &key_len) < 0) {
PRINT("ERROR: unable to read private key");
return;
}
int ee_credid = oc_pki_add_mfg_cert(0, (const unsigned char *)cert,
cert_len, (const unsigned char *)key, key_len);
if (ee_credid < 0) {
PRINT("ERROR installing manufacturer EE cert\n");
return;
}
cert_len = 8192;
if (read_pem("pki_certs/subca1.pem", cert, &cert_len) < 0) {
PRINT("ERROR: unable to read certificates\n");
return;
}
0, ee_credid, (const unsigned char *)cert, cert_len);
if (subca_credid < 0) {
PRINT("ERROR installing intermediate CA cert\n");
return;
}
cert_len = 8192;
if (read_pem("pki_certs/rootca1.pem", cert, &cert_len) < 0) {
PRINT("ERROR: unable to read certificates\n");
return;
}
int rootca_credid =
oc_pki_add_mfg_trust_anchor(0, (const unsigned char *)cert, cert_len);
if (rootca_credid < 0) {
PRINT("ERROR installing root cert\n");
return;
}
#endif // OC_SECURITY && OC_PKI
}
Parameters
[in]devicenumber of the device
[in]datacontext pointer that comes from the oc_set_factory_presets_cb() function
See also
oc_set_factory_presets_cb
oc_pki_add_mfg_cert
oc_pki_add_mfg_intermediate_cert
oc_pki_add_mfg_trust_anchor
oc_pki_set_security_profile

◆ oc_init_platform_cb_t

typedef void(* oc_init_platform_cb_t) (void *data)

Callback invoked during oc_init_platform().

The purpose is to add any additional platform properties that are not supplied to oc_init_platform() function call.

Example:

static void set_additional_platform_properties(void *data)
{
(void)data;
// Manufactures Details Link
"http://www.example.com/manufacture");
// Model Number
oc_set_custom_platform_property(mnmo, "Model No1");
// Date of Manufacture
oc_set_custom_platform_property(mndt,"2020/01/17");
//Serial Number
oc_set_custom_platform_property(mnsel, "1234567890");
}
static int app_init(void)
{
int ret = oc_init_platform("My Platform",
set_additional_platform_properties, NULL); ret |= oc_add_device("/oic/d",
"oic.d.light", "My light", "ocf.1.0.0", "ocf.res.1.0.0", NULL, NULL); return
ret;
}
Parameters
[in]datacontext pointer that comes from the oc_add_device() function
See also
oc_add_device
oc_set_custom_device_property

◆ oc_ownership_status_cb_t

typedef void(* oc_ownership_status_cb_t) (const oc_uuid_t *device_uuid, size_t device_index, bool owned, void *user_data)

Callback invoked when the "owned" property of the doxm is changed.

Parameters
[in]device_uuidthe UUID of the device that change ownership
[in]device_indexof the logical device that changed ownership
[in]ownedif true the device has been claimed by an onboarding tool
[in]user_datacontext pointer

◆ oc_random_pin_cb_t

typedef void(* oc_random_pin_cb_t) (const unsigned char *pin, size_t pin_len, void *data)

Callback invoked when an onboarding client requests device ownership via the Random PIN Ownership Transfer Method (OTM).

The purpose of the callback is to allow the device to display the random PIN to the user onboarding the device.

Example:

#ifdef OC_SECURITY
void random_pin_cb(const unsigned char *pin, size_t pin_len, void *data)
{
(void)data;
PRINT("\n\nRandom PIN: %.*s\n\n", (int)pin_len, pin);
}
#endif // OC_SECURITY
int main(void) {
...
#ifdef OC_SECURITY
oc_storage_config("./server_creds");
oc_set_random_pin_callback(random_pin_cb, NULL);
#endif // OC_SECURITY
// handler code omitted from example code see oc_main_init
oc_main_init(&handler)
...
return 0;
}
Parameters
[in]datacontext pointer that comes from the oc_init_platform() function
See also
oc_set_random_pin_callback

Function Documentation

◆ oc_add_device()

int oc_add_device ( const char *  uri,
const char *  rt,
const char *  name,
const char *  spec_version,
const char *  data_model_version,
oc_add_device_cb_t  add_device_cb,
void *  data 
)

Add an ocf device to the the stack.

This function is typically called as part of the stack initialization process from inside the init callback handler.

The oc_add_device function may be called as many times as needed. Each call will add a new device to the stack with its own port address. Each device is automatically assigned a number starting with zero and incremented by one each time the function is called. This number is not returned therefore it is important to know the order devices are added.

Example:

//app_init is an instance of the `init` callback handler.
static int app_init(void)
{
int ret = oc_init_platform("Refrigerator", NULL, NULL);
ret |= oc_add_device("/oic/d", "oic.d.refrigeration", "My fridge",
"ocf.2.0.5", "ocf.res.1.0.0,ocf.sh.1.0.0",
NULL, NULL);
ret |= oc_add_device("/oic/d", "oic.d.thermostat", "My thermostat",
"ocf.2.0.5", "ocf.res.1.0.0,ocf.sh.1.0.0",
NULL, NULL);
return ret;
}
Parameters
[in]urithe The device URI. The wellknown default URI "/oic/d" is hosted by every server. Used to expose device specific information
[in]rtthe resource type
[in]namethe user readable name of the device
[in]spec_versionThe version of the OCF Server. This is the "icv" device property
[in]data_model_versionSpec version of the resource and device specifications to which this device data model is implemtned. This is the "dmv" device property
[in]add_device_cbcallback function invoked during oc_add_device(). The purpose is to add additional device properties that are not supplied to oc_add_device() function call.
[in]datacontext pointer that is passed to the oc_add_device_cb_t
Returns
  • 0 on success
  • -1 on failure
See also
init

◆ oc_add_ownership_status_cb()

void oc_add_ownership_status_cb ( oc_ownership_status_cb_t  cb,
void *  user_data 
)

Add callback that is invoked when the doxm "owned" property is changed.

If oc_add_ownership_status_cb is called before oc_main_init or inside one of the , the oc_handler_t callback funtions the oc_ownership_status_cb_t will be invoked when the stack is initilized giving the startup ownership value. If oc_add_ownership_status_cb is called after oc_main_init the oc_add_ownership_status_cb will not be invoked for the startup ownership value.

Note
Use of this function requires building the stack with OC_SECURITY defined.
Parameters
[in]cbcallback function that will be invoked
[in]user_datacontext pointer passed to the oc_ownership_status_cb_t callback the pointer must remain valid till callback is removed.

◆ oc_get_con_res_announced()

bool oc_get_con_res_announced ( void  )

Returns whether the oic.wk.con resource is advertised.

Returns
  • true if advertised (default)
  • false if not
See also
oc_set_con_res_announced
oc_set_con_write_cb

◆ oc_init_platform()

int oc_init_platform ( const char *  mfg_name,
oc_init_platform_cb_t  init_platform_cb,
void *  data 
)

Initialize the platform.

This function is typically called as part of the stack initialization process from inside the init callback handler.

Parameters
[in]mfg_namethe name of the platform manufacture
[in]init_platform_cbcallback function invoked during oc_init_platform(). The purpose is to add additional device properties that are not supplied to oc_init_platform() function call.
[in]datacontext pointer that is passed to the oc_init_platform_cb_t
Returns
  • 0 on success
  • -1 on failure
See also
init
oc_init_platform_cb_t

◆ oc_is_owned_device()

bool oc_is_owned_device ( size_t  device_index)

Get the ownership status of the logical device this is the value of the doxm "owned" property.

If oc_is_owned_device() is called before oc_main_init() has completed it will always return false because stack security has not been initialized.

Note
Use of this function requires building the stack with OC_SECURITY defined.
Parameters
[in]device_indexthe index of the logical device
Returns
true if the device is owned by an onboarding tool

◆ oc_main_init()

int oc_main_init ( const oc_handler_t handler)

Register and call handler functions responsible for controlling the IoTivity-lite stack.

This will initialize the IoTivity-lite stack.

Before initializing the stack, a few setup functions may need to be called before calling oc_main_init those functions are:

Not all of the listed functions must be called before calling oc_main_init.

Parameters
[in]handlerstruct containing pointers callback handler functions responsible for controlling the IoTivity-lite application
Returns
  • 0 if stack has been initialized successfully
  • a negative number if there is an error in stack initialization
See also
oc_set_con_res_announced
oc_set_factory_presets_cb
oc_set_max_app_data_size
oc_set_random_pin_callback
oc_storage_config

◆ oc_main_shutdown()

void oc_main_shutdown ( void  )

Shutdown and free all stack related resources.

◆ oc_remove_ownership_status_cb()

void oc_remove_ownership_status_cb ( oc_ownership_status_cb_t  cb,
void *  user_data 
)

Remove the ownership changed callback.

Note
Use of this function requires building the stack with OC_SECURITY defined.
Parameters
[in]cbcallback function to remove
[in]user_datathe context pointer used when the callback was added

◆ oc_reset()

void oc_reset ( )

Reset all logical devices to the RFOTM state.

All devices will be placed in the 'Ready For Ownership Transfer Mode' (RFOTM). This is the initial startup state for for all devices that have not yet been onboarded. After this call all devices will need to be onboarded and provisioned again.

Note
The function oc_reset() deals only with security and provisioning it does not reset any other device settings.
Use of this function requires building with OC_SECURITY defined.

◆ oc_reset_device()

void oc_reset_device ( size_t  device)

Reset logical device to the RFOTM state.

The device will be placed in the 'Ready For Ownership Transfer Mode' (RFOTM). This is the initial state startup state for for all devices that have not yet been onboarded. After this call the device will need to be onboarded and provisioned again.

Note
The function oc_reset_device() deals only with security and provisioning it does not reset any other device settings.
Use of this function requires building the stack with OC_SECURITY defined.
Parameters
[in]deviceindex of the logical device to reset

◆ oc_set_con_res_announced()

void oc_set_con_res_announced ( bool  announce)

Sets whether the oic.wk.con resource is announced.

Note
This should be set before invoking oc_main_init().
Parameters
[in]announcetrue to announce (default) or false if not
See also
oc_get_con_res_announced
oc_set_con_write_cb

◆ oc_set_factory_presets_cb()

void oc_set_factory_presets_cb ( oc_factory_presets_cb_t  cb,
void *  data 
)

Set the factory presets callback.

The factory presets callback is called by the stack to enable per-device presets.

Note
oc_set_factory_presets_cb() must be called before oc_main_init().
Parameters
[in]cboc_factory_presets_cb_t function pointer to be called
[in]datacontext pointer that is passed to the oc_factory_presets_cb_t the pointer must be a valid pointer till after oc_main_init() call completes.

◆ oc_set_random_pin_callback()

void oc_set_random_pin_callback ( oc_random_pin_cb_t  cb,
void *  data 
)

Set the random pin callback for Random PIN Ownership Transfer Method (OTM)

Note
This should be set before invoking oc_main_init().
Parameters
[in]cbcallback function invoked when client requests Random PIN OTM
[in]datacontext pointer that is passed to the oc_random_pin_cb_t the context pointer must be a valid pointer as long as the device is in 'Ready For Ownership Transfer Method' (RFOTM) state.
See also
oc_random_pin_cb_t
oc_main_init