2018-11-22 22:53:20 -05:00
|
|
|
/* PPPoS Client Example
|
2017-01-20 06:05:38 -05:00
|
|
|
|
|
|
|
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, this
|
|
|
|
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
|
|
CONDITIONS OF ANY KIND, either express or implied.
|
2018-11-22 22:53:20 -05:00
|
|
|
*/
|
2017-01-20 06:05:38 -05:00
|
|
|
#include <string.h>
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/event_groups.h"
|
2019-09-01 12:25:23 -04:00
|
|
|
#include "esp_netif.h"
|
2019-11-11 10:38:43 -05:00
|
|
|
#include "esp_netif_ppp.h"
|
2018-11-22 22:53:20 -05:00
|
|
|
#include "mqtt_client.h"
|
|
|
|
#include "esp_modem.h"
|
2019-11-11 10:38:43 -05:00
|
|
|
#include "esp_modem_netif.h"
|
2017-01-20 06:05:38 -05:00
|
|
|
#include "esp_log.h"
|
2018-11-22 22:53:20 -05:00
|
|
|
#include "sim800.h"
|
|
|
|
#include "bg96.h"
|
|
|
|
|
2019-09-26 21:35:26 -04:00
|
|
|
#define BROKER_URL "mqtt://mqtt.eclipse.org"
|
2018-11-22 22:53:20 -05:00
|
|
|
|
|
|
|
static const char *TAG = "pppos_example";
|
|
|
|
static EventGroupHandle_t event_group = NULL;
|
|
|
|
static const int CONNECT_BIT = BIT0;
|
|
|
|
static const int STOP_BIT = BIT1;
|
|
|
|
static const int GOT_DATA_BIT = BIT2;
|
|
|
|
|
2019-05-09 10:43:06 -04:00
|
|
|
#if CONFIG_EXAMPLE_SEND_MSG
|
2018-11-22 22:53:20 -05:00
|
|
|
/**
|
|
|
|
* @brief This example will also show how to send short message using the infrastructure provided by esp modem library.
|
|
|
|
* @note Not all modem support SMG.
|
|
|
|
*
|
2017-01-20 06:05:38 -05:00
|
|
|
*/
|
2018-11-22 22:53:20 -05:00
|
|
|
static esp_err_t example_default_handle(modem_dce_t *dce, const char *line)
|
|
|
|
{
|
|
|
|
esp_err_t err = ESP_FAIL;
|
|
|
|
if (strstr(line, MODEM_RESULT_CODE_SUCCESS)) {
|
|
|
|
err = esp_modem_process_command_done(dce, MODEM_STATE_SUCCESS);
|
|
|
|
} else if (strstr(line, MODEM_RESULT_CODE_ERROR)) {
|
|
|
|
err = esp_modem_process_command_done(dce, MODEM_STATE_FAIL);
|
2017-01-20 06:05:38 -05:00
|
|
|
}
|
2018-11-22 22:53:20 -05:00
|
|
|
return err;
|
|
|
|
}
|
2017-01-20 06:05:38 -05:00
|
|
|
|
2018-11-22 22:53:20 -05:00
|
|
|
static esp_err_t example_handle_cmgs(modem_dce_t *dce, const char *line)
|
|
|
|
{
|
|
|
|
esp_err_t err = ESP_FAIL;
|
|
|
|
if (strstr(line, MODEM_RESULT_CODE_SUCCESS)) {
|
|
|
|
err = esp_modem_process_command_done(dce, MODEM_STATE_SUCCESS);
|
|
|
|
} else if (strstr(line, MODEM_RESULT_CODE_ERROR)) {
|
|
|
|
err = esp_modem_process_command_done(dce, MODEM_STATE_FAIL);
|
|
|
|
} else if (!strncmp(line, "+CMGS", strlen("+CMGS"))) {
|
|
|
|
err = ESP_OK;
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
2017-01-20 06:05:38 -05:00
|
|
|
|
2018-11-22 22:53:20 -05:00
|
|
|
#define MODEM_SMS_MAX_LENGTH (128)
|
|
|
|
#define MODEM_COMMAND_TIMEOUT_SMS_MS (120000)
|
|
|
|
#define MODEM_PROMPT_TIMEOUT_MS (10)
|
|
|
|
|
|
|
|
static esp_err_t example_send_message_text(modem_dce_t *dce, const char *phone_num, const char *text)
|
2017-01-20 06:05:38 -05:00
|
|
|
{
|
2018-11-22 22:53:20 -05:00
|
|
|
modem_dte_t *dte = dce->dte;
|
|
|
|
dce->handle_line = example_default_handle;
|
|
|
|
/* Set text mode */
|
|
|
|
if (dte->send_cmd(dte, "AT+CMGF=1\r", MODEM_COMMAND_TIMEOUT_DEFAULT) != ESP_OK) {
|
|
|
|
ESP_LOGE(TAG, "send command failed");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
if (dce->state != MODEM_STATE_SUCCESS) {
|
|
|
|
ESP_LOGE(TAG, "set message format failed");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
ESP_LOGD(TAG, "set message format ok");
|
|
|
|
/* Specify character set */
|
|
|
|
dce->handle_line = example_default_handle;
|
|
|
|
if (dte->send_cmd(dte, "AT+CSCS=\"GSM\"\r", MODEM_COMMAND_TIMEOUT_DEFAULT) != ESP_OK) {
|
|
|
|
ESP_LOGE(TAG, "send command failed");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
if (dce->state != MODEM_STATE_SUCCESS) {
|
|
|
|
ESP_LOGE(TAG, "set character set failed");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
ESP_LOGD(TAG, "set character set ok");
|
|
|
|
/* send message */
|
|
|
|
char command[MODEM_SMS_MAX_LENGTH] = {0};
|
|
|
|
int length = snprintf(command, MODEM_SMS_MAX_LENGTH, "AT+CMGS=\"%s\"\r", phone_num);
|
|
|
|
/* set phone number and wait for "> " */
|
|
|
|
dte->send_wait(dte, command, length, "\r\n> ", MODEM_PROMPT_TIMEOUT_MS);
|
|
|
|
/* end with CTRL+Z */
|
|
|
|
snprintf(command, MODEM_SMS_MAX_LENGTH, "%s\x1A", text);
|
|
|
|
dce->handle_line = example_handle_cmgs;
|
|
|
|
if (dte->send_cmd(dte, command, MODEM_COMMAND_TIMEOUT_SMS_MS) != ESP_OK) {
|
|
|
|
ESP_LOGE(TAG, "send command failed");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
if (dce->state != MODEM_STATE_SUCCESS) {
|
|
|
|
ESP_LOGE(TAG, "send message failed");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
ESP_LOGD(TAG, "send message ok");
|
|
|
|
return ESP_OK;
|
|
|
|
err:
|
|
|
|
return ESP_FAIL;
|
|
|
|
}
|
|
|
|
#endif
|
2017-01-20 06:05:38 -05:00
|
|
|
|
2018-11-22 22:53:20 -05:00
|
|
|
static void modem_event_handler(void *event_handler_arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
|
|
|
|
{
|
|
|
|
switch (event_id) {
|
2019-11-21 07:20:13 -05:00
|
|
|
case ESP_MODEM_EVENT_PPP_START:
|
2018-11-22 22:53:20 -05:00
|
|
|
ESP_LOGI(TAG, "Modem PPP Started");
|
2017-01-20 06:05:38 -05:00
|
|
|
break;
|
2019-11-21 07:20:13 -05:00
|
|
|
case ESP_MODEM_EVENT_PPP_STOP:
|
2018-11-22 22:53:20 -05:00
|
|
|
ESP_LOGI(TAG, "Modem PPP Stopped");
|
|
|
|
xEventGroupSetBits(event_group, STOP_BIT);
|
2017-01-20 06:05:38 -05:00
|
|
|
break;
|
2019-11-21 07:20:13 -05:00
|
|
|
case ESP_MODEM_EVENT_UNKNOWN:
|
2018-11-22 22:53:20 -05:00
|
|
|
ESP_LOGW(TAG, "Unknow line received: %s", (char *)event_data);
|
2017-01-20 06:05:38 -05:00
|
|
|
break;
|
2018-11-22 22:53:20 -05:00
|
|
|
default:
|
2017-01-20 06:05:38 -05:00
|
|
|
break;
|
|
|
|
}
|
2018-11-22 22:53:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static esp_err_t mqtt_event_handler(esp_mqtt_event_handle_t event)
|
|
|
|
{
|
|
|
|
esp_mqtt_client_handle_t client = event->client;
|
|
|
|
int msg_id;
|
|
|
|
switch (event->event_id) {
|
|
|
|
case MQTT_EVENT_CONNECTED:
|
|
|
|
ESP_LOGI(TAG, "MQTT_EVENT_CONNECTED");
|
|
|
|
msg_id = esp_mqtt_client_subscribe(client, "/topic/esp-pppos", 0);
|
|
|
|
ESP_LOGI(TAG, "sent subscribe successful, msg_id=%d", msg_id);
|
2017-01-20 06:05:38 -05:00
|
|
|
break;
|
2018-11-22 22:53:20 -05:00
|
|
|
case MQTT_EVENT_DISCONNECTED:
|
|
|
|
ESP_LOGI(TAG, "MQTT_EVENT_DISCONNECTED");
|
2017-01-20 06:05:38 -05:00
|
|
|
break;
|
2018-11-22 22:53:20 -05:00
|
|
|
case MQTT_EVENT_SUBSCRIBED:
|
|
|
|
ESP_LOGI(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d", event->msg_id);
|
|
|
|
msg_id = esp_mqtt_client_publish(client, "/topic/esp-pppos", "esp32-pppos", 0, 0, 0);
|
|
|
|
ESP_LOGI(TAG, "sent publish successful, msg_id=%d", msg_id);
|
2017-01-20 06:05:38 -05:00
|
|
|
break;
|
2018-11-22 22:53:20 -05:00
|
|
|
case MQTT_EVENT_UNSUBSCRIBED:
|
|
|
|
ESP_LOGI(TAG, "MQTT_EVENT_UNSUBSCRIBED, msg_id=%d", event->msg_id);
|
2017-01-20 06:05:38 -05:00
|
|
|
break;
|
2018-11-22 22:53:20 -05:00
|
|
|
case MQTT_EVENT_PUBLISHED:
|
|
|
|
ESP_LOGI(TAG, "MQTT_EVENT_PUBLISHED, msg_id=%d", event->msg_id);
|
2017-01-20 06:05:38 -05:00
|
|
|
break;
|
2018-11-22 22:53:20 -05:00
|
|
|
case MQTT_EVENT_DATA:
|
|
|
|
ESP_LOGI(TAG, "MQTT_EVENT_DATA");
|
|
|
|
printf("TOPIC=%.*s\r\n", event->topic_len, event->topic);
|
|
|
|
printf("DATA=%.*s\r\n", event->data_len, event->data);
|
|
|
|
xEventGroupSetBits(event_group, GOT_DATA_BIT);
|
2017-01-20 06:05:38 -05:00
|
|
|
break;
|
2018-11-22 22:53:20 -05:00
|
|
|
case MQTT_EVENT_ERROR:
|
|
|
|
ESP_LOGI(TAG, "MQTT_EVENT_ERROR");
|
2017-01-20 06:05:38 -05:00
|
|
|
break;
|
2018-11-22 22:53:20 -05:00
|
|
|
default:
|
|
|
|
ESP_LOGI(TAG, "MQTT other event id: %d", event->event_id);
|
2017-01-20 06:05:38 -05:00
|
|
|
break;
|
|
|
|
}
|
2018-11-22 22:53:20 -05:00
|
|
|
return ESP_OK;
|
2017-01-20 06:05:38 -05:00
|
|
|
}
|
|
|
|
|
2019-11-11 10:38:43 -05:00
|
|
|
static void on_ppp_changed(void *arg, esp_event_base_t event_base,
|
|
|
|
int32_t event_id, void *event_data)
|
|
|
|
{
|
|
|
|
ESP_LOGI(TAG, "PPP state changed event %d", event_id);
|
|
|
|
if (event_id == NETIF_PPP_ERRORUSER) {
|
|
|
|
/* User interrupted event from esp-netif */
|
|
|
|
esp_netif_t *netif = event_data;
|
|
|
|
ESP_LOGI(TAG, "User interrupted event from netif:%p", netif);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void on_ip_event(void *arg, esp_event_base_t event_base,
|
|
|
|
int32_t event_id, void *event_data)
|
|
|
|
{
|
2020-01-31 09:18:19 -05:00
|
|
|
ESP_LOGD(TAG, "IP event! %d", event_id);
|
2019-11-11 10:38:43 -05:00
|
|
|
if (event_id == IP_EVENT_PPP_GOT_IP) {
|
|
|
|
esp_netif_dns_info_t dns_info;
|
|
|
|
|
|
|
|
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
|
|
|
|
esp_netif_t *netif = event->esp_netif;
|
|
|
|
|
|
|
|
ESP_LOGI(TAG, "Modem Connect to PPP Server");
|
|
|
|
ESP_LOGI(TAG, "~~~~~~~~~~~~~~");
|
|
|
|
ESP_LOGI(TAG, "IP : " IPSTR, IP2STR(&event->ip_info.ip));
|
|
|
|
ESP_LOGI(TAG, "Netmask : " IPSTR, IP2STR(&event->ip_info.netmask));
|
2020-01-31 09:18:19 -05:00
|
|
|
ESP_LOGI(TAG, "Gateway : " IPSTR, IP2STR(&event->ip_info.gw));
|
2019-11-11 10:38:43 -05:00
|
|
|
esp_netif_get_dns_info(netif, 0, &dns_info);
|
|
|
|
ESP_LOGI(TAG, "Name Server1: " IPSTR, IP2STR(&dns_info.ip.u_addr.ip4));
|
|
|
|
esp_netif_get_dns_info(netif, 1, &dns_info);
|
|
|
|
ESP_LOGI(TAG, "Name Server2: " IPSTR, IP2STR(&dns_info.ip.u_addr.ip4));
|
|
|
|
ESP_LOGI(TAG, "~~~~~~~~~~~~~~");
|
|
|
|
xEventGroupSetBits(event_group, CONNECT_BIT);
|
|
|
|
|
|
|
|
ESP_LOGI(TAG, "GOT ip event!!!");
|
|
|
|
} else if (event_id == IP_EVENT_PPP_LOST_IP) {
|
|
|
|
ESP_LOGI(TAG, "Modem Disconnect from PPP Server");
|
2020-02-25 05:43:02 -05:00
|
|
|
} else if (event_id == IP_EVENT_GOT_IP6) {
|
|
|
|
ESP_LOGI(TAG, "GOT IPv6 event!");
|
|
|
|
|
|
|
|
ip_event_got_ip6_t *event = (ip_event_got_ip6_t *)event_data;
|
|
|
|
ESP_LOGI(TAG, "Got IPv6 address " IPV6STR, IPV62STR(event->ip6_info.ip));
|
2019-11-11 10:38:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-16 05:33:30 -04:00
|
|
|
void app_main(void)
|
2017-01-20 06:05:38 -05:00
|
|
|
{
|
2019-11-11 10:38:43 -05:00
|
|
|
#if CONFIG_LWIP_PPP_PAP_SUPPORT
|
|
|
|
esp_netif_auth_type_t auth_type = NETIF_PPP_AUTHTYPE_PAP;
|
|
|
|
#elif CONFIG_LWIP_PPP_CHAP_SUPPORT
|
|
|
|
esp_netif_auth_type_t auth_type = NETIF_PPP_AUTHTYPE_CHAP;
|
2020-03-31 07:10:42 -04:00
|
|
|
#elif !defined(CONFIG_EXAMPLE_MODEM_PPP_AUTH_NONE)
|
2019-11-11 10:38:43 -05:00
|
|
|
#error "Unsupported AUTH Negotiation"
|
|
|
|
#endif
|
2019-11-29 04:54:02 -05:00
|
|
|
ESP_ERROR_CHECK(esp_netif_init());
|
2019-11-11 10:38:43 -05:00
|
|
|
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
|
|
|
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, &on_ip_event, NULL));
|
|
|
|
ESP_ERROR_CHECK(esp_event_handler_register(NETIF_PPP_STATUS, ESP_EVENT_ANY_ID, &on_ppp_changed, NULL));
|
|
|
|
|
2018-11-22 22:53:20 -05:00
|
|
|
event_group = xEventGroupCreate();
|
2019-11-11 10:38:43 -05:00
|
|
|
|
|
|
|
// Init netif object
|
|
|
|
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_PPP();
|
|
|
|
esp_netif_t *esp_netif = esp_netif_new(&cfg);
|
|
|
|
assert(esp_netif);
|
|
|
|
|
2018-11-22 22:53:20 -05:00
|
|
|
/* create dte object */
|
|
|
|
esp_modem_dte_config_t config = ESP_MODEM_DTE_DEFAULT_CONFIG();
|
2020-03-30 10:06:27 -04:00
|
|
|
/* setup UART specific configuration based on kconfig options */
|
|
|
|
config.tx_io_num = CONFIG_EXAMPLE_MODEM_UART_TX_PIN;
|
|
|
|
config.rx_io_num = CONFIG_EXAMPLE_MODEM_UART_RX_PIN;
|
|
|
|
config.rts_io_num = CONFIG_EXAMPLE_MODEM_UART_RTS_PIN;
|
|
|
|
config.cts_io_num = CONFIG_EXAMPLE_MODEM_UART_CTS_PIN;
|
|
|
|
config.rx_buffer_size = CONFIG_EXAMPLE_MODEM_UART_RX_BUFFER_SIZE;
|
|
|
|
config.tx_buffer_size = CONFIG_EXAMPLE_MODEM_UART_TX_BUFFER_SIZE;
|
|
|
|
config.pattern_queue_size = CONFIG_EXAMPLE_MODEM_UART_PATTERN_QUEUE_SIZE;
|
|
|
|
config.event_queue_size = CONFIG_EXAMPLE_MODEM_UART_EVENT_QUEUE_SIZE;
|
|
|
|
config.event_task_stack_size = CONFIG_EXAMPLE_MODEM_UART_EVENT_TASK_STACK_SIZE;
|
|
|
|
config.event_task_priority = CONFIG_EXAMPLE_MODEM_UART_EVENT_TASK_PRIORITY;
|
|
|
|
config.line_buffer_size = CONFIG_EXAMPLE_MODEM_UART_RX_BUFFER_SIZE/2;
|
2018-11-22 22:53:20 -05:00
|
|
|
modem_dte_t *dte = esp_modem_dte_init(&config);
|
|
|
|
/* Register event handler */
|
2019-11-21 07:20:13 -05:00
|
|
|
ESP_ERROR_CHECK(esp_modem_set_event_handler(dte, modem_event_handler, ESP_EVENT_ANY_ID, NULL));
|
2018-11-22 22:53:20 -05:00
|
|
|
/* create dce object */
|
2019-05-09 10:43:06 -04:00
|
|
|
#if CONFIG_EXAMPLE_MODEM_DEVICE_SIM800
|
2018-11-22 22:53:20 -05:00
|
|
|
modem_dce_t *dce = sim800_init(dte);
|
2019-05-09 10:43:06 -04:00
|
|
|
#elif CONFIG_EXAMPLE_MODEM_DEVICE_BG96
|
2018-11-22 22:53:20 -05:00
|
|
|
modem_dce_t *dce = bg96_init(dte);
|
|
|
|
#else
|
|
|
|
#error "Unsupported DCE"
|
|
|
|
#endif
|
2020-05-07 06:47:46 -04:00
|
|
|
assert(dce != NULL);
|
2018-11-22 22:53:20 -05:00
|
|
|
ESP_ERROR_CHECK(dce->set_flow_ctrl(dce, MODEM_FLOW_CONTROL_NONE));
|
|
|
|
ESP_ERROR_CHECK(dce->store_profile(dce));
|
|
|
|
/* Print Module ID, Operator, IMEI, IMSI */
|
|
|
|
ESP_LOGI(TAG, "Module: %s", dce->name);
|
|
|
|
ESP_LOGI(TAG, "Operator: %s", dce->oper);
|
|
|
|
ESP_LOGI(TAG, "IMEI: %s", dce->imei);
|
|
|
|
ESP_LOGI(TAG, "IMSI: %s", dce->imsi);
|
|
|
|
/* Get signal quality */
|
|
|
|
uint32_t rssi = 0, ber = 0;
|
|
|
|
ESP_ERROR_CHECK(dce->get_signal_quality(dce, &rssi, &ber));
|
|
|
|
ESP_LOGI(TAG, "rssi: %d, ber: %d", rssi, ber);
|
|
|
|
/* Get battery voltage */
|
|
|
|
uint32_t voltage = 0, bcs = 0, bcl = 0;
|
|
|
|
ESP_ERROR_CHECK(dce->get_battery_status(dce, &bcs, &bcl, &voltage));
|
|
|
|
ESP_LOGI(TAG, "Battery voltage: %d mV", voltage);
|
2019-11-11 10:38:43 -05:00
|
|
|
/* setup PPPoS network parameters */
|
2020-03-31 07:10:42 -04:00
|
|
|
#if !defined(CONFIG_EXAMPLE_MODEM_PPP_AUTH_NONE) && (defined(CONFIG_LWIP_PPP_PAP_SUPPORT) || defined(CONFIG_LWIP_PPP_CHAP_SUPPORT))
|
2019-11-11 10:38:43 -05:00
|
|
|
esp_netif_ppp_set_auth(esp_netif, auth_type, CONFIG_EXAMPLE_MODEM_PPP_AUTH_USERNAME, CONFIG_EXAMPLE_MODEM_PPP_AUTH_PASSWORD);
|
2020-03-31 07:10:42 -04:00
|
|
|
#endif
|
2019-11-11 10:38:43 -05:00
|
|
|
void *modem_netif_adapter = esp_modem_netif_setup(dte);
|
|
|
|
esp_modem_netif_set_default_handlers(modem_netif_adapter, esp_netif);
|
|
|
|
/* attach the modem to the network interface */
|
|
|
|
esp_netif_attach(esp_netif, modem_netif_adapter);
|
2018-11-22 22:53:20 -05:00
|
|
|
/* Wait for IP address */
|
|
|
|
xEventGroupWaitBits(event_group, CONNECT_BIT, pdTRUE, pdTRUE, portMAX_DELAY);
|
|
|
|
/* Config MQTT */
|
|
|
|
esp_mqtt_client_config_t mqtt_config = {
|
|
|
|
.uri = BROKER_URL,
|
|
|
|
.event_handle = mqtt_event_handler,
|
|
|
|
};
|
|
|
|
esp_mqtt_client_handle_t mqtt_client = esp_mqtt_client_init(&mqtt_config);
|
|
|
|
esp_mqtt_client_start(mqtt_client);
|
|
|
|
xEventGroupWaitBits(event_group, GOT_DATA_BIT, pdTRUE, pdTRUE, portMAX_DELAY);
|
|
|
|
esp_mqtt_client_destroy(mqtt_client);
|
|
|
|
/* Exit PPP mode */
|
2019-11-11 10:38:43 -05:00
|
|
|
ESP_ERROR_CHECK(esp_modem_stop_ppp(dte));
|
|
|
|
/* Destroy the netif adapter withe events, which internally frees also the esp-netif instance */
|
|
|
|
esp_modem_netif_clear_default_handlers(modem_netif_adapter);
|
|
|
|
esp_modem_netif_teardown(modem_netif_adapter);
|
2018-11-22 22:53:20 -05:00
|
|
|
xEventGroupWaitBits(event_group, STOP_BIT, pdTRUE, pdTRUE, portMAX_DELAY);
|
2019-05-09 10:43:06 -04:00
|
|
|
#if CONFIG_EXAMPLE_SEND_MSG
|
2018-11-22 22:53:20 -05:00
|
|
|
const char *message = "Welcome to ESP32!";
|
2019-05-09 10:43:06 -04:00
|
|
|
ESP_ERROR_CHECK(example_send_message_text(dce, CONFIG_EXAMPLE_SEND_MSG_PEER_PHONE_NUMBER, message));
|
2018-11-22 22:53:20 -05:00
|
|
|
ESP_LOGI(TAG, "Send send message [%s] ok", message);
|
|
|
|
#endif
|
|
|
|
/* Power down module */
|
|
|
|
ESP_ERROR_CHECK(dce->power_down(dce));
|
|
|
|
ESP_LOGI(TAG, "Power down");
|
|
|
|
ESP_ERROR_CHECK(dce->deinit(dce));
|
|
|
|
ESP_ERROR_CHECK(dte->deinit(dte));
|
2017-01-20 06:05:38 -05:00
|
|
|
}
|