STM32 + PPP + GSM + LwIp + TLS 1.2
Recently, I had to raise PPP to STM32 again.
The first part .
The task was complicated by the mandatory requirement to use TLS 1.2 and send data via MQTT.
Let me remind you that MQTT and TLS are above TCP ( google osi) .
A quick search returned a meager
Amazon FreeRTOS results table, a
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 soldered to the board (STM32F429).
His closest relative in the list was L475, under stm32l475_discovery, respectively.
They didn’t end with this, discovery uses WI-FI ISM43362-M3G-L44, he added difficulties in understanding the work.
A few days of dulling in the monitor. Almost no line of code. When the project was ported, TCP did not work as expected. I saw getting ip from hostname, establishing a connection, a few ack and server side break.
It wasn’t enough to simply replace the WI-FI API with the lwIp socket implementation.
Obviously, MbedTls didn’t work.
At some point I got confused and decided to look at the second option .
This idea turned out to be more successful.
The starting point was the B-L475E-IOT01 .
And then things went!
The code turned out to be 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.
Started a PPP session. Read readme in git of lwip itself, everything is pretty chewed up there .
The latest version of lwIP (2.1.2) shows noticeable improvements in PPP.
The whole point boils down to creating pcb, setting up authentication, and calling something similar:
ppp = pppos_create (& ppp_netif, output_cb, status_cb, ctx_cb_callback);
.
In the ctx_cb_callback callback, you should get the last PPP status in order to know when the connection is established and you can turn on the top level, or when a break occurred.
Then I turned on mbedTls log output and it turned out something like this:
This is of course already more interesting, but the cycle hung endlessly on handshakes. Some googling led to the advice to update the version of mbedTls to the latest.
After that I got what I wanted:
And of course, I was very pleased with the data that arrived in the aws admin panel:
The result of
TLS 1.2 on the microcontroller is real!
It is useful to use the latest library versions. Never give up, look for other directions if you are at a standstill :)