I’m implementing a project using Arduino. The project is based on encrypted UDP communication (DTLS). By default, DTLS functionality is not available in Arduino. My question is how to proceed step by step to rebuild the framework with this functionality and then compile my project with this new available functionality?
Configuration options for mbedtls are put in the file esp_config.h. You can either directly enable the mbedtls macros or their surrounding config macros.
So the first thing to try would be to add build_flags = -D CONFIG_MBEDTLS_SSL_PROTO_DTLS to the platformio.ini and see if you can compile a firmware which uses DTLS functions. E.g., activating that CONFIG_ macro should make the function mbedtls_ssl_conf_dtls_anti_replay() available so a simple code like
Ok, I checked it out.
At first the compilation indicated an error: no reference to the indicated method.
Only after rebulid using ESP-IDF tools did the error disappear and the project began to compile.
However, another problem arose after calling the method: mbedtls_ssl_handshake
debug indicates this method’s error (-28928) and interception of communication from mbedtls_ssl_send_t indicates that even Client Hello was not generated.
Ok what exactly did you execute to rebuild it “using ESP-IDF tools”?
This is -0x7100 and indicates bad input data.
What is exactly the test firmware and against which server are you talking about? Note that the CONFIG_MBEDTLS_SSL_PROTO_DTLS will generate a ClientHello which wants a HelloVerifyRequest. If your server sends something else you get that error.
If you do not want that then you musn’t use the CONFIG_ macro but instead the direct collection of mbedtls macros, e.g.
Uh, I may be mistaken, but as far as I understand, ESP-IDF framework is precompiled in Arduino framework. To recompile ESP-IDF with new settings, you need to use Arduino as ESP-IDF component. More info can be found in this issue.
The relevant lines in your platformio.ini should read: