Skip to content

PPP Crash while im call PPP.end() and Call WiFi.begin(ssid,pass); #10165

@The3ven

Description

@The3ven

Board

ESP32S3 Dev Module

Device Description

im using esp32s3 with esp32-3.0.3 core, 16 mb internal memory, i have Quectel EC200CN atteched with gpio 4 and 5.

Hardware Configuration

4 , 5 Quectel EC200UCN
SD card default pin

Version

v3.0.3

IDE Name

Arduino IDE

Operating System

Windows 10 22H2 (OS Build 19045.4717)

Flash frequency

QIO 80MHz

PSRAM enabled

no

Upload speed

921600

Description

my esp32s3 crash when im call WiFi.begin(ssid,pass); after PPP.end(); it crash with network _network_event_task task, idk how to fix this please help me.

Sketch

#include <PPP.h>
#include <WiFi.h>


String ssid = "ssid";
String pass = "pass";

int loop_cnt = 0;
bool quectelOffOnce = true;
bool quackOff = false;

#define PPP_MODEM_APN "AIRTELGPRS.COM" // For SimCard ISP
#define PPP_MODEM_PIN   NULL // or NULL

// EC200U copyed from WaveShare SIM7600 HW Flow Control
#define PPP_MODEM_RST     41 // as vishal sys it will aviliable in next rev
#define PPP_MODEM_RST_LOW true  //active HIGH
#define PPP_MODEM_TX      4
#define PPP_MODEM_RX      5
#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_GENERIC

void onEvent(arduino_event_id_t event, arduino_event_info_t info) {
    switch (event) {
    case ARDUINO_EVENT_PPP_START:
        Serial.println("PPP Started");
        break;
    case ARDUINO_EVENT_PPP_CONNECTED:
        Serial.println("PPP Connected");
        break;
    case ARDUINO_EVENT_PPP_GOT_IP:
        Serial.println("PPP Got IP");
        break;
    case ARDUINO_EVENT_PPP_LOST_IP:
        Serial.println("PPP Lost IP");
        break;
    case ARDUINO_EVENT_PPP_DISCONNECTED:
        Serial.println("PPP Disconnected");
        break;
    case ARDUINO_EVENT_PPP_STOP:
        Serial.println("PPP Stopped");
        break;
    default:
        break;
    }
}

void testClient(const char* host, uint16_t port) {
    NetworkClient client;
    if (!client.connect(host, port)) {
        Serial.println("Connection Failed");
        return;
    }
    client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host);
    while (client.connected() && !client.available());
    while (client.available()) {
        client.read();  //Serial.write(client.read());
    }

    Serial.println("Connection Success");
    client.stop();
}


void Quectelbegin() {
    // Listen for modem events
    Network.onEvent(onEvent);

    // Configure the modem
    PPP.setApn(PPP_MODEM_APN);
    PPP.setPin(PPP_MODEM_PIN);
    PPP.setResetPin(PPP_MODEM_RST, PPP_MODEM_RST_LOW, 300);
    PPP.setPins(PPP_MODEM_TX, PPP_MODEM_RX, PPP_MODEM_RTS, PPP_MODEM_CTS, PPP_MODEM_FC);

    Serial.println("Starting the modem. It might take a while!");
    PPP.begin(PPP_MODEM_MODEL);

    Serial.print("Manufacturer: ");
    Serial.println(PPP.cmd("AT+CGMI", 10000));
    Serial.print("Model: ");
    Serial.println(PPP.moduleName());
    Serial.print("IMEI: ");
    Serial.println(PPP.IMEI());

    bool attached = PPP.attached();
    if (!attached) {
        int i = 0;
        unsigned int s = millis();
        Serial.print("Waiting to connect to network");
        while (!attached && ((++i) < 600)) {
            Serial.print(".");
            delay(100);
            attached = PPP.attached();
        }
        Serial.print((millis() - s) / 1000.0, 1);
        Serial.println("s");
        attached = PPP.attached();
    }

    Serial.print("Attached: ");
    Serial.println(attached);
    Serial.print("State: ");
    Serial.println(PPP.radioState());
    if (attached) {
        Serial.print("Operator: ");
        Serial.println(PPP.operatorName());
        Serial.print("IMSI: ");
        Serial.println(PPP.IMSI());
        Serial.print("RSSI: ");
        Serial.println(PPP.RSSI());
        int ber = PPP.BER();
        if (ber > 0) {
            Serial.print("BER: ");
            Serial.println(ber);
            Serial.print("NetMode: ");
            Serial.println(PPP.networkMode());
        }

        Serial.println("Switching to data mode...");
        PPP.mode(ESP_MODEM_MODE_CMUX);  // Data and Command mixed mode
        if (!PPP.waitStatusBits(ESP_NETIF_CONNECTED_BIT, 1000)) {
            Serial.println("Failed to connect to internet!");
        }
        else {
            Serial.println("Connected to internet!");
        }
    }
    else {
        Serial.println("Failed to connect to network!");
    }
}

