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: Freddie Chopin
Subject: Re: [lwip-users] Can you connect a MQTT client directly from a PPPoS status callback?
Date: Thu, 16 May 2019 18:31:17 +0200
User-agent: Evolution 3.32.1

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




reply via email to

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