Please delete the other topic that I created: mbedTLS on ESP8266 RTOS SDK - multithreading - processor reseting
I 'm testing the ESP8266 RTOS SDK (which uses freeRTOS), latest version, which includes mbedTLS. I am working with Firebase database. I am able to do these things correctly using mbedTLS:
(1) connect to the host with a persistent sock and keep listening for changes inside a given resource.
(2) write data to a given resource of the same database.
Both these things are only working separately. I did one task for each purpose and I can only create only one of the tasks at the main(), if I create both tasks the processor keeps reseting.
My plan is to be able to keep a socket open to keep monitoring (1), when needed, be able to write (2), I want both thing can wok in parallel.
On config.h MBEDTLS_THREADING_C and MBEDTLS_THREADING_PTHREAD are defined.
I have made mbedtls_ssl_config conf; global, and I only call mbedtls_ssl_config_init(&conf); one time in setup of main. That is, I am using an unique conf for both tasks.
Here is my current code: https://github.com/jefersonpehls/esp8266_freeRTOS_firebase/blob/master/https_mbedtls_firebase_v2.c
I want to use mutiple instances of mbedTLS as HTTPS client. As I was reading on web about this, I will need to use mutexes, in which places of my code I will need to add these mutexes?
Based on the code above, I edited it in order the following structs be shared between the tasks, to not declare one on each task:
But anyway, the code only works if I create just one of the tasks (or just monitor task or just write task). Creating both makes the processor stay resetting.
If you want you can check it here: https://github.com/jefersonpehls/esp8266_freeRTOS_firebase/blob/master/https_mbedtls_firebase_v3.c
Which resources of mbedTLS are making my program crash?