mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-23 23:37:31 +02:00
fix(esp_modem): Extend pppos example project config
This commit is contained in:
committed by
David Cermak
parent
5097065a22
commit
ebc36a3519
@ -29,10 +29,18 @@ menu "Example Configuration"
|
|||||||
bool "BG96"
|
bool "BG96"
|
||||||
help
|
help
|
||||||
Quectel BG96 is a series of LTE Cat M1/Cat NB1/EGPRS module.
|
Quectel BG96 is a series of LTE Cat M1/Cat NB1/EGPRS module.
|
||||||
|
config EXAMPLE_MODEM_DEVICE_SIM7000
|
||||||
|
bool "SIM7000"
|
||||||
|
help
|
||||||
|
SIM7000 is a Multi-Band LTE-FDD and GSM/GPRS/EDGE module.
|
||||||
|
config EXAMPLE_MODEM_DEVICE_SIM7070
|
||||||
|
bool "SIM7070"
|
||||||
|
help
|
||||||
|
SIM7070 is Multi-Band CAT M and NB IoT module.
|
||||||
config EXAMPLE_MODEM_DEVICE_SIM7600
|
config EXAMPLE_MODEM_DEVICE_SIM7600
|
||||||
bool "SIM7600"
|
bool "SIM7600"
|
||||||
help
|
help
|
||||||
SIM7600 is Multi-Band LTE-TDD/LTE-FDD/HSPA+ and GSM/GPRS/EDGE module
|
SIM7600 is a Multi-Band LTE-TDD/LTE-FDD/HSPA+ and GSM/GPRS/EDGE module.
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
config EXAMPLE_MODEM_PPP_APN
|
config EXAMPLE_MODEM_PPP_APN
|
||||||
@ -88,6 +96,20 @@ menu "Example Configuration"
|
|||||||
help
|
help
|
||||||
Pin to unlock the SIM
|
Pin to unlock the SIM
|
||||||
|
|
||||||
|
choice EXAMPLE_FLOW_CONTROL
|
||||||
|
bool "Set preferred modem control flow"
|
||||||
|
default EXAMPLE_FLOW_CONTROL_NONE
|
||||||
|
help
|
||||||
|
Set the modem's preferred control flow
|
||||||
|
|
||||||
|
config EXAMPLE_FLOW_CONTROL_NONE
|
||||||
|
bool "No control flow"
|
||||||
|
config EXAMPLE_FLOW_CONTROL_SW
|
||||||
|
bool "SW control flow"
|
||||||
|
config EXAMPLE_FLOW_CONTROL_HW
|
||||||
|
bool "HW control flow"
|
||||||
|
endchoice
|
||||||
|
|
||||||
menu "UART Configuration"
|
menu "UART Configuration"
|
||||||
depends on EXAMPLE_SERIAL_CONFIG_UART
|
depends on EXAMPLE_SERIAL_CONFIG_UART
|
||||||
config EXAMPLE_MODEM_UART_TX_PIN
|
config EXAMPLE_MODEM_UART_TX_PIN
|
||||||
|
@ -21,6 +21,15 @@
|
|||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CONFIG_EXAMPLE_FLOW_CONTROL_NONE)
|
||||||
|
#define EXAMPLE_FLOW_CONTROL ESP_MODEM_FLOW_CONTROL_NONE
|
||||||
|
#elif defined(CONFIG_EXAMPLE_FLOW_CONTROL_SW)
|
||||||
|
#define EXAMPLE_FLOW_CONTROL ESP_MODEM_FLOW_CONTROL_SW
|
||||||
|
#elif defined(CONFIG_EXAMPLE_FLOW_CONTROL_HW)
|
||||||
|
#define EXAMPLE_FLOW_CONTROL ESP_MODEM_FLOW_CONTROL_HW
|
||||||
|
#endif
|
||||||
|
|
||||||
#define BROKER_URL "mqtt://mqtt.eclipseprojects.io"
|
#define BROKER_URL "mqtt://mqtt.eclipseprojects.io"
|
||||||
|
|
||||||
static const char *TAG = "pppos_example";
|
static const char *TAG = "pppos_example";
|
||||||
@ -161,6 +170,7 @@ void app_main(void)
|
|||||||
dte_config.uart_config.rx_io_num = CONFIG_EXAMPLE_MODEM_UART_RX_PIN;
|
dte_config.uart_config.rx_io_num = CONFIG_EXAMPLE_MODEM_UART_RX_PIN;
|
||||||
dte_config.uart_config.rts_io_num = CONFIG_EXAMPLE_MODEM_UART_RTS_PIN;
|
dte_config.uart_config.rts_io_num = CONFIG_EXAMPLE_MODEM_UART_RTS_PIN;
|
||||||
dte_config.uart_config.cts_io_num = CONFIG_EXAMPLE_MODEM_UART_CTS_PIN;
|
dte_config.uart_config.cts_io_num = CONFIG_EXAMPLE_MODEM_UART_CTS_PIN;
|
||||||
|
dte_config.uart_config.flow_control = EXAMPLE_FLOW_CONTROL;
|
||||||
dte_config.uart_config.rx_buffer_size = CONFIG_EXAMPLE_MODEM_UART_RX_BUFFER_SIZE;
|
dte_config.uart_config.rx_buffer_size = CONFIG_EXAMPLE_MODEM_UART_RX_BUFFER_SIZE;
|
||||||
dte_config.uart_config.tx_buffer_size = CONFIG_EXAMPLE_MODEM_UART_TX_BUFFER_SIZE;
|
dte_config.uart_config.tx_buffer_size = CONFIG_EXAMPLE_MODEM_UART_TX_BUFFER_SIZE;
|
||||||
dte_config.uart_config.event_queue_size = CONFIG_EXAMPLE_MODEM_UART_EVENT_QUEUE_SIZE;
|
dte_config.uart_config.event_queue_size = CONFIG_EXAMPLE_MODEM_UART_EVENT_QUEUE_SIZE;
|
||||||
@ -174,6 +184,12 @@ void app_main(void)
|
|||||||
#elif CONFIG_EXAMPLE_MODEM_DEVICE_SIM800 == 1
|
#elif CONFIG_EXAMPLE_MODEM_DEVICE_SIM800 == 1
|
||||||
ESP_LOGI(TAG, "Initializing esp_modem for the SIM800 module...");
|
ESP_LOGI(TAG, "Initializing esp_modem for the SIM800 module...");
|
||||||
esp_modem_dce_t *dce = esp_modem_new_dev(ESP_MODEM_DCE_SIM800, &dte_config, &dce_config, esp_netif);
|
esp_modem_dce_t *dce = esp_modem_new_dev(ESP_MODEM_DCE_SIM800, &dte_config, &dce_config, esp_netif);
|
||||||
|
#elif CONFIG_EXAMPLE_MODEM_DEVICE_SIM7000 == 1
|
||||||
|
ESP_LOGI(TAG, "Initializing esp_modem for the SIM7000 module...");
|
||||||
|
esp_modem_dce_t *dce = esp_modem_new_dev(ESP_MODEM_DCE_SIM7000, &dte_config, &dce_config, esp_netif);
|
||||||
|
#elif CONFIG_EXAMPLE_MODEM_DEVICE_SIM7070 == 1
|
||||||
|
ESP_LOGI(TAG, "Initializing esp_modem for the SIM7070 module...");
|
||||||
|
esp_modem_dce_t *dce = esp_modem_new_dev(ESP_MODEM_DCE_SIM7070, &dte_config, &dce_config, esp_netif);
|
||||||
#elif CONFIG_EXAMPLE_MODEM_DEVICE_SIM7600 == 1
|
#elif CONFIG_EXAMPLE_MODEM_DEVICE_SIM7600 == 1
|
||||||
ESP_LOGI(TAG, "Initializing esp_modem for the SIM7600 module...");
|
ESP_LOGI(TAG, "Initializing esp_modem for the SIM7600 module...");
|
||||||
esp_modem_dce_t *dce = esp_modem_new_dev(ESP_MODEM_DCE_SIM7600, &dte_config, &dce_config, esp_netif);
|
esp_modem_dce_t *dce = esp_modem_new_dev(ESP_MODEM_DCE_SIM7600, &dte_config, &dce_config, esp_netif);
|
||||||
@ -199,6 +215,16 @@ void app_main(void)
|
|||||||
xEventGroupClearBits(event_group, CONNECT_BIT | GOT_DATA_BIT | USB_DISCONNECTED_BIT);
|
xEventGroupClearBits(event_group, CONNECT_BIT | GOT_DATA_BIT | USB_DISCONNECTED_BIT);
|
||||||
|
|
||||||
/* Run the modem demo app */
|
/* Run the modem demo app */
|
||||||
|
|
||||||
|
if (dte_config.uart_config.flow_control == ESP_MODEM_FLOW_CONTROL_HW) {
|
||||||
|
esp_err_t err = esp_modem_set_flow_control(dce, 2, 2); //2/2 means HW Flow Control.
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGE(TAG, "Failed to set the set_flow_control mode");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ESP_LOGI(TAG, "set_flow_control OK");
|
||||||
|
}
|
||||||
|
|
||||||
#if CONFIG_EXAMPLE_NEED_SIM_PIN == 1
|
#if CONFIG_EXAMPLE_NEED_SIM_PIN == 1
|
||||||
// check if PIN needed
|
// check if PIN needed
|
||||||
bool pin_ok = false;
|
bool pin_ok = false;
|
||||||
@ -214,7 +240,7 @@ void app_main(void)
|
|||||||
int rssi, ber;
|
int rssi, ber;
|
||||||
esp_err_t err = esp_modem_get_signal_quality(dce, &rssi, &ber);
|
esp_err_t err = esp_modem_get_signal_quality(dce, &rssi, &ber);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "esp_modem_get_signal_quality failed with %d", err);
|
ESP_LOGE(TAG, "esp_modem_get_signal_quality failed with %d %s", err, esp_err_to_name(err));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "Signal quality: rssi=%d, ber=%d", rssi, ber);
|
ESP_LOGI(TAG, "Signal quality: rssi=%d, ber=%d", rssi, ber);
|
||||||
|
Reference in New Issue
Block a user