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

konova
Posts: 3
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: 90
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).

User avatar
xvinny
Posts: 12
Joined: Wed Aug 16, 2017 1:15 pm
Location: Curitiba, Brazil

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)?
___________________________________________________________________________________________________________________________
Tell me if you knows how to use the Programmer module of Windows Calc and I'm gonna say who you are.

markwj
Posts: 90
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: 2
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: 8
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.

User avatar
xvinny
Posts: 12
Joined: Wed Aug 16, 2017 1:15 pm
Location: Curitiba, Brazil

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.
___________________________________________________________________________________________________________________________
Tell me if you knows how to use the Programmer module of Windows Calc and I'm gonna say who you are.

markwj
Posts: 90
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.

mr1000
Posts: 23
Joined: Fri Jan 12, 2018 9:05 am

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

Postby mr1000 » Mon Jul 23, 2018 7:58 am

Hi all, first of all want to say thanks to loboris for the example, it helped me a lot.

For now I could connect to internet for almost 24h without the module getting disconnected, the thing is when it disconnects it doesn't call the callback so the FSM doesn't continue and the program gets stuck.

Also, I have tried to remove the SIM card while the module is connected just to see 'what happens', I see the follow:
-Module registration goes off (led_wwan# turns off)
-The task which send POST to a server returns: "mbedtls_net_connect returned -52" which is * (see below)
-Can't see the callback being called neither

So why could ppp layer not be detecting the disconnection?
I initialize ppp layer like loboris example. Am I missing something?

Any advice or workaround I can try will be much apreciated.
Thanks in advance.

*

Code: Select all

#define MBEDTLS_ERR_NET_UNKNOWN_HOST                      -0x0052  /**< Failed to get an IP address for the given hostname. */

drbomb
Posts: 3
Joined: Mon Oct 16, 2017 1:41 pm

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

Postby drbomb » Sat Jul 28, 2018 1:01 am

markwj wrote:
drbomb wrote:Is it possible to put the PPPoS connection in "Hold" while I send AT commands to the modem? I know I can escape the PPP interface with the <pause>+++<pause> sequence, but I'd like to be able to send the AT command and resume the PPPoS stack.
We're using SIM5360 and the GSM MUX functionality. This allows us to create virtual comm ports to the SIMCOM modem, with each COM port doing a different function. So, we can have GPS/GNS NMEA streaming in on one, PPP on another, SMS on a third, and a fourth for general AT commands.

Our code is still very unpolished, but you are welcome to see it here:

https://github.com/openvehicles/Open-Ve ... simcom/src
Wow! I didn't know about this MUX protocol, very cool thanks!

Who is online

Users browsing this forum: No registered users and 6 guests