lightduer_coap_ep.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * Copyright (2017) Baidu Inc. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. // Author: Su Hao (suhao@baidu.com)
  17. //
  18. // Description: The CoAP endpoint definitions.
  19. #ifndef BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SOURCE_BAIDU_CA_COAP_EP_H
  20. #define BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SOURCE_BAIDU_CA_COAP_EP_H
  21. #include "lightduer_lib.h"
  22. #define LIFETIME_MAX_LEN (10)
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /**
  27. * Endpoint registration parameters
  28. */
  29. typedef struct _baidu_ca_coap_endpoint_s {
  30. char* name_ptr; // Endpoint name
  31. duer_size_t name_len;
  32. char* type_ptr; // Endpoint type
  33. duer_size_t type_len;
  34. char* lifetime_ptr; // Endpoint lifetime in seconds. eg. "1200" = 1200 seconds
  35. duer_size_t lifetime_len;
  36. duer_addr_t* address; // Endpoint address to be accessed by the server, optional, default NULL
  37. } duer_coap_ep_t, *duer_coap_ep_ptr;
  38. /*
  39. * Create the endpoint.
  40. *
  41. * @Param hdlr, in, the global context for baidu ca
  42. * @Param name, in, the endpoint name
  43. * @Param type, in, the endpoint type
  44. * @Param lifetime, in, the lifetime of the endpoint
  45. * @Param addr, in, the endpoint address to be accessed by the server, optional, default NULL
  46. * @Return duer_coap_ep_ptr, the endpoint context pointer
  47. */
  48. DUER_INT duer_coap_ep_ptr duer_coap_ep_create(const char* name,
  49. const char* type,
  50. duer_u32_t lifetime,
  51. const duer_addr_t* addr);
  52. /*
  53. * Destroy the endpoint that created by ${link duer_coap_ep_create}.
  54. *
  55. * @Param hdlr, in, the global context for baidu ca
  56. * @Param ptr, in, the endpoint context pointer
  57. * @Return duer_status_t, the operation result
  58. */
  59. DUER_INT duer_status_t duer_coap_ep_destroy(duer_coap_ep_ptr ptr);
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif // BAIDU_IOT_TINYDU_IOT_OS_SRC_IOT_BAIDU_CA_SOURCE_BAIDU_CA_COAP_EP_H