Hi,
After you do a successful TLS handshake between the peers, you send \ recv application data between them.
mbedtls_ssl_write()
and a correspondingmbedtls_ssl_read()
are the the public API that you call to send\recv data to\from the peer. Internally, they encrypt \ decrypt the data with the TLS session key, and call the callbacks you have set.
OK, it is perfectly clear, thanks.
I am afraid I hit the roadblock Paul warned me regarding ram usage. I am getting an error 0x7200 from mbedtls_ssl_handshake(&ssl)
.
Looking back at other users had similar issues and your response, I am stripping down the config.h per the mini-TLS 1.2 example and your article suggestion.
Another thing I noticed:
static int my_send(void *ctx, const unsigned char *buf, size_t len) {
HAL_UART_Transmit(&huart6, buf, len, 0xffff);
custom_print(len);
return len;
}
static int my_recv(void *ctx, unsigned char *buf, size_t len) {
UART6rxComple = false; /* is true when UART IDLE interrupt */
HAL_UART_Receive_DMA(&huart6, (uint8_t *) buf, len);
while (!UART6rxComple) { /* HACKS */ }
HAL_UART_DMAStop(&huart6); /* no more data in UART, stop DMA */
custom_print(len);
return len;
}
During handshaking, I am printing len
for both send and recv, and it is populated, something like 1kb (i think, i am currently trying to enable the debug feature with UART and i will retest) for sending and 5 bytes(!) for recv. I will try to increase the MCU-modem baudrate or maybe somehow give the modem some time to spit out data because I suspect that there is something asynchronously messing up the recv buffer contents. For anyone else’s reference, I am utilizing an IDLE line interrupt from the UART to catch end of data receive, with volatile bool UART6rxComple
toggling inside the IRQ IDLE callback. I can confirm that this modem, even for plain HTTP GET requests somehow transmits in UART the received data in chunks, e.g. one server response triggers two IDLE line interrupts.
I will write back further results.
Have a nice week,
Dimitris
edit: Let me add that until now, about 50% of my time with wrong configurations both on my host PC and on STM32, were because cmake cashes something (idk what) causing a new configuration to not load after compilations, expect if I also edit the source file as well or if I clear the cache