We're using LTE to communicate somewhat large data packets over MQTT, and we'd like to build in some robustness in case the link goes down or a publish fails to receive an acknowledgment. We have several questions:
1. We use lte_lc_init_and_connect() to attach to LTE, which seems to work fine. What command should be used to disconnect? It seems there are functions called lte_lc_offline(), lte_lc_power_off(), and lte_lc_normal() - what do each of these do? We would need to be able to reconnect after disconnecting, at least at some point.
2. Is there a command to tell if we were disconnected somehow from LTE without having called a function from the above answer? We've noticed a power supply current spike every second or so, and we're assuming that this is some sort of automatic ping. Right now our software would never reconnect on a drop since it can't determine if the link is currently valid. We're certainly comfortable issuing some sort of AT command for this if possible, every second or so. Also, what do lte_lc_psm_req(...) and lte_lc_psm_get(...) do?
3. If we never receive an MQTT_EVT_PUBACK after a publish, what should we do? After a delay, should we reattempt the publish, or disconnect from MQTT and try to reconnect/republish? Would this answer be different if using QoS 2? We can't seem to find any "publish failed" indications besides the lack of an ACK over time.
4. Can we call mqtt_client_init(...) and broker_init() again, when we decide to reconnect, using the same mqtt_client variable if we've called mqtt_disconnect(...) on it prior to that? Is there any situation where either of these three functions could cause a hang/crash, besides simply passing a NULL to them, such as if the LTE link is down? (We did experience a hang while connecting with a non-released software base newer than v1.0.0 due to a semaphore, but it seems from Gitmemory that it's been resolved.)
5. Is it problematic to call mqtt_disconnect(...) after already receiving MQTT_EVT_DISCONNECT if that were to happen somehow accidentally? Will we ever get this latter event if we hadn't called mqtt_disconnect(...) first, say if the server kicks us off (if that's possible)? What would mqtt_disconnect(...) return if the connection was lost, or if it's already been called? Also, is there ever a chance we wouldn't receive MQTT_EVT_DISCONNECT after calling mqtt_disconnect(...), and if so, what would be the best course of action (and likewise, for connecting)?
6. Will mqtt_disconnect(...) ever get called, or equivalently, from any other internal code besides ours? If the LTE or MQTT connection drops for any reason, is it safe to rely on a loop such as the main() "while(1)" in the mqtt_simple sample to detect it and break out? Under what circumstances would it break due to the poll(...) and mqtt_live(...) functions? We suppose "no news is bad news" when it comes to these sorts of protocols, and the only way either side knows that the link is still open is via a ping or a message, but we just wanted to make sure.
We're hoping at least some of this will assist other users as well. Thanks in advance!