Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Typedefs | Functions

Routines to create servers talking the OIC protocol. More...

Data Structures

struct  sol_oic_resource_type
 structure defining the type of a resource. More...
 

Typedefs

typedef struct
sol_oic_resource_type 
sol_oic_resource_type
 structure defining the type of a resource. More...
 
typedef struct
sol_oic_server_resource 
sol_oic_server_resource
 Opaque handler for a server resource. More...
 

Functions

struct sol_oic_responsesol_oic_server_notification_new (struct sol_oic_server_resource *resource)
 Create a notification response to send to observing clients of resource. More...
 
int sol_oic_server_notify (struct sol_oic_response *notification)
 Send notification to all observing clients. More...
 
struct sol_oic_server_resourcesol_oic_server_register_resource (const struct sol_oic_resource_type *rt, const void *handler_data, enum sol_oic_resource_flag flags)
 Add resource to OIC server. More...
 
struct sol_oic_map_readersol_oic_server_request_get_reader (struct sol_oic_request *request)
 Get the packet reader from a request. More...
 
void sol_oic_server_response_free (struct sol_oic_response *response)
 Free the response and all memory hold by it. More...
 
struct sol_oic_map_writersol_oic_server_response_get_writer (struct sol_oic_response *response)
 Get the packet writer from a response. More...
 
struct sol_oic_responsesol_oic_server_response_new (struct sol_oic_request *request)
 Create a new response to send a reply to request. More...
 
int sol_oic_server_send_response (struct sol_oic_request *request, struct sol_oic_response *response, enum sol_coap_response_code code)
 Send a response as a reply to a request. More...
 
void sol_oic_server_unregister_resource (struct sol_oic_server_resource *resource)
 Delete a resource from the OIC server. More...
 

Detailed Description

Routines to create servers talking the OIC protocol.

Typedef Documentation

structure defining the type of a resource.

See Also
sol_oic_server_register_resource

Opaque handler for a server resource.

Function Documentation

struct sol_oic_response* sol_oic_server_notification_new ( struct sol_oic_server_resource resource)

Create a notification response to send to observing clients of resource.

Parameters
resourceThe resource that will be used to create this notification.
Returns
A notification response on success or NULL on errors.
See Also
sol_oic_server_notify
int sol_oic_server_notify ( struct sol_oic_response notification)

Send notification to all observing clients.

Send a notification packet with data filled in notification to all observing clients of the resouce used to create notification. This function always clear and invalidate the notification memory.

Parameters
notificationThe notification response created using sol_oic_server_notification_new() function.
Returns
0 on success or a negative number on errors.
struct sol_oic_server_resource* sol_oic_server_register_resource ( const struct sol_oic_resource_type rt,
const void *  handler_data,
enum sol_oic_resource_flag  flags 
)

Add resource to OIC server.

Create a new sol_oic_server_resource and associate it to the OIC server.

Parameters
rtThe sol_oic_resource_type structure with information about the resource that is being added.
handler_dataPointer to user data that will be passed to callbacks defined in rt.
flagsResourse flags.
Returns
On success, a pointer to the new resource created. On errors, NULL.
See Also
sol_oic_server_unregister_resource
Examples:
/src/samples/coap/oic-server.c.

Referenced by register_light_resource_type().

struct sol_oic_map_reader* sol_oic_server_request_get_reader ( struct sol_oic_request request)

Get the packet reader from a request.

Parameters
requestThe request to retrieve the reader.
Returns
The packet reader from this request or NULL if the informed request is not a server request.
Examples:
/src/samples/coap/oic-server.c.

Referenced by user_handle_put().

void sol_oic_server_response_free ( struct sol_oic_response response)

Free the response and all memory hold by it.

Parameters
responseThe response to be freed.
Examples:
/src/samples/coap/oic-server.c.

Referenced by user_handle_get().

struct sol_oic_map_writer* sol_oic_server_response_get_writer ( struct sol_oic_response response)

Get the packet writer from a response.

Parameters
responseThe response to retrieve the writer.
Returns
The packet writer from this response.
Examples:
/src/samples/coap/oic-server.c.

Referenced by user_handle_get().

struct sol_oic_response* sol_oic_server_response_new ( struct sol_oic_request request)

Create a new response to send a reply to request.

Parameters
requestThe request to be used to reply with this response.
Returns
A new response on success or NULL on errors.
Examples:
/src/samples/coap/oic-server.c.

Referenced by user_handle_get().

int sol_oic_server_send_response ( struct sol_oic_request request,
struct sol_oic_response response,
enum sol_coap_response_code  code 
)

Send a response as a reply to a request.

After sending the response, response and request elements memory are released even on errors.

Parameters
requestThe request that created this response.
responseThe response to be sent.
codeThe CoAP code to be used in response packet.
Returns
0 on success or a negative number on errors.
Examples:
/src/samples/coap/oic-server.c.

Referenced by user_handle_get(), and user_handle_put().

void sol_oic_server_unregister_resource ( struct sol_oic_server_resource resource)

Delete a resource from the OIC server.

Remove a resource created using sol_oic_server_register_resource from the OIC server

Parameters
resourceThe resource to be removed from server.
See Also
sol_oic_server_register_resource
Examples:
/src/samples/coap/oic-server.c.

Referenced by main().