KNX IoT
KNX IoT Point API stack implementation
oc_client_state.h
Go to the documentation of this file.
1 /*
2 // Copyright (c) 2016, 2020 Intel Corporation
3 // Copyright (c) 2021 Cascoda Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 */
21 #ifndef OC_CLIENT_STATE_H
22 #define OC_CLIENT_STATE_H
23 
24 #include "messaging/coap/constants.h"
25 #ifdef OC_OSCORE
26 #include "messaging/coap/oscore_constants.h"
27 #endif /* OC_OSCORE */
28 #include "oc_endpoint.h"
29 #include "oc_ri.h"
30 #include <stdbool.h>
31 #ifdef OC_BLOCK_WISE
32 #include "oc_blockwise.h"
33 #endif /* OC_BLOCK_WISE */
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
43 typedef enum {
44  HIGH_QOS = 0,
45  LOW_QOS
47 
52 typedef struct
53 {
55  const uint8_t *_payload;
56  size_t _payload_len;
59  void *client_cb;
60  void
66 
71 typedef enum {
75 
81  const char *, int len, oc_endpoint_t *endpoint, void *);
82 
83 typedef oc_discovery_flags_t (*oc_discovery_handler_t)(
84  const char *, int len, const char *, oc_string_array_t, oc_interface_mask_t,
86 
92 
97 typedef struct oc_client_handler_t
98 {
100  oc_discovery_handler_t
105 
110 typedef struct oc_client_cb_t
111 {
113  oc_string_t uri;
114  oc_string_t query;
117  void *user_data;
118  int32_t observe_seq;
119  oc_clock_time_t timestamp;
122  uint16_t mid;
123  uint8_t token[COAP_TOKEN_LEN];
124  uint8_t token_len;
125  bool discovery;
126  bool multicast;
128  uint8_t ref_count;
129  uint8_t separate;
130 #ifdef OC_OSCORE
131  uint8_t piv[OSCORE_PIV_LEN];
132  uint8_t piv_len;
133  uint64_t notification_num;
134 #endif /* OC_OSCORE */
136 
137 #ifdef OC_BLOCK_WISE
148 bool oc_ri_invoke_client_cb(void *response,
149  oc_blockwise_state_t **response_state,
151 #else /* OC_BLOCK_WISE */
161 bool oc_ri_invoke_client_cb(void *response, oc_client_cb_t *cb,
163 #endif /* !OC_BLOCK_WISE */
164 
178  oc_method_t method, const char *query,
180  void *user_data);
181 
192 
201 
210  uint8_t token_len);
211 
219 
226 
233 
247  uint8_t *payload, int len, oc_client_handler_t handler,
249 
250 #ifdef __cplusplus
251 }
252 #endif
253 
254 #endif /* OC_CLIENT_STATE_H */
CoAP block wise transfer implementation.
oc_qos_t
Quality of Service.
@ HIGH_QOS
confirmable messages
@ LOW_QOS
non-confirmable messages
oc_discovery_flags_t oc_ri_process_discovery_payload(uint8_t *payload, int len, oc_client_handler_t handler, oc_endpoint_t *endpoint, oc_content_format_t content, void *user_data)
handle the discovery payload (e.g.
oc_client_cb_t * oc_ri_find_client_cb_by_mid(uint16_t mid)
find the client callback info by message id (mid)
bool oc_ri_is_client_cb_valid(oc_client_cb_t *client_cb)
is the client callback information valid
void oc_ri_free_client_cbs_by_endpoint(oc_endpoint_t *endpoint)
free the client callback information by endpoint
oc_discovery_flags_t(* oc_discovery_all_handler_t)(const char *, int len, oc_endpoint_t *endpoint, void *)
discovery_all handler
struct oc_client_cb_t oc_client_cb_t
client callback information
bool oc_ri_invoke_client_cb(void *response, oc_blockwise_state_t **response_state, oc_client_cb_t *cb, oc_endpoint_t *endpoint)
invoke the Client callback when a response is received
oc_client_cb_t * oc_ri_find_client_cb_by_token(uint8_t *token, uint8_t token_len)
find the client callback info by token
struct oc_client_handler_t oc_client_handler_t
client handler information
oc_discovery_flags_t
discovery flags
@ OC_CONTINUE_DISCOVERY
continue discovering (more data)
@ OC_STOP_DISCOVERY
stop discovering (also no more data)
oc_client_cb_t * oc_ri_alloc_client_cb(const char *uri, oc_endpoint_t *endpoint, oc_method_t method, const char *query, oc_client_handler_t handler, oc_qos_t qos, void *user_data)
allocate the client callback information
void(* oc_response_handler_t)(oc_client_response_t *)
client response handler
void oc_ri_free_client_cbs_by_mid(uint16_t mid)
free the client callback information by message id (mid)
oc_client_cb_t * oc_ri_get_client_cb(const char *uri, oc_endpoint_t *endpoint, oc_method_t method)
retrieve the client callback information
end point implementation, e.g.
resource internals
oc_status_t
CoAP status codes.
Definition: oc_ri.h:152
oc_method_t
CoAP methods.
Definition: oc_ri.h:124
oc_content_format_t
payload content formats
Definition: oc_ri.h:184
oc_interface_mask_t
interface masks security access scopes defined as interfaces note that scope = 1 is not used.
Definition: oc_ri.h:261
oc_resource_properties_t
resource properties (bit mask)
Definition: oc_ri.h:136
client callback information
void * user_data
user data for the callbacks
bool discovery
discovery call
uint8_t token[COAP_TOKEN_LEN]
CoAP token.
bool multicast
multi cast
oc_client_handler_t handler
handler information
oc_string_t query
query parameters
oc_endpoint_t endpoint
endpoint
struct oc_client_cb_t * next
pointer next callback information
oc_clock_time_t timestamp
time stamp
uint8_t separate
separate responses
uint8_t ref_count
reference counting on this data block
int32_t observe_seq
observe sequence number
uint16_t mid
CoAP message identifier.
oc_method_t method
method used
uint8_t token_len
CoAP token length.
oc_string_t uri
the uri
oc_qos_t qos
quality of service
bool stop_multicast_receive
stop receiving multi cast
client handler information
oc_discovery_handler_t discovery
discovery handler, e.g.
oc_response_handler_t response
response handler
oc_discovery_all_handler_t discovery_all
discovery all handler, full payload
Client response information.
int observe_option
observe indication
void * user_data
user data to be supplied to the callback to the client
oc_rep_t * payload
response payload, interpreted as cbor
oc_content_format_t content_format
content format of the payload
oc_endpoint_t * endpoint
endpoint on where the response has been received
oc_status_t code
status of the response
const uint8_t * _payload
payload buffer
size_t _payload_len
payload buffer length
void * client_cb
callback for the response to the calling client
the endpoint information
Definition: oc_endpoint.h:78
parsed entry of a cbor object This represents a link list of response values one can iterate over the...
Definition: oc_rep.h:1642