forked from espressif/esp-protocols
esp_modem: Initial version based on IDF 4.3
This commit is contained in:
1 parent
d42b6670c5
commit
5565a09ed1
20 files changed
+2776
No files matched your search
@@ -0,0 +1,33 @@
|
||||
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_modem_dce_service.h"
|
||||
#include "esp_modem.h"
|
||||
|
||||
/**
|
||||
* @brief Create and initialize BG96 object
|
||||
*
|
||||
* @param dte Modem DTE object
|
||||
* @return modem_dce_t* Modem DCE object
|
||||
*/
|
||||
modem_dce_t *bg96_init(modem_dte_t *dte);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,174 @@
|
||||
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_modem_dce.h"
|
||||
#include "esp_modem_dte.h"
|
||||
#include "esp_event.h"
|
||||
#include "driver/uart.h"
|
||||
#include "esp_modem_compat.h"
|
||||
|
||||
/**
|
||||
* @brief Declare Event Base for ESP Modem
|
||||
*
|
||||
*/
|
||||
ESP_EVENT_DECLARE_BASE(ESP_MODEM_EVENT);
|
||||
|
||||
/**
|
||||
* @brief ESP Modem Event
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_MODEM_EVENT_PPP_START = 0, /*!< ESP Modem Start PPP Session */
|
||||
ESP_MODEM_EVENT_PPP_STOP = 3, /*!< ESP Modem Stop PPP Session*/
|
||||
ESP_MODEM_EVENT_UNKNOWN = 4 /*!< ESP Modem Unknown Response */
|
||||
} esp_modem_event_t;
|
||||
|
||||
/**
|
||||
* @brief ESP Modem DTE Configuration
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
uart_port_t port_num; /*!< UART port number */
|
||||
uart_word_length_t data_bits; /*!< Data bits of UART */
|
||||
uart_stop_bits_t stop_bits; /*!< Stop bits of UART */
|
||||
uart_parity_t parity; /*!< Parity type */
|
||||
modem_flow_ctrl_t flow_control; /*!< Flow control type */
|
||||
uint32_t baud_rate; /*!< Communication baud rate */
|
||||
int tx_io_num; /*!< TXD Pin Number */
|
||||
int rx_io_num; /*!< RXD Pin Number */
|
||||
int rts_io_num; /*!< RTS Pin Number */
|
||||
int cts_io_num; /*!< CTS Pin Number */
|
||||
int rx_buffer_size; /*!< UART RX Buffer Size */
|
||||
int tx_buffer_size; /*!< UART TX Buffer Size */
|
||||
int pattern_queue_size; /*!< UART Pattern Queue Size */
|
||||
int event_queue_size; /*!< UART Event Queue Size */
|
||||
uint32_t event_task_stack_size; /*!< UART Event Task Stack size */
|
||||
int event_task_priority; /*!< UART Event Task Priority */
|
||||
int line_buffer_size; /*!< Line buffer size for command mode */
|
||||
} esp_modem_dte_config_t;
|
||||
|
||||
/**
|
||||
* @brief Type used for reception callback
|
||||
*
|
||||
*/
|
||||
typedef esp_err_t (*esp_modem_on_receive)(void *buffer, size_t len, void *context);
|
||||
|
||||
/**
|
||||
* @brief ESP Modem DTE Default Configuration
|
||||
*
|
||||
*/
|
||||
#define ESP_MODEM_DTE_DEFAULT_CONFIG() \
|
||||
{ \
|
||||
.port_num = UART_NUM_1, \
|
||||
.data_bits = UART_DATA_8_BITS, \
|
||||
.stop_bits = UART_STOP_BITS_1, \
|
||||
.parity = UART_PARITY_DISABLE, \
|
||||
.baud_rate = 115200, \
|
||||
.flow_control = MODEM_FLOW_CONTROL_NONE,\
|
||||
.tx_io_num = 25, \
|
||||
.rx_io_num = 26, \
|
||||
.rts_io_num = 27, \
|
||||
.cts_io_num = 23, \
|
||||
.rx_buffer_size = 1024, \
|
||||
.tx_buffer_size = 512, \
|
||||
.pattern_queue_size = 20, \
|
||||
.event_queue_size = 30, \
|
||||
.event_task_stack_size = 2048, \
|
||||
.event_task_priority = 5, \
|
||||
.line_buffer_size = 512 \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create and initialize Modem DTE object
|
||||
*
|
||||
* @param config configuration of ESP Modem DTE object
|
||||
* @return modem_dte_t*
|
||||
* - Modem DTE object
|
||||
*/
|
||||
modem_dte_t *esp_modem_dte_init(const esp_modem_dte_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Register event handler for ESP Modem event loop
|
||||
*
|
||||
* @param dte modem_dte_t type object
|
||||
* @param handler event handler to register
|
||||
* @param handler_args arguments for registered handler
|
||||
* @return esp_err_t
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM on allocating memory for the handler failed
|
||||
* - ESP_ERR_INVALID_ARG on invalid combination of event base and event id
|
||||
*/
|
||||
esp_err_t esp_modem_set_event_handler(modem_dte_t *dte, esp_event_handler_t handler, int32_t event_id, void *handler_args);
|
||||
|
||||
/**
|
||||
* @brief Unregister event handler for ESP Modem event loop
|
||||
*
|
||||
* @param dte modem_dte_t type object
|
||||
* @param handler event handler to unregister
|
||||
* @return esp_err_t
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG on invalid combination of event base and event id
|
||||
*/
|
||||
esp_err_t esp_modem_remove_event_handler(modem_dte_t *dte, esp_event_handler_t handler);
|
||||
|
||||
/**
|
||||
* @brief Setup PPP Session
|
||||
*
|
||||
* @param dte Modem DTE object
|
||||
* @return esp_err_t
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL on error
|
||||
*/
|
||||
esp_err_t esp_modem_start_ppp(modem_dte_t *dte);
|
||||
|
||||
/**
|
||||
* @brief Exit PPP Session
|
||||
*
|
||||
* @param dte Modem DTE Object
|
||||
* @return esp_err_t
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL on error
|
||||
*/
|
||||
esp_err_t esp_modem_stop_ppp(modem_dte_t *dte);
|
||||
|
||||
/**
|
||||
* @brief Setup on reception callback
|
||||
*
|
||||
* @param dte ESP Modem DTE object
|
||||
* @param receive_cb Function pointer to the reception callback
|
||||
* @param receive_cb_ctx Contextual pointer to be passed to the reception callback
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_modem_set_rx_cb(modem_dte_t *dte, esp_modem_on_receive receive_cb, void *receive_cb_ctx);
|
||||
|
||||
/**
|
||||
* @brief Notify the modem, that ppp netif has closed
|
||||
*
|
||||
* @note This API should only be used internally by the modem-netif layer
|
||||
*
|
||||
* @param dte ESP Modem DTE object
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_modem_notify_ppp_netif_closed(modem_dte_t *dte);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,62 @@
|
||||
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "lwip/ip.h"
|
||||
|
||||
/**
|
||||
* @brief ESP Modem Event backward compatible version
|
||||
*/
|
||||
typedef enum {
|
||||
MODEM_EVENT_PPP_START = 0x100,
|
||||
MODEM_EVENT_PPP_CONNECT = 0x101,
|
||||
MODEM_EVENT_PPP_DISCONNECT = 0x102,
|
||||
MODEM_EVENT_PPP_STOP = 0x103,
|
||||
MODEM_EVENT_UNKNOWN = 0x104,
|
||||
} esp_modem_compat_event_t;
|
||||
|
||||
/**
|
||||
* @brief PPPoS Client IP Information backward compatible version
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
ip4_addr_t ip; /*!< IP Address */
|
||||
ip4_addr_t netmask; /*!< Net Mask */
|
||||
ip4_addr_t gw; /*!< Gateway */
|
||||
ip4_addr_t ns1; /*!< Name Server1 */
|
||||
ip4_addr_t ns2; /*!< Name Server2 */
|
||||
} ppp_client_ip_info_t;
|
||||
|
||||
/**
|
||||
* @brief Backward compatible version of esp_modem_set_event_handler()
|
||||
*/
|
||||
esp_err_t esp_modem_add_event_handler(modem_dte_t *dte, esp_event_handler_t handler, void *handler_args) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Backward compatible version of creating esp-netif(PPP) and attaching to esp_modem_start_ppp()
|
||||
*/
|
||||
esp_err_t esp_modem_setup_ppp(modem_dte_t *dte) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Backward compatible version of deleting esp-netif and esp_modem_stop_ppp()
|
||||
*/
|
||||
esp_err_t esp_modem_exit_ppp(modem_dte_t *dte) __attribute__ ((deprecated));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,99 @@
|
||||
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_types.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_modem_dte.h"
|
||||
|
||||
typedef struct modem_dce modem_dce_t;
|
||||
typedef struct modem_dte modem_dte_t;
|
||||
|
||||
/**
|
||||
* @brief Result Code from DCE
|
||||
*
|
||||
*/
|
||||
#define MODEM_RESULT_CODE_SUCCESS "OK" /*!< Acknowledges execution of a command */
|
||||
#define MODEM_RESULT_CODE_CONNECT "CONNECT" /*!< A connection has been established */
|
||||
#define MODEM_RESULT_CODE_RING "RING" /*!< Detect an incoming call signal from network */
|
||||
#define MODEM_RESULT_CODE_NO_CARRIER "NO CARRIER" /*!< Connection termincated or establish a connection failed */
|
||||
#define MODEM_RESULT_CODE_ERROR "ERROR" /*!< Command not recognized, command line maximum length exceeded, parameter value invalid */
|
||||
#define MODEM_RESULT_CODE_NO_DIALTONE "NO DIALTONE" /*!< No dial tone detected */
|
||||
#define MODEM_RESULT_CODE_BUSY "BUSY" /*!< Engaged signal detected */
|
||||
#define MODEM_RESULT_CODE_NO_ANSWER "NO ANSWER" /*!< Wait for quiet answer */
|
||||
|
||||
/**
|
||||
* @brief Specific Length Constraint
|
||||
*
|
||||
*/
|
||||
#define MODEM_MAX_NAME_LENGTH (32) /*!< Max Module Name Length */
|
||||
#define MODEM_MAX_OPERATOR_LENGTH (32) /*!< Max Operator Name Length */
|
||||
#define MODEM_IMEI_LENGTH (15) /*!< IMEI Number Length */
|
||||
#define MODEM_IMSI_LENGTH (15) /*!< IMSI Number Length */
|
||||
|
||||
/**
|
||||
* @brief Specific Timeout Constraint, Unit: millisecond
|
||||
*
|
||||
*/
|
||||
#define MODEM_COMMAND_TIMEOUT_DEFAULT (500) /*!< Default timeout value for most commands */
|
||||
#define MODEM_COMMAND_TIMEOUT_OPERATOR (75000) /*!< Timeout value for getting operator status */
|
||||
#define MODEM_COMMAND_TIMEOUT_MODE_CHANGE (5000) /*!< Timeout value for changing working mode */
|
||||
#define MODEM_COMMAND_TIMEOUT_HANG_UP (90000) /*!< Timeout value for hang up */
|
||||
#define MODEM_COMMAND_TIMEOUT_POWEROFF (1000) /*!< Timeout value for power down */
|
||||
|
||||
/**
|
||||
* @brief Working state of DCE
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
MODEM_STATE_PROCESSING, /*!< In processing */
|
||||
MODEM_STATE_SUCCESS, /*!< Process successfully */
|
||||
MODEM_STATE_FAIL /*!< Process failed */
|
||||
} modem_state_t;
|
||||
|
||||
/**
|
||||
* @brief DCE(Data Communication Equipment)
|
||||
*
|
||||
*/
|
||||
struct modem_dce {
|
||||
char imei[MODEM_IMEI_LENGTH + 1]; /*!< IMEI number */
|
||||
char imsi[MODEM_IMSI_LENGTH + 1]; /*!< IMSI number */
|
||||
char name[MODEM_MAX_NAME_LENGTH]; /*!< Module name */
|
||||
char oper[MODEM_MAX_OPERATOR_LENGTH]; /*!< Operator name */
|
||||
modem_state_t state; /*!< Modem working state */
|
||||
modem_mode_t mode; /*!< Working mode */
|
||||
modem_dte_t *dte; /*!< DTE which connect to DCE */
|
||||
esp_err_t (*handle_line)(modem_dce_t *dce, const char *line); /*!< Handle line strategy */
|
||||
esp_err_t (*sync)(modem_dce_t *dce); /*!< Synchronization */
|
||||
esp_err_t (*echo_mode)(modem_dce_t *dce, bool on); /*!< Echo command on or off */
|
||||
esp_err_t (*store_profile)(modem_dce_t *dce); /*!< Store user settings */
|
||||
esp_err_t (*set_flow_ctrl)(modem_dce_t *dce, modem_flow_ctrl_t flow_ctrl); /*!< Flow control on or off */
|
||||
esp_err_t (*get_signal_quality)(modem_dce_t *dce, uint32_t *rssi, uint32_t *ber); /*!< Get signal quality */
|
||||
esp_err_t (*get_battery_status)(modem_dce_t *dce, uint32_t *bcs,
|
||||
uint32_t *bcl, uint32_t *voltage); /*!< Get battery status */
|
||||
esp_err_t (*define_pdp_context)(modem_dce_t *dce, uint32_t cid,
|
||||
const char *type, const char *apn); /*!< Set PDP Contex */
|
||||
esp_err_t (*set_working_mode)(modem_dce_t *dce, modem_mode_t mode); /*!< Set working mode */
|
||||
esp_err_t (*hang_up)(modem_dce_t *dce); /*!< Hang up */
|
||||
esp_err_t (*power_down)(modem_dce_t *dce); /*!< Normal power down */
|
||||
esp_err_t (*deinit)(modem_dce_t *dce); /*!< Deinitialize */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,131 @@
|
||||
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_modem_dce.h"
|
||||
|
||||
/**
|
||||
* @brief Indicate that processing current command has done
|
||||
*
|
||||
* @param dce Modem DCE object
|
||||
* @param state Modem state after processing
|
||||
* @return esp_err_t
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL on error
|
||||
*/
|
||||
static inline esp_err_t esp_modem_process_command_done(modem_dce_t *dce, modem_state_t state)
|
||||
{
|
||||
dce->state = state;
|
||||
return dce->dte->process_cmd_done(dce->dte);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Strip the tailed "\r\n"
|
||||
*
|
||||
* @param str string to strip
|
||||
* @param len length of string
|
||||
*/
|
||||
static inline void strip_cr_lf_tail(char *str, uint32_t len)
|
||||
{
|
||||
if (str[len - 2] == '\r') {
|
||||
str[len - 2] = '\0';
|
||||
} else if (str[len - 1] == '\r') {
|
||||
str[len - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Default handler for response
|
||||
* Some responses for command are simple, commonly will return OK when succeed of ERROR when failed
|
||||
*
|
||||
* @param dce Modem DCE object
|
||||
* @param line line string
|
||||
* @return esp_err_t
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL on error
|
||||
*/
|
||||
esp_err_t esp_modem_dce_handle_response_default(modem_dce_t *dce, const char *line);
|
||||
|
||||
/**
|
||||
* @brief Syncronization
|
||||
*
|
||||
* @param dce Modem DCE object
|
||||
* @return esp_err_t
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL on error
|
||||
*/
|
||||
esp_err_t esp_modem_dce_sync(modem_dce_t *dce);
|
||||
|
||||
/**
|
||||
* @brief Enable or not echo mode of DCE
|
||||
*
|
||||
* @param dce Modem DCE object
|
||||
* @param on true to enable echo mode, false to disable echo mode
|
||||
* @return esp_err_t
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL on error
|
||||
*/
|
||||
esp_err_t esp_modem_dce_echo(modem_dce_t *dce, bool on);
|
||||
|
||||
/**
|
||||
* @brief Store current parameter setting in the user profile
|
||||
*
|
||||
* @param dce Modem DCE object
|
||||
* @return esp_err_t
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL on error
|
||||
*/
|
||||
esp_err_t esp_modem_dce_store_profile(modem_dce_t *dce);
|
||||
|
||||
/**
|
||||
* @brief Set flow control mode of DCE in data mode
|
||||
*
|
||||
* @param dce Modem DCE object
|
||||
* @param flow_ctrl flow control mode
|
||||
* @return esp_err_t
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL on error
|
||||
*/
|
||||
esp_err_t esp_modem_dce_set_flow_ctrl(modem_dce_t *dce, modem_flow_ctrl_t flow_ctrl);
|
||||
|
||||
/**
|
||||
* @brief Define PDP context
|
||||
*
|
||||
* @param dce Modem DCE object
|
||||
* @param cid PDP context identifier
|
||||
* @param type Protocol type
|
||||
* @param apn Access point name
|
||||
* @return esp_err_t
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL on error
|
||||
*/
|
||||
esp_err_t esp_modem_dce_define_pdp_context(modem_dce_t *dce, uint32_t cid, const char *type, const char *apn);
|
||||
|
||||
/**
|
||||
* @brief Hang up
|
||||
*
|
||||
* @param dce Modem DCE object
|
||||
* @return esp_err_t
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL on error
|
||||
*/
|
||||
esp_err_t esp_modem_dce_hang_up(modem_dce_t *dce);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_types.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_event.h"
|
||||
|
||||
typedef struct modem_dte modem_dte_t;
|
||||
typedef struct modem_dce modem_dce_t;
|
||||
|
||||
/**
|
||||
* @brief Working mode of Modem
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
MODEM_COMMAND_MODE = 0, /*!< Command Mode */
|
||||
MODEM_PPP_MODE, /*!< PPP Mode */
|
||||
MODEM_TRANSITION_MODE /*!< Transition Mode betwen data and command mode indicating that
|
||||
the modem is not yet ready for sending commands nor data */
|
||||
} modem_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Modem flow control type
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
MODEM_FLOW_CONTROL_NONE = 0,
|
||||
MODEM_FLOW_CONTROL_SW,
|
||||
MODEM_FLOW_CONTROL_HW
|
||||
} modem_flow_ctrl_t;
|
||||
|
||||
/**
|
||||
* @brief DTE(Data Terminal Equipment)
|
||||
*
|
||||
*/
|
||||
struct modem_dte {
|
||||
modem_flow_ctrl_t flow_ctrl; /*!< Flow control of DTE */
|
||||
modem_dce_t *dce; /*!< DCE which connected to the DTE */
|
||||
esp_err_t (*send_cmd)(modem_dte_t *dte, const char *command, uint32_t timeout); /*!< Send command to DCE */
|
||||
int (*send_data)(modem_dte_t *dte, const char *data, uint32_t length); /*!< Send data to DCE */
|
||||
esp_err_t (*send_wait)(modem_dte_t *dte, const char *data, uint32_t length,
|
||||
const char *prompt, uint32_t timeout); /*!< Wait for specific prompt */
|
||||
esp_err_t (*change_mode)(modem_dte_t *dte, modem_mode_t new_mode); /*!< Changing working mode */
|
||||
esp_err_t (*process_cmd_done)(modem_dte_t *dte); /*!< Callback when DCE process command done */
|
||||
esp_err_t (*deinit)(modem_dte_t *dte); /*!< Deinitialize */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Creates handle to esp_modem used as an esp-netif driver
|
||||
*
|
||||
* @param dte ESP Modem DTE object
|
||||
*
|
||||
* @return opaque pointer to esp-modem IO driver used to attach to esp-netif
|
||||
*/
|
||||
void *esp_modem_netif_setup(modem_dte_t *dte);
|
||||
|
||||
/**
|
||||
* @brief Destroys the esp-netif driver handle
|
||||
*
|
||||
* @param h pointer to the esp-netif adapter for esp-modem
|
||||
*/
|
||||
void esp_modem_netif_teardown(void *h);
|
||||
|
||||
/**
|
||||
* @brief Clears default handlers for esp-modem lifecycle
|
||||
*
|
||||
* @param h pointer to the esp-netif adapter for esp-modem
|
||||
*/
|
||||
esp_err_t esp_modem_netif_clear_default_handlers(void *h);
|
||||
|
||||
/**
|
||||
* @brief Setups default handlers for esp-modem lifecycle
|
||||
*
|
||||
* @param h pointer to the esp-netif adapter for esp-modem
|
||||
* @param esp_netif pointer corresponding esp-netif instance
|
||||
*/
|
||||
esp_err_t esp_modem_netif_set_default_handlers(void *h, esp_netif_t * esp_netif);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_modem_dce_service.h"
|
||||
#include "esp_modem.h"
|
||||
|
||||
/**
|
||||
* @brief Create and initialize SIM7600 object
|
||||
*
|
||||
* @param dte Modem DTE object
|
||||
* @return modem_dce_t* Modem DCE object
|
||||
*/
|
||||
modem_dce_t *sim7600_init(modem_dte_t *dte);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_modem_dce_service.h"
|
||||
#include "esp_modem.h"
|
||||
|
||||
/**
|
||||
* @brief Create and initialize SIM800 object
|
||||
*
|
||||
* @param dte Modem DTE object
|
||||
* @return modem_dce_t* Modem DCE object
|
||||
*/
|
||||
modem_dce_t *sim800_init(modem_dte_t *dte);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user