bowen liu
/
mbed-os-example-blinky
ex
Fork of mbed-os-example-mbed5-blinky by
Embed:
(wiki syntax)
Show/hide line numbers
baidu_ca_coap.h
00001 // Copyright 2017 Baidu Inc. All Rights Reserved. 00002 // Author: Su Hao (suhao@baidu.com) 00003 // 00004 // Description: The CoAP adapter. 00005 00006 #ifndef BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SOURCE_BAIDU_CA_COAP_H 00007 #define BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SOURCE_BAIDU_CA_COAP_H 00008 00009 #include "baidu_ca_coap_ep.h" 00010 00011 typedef void* bca_coap_handler; 00012 00013 typedef bca_status_t (*bca_coap_result_f)(bca_context ctx, 00014 bca_coap_handler hdlr, 00015 const bca_msg_t* msg, 00016 const bca_addr_t* addr); 00017 00018 #define BCA_COAP_MESSAGE_ID_INVALID (0) 00019 00020 #ifdef __cplusplus 00021 extern "C" { 00022 #endif 00023 00024 /* 00025 * Acquire the coap handler. 00026 * 00027 * @Param f_result, in, the callback for user handling events 00028 * @Param context, in, the user context for f_result callback 00029 * @Param ctx_context, in, the user socket context 00030 * @Return bca_coap_handler, the coap context 00031 */ 00032 BCA_INT bca_coap_handler bca_coap_acquire(bca_coap_result_f f_result, 00033 bca_context context, 00034 bca_context ctx_context); 00035 00036 /* 00037 * Connect to remote CoAP server 00038 * 00039 * @Param hdlr, in, the CoAP context 00040 * @Param addr, in, the remote server address 00041 * @Param data, in, the security suite data 00042 * @Param size, in, the data size 00043 * @Return bca_status_t, the connect status 00044 */ 00045 BCA_INT bca_status_t bca_coap_connect(bca_coap_handler hdlr, 00046 const bca_addr_t* addr, 00047 const void* data, 00048 bca_size_t size); 00049 00050 /* 00051 * Disconnect from remote CoAP server 00052 * 00053 * @Param hdlr, in, the CoAP context 00054 * @Return bca_status_t, the connect status 00055 */ 00056 BCA_INT bca_status_t bca_coap_disconnect(bca_coap_handler hdlr); 00057 00058 /* 00059 * Add the resource for CoAP request from other endpoints 00060 * 00061 * @Param hdlr, in, the CoAP context 00062 * @Param res, in, the resource information 00063 * @Return bca_status_t, the result 00064 */ 00065 BCA_INT bca_status_t bca_coap_resource_add(bca_coap_handler hdlr, 00066 const bca_res_t* res); 00067 00068 /* 00069 * Remove the resource for CoAP request from other endpoints 00070 * 00071 * @Param hdlr, in, the CoAP context 00072 * @Param path, in, the resource path 00073 * @Return bca_status_t, the result 00074 */ 00075 BCA_INT bca_status_t bca_coap_resource_remove(bca_coap_handler coap, 00076 const char* path); 00077 00078 /* 00079 * Register endpoint by LWM2M 00080 * 00081 * @Param hdlr, in, the CoAP context 00082 * @Param ep, in, the endpoint information 00083 * @Return bca_status_t, if > 0, the result is the register message id, else is the error status 00084 */ 00085 BCA_INT bca_status_t bca_coap_register(bca_coap_handler coap, 00086 const bca_coap_ep_t* ep); 00087 00088 /* 00089 * Unregister the endpoint by LWM2M 00090 * 00091 * @Param hdlr, in, the CoAP context 00092 * @Return bca_status_t, if > 0, the result is the unregister message id, else is the error status 00093 */ 00094 BCA_INT bca_status_t bca_coap_unregister(bca_coap_handler coap); 00095 00096 /* 00097 * Update registration by LWM2M 00098 * 00099 * @Param hdlr, in, the CoAP context 00100 * @Param lifetime, in, the endpoint lifetime 00101 * @Return bca_status_t, if > 0, the result is the update registration message id, 00102 * else is the error status 00103 */ 00104 BCA_INT bca_status_t bca_coap_update_registration(bca_coap_handler coap, 00105 bca_u32_t lifetime); 00106 00107 /* 00108 * Send the CoAP message 00109 * 00110 * @Param hdlr, in, the CoAP context 00111 * @Param msg, in, the CoAP message 00112 * @Return bca_status_t, the result 00113 */ 00114 BCA_INT bca_status_t bca_coap_send(bca_coap_handler coap, const bca_msg_t* msg); 00115 00116 /* 00117 * Receive the CoAP message 00118 * 00119 * @Param hdlr, in, the CoAP context 00120 * @Return bca_status_t, the result 00121 */ 00122 BCA_INT bca_status_t bca_coap_data_available(bca_coap_handler coap); 00123 00124 /* 00125 * Execute the cached CoAP data 00126 * 00127 * @Param hdlr, in, the CoAP context 00128 * @Param timestamp, in, the timestamp for mark the message 00129 * @Return bca_status_t, the result 00130 */ 00131 BCA_INT bca_status_t bca_coap_exec(bca_coap_handler hdlr, bca_u32_t timestamp); 00132 00133 /* 00134 * Release the CoAP context 00135 * 00136 * @Param hdlr, in, the CoAP context 00137 * @Return bca_status_t, the result 00138 */ 00139 BCA_INT bca_status_t bca_coap_release(bca_coap_handler coap); 00140 00141 /* 00142 * Set read timeout 00143 * 00144 * @Param hdlr, in, the CoAP context 00145 * @Param timeout, in, the timeout value by milliseconds 00146 * @Return bca_bool, if match return BCA_TRUE, else return BCA_FALSE 00147 */ 00148 BCA_INT bca_status_t bca_coap_set_read_timeout(bca_coap_handler coap, bca_u32_t timeout); 00149 00150 #ifdef __cplusplus 00151 } 00152 #endif 00153 00154 #endif // BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SOURCE_BAIDU_CA_COAP_H
Generated on Tue Jul 12 2022 16:28:52 by 1.7.2