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
sol-oic-server.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Soletta (TM) Project
3  *
4  * Copyright (C) 2015 Intel Corporation. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #pragma once
20 
21 #include <sol-str-slice.h>
22 #include <sol-coap.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #include "sol-oic.h"
29 
51 
57 typedef struct sol_oic_resource_type {
58 #ifndef SOL_NO_API_VERSION
59 #define SOL_OIC_RESOURCE_TYPE_API_VERSION (1)
60  uint16_t api_version;
61 #endif
62 
69 
74 
81 
82  struct {
83  int (*handle)(void *data, struct sol_oic_request *request);
84  }
101  get,
118  put,
135  post,
152  del;
154 
172  const struct sol_oic_resource_type *rt, const void *handler_data,
173  enum sol_oic_resource_flag flags);
174 
186 
199 int sol_oic_server_notify(struct sol_oic_response *notification);
200 
212 
225 int sol_oic_server_send_response(struct sol_oic_request *request, struct sol_oic_response *response, enum sol_coap_response_code code);
226 
235 
241 void sol_oic_server_response_free(struct sol_oic_response *response);
242 
251 
261 
266 #ifdef __cplusplus
267 }
268 #endif
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.
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.
struct sol_str_slice path
String representation of the path of this resource.
Definition: sol-oic-server.h:80
void sol_oic_server_unregister_resource(struct sol_oic_server_resource *resource)
Delete a resource from the OIC server.
struct sol_oic_response sol_oic_response
Information about a server response.
Definition: sol-oic.h:458
struct sol_oic_map_writer * sol_oic_server_response_get_writer(struct sol_oic_response *response)
Get the packet writer from a response.
int sol_oic_server_notify(struct sol_oic_response *notification)
Send notification to all observing clients.
struct sol_str_slice interface
String representation of the interface implemeneted by this resource.
Definition: sol-oic-server.h:73
uint16_t api_version
API version.
Definition: sol-oic-server.h:60
int(* handle)(void *data, struct sol_oic_request *request)
Definition: sol-oic-server.h:83
struct sol_oic_resource_type sol_oic_resource_type
structure defining the type of a resource.
struct sol_oic_resource_type::@13 del
Callback handle to DELETE requests.
String slice type.
Definition: sol-str-slice.h:84
struct sol_oic_resource_type::@13 put
Callback handle to PUT requests.
struct sol_oic_response * sol_oic_server_response_new(struct sol_oic_request *request)
Create a new response to send a reply to request.
sol_coap_response_code
Set of response codes available for a response packet.
Definition: sol-coap.h:190
struct sol_oic_request sol_oic_request
Information about a client request.
Definition: sol-oic.h:448
sol_oic_resource_flag
Flags to set when adding a new resource to a server.
Definition: sol-oic.h:122
struct sol_oic_resource_type::@13 post
Callback handle to POST requests.
struct sol_oic_map_writer sol_oic_map_writer
Opaque handler for an OIC packet map writer.
Definition: sol-oic.h:384
struct sol_str_slice resource_type
String representation of the resource type.
Definition: sol-oic-server.h:68
struct sol_oic_map_reader * sol_oic_server_request_get_reader(struct sol_oic_request *request)
Get the packet reader from a request.
These are routines that Soletta provides for its string slice implementation.
void sol_oic_server_response_free(struct sol_oic_response *response)
Free the response and all memory hold by it.
struct sol_oic_server_resource sol_oic_server_resource
Opaque handler for a server resource.
Definition: sol-oic-server.h:50
Routines to handle CoAP protocol.
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.
Handler for an OIC packet map reader.
Definition: sol-oic.h:431
structure defining the type of a resource.
Definition: sol-oic-server.h:57