esp_modem_dte.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2018 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include "esp_types.h"
  19. #include "esp_err.h"
  20. #include "esp_event.h"
  21. typedef struct modem_dte modem_dte_t;
  22. typedef struct modem_dce modem_dce_t;
  23. /**
  24. * @brief Working mode of Modem
  25. *
  26. */
  27. typedef enum {
  28. MODEM_COMMAND_MODE = 0, /*!< Command Mode */
  29. MODEM_PPP_MODE /*!< PPP Mode */
  30. } modem_mode_t;
  31. /**
  32. * @brief Modem flow control type
  33. *
  34. */
  35. typedef enum {
  36. MODEM_FLOW_CONTROL_NONE = 0,
  37. MODEM_FLOW_CONTROL_SW,
  38. MODEM_FLOW_CONTROL_HW
  39. } modem_flow_ctrl_t;
  40. /**
  41. * @brief DTE(Data Terminal Equipment)
  42. *
  43. */
  44. struct modem_dte {
  45. modem_flow_ctrl_t flow_ctrl; /*!< Flow control of DTE */
  46. modem_dce_t *dce; /*!< DCE which connected to the DTE */
  47. esp_err_t (*send_cmd)(modem_dte_t *dte, const char *command, uint32_t timeout); /*!< Send command to DCE */
  48. int (*send_data)(modem_dte_t *dte, const char *data, uint32_t length); /*!< Send data to DCE */
  49. esp_err_t (*send_wait)(modem_dte_t *dte, const char *data, uint32_t length,
  50. const char *prompt, uint32_t timeout); /*!< Wait for specific prompt */
  51. esp_err_t (*change_mode)(modem_dte_t *dte, modem_mode_t new_mode); /*!< Changing working mode */
  52. esp_err_t (*process_cmd_done)(modem_dte_t *dte); /*!< Callback when DCE process command done */
  53. esp_err_t (*deinit)(modem_dte_t *dte); /*!< Deinitialize */
  54. };
  55. #ifdef __cplusplus
  56. }
  57. #endif