KNX IoT
KNX IoT Point API stack implementation
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 incoming events are being processed. More...
 

Detailed Description

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

See also
oc_main_init

Definition at line 115 of file oc_api.h.

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

Definition at line 141 of file oc_api.h.

◆ 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, "urn:knx:dpa.417.61");
oc_resource_bind_dpt(bswitch, "urn:knx:dpt.switch");
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 .well-known/core 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.
void oc_resource_bind_dpt(oc_resource_t *resource, const char *dpt)
Add a Data Point Type "dpt" property to the resource.
bool oc_add_resource(oc_resource_t *resource)
Add a resource to the stack.
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:126
@ OC_PUT
PUT.
Definition: oc_ri.h:127
@ OC_GET
GET.
Definition: oc_ri.h:125
@ OC_IF_A
if.a (128)
Definition: oc_ri.h:269
void(* register_resources)(void)
Resource registration callback.
Definition: oc_api.h:191
resource structure
Definition: oc_ri.h:482
See also
init
oc_new_resource
oc_resource_bind_resource_interface
oc_resource_bind_resource_type
oc_resource_bind_dpt
oc_resource_make_public
oc_resource_set_discoverable
oc_resource_set_observable
oc_resource_set_periodic_observable
oc_resource_set_request_handler
oc_add_resource

Definition at line 191 of file oc_api.h.

◆ 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("dpa.321.51", &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

Definition at line 214 of file oc_api.h.

◆ signal_event_loop

void(* signal_event_loop) (void)

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

See also
oc_main_poll

Definition at line 149 of file oc_api.h.


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