STM32 + PPP + GSM + LwIp + TLS 1.2

    Recently I had to raise PPP again on STM32
    First part

    The task was complicated by the requirement to use TLS 1.2 and send data on MQTT
    Recall that MQTT and TLS are above TCP (google osi)

    A quick search gave meager results table
    Amazon FreeRTOS
    very similar implementation from ST

    In the first version, there were about 10 different architectural platforms.
    As often happens, the chip has already been selected and sealed to the board (STM32F429)
    His closest relative on the list was L475, under stm32l475_discovery, respectively
    On this distinction did not end, WI-FI ISM43362-M3G-L44 is used in discovery, it added difficulties in understanding the work

    A few days of stupor in the monitor)
    Practically not a single line of code)
    When the project was ported, TCP did not work as expected.
    I have seen getting ip from the hostname, establishing a connection, several ack and server side disconnect

    A simple replacement of the API from WI-FI to the implementation of lwIp sockets was not enough
    Obviously MbedTls didn't work.

    At one point, I got confused and decided to look at the second variant
    This idea turned out to be more successful.

    B-L475E-IOT01 was chosen as a starting point
    And then it went!
    The code was much clearer
    The project is logically divided into two parts:
    — controller level (wifi, HAL, gpio, etc.)
    — AWS (Projects / Common / AWS)

    Removed all unnecessary
    Added my part from GSM and PPP
    Logged in a PPP session Read the readme in the git of lwip itself, everything is pretty chewed up
    The latest version of lwIP (2.1.2) shows improvements in PPP

    The whole point is to create a pcb, set the authentication and call something like this:
    ppp = pppos_create(&ppp_netif, output_cb, status_cb, ctx_cb_callback);

    In the ctx_cb_callback callback, you should get the latest PPP status to know when the connection is established and you can turn on the top level, or when a break has occurred

    Then I turned on the output of mbedTls logs and it turned out like this:

    This is of course more interesting, but the cycle hung endlessly on the handshake
    Some googling led to a tip to update the latest version of mbedTls

    After that I got what I wanted:

    And of course, I was very pleased with the data that came in the aws admin panel:

    TLS 1.2 on the microcontroller is real!

    Useful to use fresh versions of libraries.
    Never wait, look for other directions if you are at a dead end)

    Sorry for my bad english)

    Jetzt auch beliebt: