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)
 Function to signal the event loop so that incomming events are being processed. More...
 

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);
}
void oc_resource_set_discoverable(oc_resource_t *resource, bool state)
Specify if a resource can be found using OCF discover mechanisms.
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.
bool oc_add_resource(oc_resource_t *resource)
Add a resource to the IoTivity stack.
void oc_resource_set_default_interface(oc_resource_t *resource, oc_interface_mask_t iface_mask)
Select the default interface.
void oc_resource_bind_resource_type(oc_resource_t *resource, const char *type)
Add a Resource Type "rt" property to the resource.
void oc_resource_bind_resource_interface(oc_resource_t *resource, oc_interface_mask_t iface_mask)
Add the supported interface(s) to the resource.
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.
@ OC_POST
POST.
Definition: oc_ri.h:46
@ OC_PUT
PUT.
Definition: oc_ri.h:47
@ OC_GET
GET.
Definition: oc_ri.h:45
@ OC_IF_A
oic.if.a
Definition: oc_ri.h:175
void(* register_resources)(void)
Resource registration callback.
Definition: oc_api.h:147
resource structure
Definition: oc_ri.h:326
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);
}
bool oc_do_ip_discovery(const char *rt, oc_discovery_handler_t handler, void *user_data)
Discover all servers that have a resource type.
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

◆ signal_event_loop

void(* signal_event_loop) (void)

Function to signal the event loop so that incomming events are being processed.

See also
oc_main_poll

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