I am taking mqqt_simple of NRF9160 as reference for this question,
This is questing regarding, what is recommendation / Philosophy of using MQTT in NRF9160 with other codes e.g. sensor data or gps data or machine learning etc.
here is my understanding of how MQTT code loops works,
=========================================
Once connection is made to MQTT server, program will enter while loop and continuously poll for incoming data, as shown below.
err = poll(&fds, 1, K_SECONDS(CONFIG_MQTT_KEEPALIVE)); // for most of the time main loop will be stuck here.
This loop will timeout after CONFIG_MQTT_KEEPALIVE,during this time code will come out of poll section thus we can run other routines in the code.
In addition if you have interrupt routine, then also poll will exiting and during this time code in ISR and other code in main loop will run.
Multi-thread may be option but still the same result as thread running poll function will block other thread until it times out or ISR occurs.
My question is,
Code above works as provided but when MQTT code has to work will other section code , e.g. polling other sensor every second or some longer time consuming routing, then poll routine will block/consume most part of while loop time. So how to get round this problem.
Regards