ESP32 with GSM modem - PPP over Serial (PPPoS) client example

konova
Posts: 1
Joined: Mon Mar 19, 2018 3:09 pm

Re: ESP32 with GSM modem - PPP over Serial (PPPoS) client example

Postby konova » Mon Mar 19, 2018 3:11 pm

Hello,

Same issue with me.

The uart_driver_install() function disallows anything above 128 bytes for Tx or Rx, the size of the hardware UART FIFOs.

Breakpoint error at line 803 in uart.c:

Code: Select all

//We have to read out all data in RX FIFO to clear the interrupt signal
while (buf_idx < rx_fifo_len) {
   p_uart->rx_data_buf[buf_idx++] = uart_reg->fifo.rw_byte;
 }
 

markwj
Posts: 82
Joined: Tue Mar 08, 2016 5:03 am

Re: ESP32 with GSM modem - PPP over Serial (PPPoS) client example

Postby markwj » Tue Mar 20, 2018 4:06 am

xvinny wrote:I'm using your code as a base for my application.
My project contains a ESP32 together with GPS and a SIM800L board.
The target is to do GPS tracking through Wi-Fi and 3G.
Is there some library that does the connection management, switching between GPRS and Wi-Fi (when the configured network is available)?

Best regards

Vinicius


An update. After much messing around, the solution we've come up with is to leave both interfaces up and to use lwip netif_set_default() to set the default interface based on priority. If you are using standard C sockets, you could alternatively bind() the outgoing socket to a particular IP (again based on interface priority order).

xvinny
Posts: 5
Joined: Wed Aug 16, 2017 1:15 pm

Re: ESP32 with GSM modem - PPP over Serial (PPPoS) client example

Postby xvinny » Wed Mar 21, 2018 3:10 pm

markwj wrote:
An update. After much messing around, the solution we've come up with is to leave both interfaces up and to use lwip netif_set_default() to set the default interface based on priority. If you are using standard C sockets, you could alternatively bind() the outgoing socket to a particular IP (again based on interface priority order).


Actually I do the control of the Wi-Fi and GSM interfaces following these steps:

1. I start up the WiFi interface with the default configs in STA mode
2. I start up the PPPOS interface (ppposInit), then it connects to the GSM network
3. I start up a WiFi scan in order to discover if my Wi-Fi network is available
4. If it is available, I disconnect the GSM (ppposDisconnect) and connect to my WiFi passing the SSID, password (esp_wifi_connect)
5. If I lose the WiFi connection (event SYSTEM_EVENT_STA_DISCONNECTED), I go back to the GSM connection (ppposInit) again.

How do I put both interfaces up in the same time and set which one is the default for (netif)?

markwj
Posts: 82
Joined: Tue Mar 08, 2016 5:03 am

Re: ESP32 with GSM modem - PPP over Serial (PPPoS) client example

Postby markwj » Thu Mar 22, 2018 1:28 am

xvinny wrote:How do I put both interfaces up in the same time and set which one is the default for (netif)?


Have a look here:

https://github.com/openvehicles/Open-Ve ... anager.cpp

Function OvmsNetManager::PrioritiseAndIndicate().

The approach we use is to iterate over the netif_list looking for wifi station 'st' or modem 'pp' interfaces, with wifi taking priority. Then call netif_set_default() on the one you want to be the default.

You need to call this function every time an interface changes state (up/down, etc).

Alternatively, if you are using sockets for outbound IP connections, you can bind() the socket (after creating it) to the wifi/modem IP (depending on priority and what is up).

somyob
Posts: 1
Joined: Tue Apr 03, 2018 2:59 pm

Re: ESP32 with GSM modem - PPP over Serial (PPPoS) client example

Postby somyob » Tue Apr 03, 2018 3:20 pm

@loboris, I had a look at your GITHub project https://github.com/loboris/ESP32-PPPOS-EXAMPLE, while looking for ways to use ESP32 to talk to AWS IOT via GSM Module (SIM800L). I already have the connectivity working in WiFi. I have been struggling to understand how to use your work in programming my ESP32 using Arduino IDE. Seems like I am a bit of a layman compared to most in this forum :) it will be of great help if you tell me how to create an Arduino IDE library out of your project, and how to use the library (may be in a sample code). In case am looking at the wrong GITHub project, do point me to the right one. Many thanks in advance!

Ansics
Posts: 5
Joined: Mon May 22, 2017 11:27 am

Re: ESP32 with GSM modem - PPP over Serial (PPPoS) client example

Postby Ansics » Fri Jun 29, 2018 5:36 am

What is the expected output of this PPPOS?
I have interfaced GSM module(from simcom) with ESP32 and ESP32 is in WIFI AP mode. I need internet access to devices which are connected to ESP.

xvinny
Posts: 5
Joined: Wed Aug 16, 2017 1:15 pm

Re: ESP32 with GSM modem - PPP over Serial (PPPoS) client example

Postby xvinny » Thu Jul 05, 2018 4:33 pm

Hi all,

I found some problems in the library.

It doesn't support you to disconnect (ppposDisconnect) and reconnect (ppposInit) later because it doesn't uninstall the serial driver. I've made a fix for this.
Another change is that I created a parameter ConnectionSettings for ppposInit in order to support APN, user and password as parameters.
In this way, your can change the SIM card of your system without the need to recompile the software. In my software, I set these settings in a config file in the microSD card. So the software loads these settings before initializing the pppos.

Using these settings before the compilation (like it's done actually) is not a good practice.

There is another fix that I did. The library doesn't support roaming connection. I changed it to support the AT+CREG? response CREG: 0,5.

I'm not going to post the code here because first I'd like to send the fixes to the lib developer.

markwj
Posts: 82
Joined: Tue Mar 08, 2016 5:03 am

Re: ESP32 with GSM modem - PPP over Serial (PPPoS) client example

Postby markwj » Thu Jul 05, 2018 11:43 pm

Ansics wrote:What is the expected output of this PPPOS?
I have interfaced GSM module(from simcom) with ESP32 and ESP32 is in WIFI AP mode. I need internet access to devices which are connected to ESP.


A wifi hotspot? What you would need is:

  • A router for messages going between the two interfaces.
  • To do Source NAT (changing source IP address of outgoing Wifi traffic to IP of PPPoS link, and possibly changing source port if a conflict with another connection arises)
  • Connection tracking for the above (to address source port conflicts)
  • Connection tracking helpers for the more complex protocols (FTP, for example)

The code for this is not in the current ESP-IDF framework and is non-trivial.

Who is online

Users browsing this forum: No registered users and 4 guests