Hello Devanand!
On Thu, 2019-05-16 at 20:41 +0530, Devanand Biradar wrote:
I have connected to mosquito cloud using Lwip via MQTT.
Using PPPOS with GSM module.
Yes, I know this can be done, because I already have done it and it
works (; But now I would like to make it more error-proof and
responsive - my code so far is just a dirty proof-of-concept using
stupid things like global flags and polling.
So what I'm asking is this - is it safe to have code like this:
// this function is registered via pppapi_pppos_create(...)
// it is executed from within lwIP's TCP/IP thread
void pppLinkStatus(ppp_pcb* pcb, int errorCode, void* context)
{
if (errorCode == PPPERR_NONE) // PPP is connected successfully?
mqtt_client_connect(...);
else // PPP connection is lost
mqtt_client_disconnect(...);
}
The alternative is - for example - to call mqtt_client_connect(...)
until it succeeds (including the last phase done in the MQTT's connect
callback) periodically, for example every 10 seconds. However - if
possible - I would prefer the first version, more "event based" and not
requiring a thread that would have to monitor that.
Regards,
FCh
_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users