bool queConnected() {
    return PPP.connected();
}

String getIP() {
    return String(PPP.localIP().toString());
}

void setup()
{
    Serial.begin(115200);
    Quectelbegin(); // begin quectel to get connect to internet
    while (!queConnected()) // check if quectel connect to internet if not wait for it
    {
        // boo!
    }
    if (queConnected())
    {
        String IP = getIP();
        if (IP != "0.0.0.0")
        {
            Serial.println("PPPOS CONNECTED !");
            Serial.println("IP : " + IP);
        }
    }
}


void resetQuectel()
{
    if (quectelOffOnce)
    {
        if (PPP.connected() && WiFi.status() != WL_CONNECTED)
        {
            Serial.println("PPP.connected() : " + String(PPP.connected()));
            Serial.println("WiFi.status() == WL_DISCONNECTED : " + String(WiFi.status() == WL_DISCONNECTED));
            Serial.println("+PPP END #1");
            PPP.end();
            Serial.println("+PPP END #2");
        }

        Serial.println("PPP end here !");
        pinMode(PPP_MODEM_RST, OUTPUT);
        digitalWrite(PPP_MODEM_RST, true);
        delay(3000);
        digitalWrite(PPP_MODEM_RST, false);
        delay(100);
        Serial.println("Modem Reset Done");
        quectelOffOnce = false;
    }
}


void connectAndCheckWiFiStatus()
{
    if (WiFi.status() != WL_CONNECTED)
    {
        WiFi.begin(ssid, pass);
        delay(200);
        while (WiFi.status() != WL_CONNECTED)
        {
            Serial.print(".");
            delay(100);
        }
        if (WiFi.status() == WL_CONNECTED)
        {
            return;
        }
    }
}



void loop()
{
    if (!quackOff)
    {
        if (!queConnected())
        {
            Quectelbegin();
        }
        while (!queConnected())
        {
        }; // check if quectel connect to internet if not wait for it
    }
    delay(100);
    testClient("google.com", 80);
    if (loop_cnt >= 200)
    {
        if (!quackOff)
        {
            resetQuectel();
            quackOff = true;
        }
    }
    if (quackOff)
    {
        connectAndCheckWiFiStatus();
    }
    loop_cnt++;
    delay(2000);
}

Debug Message

Core  1 register dump:
PC      : 0x00000000  PS      : 0x00060530  A0      : 0x82089248  A1      : 0x3fca8700  
A2      : 0x00000001  A3      : 0x3fca23c0  A4      : 0x3fca1600  A5      : 0x3fca8710  
A6      : 0x3fca87e0  A7      : 0x3fce9ff0  A8      : 0x82089219  A9      : 0x3fca86f0  
A10     : 0x3fca8710  A11     : 0x3fca8704  A12     : 0x3fca8728  A13     : 0x3fca87dc  
A14     : 0x00000032  A15     : 0x00000000  SAR     : 0x00000019  EXCCAUSE: 0x00000014  
EXCVADDR: 0x00000000  LBEG    : 0x40056f5c  LEND    : 0x40056f72  LCOUNT  : 0x00000000  


Backtrace: 0xfffffffd:0x3fca8700 0x42089245:0x3fca8800 0x40380e36:0x3fca8820



ELF file SHA256: c90df16c60dd61c6

Other Steps to Reproduce

i have only windows.

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

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions