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 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 #include "esp_types.h" 21 #include "esp_err.h" 22 #include "esp_event.h" 23 24 typedef struct modem_dte modem_dte_t; 25 typedef struct modem_dce modem_dce_t; 26 27 /** 28 * @brief Working mode of Modem 29 * 30 */ 31 typedef enum { 32 MODEM_COMMAND_MODE = 0, /*!< Command Mode */ 33 MODEM_PPP_MODE, /*!< PPP Mode */ 34 MODEM_TRANSITION_MODE /*!< Transition Mode between data and command mode indicating that 35 the modem is not yet ready for sending commands nor data */ 36 } modem_mode_t; 37 38 /** 39 * @brief Modem flow control type 40 * 41 */ 42 typedef enum { 43 MODEM_FLOW_CONTROL_NONE = 0, 44 MODEM_FLOW_CONTROL_SW, 45 MODEM_FLOW_CONTROL_HW 46 } modem_flow_ctrl_t; 47 48 /** 49 * @brief DTE(Data Terminal Equipment) 50 * 51 */ 52 struct modem_dte { 53 modem_flow_ctrl_t flow_ctrl; /*!< Flow control of DTE */ 54 modem_dce_t *dce; /*!< DCE which connected to the DTE */ 55 esp_err_t (*send_cmd)(modem_dte_t *dte, const char *command, uint32_t timeout); /*!< Send command to DCE */ 56 int (*send_data)(modem_dte_t *dte, const char *data, uint32_t length); /*!< Send data to DCE */ 57 esp_err_t (*send_wait)(modem_dte_t *dte, const char *data, uint32_t length, 58 const char *prompt, uint32_t timeout); /*!< Wait for specific prompt */ 59 esp_err_t (*change_mode)(modem_dte_t *dte, modem_mode_t new_mode); /*!< Changing working mode */ 60 esp_err_t (*process_cmd_done)(modem_dte_t *dte); /*!< Callback when DCE process command done */ 61 esp_err_t (*deinit)(modem_dte_t *dte); /*!< Deinitialize */ 62 }; 63 64 #ifdef __cplusplus 65 } 66 #endif 67