IoTivity-Lite
oc_handler_t Struct Reference

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

#include <oc_api.h>

Data Fields

int(* init )(void)
 Device initialization callback that is invoked to initialize the platform and device(s). More...
 
void(* register_resources )(void)
 Resource registration callback. More...
 
void(* requests_entry )(void)
 Callback invoked when the stack is ready to issue discovery requests. More...
 
void(* signal_event_loop )(void)
 

Detailed Description

Call back handlers that are invoked in response to oc_main_init()

See also
oc_main_init

Field Documentation

◆ init

int(* init) (void)

Device initialization callback that is invoked to initialize the platform and device(s).

At a minimum the platform should be initialized and at least one device added.

Multiple devices can be added by making multiple calls to oc_add_device().

Other actions may be taken in the init handler

Returns
  • 0 to indicate success initializing the application
  • value less than zero to indicate failure initializing the application
See also
oc_activate_interrupt_handler
oc_add_device
oc_init_platform
oc_set_immutable_device_identifier
oc_set_introspection_data

◆ register_resources

void(* register_resources) (void)

Resource registration callback.

Callback is invoked after the device initialization callback.

Use this callback to add resources to the devices added during the device initialization. This where the properties and callbacks associated with the resources are typically done.

Note: Callback is only invoked when OC_SERVER macro is defined.

Example:

static void register_resources(void)
{
oc_resource_t *bswitch = oc_new_resource(NULL, "/switch", 1, 0);
oc_resource_bind_resource_type(bswitch, "oic.r.switch.binary");
oc_resource_set_request_handler(bswitch, OC_GET, get_switch, NULL);
oc_resource_set_request_handler(bswitch, OC_PUT, put_switch, NULL);
oc_resource_set_request_handler(bswitch, OC_POST, post_switch, NULL);
oc_add_resource(bswitch);
}
See also
init
oc_new_resource
oc_resource_bind_resource_interface
oc_resource_set_default_interface
oc_resource_bind_resource_type
oc_resource_make_public
oc_resource_set_discoverable
oc_resource_set_observable
oc_resource_set_periodic_observable
oc_resource_set_properties_cbs
oc_resource_set_request_handler
oc_add_resource

◆ requests_entry

void(* requests_entry) (void)

Callback invoked when the stack is ready to issue discovery requests.

Callback is invoked after the device initialization callback.

Example:

static void issue_requests(void)
{
oc_do_ip_discovery("oic.r.switch.binary", &discovery, NULL);
}
See also
init
oc_do_ip_discovery
oc_do_ip_discovery_at_endpoint
oc_do_site_local_ipv6_discovery
oc_do_realm_local_ipv6_discovery

The documentation for this struct was generated from the following file: