esp_modem_dte.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_TRANSITION_MODE /*!< Transition Mode between data and command mode indicating that
  31. the modem is not yet ready for sending commands nor data */
  32. } modem_mode_t;
  33. /**
  34. * @brief Modem flow control type
  35. *
  36. */
  37. typedef enum {
  38. MODEM_FLOW_CONTROL_NONE = 0,
  39. MODEM_FLOW_CONTROL_SW,
  40. MODEM_FLOW_CONTROL_HW
  41. } modem_flow_ctrl_t;
  42. /**
  43. * @brief DTE(Data Terminal Equipment)
  44. *
  45. */
  46. struct modem_dte {
  47. modem_flow_ctrl_t flow_ctrl; /*!< Flow control of DTE */
  48. modem_dce_t *dce; /*!< DCE which connected to the DTE */
  49. esp_err_t (*send_cmd)(modem_dte_t *dte, const char *command, uint32_t timeout); /*!< Send command to DCE */
  50. int (*send_data)(modem_dte_t *dte, const char *data, uint32_t length); /*!< Send data to DCE */
  51. esp_err_t (*send_wait)(modem_dte_t *dte, const char *data, uint32_t length,
  52. const char *prompt, uint32_t timeout); /*!< Wait for specific prompt */
  53. esp_err_t (*change_mode)(modem_dte_t *dte, modem_mode_t new_mode); /*!< Changing working mode */
  54. esp_err_t (*process_cmd_done)(modem_dte_t *dte); /*!< Callback when DCE process command done */
  55. esp_err_t (*deinit)(modem_dte_t *dte); /*!< Deinitialize */
  56. };
  57. #ifdef __cplusplus
  58. }
  59. #endif