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

User avatar
Posts: 74
Joined: Wed Dec 21, 2016 7:40 pm

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

Postby loboris » Mon Mar 20, 2017 7:31 pm

This example uses the pppos patches proposed by amuzyka-grinn (
Until those patches are not pulled to esp-idf, you must patch your esp-idf. See instructions in

Before you run this example, make sure your GSM module is powered on, in command mode, registered to network and connected to your ESP32 UART on pins #16 & #17 (hw flow controll is not used, but can be easily enabled if desired).

The example demonstrates using lwip-pppos, sntp, http, https, cJSON ...:

  • Creates the pppos client task which initializes GSM modem on UART port and handles lwip interaction
  • When connection to the Internet is established, gets the current time using SNTP protocol
  • Creates http and https tasks synchronized with mutex
  • HTTP task gets text file from server and displays the header and data
  • HTTPS task gets ssl info from server and displays the header and received JSON data with info about used SSL
  • HTTP/HTTPS tasks repeats operation every 30 seconds
Tested with cheap ebay SIM800L module, should also work with SIMCOM, Telit or other GSM modules.

Sample terminal output:

Code: Select all

I (9200) [PPPOS CLIENT]:

I (9700) [PPPOS CLIENT]:

I (10200) [PPPOS CLIENT]:


I (10200) [PPPOS CLIENT]: AT+CGDCONT=1,"IP","web.htgprs"
I (10700) [PPPOS CLIENT]:

I (10700) [PPPOS CLIENT]: ATDT*99***1#
I (11200) [PPPOS CLIENT]:

I (11200) [PPPOS CLIENT]: Gsm init end
I (11200) [PPPOS CLIENT]: After pppapi_pppos_create
I (11200) [PPPOS CLIENT]: After pppapi_set_default
I (11200) [PPPOS CLIENT]: After pppapi_set_auth
I (11210) [PPPOS CLIENT]: After pppapi_connect, waiting
I (11870) [PPPOS CLIENT]: status_cb: Connected

I (11870) [PPPOS CLIENT]:    our_ipaddr  =

I (11870) [PPPOS CLIENT]:    his_ipaddr  =

I (11870) [PPPOS CLIENT]:    netmask     =

I (11880) [PPPOS CLIENT]:    our6_ipaddr = ::

I (12780) [SNTP]: Initializing SNTP
I (12780) [SNTP]: Waiting for system time to be set... (1/10)
I (14780) [SNTP]: TIME SET TO Mon Mar 20 15:54:08 2017

I (14780) [HTTP]: ===== HTTP GET REQUEST =========================================

I (15120) [HTTP]: DNS lookup succeeded. IP=
I (15120) [HTTP]: ... allocated socket

I (15340) [HTTP]: ... connected
I (15340) [HTTP]: ... socket send success
I (15340) [HTTP]: ... reading HTTP response...
HTTP/1.1 200 OK
Date: Mon, 20 Mar 2017 15:54:10 GMT
Server: Apache/2.4.7 (Ubuntu)
Last-Modified: Sat, 18 Mar 2017 17:32:44 GMT
ETag: "149-54b04ae918eb8"
Accept-Ranges: bytes
Content-Length: 329
Vary: Accept-Encoding
Content-Type: text/plain
Welcome to ESP32
The ESP32 is a low cost, low power microcontroller with integrated Wi-Fi & dual-mode Bluetooth,
which employs a dual-core Tensilica Xtensa LX6 microprocessor.
ESP32 is created and developed by Espressif Systems, a Shanghai-based Chinese company,
and is manufactured by TSMC using their 40 nm process.

2017 LoBo

I (21280) [HTTP]: ... done reading from socket. 581 bytes read, 581 in buffer, errno=22

I (21290) [HTTP]: Waiting 30 sec...
I (21290) [HTTP]: ================================================================

I (21300) [HTTPS]: Seeding the random number generator
I (21310) [HTTPS]: Loading the CA root certificate...
I (21320) [HTTPS]: Setting hostname for TLS session...
I (21320) [HTTPS]: Setting up the SSL/TLS structure...
I (22330) [HTTPS]: ===== HTTPS GET REQUEST =========================================

I (22330) [HTTPS]: Connecting to
I (22940) [HTTPS]: Connected.
I (22940) [HTTPS]: Performing the SSL/TLS handshake...
I (25400) [HTTPS]: Verifying peer X.509 certificate...
W (25400) [HTTPS]: Failed to verify peer certificate!
W (25400) [HTTPS]: verification info:   ! The certificate Common Name (CN) does not match with the expected CN

I (25410) [HTTPS]: Writing HTTP request...
I (25410) [HTTPS]: 102 bytes written
I (25420) [HTTPS]: Reading HTTP response...
I (26930) [HTTPS]: 5524 bytes read, 5524 in buffer
HTTP/1.1 200 OK
Content-Length: 5289
Access-Control-Allow-Origin: *
Connection: close
Content-Type: application/json
Date: Mon, 20 Mar 2017 15:54:19 GMT
Strict-Transport-Security: max-age=631138519; includeSubdomains; preload
I (26950) [HTTPS]: JSON data received.
I (26950) [HTTPS]: parsing JSON data:
given_cipher_suites = [Array] of 131 items
   + 128 more...
ephemeral_keys_supported = True
session_ticket_supported = True
tls_compression_supported = False
unknown_cipher_suite_supported = False
beast_vuln = False
able_to_detect_n_minus_one_splitting = False
insecure_cipher_suites = {Object}
tls_version = TLS 1.2
rating = Probably Okay
I (27000) [HTTPS]: Waiting 30 sec...
I (27000) [HTTPS]: =================================================================

User avatar
Posts: 74
Joined: Wed Dec 21, 2016 7:40 pm

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

Postby loboris » Tue Apr 25, 2017 6:25 pm

PPPoS support is now included in esp-idf.
No patches are necessary. GitHub repository updated.

Who is online

Users browsing this forum: No registered users and 1 guest