@@ -13,8 +13,8 @@ extern "C" {
13
13
14
14
#include <string.h>
15
15
16
- #include < ns_types.h>
17
- #include < sn_coap_header.h>
16
+ #include " ns_types.h"
17
+ #include " sn_coap_header.h"
18
18
19
19
/**
20
20
* This interface is used in sending and receiving of CoAP messages to multicast address and receive multiple responses.
@@ -50,7 +50,7 @@ extern "C" {
50
50
* \param listen_port Port that Application wants to use for communicate with coap server.
51
51
* \param service_options Options of the current service.
52
52
*
53
- * \return service_id
53
+ * \return service_id / -1 for failure
54
54
*/
55
55
int8_t coap_service_initialize (int8_t interface_id , uint16_t listen_port , uint8_t service_options );
56
56
@@ -75,7 +75,7 @@ void coap_service_delete( int8_t service_id );
75
75
*
76
76
* \return Status
77
77
*/
78
- typedef int ( * coap_service_request_recv_cb ) (int8_t service_id , uint8_t source_address [static 16 ], uint16_t source_port , sn_coap_hdr_s * request_ptr );
78
+ typedef int coap_service_request_recv_cb (int8_t service_id , uint8_t source_address [static 16 ], uint16_t source_port , sn_coap_hdr_s * request_ptr );
79
79
80
80
/**
81
81
* \brief Security service start callback
@@ -85,9 +85,9 @@ typedef int (*coap_service_request_recv_cb)(int8_t service_id, uint8_t source_ad
85
85
* \param service_id Id number of the current service.
86
86
* \param EUI64 64 bit global identifier
87
87
*
88
- * \return Status
88
+ * \return 0 for success / -1 for failure
89
89
*/
90
- typedef int ( * coap_service_security_start_cb ) (int8_t service_id , uint8_t EUI64 [static 8 ]);
90
+ typedef int coap_service_security_start_cb (int8_t service_id , uint8_t EUI64 [static 8 ]);
91
91
92
92
/**
93
93
* \brief CoAP service security done callback
@@ -98,9 +98,9 @@ typedef int (*coap_service_security_start_cb)(int8_t service_id, uint8_t EUI64[s
98
98
* \param EUI64 64 bit global identifier
99
99
* \param keyblock Security key (40 bits)
100
100
*
101
- * \return Status
101
+ * \return 0 for success / -1 for failure
102
102
*/
103
- typedef int ( * coap_service_security_done_cb ) (int8_t service_id , uint8_t EUI64 [static 8 ], uint8_t keyblock [static 40 ]);
103
+ typedef int coap_service_security_done_cb (int8_t service_id , uint8_t EUI64 [static 8 ], uint8_t keyblock [static 40 ]);
104
104
105
105
106
106
/**
@@ -112,7 +112,7 @@ typedef int (*coap_service_security_done_cb)(int8_t service_id, uint8_t EUI64[st
112
112
* \param PSKd_ptr Pointer to PSK key.
113
113
* \param PSKd_len Lenght of PSK key.
114
114
*
115
- * \return Status
115
+ * \return 0 for success / -1 for failure
116
116
*/
117
117
int coap_service_security_key_set (int8_t service_id , uint8_t EUI64 [static 8 ], uint8_t * PSKd_ptr , uint8_t PSKd_len );
118
118
@@ -124,9 +124,9 @@ int coap_service_security_key_set(int8_t service_id, uint8_t EUI64[static 8], ui
124
124
* \param msg_id Id number of the current message.
125
125
* \param response_ptr Pointer to CoAP header structure.
126
126
*
127
- * \return Status
127
+ * \return 0 for success / -1 for failure
128
128
*/
129
- typedef int ( * coap_service_response_recv )( uint16_t msg_id , sn_coap_hdr_s * response_ptr );
129
+ typedef int coap_service_response_recv ( int8_t service_id , uint16_t msg_id , sn_coap_hdr_s * response_ptr );
130
130
131
131
/**
132
132
* \brief Virtual socket sent callback.
@@ -139,9 +139,9 @@ typedef int (*coap_service_response_recv)(uint16_t msg_id, sn_coap_hdr_s *respon
139
139
* \param *data_ptr Pointer to the data.
140
140
* \param data_len Lenght of the data.
141
141
*
142
- * \return Status
142
+ * \return 0 for success / -1 for failure
143
143
*/
144
- typedef int ( * coap_service_virtual_socket_send_cb ) (int8_t service_id , uint8_t destination_addr_ptr [static 16 ], uint16_t port , uint8_t * data_ptr , uint16_t data_len );
144
+ typedef int coap_service_virtual_socket_send_cb (int8_t service_id , uint8_t destination_addr_ptr [static 16 ], uint16_t port , uint8_t * data_ptr , uint16_t data_len );
145
145
146
146
/**
147
147
* \brief Virtual socket read.
@@ -154,7 +154,7 @@ typedef int (*coap_service_virtual_socket_send_cb)(int8_t service_id, uint8_t de
154
154
* \param *data_ptr Pointer to the data
155
155
* \param data_len Lenght of the data
156
156
*
157
- * \return ?
157
+ * \return 0 for success / -1 for failure
158
158
*/
159
159
int16_t coap_service_virtual_socket_recv (int8_t service_id , uint8_t source_addr_ptr [static 16 ], uint16_t port , uint8_t * data_ptr , uint16_t data_len );
160
160
@@ -166,7 +166,7 @@ int16_t coap_service_virtual_socket_recv(int8_t service_id, uint8_t source_addr_
166
166
* \param service_id Id number of the current service.
167
167
* \param *send_method_ptr Callback to coap virtual socket.
168
168
*
169
- * \return TODO
169
+ * \return 0 for success / -1 for failure
170
170
*/
171
171
int16_t coap_service_virtual_socket_set_cb (int8_t service_id , coap_service_virtual_socket_send_cb * send_method_ptr );
172
172
@@ -176,15 +176,29 @@ int16_t coap_service_virtual_socket_set_cb(int8_t service_id, coap_service_virtu
176
176
* Register application and informs CoAP services unsecure registery callback function.
177
177
*
178
178
* \param service_id Id number of the current service.
179
- * \param *uri Pointer to uri.
179
+ * \param *uri_ptr Pointer to uri.
180
180
* \param uri_len Length of uri.
181
181
* \param port port that Application wants to use for communicate with coap server.
182
182
* \param allowed_method Informs method that is allowed to use (used defines described above).
183
183
* \param *request_recv_cb CoAP service request receive callback function pointer.
184
184
*
185
- * \return TODO
185
+ * \return 0 for success / -1 for failure
186
186
*/
187
- int16_t coap_service_register_uri (int8_t service_id , uint16_t * uri , uint16_t uri_len , uint16_t port , uint8_t allowed_method , coap_service_request_recv_cb * request_recv_cb );
187
+ int8_t coap_service_register_uri (int8_t service_id , uint8_t * uri_ptr , uint16_t uri_len , uint8_t allowed_method , coap_service_request_recv_cb * request_recv_cb );
188
+
189
+ /**
190
+ * \brief Unregister unsecure callback methods to CoAP server
191
+ *
192
+ * Register application and informs CoAP services unsecure registery callback function.
193
+ *
194
+ * \param service_id Id number of the current service.
195
+ * \param *uri_ptr Pointer to uri.
196
+ * \param uri_len Length of uri.
197
+ *
198
+ * \return 0 for success / -1 for failure
199
+ */
200
+ int8_t coap_service_unregister_uri (int8_t service_id , uint8_t * uri_ptr , uint16_t uri_len );
201
+
188
202
189
203
/**
190
204
* \brief Register secure callback methods to CoAP server.
@@ -195,16 +209,16 @@ int16_t coap_service_register_uri(int8_t service_id, uint16_t *uri, uint16_t uri
195
209
* \param *start_ptr Callback to inform security handling is started.
196
210
* \param *security_done_cb Callback to inform security handling is done.
197
211
*
198
- * \return TODO
212
+ * \return -1 for failure
213
+ * instance_id For success (is used to identify registery)
199
214
*
200
- * instance id that is used to identify registery.
201
215
*/
202
- int16_t coap_service_register_uri_secure_cb_set (int8_t service_id , coap_service_security_start_cb * start_ptr , coap_service_security_done_cb * security_done_cb );
216
+ int8_t coap_service_register_uri_secure_cb_set (int8_t service_id , coap_service_security_start_cb * start_ptr , coap_service_security_done_cb * security_done_cb );
203
217
204
218
/**
205
- * \brief Sends CoAP service request
219
+ * \brief Sends CoAP service
206
220
*
207
- * Build and sends CoAP service request message.
221
+ * Build and sends CoAP service message.
208
222
*
209
223
* \param service_id Id number of the current service.
210
224
* \param options Options defined above.
@@ -215,7 +229,30 @@ int16_t coap_service_register_uri_secure_cb_set(int8_t service_id, coap_service_
215
229
*
216
230
* \return msg_id Id number of the current message.
217
231
*/
218
- uint16_t coap_service_request_send (int8_t service_id , uint8_t options , uint8_t addr [static 16 ], uint16_t destination_port , sn_coap_hdr_s * request_ptr , coap_service_response_recv * request_response_cb );
232
+ uint16_t coap_service_send (int8_t service_id , uint8_t options , uint8_t addr [static 16 ], uint16_t destination_port , sn_coap_hdr_s * request_ptr , coap_service_response_recv * request_response_cb );
233
+
234
+ /**
235
+ * \brief Sends CoAP service request
236
+ *
237
+ * Build and sends CoAP service request message.
238
+ *
239
+ * \param service_id Id number of the current service.
240
+ * \param options Options defined above.
241
+ * \param destination_addr IPv6 address.
242
+ * \param destination_port Destination port
243
+ * \param msg_type Message type can be found from sn_coap_header.
244
+ * \param msg_code Message code can be found from sn_coap_header.
245
+ * \param *uri_ptr Pointer to uri.
246
+ * \param uri_len Length of uri.
247
+ * \param cont_type Content type can be found from sn_coap_header.
248
+ * \param payload_ptr Pointer to message content.
249
+ * \param payload_len Lenght of the message.
250
+ * \param *request_response_cb Callback to inform result of the request.
251
+ *
252
+ * \return msg_id Id number of the current message.
253
+ */
254
+ uint16_t coap_service_request_send (int8_t service_id , uint8_t options , uint8_t destination_addr [static 16 ], uint16_t destination_port , uint8_t msg_type , uint8_t msg_code , uint8_t * uri_ptr , uint16_t uri_len ,
255
+ uint8_t cont_type , uint8_t * payload_ptr , uint16_t payload_len , coap_service_response_recv * request_response_cb );
219
256
220
257
/**
221
258
* \brief Sends CoAP service response
@@ -227,7 +264,8 @@ uint16_t coap_service_request_send(int8_t service_id, uint8_t options, uint8_t a
227
264
* \param options Options defined above.
228
265
* \param response_ptr Pointer to CoAP header structure.
229
266
*
230
- * \return TODO
267
+ * \return -1 For failure
268
+ *- 0 For success
231
269
*/
232
270
int8_t coap_service_response_send (int8_t service_id , uint8_t options , sn_coap_hdr_s * request_ptr , sn_coap_msg_code_e message_code , int32_t content_type ,uint8_t * payload_ptr ,uint16_t payload_len );
233
271
0 commit comments