diag_at.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* Copyright (C) 2019 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _DIAG_AT_H_
  13. #define _DIAG_AT_H_
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #include <stdlib.h>
  18. #include <stdint.h>
  19. #include <stdbool.h>
  20. #include "quec_proj_config.h"
  21. struct diag_at;
  22. /**
  23. * @brief Diag AT
  24. */
  25. typedef struct diag_at diagAt_t;
  26. /**
  27. * @brief Function type to notify diag at receive any data
  28. */
  29. typedef void (*diagAtNotify_t)(void *ctx);
  30. /**
  31. * @brief Diag AT config
  32. */
  33. typedef struct
  34. {
  35. uint32_t rxfifo_size; ///< rx fifo size
  36. diagAtNotify_t notify; ///< notifier for data coming
  37. void *context; ///< caller context
  38. } diagAtCfg_t;
  39. /**
  40. * @brief Create diag at instance
  41. *
  42. * @param cfg the config
  43. * @return
  44. * - NULL fail
  45. * - other diag at instance
  46. */
  47. diagAt_t *diagAtCreate(const diagAtCfg_t *cfg);
  48. /**
  49. * @brief Destroy the diag at
  50. *
  51. * @param d the diag at instance
  52. */
  53. void diagAtDestroy(diagAt_t *d);
  54. /**
  55. * @brief Open the diag at channel
  56. *
  57. * @param d the diag at instance
  58. * @return
  59. * - true success
  60. * - false fail
  61. */
  62. bool diagAtOpen(diagAt_t *d);
  63. /**
  64. * @brief Close the diag at channel
  65. *
  66. * @param d the diag at instance
  67. */
  68. void diagAtClose(diagAt_t *d);
  69. /**
  70. * @brief receive diag at success, send OK
  71. *
  72. * @param d the diag at
  73. */
  74. void diagAtSendOk(diagAt_t *d);
  75. /**
  76. * @brief Write data via diag at channel
  77. *
  78. * @param d the diag at
  79. * @param data data to write
  80. * @param length data length
  81. * @return
  82. * - (-1) fail
  83. * - positive number actually written
  84. */
  85. int diagAtWrite(diagAt_t *d, const void *data, size_t length);
  86. /**
  87. * @brief Read data from diag at channel
  88. *
  89. * @param d the diag at
  90. * @param buf read buffer
  91. * @param size buffer size
  92. * @return
  93. * - (-1) fail
  94. * - positive number actually read
  95. */
  96. int diagAtRead(diagAt_t *d, void *buf, size_t size);
  97. #ifdef CONFIG_QUEC_PROJECT_FEATURE_ATC_PARSE
  98. /**
  99. * @brief Read data avalable space from diag at channel
  100. *
  101. * @param d the diag at
  102. * @return
  103. * - (-1) fail
  104. * - positive number Available read
  105. */
  106. int diagAtReadAvail(diagAt_t *d);
  107. #endif
  108. #ifdef __cplusplus
  109. }
  110. #endif
  111. #endif