blob: 1d8e9ad304f2a12130dc83fff1cf6dc39f8bec60 [file] [log] [blame]
liubin281ac462023-07-19 14:22:54 +08001#include <string.h>
b.liu9e8584b2024-11-06 19:21:28 +08002#include <unistd.h>
3
liubin281ac462023-07-19 14:22:54 +08004#include "mbtk_type.h"
liubin281ac462023-07-19 14:22:54 +08005#include "mbtk_coap.h"
6#include "mbtk_coap_api.h"
7
8int coap_get_method(void);
9
10int coap_post_method(void);
11
12
13int main(int argc, char *argv[])
14{
b.liu9e8584b2024-11-06 19:21:28 +080015 //char operator[10];
16 // int opt;
17// int ret = -1;
liubin281ac462023-07-19 14:22:54 +080018
19 printf("coap_demo star\r\n");
20 coap_get_method();
21
22 sleep(20);
23 coap_post_method();
24
25 return 0;
26}
27
28
29int coap_get_method(void)
30{
b.liu9e8584b2024-11-06 19:21:28 +080031// int ret = -1;
32 mbtk_coap_ecoapnew_exec_cmd("134.102.218.18",5683,0,0); //server ip, port
liubin281ac462023-07-19 14:22:54 +080033 mbtk_coap_ecoapmsgid_exec_cmd(1); //set message id
34 mbtk_coap_ecoaptype_exec_cmd(0); //set message type
35 mbtk_coap_ecoapcode_exec_cmd(1); //set Get request method
36 mbtk_coap_ecoapopt_exec_cmd("b474657374",10); //set option
37
38 mbtk_coap_ecoapsend_exec_cmd(1, 0, NULL); //request Get
39 return 0;
40}
41
42
43int coap_post_method(void)
44{
b.liu9e8584b2024-11-06 19:21:28 +080045// int ret = -1;
46 mbtk_coap_ecoapnew_exec_cmd("134.102.218.18",5683,0,0); //server ip, port
liubin281ac462023-07-19 14:22:54 +080047 mbtk_coap_ecoapmsgid_exec_cmd(3); //set message id
48 mbtk_coap_ecoaptype_exec_cmd(0); //set message type
49 mbtk_coap_ecoapcode_exec_cmd(2); //set Post request method
50 mbtk_coap_ecoapopt_exec_cmd("b474657374",10); //set option
51
52 mbtk_coap_ecoapsend_exec_cmd(3, 7, "1111111"); //request post
53 return 0;
54}