lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Can you connect a MQTT client directly from a PPPoS sta


From: address@hidden
Subject: Re: [lwip-users] Can you connect a MQTT client directly from a PPPoS status callback?
Date: Thu, 16 May 2019 19:51:45 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

Am 16.05.2019 um 18:31 schrieb Freddie Chopin:
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:

It's probably not safe as you risk calling back into modules that are
not reentrant. I don't know this for sure, just as a saftey measurement...

Maybe you could use tcpip_trycallback() from that callback?

Regards,
Simon


// 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]