blob: 468af5c622f2f4be908a310269e383fe2e483d7f [file] [log] [blame]
liubin281ac462023-07-19 14:22:54 +08001/*************************************************************
2Description:
3 C file for L620 coap.
4Author:
5 LuoJian
6Date:
7 2019/3/25 9:23:29
8*************************************************************/
9#include <stdlib.h>
10#include <string.h>
11#include <stdio.h>
12#include <sys/types.h>
13#include <sys/socket.h>
14#include <linux/in.h>
15#include <unistd.h>
16
17#include "mbtk_coap.h"
18#include "mbtk_type.h"
19#include "mbtk_log.h"
20#include "mbtk_sock2.h"
21
22
23/*************************************************************
24 Variables:public
25*************************************************************/
26
27
28#define MBTK_ECOAP_TIMEOUT (15 * 1000)
29#define MBTK_ECOAP_WAIT_CLOSE_TIMEOUT (5 * 60 * 1000)
30#define MBTK_ECOAP_STACK_SIZE (12 * 1024) // task stack size
31
32#define ECOAPVER 1
33#define EOCAPTYPE 2
34#define ECOAPCODE 3
35#define ECOAPMSGID 4
36#define ECOAPTOKEN 5
37
38
39/*param--------------------*/
40// Point the first item.
41static mbtk_ecoap_package_s *mbtk_ecoap_head = NULL;
42static mbtk_ecoap_package_ver mbth_ecoap_package_ver={1,0,1,1};
43
44
45struct sockaddr_in serveraddr = {0};
46int socket_id;
47int addrlen;
48
49static mbtk_init_info *coap_init_info = NULL;
50static int coap_handle = -1;
51static bool coap_sock_inited = FALSE;
52static int coap_fd = -1;
53
54
55
56// Point the last item.
57static mbtk_ecoap_package_s *mbtk_ecoap_tail = NULL;
58static mbtk_ecoap_net_s mbtk_ecoap_net;
59static mbtk_ecoap_state_e mbtk_ecoap_state = MBTK_ECOAP_STATE_NON;
60
61//static uint16 mbtk_ecoap_curr_coap_id = 0;
b.liu9e8584b2024-11-06 19:21:28 +080062//static char mbtk_ecoap_host[MBTK_ECOAP_NEW_MAX+1] = {'\0'};
liubin281ac462023-07-19 14:22:54 +080063
b.liu9e8584b2024-11-06 19:21:28 +080064//static int mbtk_ecoap_port;
65//static int mbtk_ecoap_is_dtls;
liubin281ac462023-07-19 14:22:54 +080066static mbtk_ecoap_opt_2 mbtk_ecoap_option_2;
67static mbtk_ecoap_opt_3 mbtk_ecoap_option_3;
68static int mbtk_ecoap_recv = -1;
b.liu9e8584b2024-11-06 19:21:28 +080069//static int mbtk_ecoap_cur_time =0;
liubin281ac462023-07-19 14:22:54 +080070
71/*func------------------------*/
72void mbtk_ecoap_option_add(mbtk_ecoap_option_s *option);
73int mbtk_ecoap_list_del(uint16 message_id,int optDel);
b.liu9e8584b2024-11-06 19:21:28 +080074int mbtk_ecoap_get_message_type(void);
75void mbtk_ecoap_get_code(char *ptr);
liubin281ac462023-07-19 14:22:54 +080076
77#define HEXCHAR(x) ((x >= '0' && x <= '9') || (x >= 'a' && x <= 'f') || (x >= 'A' && x <= 'F'))
78
79
80#if 1
81
b.liu9e8584b2024-11-06 19:21:28 +080082#ifndef toupper
liubin281ac462023-07-19 14:22:54 +080083#define toupper(a) ((((a) >= 'a') && ((a) <= 'z')) ? ((a) - 'a' + 'A') : (a))
b.liu9e8584b2024-11-06 19:21:28 +080084#endif
liubin281ac462023-07-19 14:22:54 +080085
86void HexToStr(byte *pbDest, byte *pbSrc, int nLen)
87{
88 char ddl,ddh;
89 int i;
90
91 for (i=0; i<nLen; i++)
92 {
93 ddh = 48 + pbSrc[i] / 16;
94 ddl = 48 + pbSrc[i] % 16;
95 if (ddh > 57)
96 {
97 ddh = ddh + 7;
98 }
99 if (ddl > 57)
100 {
101 ddl = ddl + 7;
102 }
103 pbDest[i*2] = ddh;
104 pbDest[i*2+1] = ddl;
105 }
106 pbDest[nLen*2] = '\0';
107}
108
109uint8_t StrToHex(byte *pbDest, byte *pbSrc, int nLen)
110{
111 char h1,h2;
112 byte s1,s2;
113 uint8_t i;
114
115 for (i=0; i<nLen; i++)
116 {
117 h1 = pbSrc[2*i];
118 h2 = pbSrc[2*i+1];
119 s1 = toupper(h1) - 0x30;
120 if (s1 > 9)
121 {
122 s1 -= 7;
123 }
124 s2 = toupper(h2) - 0x30;
125 if (s2 > 9)
126 {
127 s2 -= 7;
128 }
129 pbDest[i] = s1*16 + s2;
130 //DS_MBTK_MSG1_HIGH("StrToHex:%.2X",pbDest[i]);
131 }
132 return i;
133}
134
135void coap_log(int is_ascii,const char* data,int len)
136{
137 if(len <= 0) {
138 return;
139 }
140
141 if(is_ascii) { // Is ASCII
142 int i = 0;
143 int count = len / 100 + 1;
144
145 // Has '\0'
146 if(len != strlen(data)) {
147 return;
148 }
149
150 while(i < count) {
151 printf("%s\n",data + i * 100);
152 i++;
153 }
154 } else { // Is hex
155 int index = 0;
156 int i = 0;
157 char buf_temp[100];
158 while(index % 16 == 0 && index < len) {
159 memset(buf_temp,0,100);
160 for(i = 0;i < 16 && index + i < len;i++) {
161 snprintf(buf_temp + i * 3,100 - i,"%.2x ",((char*)data)[index + i]);
162 }
163 index += 16;
164 printf("%s\n", buf_temp);
165 }
166 }
167}
168
169
170
171static void
172mbtk_ecoap_show_error
173(
174 int rsp_errno
175)
176{
177 char temp[50] = {0};
178 memset(temp, 0, 50);
179 snprintf(temp,50,"\r\n+MCOAPERROR:%d\r\n",rsp_errno);
180 printf("%s\n",temp);
181}
182
183int ecoap_recv_buffer(char * dest,const char* data,int len)
184{
185 if( len <= 0) {
186 return -1;
187 }
188 int buffer_len = 0;
189 char Payload[MBTK_ECOAP_DATA_MAX*2+1] ={'\0'};
190 int pud_lenth = mbtk_coap_get_pdu_Length();
191 int type = mbtk_ecoap_get_message_type();
192 char code[12];
193 memset(code,0x00,sizeof(code));
194 mbtk_ecoap_get_code(code);
195 uint16_t mesageId = coapGetRecvMessageID();
196 memset(Payload,0x00,MBTK_ECOAP_DATA_MAX*2+1);
197 snprintf(dest,MBTK_ECOAP_DATA_MAX,
198 "+COAPNMI:%d\r\nMessage Type:%d\r\nCode:\"%s\"\r\nMessage ID:%d\r\nPayload:",
199 pud_lenth,
200 type,
201 code,
b.liubcf86c92024-08-19 19:48:28 +0800202 mesageId);
liubin281ac462023-07-19 14:22:54 +0800203
204
205 int i = 0;
206 for(i = 0; i < len; i++)
207 {
208 if(data[i] == 0xFF && i> 3) //BUG 46397
209 {
210 LOGE("data[i] == 0xFF\n");
211 memcpy(Payload, data+i+1, len - i-1);
212 Payload[len-i -1]='\0';
213 break;
214 }
215 }
216
217 LOGE("len:%d, i :%d\n",len,i);
218 if(Payload[len-i -1] == '\0' )
219 {
b.liubcf86c92024-08-19 19:48:28 +0800220 LOGE("==\0-------------------\n");
liubin281ac462023-07-19 14:22:54 +0800221 // coap_log(-1,(char*)Payload,len - i-1);
222 }else{
223 LOGE("!=\0--------------------\n");
224 Payload[0]='\0';
225 }
226
b.liubcf86c92024-08-19 19:48:28 +0800227 buffer_len = strlen(dest) + strlen(Payload);
liubin281ac462023-07-19 14:22:54 +0800228 strcat(dest,Payload);
229 LOGE("2---------buffer_len:%d,coap_recv_buffer_dest:%s,Payload:%s\n",buffer_len,dest,Payload);
230 return buffer_len;
231}
232
233int mbtk_ecoap_get_message_type(void)
234{
235 switch(coapGetRecvType())
236 {
237 case COAP_CONFIRMABLE:
238 return 0;
239 break;
240
241 case COAP_NON_CONFIRMABLE:
242 return 1;
243 break;
244
245 case COAP_ACKNOWLEDGEMENT:
246 return 2;
247 break;
248
249 case COAP_RESET:
250 return 3;
251 break;
252 }
253 return 0;
254}
255
256void mbtk_ecoap_get_code(char *ptr)
257{
258 switch(coapGetRecvCode()) {
259 case COAP_EMPTY:
260 memcpy(ptr,"0.00",4);
261 break;
262 case COAP_GET:
263 memcpy(ptr,"0.01",4);
264 break;
265 case COAP_POST:
266 memcpy(ptr,"0.02",4);
267 break;
268 case COAP_PUT:
269 memcpy(ptr,"0.03",4);
270 break;
271 case COAP_DELETE:
272 memcpy(ptr,"0.04",4);
273 break;
274 case COAP_CREATED:
275 memcpy(ptr,"2.01",4);
276 break;
277 case COAP_DELETED:
278 memcpy(ptr,"2.02",4);
279 break;
280 case COAP_VALID:
281 memcpy(ptr,"2.03",4);
282 break;
283 case COAP_CHANGED:
284 memcpy(ptr,"2.04",4);
285 break;
286 case COAP_CONTENT:
287 memcpy(ptr,"2.05",4);
288 break;
289 case COAP_CONTINUE:
290 memcpy(ptr,"2.31",4);
291 break;
292 case COAP_BAD_REQUEST:
293 memcpy(ptr,"4.00",4);
294 break;
295 case COAP_UNAUTHORIZED:
296 memcpy(ptr,"4.01",4);
297 break;
298 case COAP_BAD_OPTION:
299 memcpy(ptr,"4.02",4);
300 break;
301 case COAP_FORBIDDEN:
302 memcpy(ptr,"4.03",4);
303 break;
304 case COAP_NOT_FOUND:
305 memcpy(ptr,"4.04",4);
306 break;
307 case COAP_METHOD_NOT_ALLOWED:
308 memcpy(ptr,"4.05",4);
309 break;
310 case COAP_NOT_ACCEPTABLE:
311 memcpy(ptr,"4.06",4);
312 break;
313 case COAP_PRECONDITION_FAILED:
314 memcpy(ptr,"4.12",4);
315 break;
316 case COAP_REQUEST_ENTITY_TOO_LARGE:
317 memcpy(ptr,"4.13",4);
318 break;
319 case COAP_UNSUPPORTED_CONTENT_FORMAT:
320 memcpy(ptr,"4.15",4);
321 break;
322 case COAP_INTERNAL_SERVER_ERROR:
323 memcpy(ptr,"5.00 ",4);
324 break;
325 case COAP_NOT_IMPLEMENTED:
326 memcpy(ptr,"5.01",4);
327 break;
328 case COAP_BAD_GATEWAY:
329 memcpy(ptr,"5.02",4);
330 break;
331 case COAP_SERVICE_UNAVAILABLE:
332 memcpy(ptr,"5.03",4);
333 break;
334 case COAP_GATEWAY_TIMEOUT:
335 memcpy(ptr,"5.04",4);
336 break;
337 case COAP_PROXYING_NOT_SUPPORTED:
338 memcpy(ptr,"5.05",4);
339 break;
340 default:
b.liubcf86c92024-08-19 19:48:28 +0800341 sprintf(ptr, "UndefCod%u",(unsigned)(coapGetRecvCode()));
liubin281ac462023-07-19 14:22:54 +0800342 }
343}
344
b.liu9e8584b2024-11-06 19:21:28 +0800345#if 0
liubin281ac462023-07-19 14:22:54 +0800346static int
347mbtk_ecoap_is_open()
348{
349 if(mbtk_ecoap_state >= MBTK_ECOAP_STATE_OPENED)
350 return 0;
351
352 return -1;
353}
354
355
356static void mbtk_ecoap_reset()
357{
358 memset(&mbtk_ecoap_net,0x0,sizeof(mbtk_ecoap_net_s));
359 mbtk_ecoap_net.message_id = 1; //change mbtk_ecoap_net.message_id = 0;
360 memset(&mbtk_ecoap_option_2, 0x0, sizeof(mbtk_ecoap_opt_2));
361 memset(&mbth_ecoap_package_ver, 0x0,sizeof(mbtk_ecoap_package_ver));
362 mbth_ecoap_package_ver.version = 1;
363 mbth_ecoap_package_ver.type = 0;
364 mbth_ecoap_package_ver.code = 1;
365 mbth_ecoap_package_ver.message_id = 1;
366 mbtk_ecoap_recv = -1;
367
368 mbtk_ecoap_package_s *coap = mbtk_ecoap_head;
369 mbtk_ecoap_package_s *coap_next = NULL;
370 mbtk_ecoap_option_s * option_ptr = NULL;
371 mbtk_ecoap_option_s * option_ptr_next = NULL;
b.liubcf86c92024-08-19 19:48:28 +0800372
liubin281ac462023-07-19 14:22:54 +0800373 while(coap != NULL)
374 {
375 coap_next = coap->next;
376 if(coap->payload != NULL)
377 free(coap->payload);
378
379 if(coap->options != NULL)
380 {
381 option_ptr = coap->options;
382 while(option_ptr != NULL)
383 {
384 option_ptr_next = option_ptr->next;
385 free(option_ptr);
386 option_ptr = NULL;
387 option_ptr = option_ptr_next;
388 }
b.liubcf86c92024-08-19 19:48:28 +0800389
liubin281ac462023-07-19 14:22:54 +0800390 }
b.liubcf86c92024-08-19 19:48:28 +0800391
liubin281ac462023-07-19 14:22:54 +0800392 free(coap);
393 coap = NULL;
394 coap = coap_next;
395
396 }
397
398 mbtk_ecoap_head = mbtk_ecoap_tail = NULL;
399}
400
401
402static void mbtk_ecoap_close()
403{
404
405}
b.liu9e8584b2024-11-06 19:21:28 +0800406#endif
liubin281ac462023-07-19 14:22:54 +0800407
408
409
410
411mbtk_ecoap_package_s *mbtk_ecoap_get_by_msg_id(uint16 message_id)
412{
413 if(mbtk_ecoap_head == NULL)
414 {
415 }
416 else
417 {
418 mbtk_ecoap_package_s *coap_ptr = mbtk_ecoap_head;
419 while(coap_ptr != NULL)
420 {
421 if(coap_ptr->message_id == message_id)
422 {
423 return coap_ptr;;
424 }
425 coap_ptr = coap_ptr->next;
426 }
427 }
428 return NULL;
429}
430
431static void mbtk_ecoap_list_item_init(unsigned int sig,mbtk_ecoap_package_s *coap,uint16 message_id)
432{
433 switch(sig)
434 {
435 case ECOAPVER:
436 coap->version = message_id;
437 break;
438 case EOCAPTYPE:
439 coap->type = message_id;
440 break;
441 case ECOAPCODE:
442 coap->code = message_id;
443 break;
444 case ECOAPMSGID:
445 coap->message_id = message_id;
446 break;
447 case ECOAPTOKEN:
448 coap->token_len = message_id;
449 break;
450 default:
451 break;
452 }
453 coap->next = NULL; //change delete this code
454}
455
456
457mbtk_ecoap_package_s* mbtk_ecoap_list_add(uint16 message_id)
458{
459 LOGE("mbtk_ecoap_list_add-----memssage_id:%d\n",message_id);
460 if(mbtk_ecoap_head == NULL)
461 {
462 mbtk_ecoap_head = (mbtk_ecoap_package_s*)malloc(sizeof(mbtk_ecoap_package_s));
463 memset(mbtk_ecoap_head, 0,sizeof(mbtk_ecoap_package_s));
464 mbtk_ecoap_list_item_init(ECOAPMSGID,mbtk_ecoap_head,message_id);
465 mbtk_ecoap_tail = mbtk_ecoap_head;
466 return mbtk_ecoap_head;
467 }
468 else
469 {
470 mbtk_ecoap_package_s *coap_ptr = mbtk_ecoap_head;
471 while(coap_ptr != NULL)
472 {
473 if(coap_ptr->message_id == message_id)
474 {
475 printf("Coap %d exist.\n",message_id);
476 return NULL;
477 }
478 coap_ptr = coap_ptr->next;
479 }
480 mbtk_ecoap_tail->next = (mbtk_ecoap_package_s*)malloc(sizeof(mbtk_ecoap_package_s));
481 mbtk_ecoap_list_item_init(ECOAPMSGID,mbtk_ecoap_tail->next,message_id);
482 mbtk_ecoap_tail = mbtk_ecoap_tail->next;
483 return mbtk_ecoap_tail;
484 }
485}
486
487static void mbtk_ecoap_free(mbtk_ecoap_package_s *coap)
488{
489 if(coap != NULL)
490 {
491 if(coap->payload != NULL)
492 free(coap->payload);
493
494 if(coap->options != NULL)
495 {
496 mbtk_ecoap_option_s *option_ptr = coap->options;
497 while(option_ptr != NULL)
498 {
b.liudeb8e422024-12-14 17:36:56 +0800499 mbtk_ecoap_option_s *tmp_ptr = option_ptr;
liubin281ac462023-07-19 14:22:54 +0800500 option_ptr = option_ptr->next;
b.liudeb8e422024-12-14 17:36:56 +0800501 free(tmp_ptr);
liubin281ac462023-07-19 14:22:54 +0800502 }
503 }
504
505 free(coap);
506 coap = NULL;
507 }
508}
509
510int mbtk_ecoap_list_del(uint16 message_id,int optDel)
511{
512 LOGE("mbtk_ecoap_list_del:message_id:%d\n",message_id);
513 if(mbtk_ecoap_head == NULL)
514 {
515 printf("mbtk_ecoap_head == NULL\n");
516 return -1;
517 }
518
519 mbtk_ecoap_recv = -1;
520 if(optDel)
521 {
522 memset(&mbtk_ecoap_option_2, 0x0, sizeof(mbtk_ecoap_opt_2));
523 memset(&mbtk_ecoap_option_3, 0x0, sizeof(mbtk_ecoap_opt_3));
524 memset(&mbth_ecoap_package_ver,0x0,sizeof(mbth_ecoap_package_ver));
525 mbth_ecoap_package_ver.version = 1;
526 mbth_ecoap_package_ver.type = 0;
527 mbth_ecoap_package_ver.code = 1;
528 mbth_ecoap_package_ver.message_id = 1;
529 }
530 mbtk_ecoap_package_s *coap = mbtk_ecoap_head;
531 if(mbtk_ecoap_head->message_id == message_id) // Is first item.
532 {
533 mbtk_ecoap_head = mbtk_ecoap_head->next;
534
535 mbtk_ecoap_free(coap);
536 return 0;
537 }
538 else // Not first item.
539 {
b.liubcf86c92024-08-19 19:48:28 +0800540 while(coap->next != NULL)
liubin281ac462023-07-19 14:22:54 +0800541 {
542 if(message_id == coap->next->message_id) // delete
543 {
544 mbtk_ecoap_package_s *coap_tmp = coap->next;
545 if(mbtk_ecoap_tail == coap_tmp)
546 {
547 mbtk_ecoap_tail = coap;
548 }
549 coap->next = coap_tmp->next;
550 mbtk_ecoap_free(coap_tmp);
551 return 0;;
552 }
553 coap = coap->next;
554 }
555 return -1;
556 }
557}
558
559void mbtk_ecoap_option_add(mbtk_ecoap_option_s *option)
560{
561 if(option != NULL)
562 {
563 switch(option->type)
564 {
565 case COAP_OPTION_IF_MATCH:
566 case COAP_OPTION_URI_HOST:
567 case COAP_OPTION_ETAG:
568 case COAP_OPTION_IF_NONE_MATCH:
569 case COAP_OPTION_LOCATION_PATH:
570 case COAP_OPTION_LOCATION_QUERY:
571 case COAP_OPTION_PROXY_URI:
572 case COAP_OPTION_PROXY_SCHEME:
573 case COAP_OPTION_URI_PORT:
574 case COAP_OPTION_ACCEPT:
575 case COAP_OPTION_SIZE2:
576 case COAP_OPTION_SIZE1:
577 {
578 break;
579 }
580 case COAP_OPTION_BLOCK2:
581 case COAP_OPTION_BLOCK1:
582 {
583 LOGE("option->opt.opt_block.number = %d\n",option->opt.opt_block.number);
584 if(option->opt.opt_block.number <= 0x0F)
585 {
586 uint8_t temp[1];
587 temp[0] = (uint8_t)(((option->opt.opt_block.number << 4) & 0xF0)
588 | ((option->opt.opt_block.more_flag << 3) & 0x08)
589 | (option->opt.opt_block.size & 0x07));
590 coapAddOption(option->type,1,temp);
591 }
592 else if(option->opt.opt_block.number <= 0x0FFF)
593 {
594 uint8_t temp[2];
595 temp[0] = (uint8_t)(option->opt.opt_block.number >> 4);
596 temp[1] = (uint8_t)(((option->opt.opt_block.number << 4) & 0xF0)
597 | ((option->opt.opt_block.more_flag << 3) & 0x08)
598 | (option->opt.opt_block.size & 0x07));
599 coapAddOption(option->type,2,temp);
600
601 }
602 else
603 {
604 uint8_t temp[3];
605 temp[0] = (uint8_t)(option->opt.opt_block.number >> 12);
606 temp[1] = (uint8_t)(option->opt.opt_block.number >> 4);
607 temp[2] = (uint8_t)(((option->opt.opt_block.number << 4) & 0xF0)
608 | ((option->opt.opt_block.more_flag << 3) & 0x08)
609 | (option->opt.opt_block.size & 0x07));
610 coapAddOption(option->type,3,temp);
611
612 }
613 break;
614 }
615 case COAP_OPTION_MAX_AGE:
616 {
617 uint8_t temp[1];
618 temp[0] = (uint8_t)option->opt.opt_int;
619 coapAddOption(option->type,1,temp);
620 break;
621 }
622 case COAP_OPTION_OBSERVE:
623 {
624 uint8_t temp[1];
625 temp[0] = (uint8_t)option->opt.opt_int;
626 coapAddOption(option->type,1,temp);
627 break;
628 }
629 case COAP_OPTION_URI_QUERY:
630 {
631 coapAddURIQuery((char*)option->opt.opt_str);
632 break;
633 }
634 case COAP_OPTION_URI_PATH:
635 {
636 coapSetURI((char*)option->opt.opt_str);
637 break;
638 }
639 case COAP_OPTION_CONTENT_FORMAT:
640 {
641 coapSetContentFormat(option->opt.opt_content_format);
642 break;
643 }
644 default:
b.liu9e8584b2024-11-06 19:21:28 +0800645 printf("No such type:%d\n",option->type);
liubin281ac462023-07-19 14:22:54 +0800646 break;
647 }
648 }
649}
650
651static void mbtk_ecoap_set_option(mbtk_ecoap_package_s *coap,
652 mbtk_coap_option_type type,void *str,
653 int int0,int int1,int int2)
654{
655 if(coap != NULL)
656 {
657/* if(coap->options == NULL)
658 {
659 coap->options = (mbtk_ecoap_option_s*)malloc(sizeof(mbtk_ecoap_option_s));
660 memset(coap->options,0x0,sizeof(mbtk_ecoap_option_s));
661 coap->options->type = type;
662 coap->options->next = NULL;
663 }
664*/
665 mbtk_ecoap_option_s *option = coap->options;
666 while(option != NULL)
667 {
668 LOGE("1option != NULL\n");
669 if(option->type == type)
670 {
671 break;
672 }
673 option = option->next;
674 }
675
676 LOGE("----------------------\n");
677 if(option == NULL) // Now option
678 {
679 LOGE("option == NULL\n");
680 option = (mbtk_ecoap_option_s*)malloc(sizeof(mbtk_ecoap_option_s));
681 memset(option,0x0,sizeof(mbtk_ecoap_option_s));
682// option->type = type;
683
684 option->next = coap->options;
685 coap->options = option;
686 option->type = type;
687 }
688 else // Change option
689 {
690 // Do noting.
691 }
692
693 switch(type)
694 {
695 case COAP_OPTION_IF_MATCH:
696 case COAP_OPTION_URI_HOST:
697 case COAP_OPTION_ETAG:
698 case COAP_OPTION_IF_NONE_MATCH:
699 case COAP_OPTION_LOCATION_PATH:
700 case COAP_OPTION_URI_QUERY:
701 case COAP_OPTION_LOCATION_QUERY:
702 case COAP_OPTION_PROXY_URI:
703 case COAP_OPTION_PROXY_SCHEME:
704 case COAP_OPTION_URI_PATH:
705 {
706 memset(option->opt.opt_str,0x0,128);
707 memcpy(option->opt.opt_str,str,strlen((char*)str));
708 break;
709 }
710 case COAP_OPTION_OBSERVE:
711 case COAP_OPTION_MAX_AGE:
712 case COAP_OPTION_URI_PORT:
713 case COAP_OPTION_SIZE2:
714 case COAP_OPTION_SIZE1:
715 {
716 option->opt.opt_int = (int)int0;
717 break;
718 }
719 case COAP_OPTION_BLOCK2:
720 case COAP_OPTION_BLOCK1:
721 {
722 option->opt.opt_block.size = (mbtk_ecoap_option_block_e)int0;
723 option->opt.opt_block.number = (int)int1;
724 option->opt.opt_block.more_flag = (uint8)int2;
725 break;
726 }
727 case COAP_OPTION_CONTENT_FORMAT:
728 {
729 option->opt.opt_content_format = (mbtk_content_format_type)int0;
730 break;
731 }
732 case COAP_OPTION_ACCEPT:
733 {
734 option->opt.opt_content_format = (mbtk_content_format_type)int0;
735 break;
736 }
737 default:
b.liu9e8584b2024-11-06 19:21:28 +0800738 printf("No such type:%d\n",type);
liubin281ac462023-07-19 14:22:54 +0800739 break;
740 }
741 }
742}
743
744
745static void mbtk_ecoap_send_ack(mbtk_coap_code_type code,
746 uint16_t message_id,uint8 token_len,uint8 *token)
747{
748 coapReset();
749 coapSetVersion(1);
750 coapSetType(COAP_ACKNOWLEDGEMENT);
751 coapSetMessageID(message_id);
752
753 if(code == COAP_POST || code == COAP_PUT)
754 coapSetCode(COAP_CHANGED);
755 else
756 coapSetCode(COAP_EMPTY);
757
758 if(token_len > 0)
759 {
760 coapSetToken(token, token_len);
761 }
762
763 uint8_t* pduPointer = coapGetPDUPointer();
764 int pduLen = coapGetPDULength();
765 int err;
766 int res = mbtk_sock_write(coap_handle, coap_fd, pduPointer, pduLen, 300, &err);
767 if(res != pduLen)
768 {
769 printf("Send ACK fail.[res:%d,pduLen:%d],err:%d\n",res,pduLen,err);
770 }
771 else
772 {
773 printf("Send ACK to server success.\n");
774 }
775}
776
777
778
779static int mbtk_ecoap_handle_sock_init(char *ip_addr, int port, bool is_support_ssl, bool ingnore_cert)
780{
781 mbtk_sock_info *sock_info = NULL;
782 int rc = 0;
783 int errno;
b.liubcf86c92024-08-19 19:48:28 +0800784
liubin281ac462023-07-19 14:22:54 +0800785 sock_info = (mbtk_sock_info *)malloc(sizeof(mbtk_sock_info));
786 if(sock_info == NULL)
787 {
788 rc = -1;
789 return rc;
790 }
791 memcpy(sock_info->address, ip_addr, strlen(ip_addr));
792 sock_info->port = port;
793 sock_info->is_support_ssl = is_support_ssl;
794 sock_info->ingnore_cert = ingnore_cert;
795 sock_info->type = MBTK_SOCK_UDP;
b.liubcf86c92024-08-19 19:48:28 +0800796
liubin281ac462023-07-19 14:22:54 +0800797 printf("host %s\nport %d\nis_support_ssl %d\ningnore_cert %d\n",sock_info->address,sock_info->port,sock_info->is_support_ssl,sock_info->ingnore_cert);
798
799 if(!coap_sock_inited)
800 {
801 coap_handle = mbtk_sock_init(coap_init_info);
802 if (coap_handle < 0 )
803 {
804 rc = -1;
805 return rc;
806 }
807 coap_sock_inited = TRUE;
808 }
809
810
811 coap_fd = mbtk_sock_open(coap_handle, sock_info, 3000, &errno);
812 if(coap_fd < 0)
813 {
814 printf("creat socket fail, errno:%d\n",errno);
815 rc = -1;
816 return rc;
817 }
818 mbtk_ecoap_state = MBTK_ECOAP_STATE_READY;
819 return rc;
820}
821
822
823
824int mbtk_ecoap_ecoap_send(mbtk_ecoap_package_s* coap)
825{
826 if(coap != NULL)
827 {
828 coapReset();
829 coapSetVersion(coap->version);
830 coapSetType(coap->type);
831 coapSetCode(coap->code);
832 coapSetMessageID(coap->message_id);
833
834 if(coap->token_len > 0)
835 {
836 coapSetToken(coap->token, coap->token_len);
837 }
838
839 mbtk_ecoap_option_s *option = coap->options;
840 while(option != NULL)
841 {
842 mbtk_ecoap_option_add(option);
843 option = option->next;
844 }
845
846 if(coap->payload_len > 0)
847 {
848 coapSetPayload((uint8_t*)coap->payload, coap->payload_len);
849 }
850
851 uint8_t *pduPointer = coapGetPDUPointer();
852 int pduLen = coapGetPDULength();
853 uint8_t pduPointer2[MBTK_ECOAP_DATA_MAX*2];
854 int err;
855 memset ( pduPointer2,0x00,MBTK_ECOAP_DATA_MAX*2 );
856 if((mbtk_ecoap_option_2.optlen + pduLen) > MBTK_ECOAP_DATA_MAX*2)
857 {
858 printf("This length is too long\n");
859 return -1;
860 }
861
862 LOGE("pduLen:%d, optlen:%d\n",pduLen ,mbtk_ecoap_option_2.optlen);
863 // printf("pduPointer:\n");
864 // coap_log(-1,(char*)pduPointer,pduLen);
865 int j=0,k=0;
866 LOGE("pduPointer-----------end\n");
867// int optflag = 0;
868 pduPointer2[0]= *pduPointer++;
869 pduPointer2[1]= *pduPointer++;
870 pduPointer2[2]= *pduPointer++;
871 pduPointer2[3]= *pduPointer++;
872 for(j = 0; j < mbtk_ecoap_option_2.optlen; j++)
873 {
874 pduPointer2[4+j] = mbtk_ecoap_option_2.optVal[j];
875 LOGE("j:%d, %X",j, mbtk_ecoap_option_2.optVal[j]);
876 k++;
877 }
878 int pduLen2 = 4;
879 while(pduLen > pduLen2 )
880 {
881 LOGE("\r\npduLen > pduLen2 \r\n");
882 LOGE("pduLen:%d,pduPointer:%X,k:%d\n",pduLen2,*pduPointer,k);
883 pduPointer2[pduLen2+k] = *pduPointer++;
884 pduLen2++;
885 }
886
887 pduLen += mbtk_ecoap_option_2.optlen;
888
889 printf("sendpdu:--------pduLen:%d\n",pduLen);
890 coap_log(FALSE,(char*)pduPointer2,pduLen);
891 int send_len = 0;
892
893 if((send_len = mbtk_sock_write(coap_handle, coap_fd, pduPointer2, pduLen, 300, &err)) != pduLen)
894// if((send_len = sendto(socket_id, pduPointer2, pduLen, 0, (struct sockaddr*)&serveraddr, addrlen)) != pduLen)
895 {
896 printf("coap_udp_sendto complate.[%d/%d]\n",send_len,pduLen);
897
898 coap->send_count++;
899 return -1;
900 }
901
902 if(coap->type != COAP_CONFIRMABLE)
903 {
904 mbtk_ecoap_list_del(coap->message_id,0);
905 }
906
907 }
908 return 0;
909}
910
911void mbtk_ecoap_recv_buffer(char * dest)
912{
913 int pud_lenth = mbtk_coap_get_pdu_Length();
914 int type = mbtk_ecoap_get_message_type();
915 char code[12];
916 memset(code,0x00,sizeof(code));
917 mbtk_ecoap_get_code(code);
918 uint16_t mesageId = coapGetRecvMessageID();
919 memset(dest,0x00,129);
920 snprintf(dest,128,
921 "+COAPNMI:%d\r\nMessage Type:%d\r\nCode:\"%s\"\r\nMessage ID:%d\r\nPayload:",
922 pud_lenth,
923 type,
924 code,
b.liubcf86c92024-08-19 19:48:28 +0800925 mesageId);
liubin281ac462023-07-19 14:22:54 +0800926}
927
928
929static void mbtk_ecoap_recv_resolve(const void *data,uint16 data_len)
930{
931 if(coapCreateRecv((uint8_t*)data, data_len) <= 0)
932 {
933 printf("coapCreateRecv fail.\n");
934 }
935 else
936 {
937 LOGE("coapCreateRecv() success.\n");
938
939 uint8_t version = coapGetRecvVersion();
940 mbtk_coap_type type = coapGetRecvType();
941 mbtk_coap_code_type code = coapGetRecvCode();
942 uint16_t message_id = coapGetRecvMessageID();
943 int pud_lenth = mbtk_coap_get_pdu_Length();
944 LOGE("version:%d;type:%d\n",version,type);
945 LOGE("code:%d;message_id:%d,pud_lenth:%d\n",code,message_id,pud_lenth);
946
947 uint8 token_len = coapGetRecvTokenLength();
948 char token[9] = {0};
949 memcpy(token,coapGetRecvTokenPointer(),token_len);
950 LOGE("token[%d]:%s\n",token_len,token);
951
b.liu9e8584b2024-11-06 19:21:28 +0800952// uint16 playload_len = coapGetRecvPayloadLength();
953// uint8 *playload = coapGetRecvPayloadPointer();
liubin281ac462023-07-19 14:22:54 +0800954// printf("----------------payload-----------------\n");
955// coap_log(0,(char*)playload,playload_len);
956// printf("--------------payload end----------------\n");
957
958
959 char buff_data[MBTK_ECOAP_DATA_MAX*2+1];
960 memset ( buff_data,0x00,MBTK_ECOAP_DATA_MAX*2+1 );
961 int buffer_len = ecoap_recv_buffer(buff_data, data, data_len);
962 printf("recv buff_len:%d\n",buffer_len);
963 printf("buf:\n%s\r\n",buff_data);
b.liubcf86c92024-08-19 19:48:28 +0800964
liubin281ac462023-07-19 14:22:54 +0800965 LOGE("type:%X\n",type);
966 if(type == COAP_CONFIRMABLE) // Should ACK
967 {
968 mbtk_ecoap_send_ack(code,message_id,token_len,(uint8*)token);
969 }
970 else if(type == COAP_NON_CONFIRMABLE)
971 {
972 // Do nothing.
973 }
974 else if(type == COAP_ACKNOWLEDGEMENT)
975 {
976 mbtk_ecoap_package_s * coap_send = mbtk_ecoap_get_by_msg_id(message_id);
977 if(coap_send != NULL)
978 {
b.liu9e8584b2024-11-06 19:21:28 +0800979 uint32_t number;
liubin281ac462023-07-19 14:22:54 +0800980 uint8_t more_flag;
981 uint8_t size;
982 LOGE("Get message(%d) ack.\n",message_id);
983 if(coapGetRecvOptionBlock2(&number, &more_flag, &size))
984 {
985 LOGE("Block2 (size:%d; more_flag:%d; number:%d)\n",size,more_flag,number);
986 if(more_flag) // Has data no read.
987 {
988 coap_send->message_id = ++mbtk_ecoap_net.message_id ;
989 mbtk_ecoap_set_option(coap_send, COAP_OPTION_BLOCK2, NULL,
990 size,number + 1,0);
991
992 mbtk_ecoap_ecoap_send(coap_send);
993 }
994 else
995 {
996 mbtk_ecoap_list_del(message_id,0);
997 }
998 }
999 else
1000 {
1001 printf("coapGetRecvOptionBlock2() fail.\n");
1002 mbtk_ecoap_list_del(message_id,0);
1003 }
1004 }
1005 else
1006 {
1007 printf("Coap not match.\n");
1008 }
1009 }
1010 else // COAP_RESET
1011 {
1012 printf("Coap type error.\n");
1013 }
1014 }
1015 coapDeleteRecv();
1016
1017}
1018
1019
1020static int ecoap_sig_recv_handle(void)
1021{
1022 LOGE("coap_sig_recv_handle----------start\n");
1023
1024 uint8_t buffer[MBTK_ECOAP_DATA_MAX*2+1];
1025 memset ( buffer,0x00,MBTK_ECOAP_DATA_MAX*2+1 );
1026 int ret=-1;
1027 int err = -1;
1028 while(TRUE)
1029 {
1030 ret = mbtk_sock_read(coap_handle, coap_fd, buffer, MBTK_ECOAP_DATA_MAX*2, 1000*10, &err);
1031 if(ret <= 0)
1032 {
1033 printf("read fail, err:%d",err);
1034 break;
1035 }
1036 printf("recv_from ret:%d\n",ret);
1037 coap_log(FALSE,(char*)buffer,ret);
1038 mbtk_ecoap_recv_resolve(buffer,ret);
1039 }
1040
1041 return ret;
1042}
1043
1044static int ecoap_sig_send_complete_handle(void )
1045{
1046 int ret=-1;
1047 mbtk_ecoap_package_s *coap = mbtk_ecoap_get_by_msg_id(mbtk_ecoap_net.message_id);
1048 if(coap == NULL)
1049 {
1050 mbtk_ecoap_show_error(MBTK_ECOAP_ERR_MSG_ID);
1051 return -1;
1052 }
1053
1054 ret = mbtk_ecoap_ecoap_send(coap);
1055
1056 return ret;
1057
1058}
1059
b.liu9e8584b2024-11-06 19:21:28 +08001060//static int mbtk_ecoap_open(int open);
liubin281ac462023-07-19 14:22:54 +08001061
1062
1063
1064#endif
1065
1066
1067/*************************************************************
1068 Public Function Definitions
1069*************************************************************/
1070
1071/*************************************************************
1072 ip_addr: url
1073 port
1074
1075*************************************************************/
1076int mbtk_coap_ecoapnew_exec_cmd
1077(
1078 char *ip_addr,
1079 int port,
b.liubcf86c92024-08-19 19:48:28 +08001080 bool is_support_ssl,
liubin281ac462023-07-19 14:22:54 +08001081 bool ingnore_cert
1082)
1083{
1084 printf("mbtk_coap_ecoapnew_exec_cmd()------start1\n");
1085 int ret = 0;
1086 if( !ip_addr)
1087 {
1088 mbtk_ecoap_show_error(MBTK_ECOAP_ERR_NO_READY);
1089 return -1;
1090 }
1091
1092 ret = mbtk_ecoap_handle_sock_init(ip_addr, port, is_support_ssl, ingnore_cert);
b.liubcf86c92024-08-19 19:48:28 +08001093
liubin281ac462023-07-19 14:22:54 +08001094 return ret;
1095}
1096
1097int mbtk_coap_ecoaprxmod_exec_cmd
1098(
1099 int mode
1100)
1101{
1102 int result = 0;
b.liu9e8584b2024-11-06 19:21:28 +08001103// int rx_mod = mode;
b.liubcf86c92024-08-19 19:48:28 +08001104
liubin281ac462023-07-19 14:22:54 +08001105 return result;
1106}
1107
1108int mbtk_coap_ecoappr_exec_cmd
1109(
1110 int format
1111)
1112{
1113 int result = 0;
b.liu9e8584b2024-11-06 19:21:28 +08001114// uint16 ecoappr = format;
liubin281ac462023-07-19 14:22:54 +08001115 return result;
1116}
1117
1118int mbtk_coap_ecoaprxget_exec_cmd
1119(
1120 int len
1121)
1122{
1123 int result = 0;
b.liu9e8584b2024-11-06 19:21:28 +08001124// int get_len = len;
b.liubcf86c92024-08-19 19:48:28 +08001125
liubin281ac462023-07-19 14:22:54 +08001126 return result;
1127
1128}
1129
1130int mbtk_coap_ecoapver_exec_cmd
1131(
1132 int version
1133)
1134{
1135 int result = 0;
1136 mbth_ecoap_package_ver.version = version;
1137 return result;
1138
1139}
1140
1141int mbtk_coap_ecoaptype_exec_cmd
1142(
1143 mbtk_coap_type type
1144)
1145{
1146 int result = 0;
1147 mbth_ecoap_package_ver.type = type;
b.liubcf86c92024-08-19 19:48:28 +08001148
liubin281ac462023-07-19 14:22:54 +08001149 return result;
1150
1151}
1152
1153
1154int mbtk_coap_ecoapcode_exec_cmd
1155(
1156 mbtk_coap_code_type code
1157)
1158{
1159 int result = 0;
1160 mbth_ecoap_package_ver.code = code;
1161 LOGE("ver:%d,type:%d,code:%d,msg:%d\n",
1162 mbth_ecoap_package_ver.version,
1163 mbth_ecoap_package_ver.type,
1164 mbth_ecoap_package_ver.code,
1165 mbth_ecoap_package_ver.message_id);
1166 return result;
1167
1168}
1169
1170int mbtk_coap_ecoaptoken_exec_cmd
1171(
1172 char *token_buf, int len
1173)
1174{
1175 int result = 0;
1176 uint16 token_length = len;
b.liubcf86c92024-08-19 19:48:28 +08001177 char * token = token_buf;
liubin281ac462023-07-19 14:22:54 +08001178 if(strlen(token) != token_length)
1179 {
1180 return -1;
1181 }
b.liubcf86c92024-08-19 19:48:28 +08001182
liubin281ac462023-07-19 14:22:54 +08001183 mbth_ecoap_package_ver.token_len = token_length;
1184 memcpy(mbth_ecoap_package_ver.token, token, strlen(token));
1185
1186 return result;
1187}
1188
1189int mbtk_coap_ecoapmsgid_exec_cmd
1190(
1191 int msg_id
1192)
1193{
1194 int result = 0;
b.liubcf86c92024-08-19 19:48:28 +08001195 mbth_ecoap_package_ver.message_id = msg_id;
liubin281ac462023-07-19 14:22:54 +08001196
1197 return result;
1198}
1199
1200int mbtk_coap_ecoapopt_exec_cmd
1201(
1202 char *value_buf, int buf_len
1203)
1204{
1205 int result = 0;
1206 int opt = buf_len;
1207 char* value = value_buf;
1208
1209 if(value == NULL)
1210 {
1211 return -1;
1212 }
1213 if(opt != strlen(value))
1214 {
1215 return -1;
1216 }
1217
1218 memset(&mbtk_ecoap_option_2, 0x0, sizeof(mbtk_ecoap_opt_2));
1219 memset(&mbtk_ecoap_option_3, 0x0, sizeof(mbtk_ecoap_opt_3));
1220
1221 mbtk_ecoap_option_3.optlen = opt;
1222 mbtk_ecoap_option_2.optlen = opt / 2;
1223
1224 if(mbtk_ecoap_option_2.optlen > 0)
1225 {
1226 memcpy(mbtk_ecoap_option_3.optVal, value, opt);
1227 mbtk_ecoap_option_3.optVal[opt] = '\0';
1228 StrToHex((byte*)mbtk_ecoap_option_2.optVal, (byte*)value, strlen(value));
1229// printf("\r\nopt2---------option_len,option_data");
1230// coap_log(FALSE,(char*)mbtk_ecoap_option_2.optVal,mbtk_ecoap_option_2.optlen);
1231 }
1232 return result;
1233
1234}
1235
1236int mbtk_coap_ecoapsend_exec_cmd
1237(
1238 int message_id, int Data_len, char *data
1239)
1240{
1241 int data_len = Data_len;
1242 char * send_data = NULL;
1243 int err = -1;
1244 if(data_len != 0 )
1245 {
1246 send_data = data;
1247 }
1248 int coap_id = message_id;
1249
1250 LOGE("send---------coap_id:%d,data_len:%d\n",coap_id,data_len);
1251
1252 if(mbtk_ecoap_state <= MBTK_ECOAP_STATE_CLOSING )
1253 {
1254 mbtk_ecoap_show_error(MBTK_ECOAP_ERR_NO_OPEN);
1255 return -1;
1256 }
1257
1258 if(coap_id != mbth_ecoap_package_ver.message_id)
1259 {
1260 mbtk_ecoap_show_error(MBTK_ECOAP_ERR_MSG_ID);
1261 return -1;
1262 }
1263
1264 if(coap_id != mbtk_ecoap_net.message_id)
1265 {
1266 printf("send_cmd del message_id:%d\n",mbtk_ecoap_net.message_id);
1267 mbtk_ecoap_list_del(mbtk_ecoap_net.message_id,-1);
1268 }
1269
1270 if(send_data)
1271 {
1272 if(data_len != strlen(send_data) || data_len > 1024)
1273 {
1274 mbtk_ecoap_show_error(MBTK_ECOAP_ERR_PAYLOAD_LENGTH);
1275 return -1;
1276 }
1277 }
1278
1279 mbtk_ecoap_package_s *coap = mbtk_ecoap_get_by_msg_id(coap_id);
1280 if( !coap)
1281 {
1282 mbtk_ecoap_net.message_id = mbth_ecoap_package_ver.message_id;
1283 coap = mbtk_ecoap_list_add(mbtk_ecoap_net.message_id);
1284 if(coap != NULL)
1285 {
1286 mbtk_ecoap_list_item_init(ECOAPVER,coap,mbth_ecoap_package_ver.version);
1287 mbtk_ecoap_list_item_init(EOCAPTYPE,coap,mbth_ecoap_package_ver.type);
1288 mbtk_ecoap_list_item_init(ECOAPCODE,coap,mbth_ecoap_package_ver.code);
1289 if(mbth_ecoap_package_ver.token_len > 0)
1290 {
1291 coap->token_len = mbth_ecoap_package_ver.token_len;
1292 memcpy(coap->token, mbth_ecoap_package_ver.token, strlen((char *)mbth_ecoap_package_ver.token));
1293 }
b.liubcf86c92024-08-19 19:48:28 +08001294
liubin281ac462023-07-19 14:22:54 +08001295 if(data_len > 0)
1296 {
1297 coap->payload_len = data_len;
1298 if(coap->payload != NULL)
1299 {
1300 free(coap->payload);
1301 coap->payload = NULL;
1302 }
1303 coap->payload = (uint8*)malloc(data_len + 1);
1304 memset(coap->payload,0x00,data_len + 1);
1305 memcpy(coap->payload,send_data,data_len);
1306 }
1307
1308 }
1309 else{
1310 printf("coap new error\n");
1311 }
1312
1313 }
1314 else
1315 {
1316 printf("coap is NULL\n");
1317 }
1318
1319 mbtk_ecoap_recv = 0;
1320 if(mbtk_ecoap_state < MBTK_ECOAP_STATE_READY)
1321 {
1322 printf("State[%d] error,not ready...\n",mbtk_ecoap_state);
1323 return -1;
1324 }
1325
1326 if( !ecoap_sig_send_complete_handle() )
1327 {
1328 ecoap_sig_recv_handle();
1329 }
1330
1331 if(mbtk_sock_close(coap_handle, coap_fd,1000, &err)) {
1332 return -1;
1333 }
1334
1335 coap_fd = -1;
1336 return 0;
1337
1338}
1339
1340int mbtk_coap_ecoapdel_exec_cmd( int del_id )
1341{
1342
1343 int result = 0;
1344 LOGE("del---------del_id:%d\n",del_id);
1345 if(del_id != 1)
1346 {
1347 return -1;
1348 }
b.liubcf86c92024-08-19 19:48:28 +08001349
liubin281ac462023-07-19 14:22:54 +08001350 if(mbtk_ecoap_state <= MBTK_ECOAP_STATE_CLOSING )
1351 {
1352 mbtk_ecoap_show_error(MBTK_ECOAP_ERR_NO_OPEN);
1353 return -1;
1354 }
b.liubcf86c92024-08-19 19:48:28 +08001355
liubin281ac462023-07-19 14:22:54 +08001356 LOGE("del---------del_id:%d\n",del_id);
1357
1358 return result;
1359
1360}
1361
1362int mbtk_coap_ecoapclose_exec_cmd( void )
1363{
1364 int result = 0;
1365 if(!coap_sock_inited) {
1366 LOGE("HTTP not inited.");
1367 return -1;
1368 }
1369
1370 int err = mbtk_sock_deinit(coap_handle);
1371 if(err != MBTK_SOCK_SUCCESS) {
1372 LOGE("mbtk_sock_deinit() fail.");
1373 return -1;
1374 }
1375
1376 coap_handle = -1;
1377 coap_sock_inited = FALSE;
1378 return 0;
1379
1380 return result;
1381}
1382
b.liubcf86c92024-08-19 19:48:28 +08001383void mbtk_coap_lib_info_print()
1384{
1385 MBTK_SOURCE_INFO_PRINT("mbtk_coap_lib");
1386}
liubin281ac462023-07-19 14:22:54 +08001387