-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Open
Labels
Status: Awaiting triageIssue is waiting for triageIssue is waiting for triage
Description
Board
Lilygo T-A7670E/G/SA
Device Description
The module with power, antenna and sim card.
Hardware Configuration
Nothing connected to the lilygo.
Version
v3.3.2
Type
Bug
IDE Name
Platformio
Operating System
Windows 11
Flash frequency
40MHz
PSRAM enabled
no
Upload speed
921600
Description
PPPOS connection cycling crashes when PPP.end() is called.
My main project needs to shutdown the modem when wifi is available. It was crashing and I thought that it was related to wifi also, but this reduced version also does the same.
I would like to know how to properly end the pppos link and power off the modem to save energy.
Sketch
#include <Arduino.h>
#include <PPP.h>
#define PPP_MODEM_RST GPIO_NUM_5
#define PPP_MODEM_POWER GPIO_NUM_4
#define PPP_MODEM_RST_LOW false // active HIGH
#define PPP_MODEM_RST_DELAY 200
#define PPP_MODEM_TX GPIO_NUM_26
#define PPP_MODEM_RX GPIO_NUM_27
#define PPP_MODEM_RTS -1
#define PPP_MODEM_CTS -1
#define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_NONE
#define PPP_MODEM_MODEL PPP_MODEM_SIM7600
bool must_connect = false, must_disconnect = false, must_power_off = false, is_connecting = false, has_started = false, got_ppp = false;
static void _power_cycle(void) {
log_i("Modem power cycle");
digitalWrite(PPP_MODEM_POWER, 1);
vTaskDelay(2500);
digitalWrite(PPP_MODEM_POWER, 0);
vTaskDelay(1500);
}
void net_callback(arduino_event_id_t event, arduino_event_info_t info) {
switch (event) {
case ARDUINO_EVENT_PPP_GOT_IP:
log_i("ARDUINO_EVENT_PPP_GOT_IP");
got_ppp = true;
break;
}
}
static void pppos_worker(void *pvParameters) {
while (1) {
if (got_ppp) {
got_ppp = false;
delay(5000);
must_disconnect = true;
}
while (must_connect == false && must_disconnect == false && must_power_off == false) {
vTaskDelay(2000);
}
if (must_power_off) {
if (!is_connecting) {
must_power_off = false;
must_connect = false;
_power_cycle();
}
}
if (must_disconnect) {
if (!is_connecting) {
must_disconnect = false;
if (has_started) {
log_i("PPP.end()");
delay(2000);
PPP.end();
must_power_off = true;
}
}
}
if (must_connect) {
is_connecting = true;
bool success = false;
_power_cycle();
do {
PPP.setApn("tim.br");
PPP.setPin("0000");
PPP.setResetPin(PPP_MODEM_RST, PPP_MODEM_RST_LOW, PPP_MODEM_RST_DELAY);
PPP.setPins(PPP_MODEM_TX, PPP_MODEM_RX, PPP_MODEM_RTS, PPP_MODEM_CTS, PPP_MODEM_FC);
success = PPP.begin(PPP_MODEM_MODEL);
if (!success) {
log_i("Failed starting the modem");
_power_cycle();
}
} while (!success);
log_i("Starting the modem. It might take a while!");
log_i("Manufacturer: %s", PPP.cmd("AT+CGMI", 10000).c_str());
log_i("Model: %s", PPP.moduleName().c_str());
bool attached = PPP.attached();
if (!attached) {
int i = 0;
unsigned int s = millis();
log_i("Attaching to the network...");
while ((++i) <= 20) { // 1 min to connect
attached = PPP.attached();
if (attached) {
break;
}
vTaskDelay(5000);
}
log_i("%dms", millis() - s);
attached = PPP.attached();
}
log_i("Attached: %s", attached ? "YES" : "NO");
log_i("State: %d", PPP.radioState());
if (!attached) {
PPP.end();
} else {
has_started = true;
PPP.setApn("tim.br");
log_i("RSSI: %d", PPP.RSSI());
int ber = PPP.BER();
if (ber > 0) {
log_i("BER: %d", ber);
log_i("NetMode: %d", PPP.networkMode());
}
log_i("Switching to data mode...");
PPP.mode(ESP_MODEM_MODE_CMUX); // Data and Command mixed mode
if (0 == PPP.waitStatusBits(ESP_NETIF_CONNECTED_BIT, 20000)) {
log_i("failed ESP_NETIF_CONNECTED_BIT");
PPP.end();
} else {
log_i("success ESP_NETIF_CONNECTED_BIT");
must_connect = false;
}
}
is_connecting = false;
}
}
}
void setup(void) {
Serial.begin(115200);
pinMode(PPP_MODEM_POWER, OUTPUT);
digitalWrite(PPP_MODEM_POWER, 0);
xTaskCreate(pppos_worker, "pppos_worker", 16384, NULL, tskIDLE_PRIORITY, NULL);
Network.onEvent(net_callback);
must_connect = true;
}
void loop(void) {
}
Debug Message
rst:0x1 (POWERON_RESET),boot:0x12 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4744
load:0x40078000,len:15712
load:0x40080400,len:3152
#0 0x40080400 in _invalid_pc_placeholder at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/xtensa/xtensa_vectors.S:2235
entry 0x4008059c
[ 58][I][main.cpp:19] _power_cycle(): Modem power cycle
[ 9413][I][main.cpp:78] pppos_worker(): Starting the modem. It might take a while!
[ 9420][I][main.cpp:79] pppos_worker(): Manufacturer: INCORPORATED
[ 9436][I][main.cpp:80] pppos_worker(): Model: A7670SA-LASC
[ 9462][I][main.cpp:85] pppos_worker(): Attaching to the network...
[ 14487][I][main.cpp:93] pppos_worker(): 5025ms
[ 14501][I][main.cpp:96] pppos_worker(): Attached: YES
[ 14506][I][main.cpp:97] pppos_worker(): State: 1
[ 14521][I][main.cpp:103] pppos_worker(): RSSI: 31
[ 14544][I][main.cpp:106] pppos_worker(): BER: 99
[ 14549][I][main.cpp:107] pppos_worker(): NetMode: 8
[ 14564][I][main.cpp:109] pppos_worker(): Switching to data mode...
[ 14861][I][main.cpp:29] net_callback(): ARDUINO_EVENT_PPP_GOT_IP
[ 14863][I][main.cpp:115] pppos_worker(): success ESP_NETIF_CONNECTED_BIT
[ 19876][I][main.cpp:56] pppos_worker(): PPP.end()
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x40104cf2 PS : 0x00060f30 A0 : 0x80173de0 A1 : 0x3ffb3500
#0 0x40104cf2 in on_ppp_notify_phase at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_netif/lwip/esp_netif_lwip_ppp.c:164 (discriminator 1)
A2 : 0x3ffae89c A3 : 0x0000000c A4 : 0x3ffb998c A5 : 0x00060f23
A6 : 0x00000001 A7 : 0x3ffb5fb4 A8 : 0x00000000 A9 : 0x3ffb3500
A10 : 0x3ffb9958 A11 : 0x0000000c A12 : 0x3ffb351c A13 : 0x3ffd1054
A14 : 0x3ffd1054 A15 : 0x3ffb5fe8 SAR : 0x00000019 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000004 LBEG : 0x40088db4 LEND : 0x40088dca LCOUNT : 0xffffffff
Backtrace: 0x40104cef:0x3ffb3500 0x40173ddd:0x3ffb3540 0x400ffdca:0x3ffb3560 0x401019a9:0x3ffb3580 0x40102fe2:0x3ffb35a0 0x40101931:0x3ffb35d0 0x400fbf7e:0x3ffb35f0 0x400fc744:0x3ffb3620 0x400fc8f8:0x3ffb3650 0x400ed036:0x3ffb3670 0x4008c65d:0x3ffb36a0
#0 0x40104cef in on_ppp_notify_phase at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp_netif/lwip/esp_netif_lwip_ppp.c:132 (discriminator 2)
#1 0x40173ddd in new_phase at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/netif/ppp/ppp.c:1029
#2 0x400ffdca in link_terminated at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/netif/ppp/auth.c:627
#3 0x401019a9 in lcp_finished at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/netif/ppp/lcp.c:2373
#4 0x40102fe2 in fsm_rtermack at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/netif/ppp/fsm.c:623
(inlined by) fsm_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/netif/ppp/fsm.c:373
#5 0x40101931 in lcp_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/netif/ppp/lcp.c:517
#6 0x400fbf7e in ppp_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/netif/ppp/ppp.c:943
#7 0x400fc744 in pppos_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/netif/ppp/pppos.c:591
#8 0x400fc8f8 in pppos_input_sys at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/netif/ppp/pppos.c:450
#9 0x400ed036 in tcpip_thread_handle_msg at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c:179
(inlined by) tcpip_thread at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c:148
#10 0x4008c65d in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:139
ELF file SHA256: c7a6b1648
Rebooting..
Other Steps to Reproduce
Simply run the sketch, wait for the PPP to get the IP. After a while the code will call PPP.end() and will crash.
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.
Metadata
Metadata
Assignees
Labels
Status: Awaiting triageIssue is waiting for triageIssue is waiting for triage