-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to restart pppos client? (IDFGH-2105) (IDFGH-2106) #4268
Comments
Any suggestions? |
Having issues with this too I see that once MODEM_EVENT_PPP_DISCONNECT has been raised, esp_modem_exit_ppp causes the the task to wait |
Having similiar issues to restart ppos client. Particularly, using trying to reinit the client causes crashing, anyway, i also posted a similar issue on github called: "PppoS: Uart Resync Problems". Hope they will fix this soon :) |
Found some interesting info in #3506 ! |
During the ppp setup call pppapi_pppos_create and pppapi_set_default only 1 time. So when it is reconnecting skip these functions and call only pppapi_connect. In exit it must call only pppapi_close. Do not call pppapi_free! That will solve the issue. Example:
|
Ive been trying to reconnect the ppp connection after a connection drop. For my test I get a proper connection and then cover the modem with foil, after receiving PPPERR_PEERDEAD err_code on ppp_status_cb from missed LCP echo packages I remove foil cover, wait some seconds, and call only pppapi_connect(ppp, 0) but it always just return PPPERR_PEERDEAD err_code again on ppp_status_cb. Should I do all the chat script again after a connection drop? |
@diogoviannaaraujo Thanks for reporting. Would you please help file a new ticket for the new issue? Thanks. |
Environment
ESP32-WROOM-32U
v3.3
CMake
Windows 10
USB
Problem Description
I'm trying to develop a function that restart the pppos client every X seconds.
I take the code from you repo (https://github.com/espressif/esp-idf/blob/master/examples/protocols/pppos_client/main/pppos_client_main.c).
I just changed the function name from "app_main()" to "pppos_init()", so this is my function (in pppos.c):
void pppos_init()
{
tcpip_adapter_init();
event_group = xEventGroupCreate();
/* create dte object */
esp_modem_dte_config_t config = ESP_MODEM_DTE_DEFAULT_CONFIG();
modem_dte_t *dte = esp_modem_dte_init(&config);
// Register event handler //
ESP_ERROR_CHECK(esp_modem_add_event_handler(dte, modem_event_handler, NULL));
// create dce object //
#if CONFIG_ESP_MODEM_DEVICE_SIM800
modem_dce_t *dce = sim800_init(dte);
#elif CONFIG_ESP_MODEM_DEVICE_BG96
modem_dce_t *dce = bg96_init(dte);
#else
#error "Unsupported DCE"
#endif
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);
// Setup PPP environment //
esp_modem_setup_ppp(dte, configuration_get(CONF_APN));
// 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 //
ESP_ERROR_CHECK(esp_modem_exit_ppp(dte));
xEventGroupWaitBits(event_group, STOP_BIT, pdTRUE, pdTRUE, portMAX_DELAY);
#if CONFIG_EXAMPLE_SEND_MSG
const char *message = "Welcome to ESP32!";
ESP_ERROR_CHECK(example_send_message_text(dce, CONFIG_EXAMPLE_SEND_MSG_PEER_PHONE_NUMBER, message));
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));
}
In my main function (main.c) I run the following function:
void app_main()
{
for(int i=0; i<5; i++){
vTaskDelay( 20000 / portTICK_PERIOD_MS );
pppos_init();
}
}
The first time (i=0) i can see "Modem PPP Started" and all data are sent via MQTT. At the second time (i=1) it stucks.
Any guidance will be helpful.
Thanks
The text was updated successfully, but these errors were encountered: