What happens to the UART connection of Argon while the device try to reconnect to WI-Fi?

Hi Guys,

I am trying to upload some data from my sensor to particle cloud, for that I have cc1310 connected to argon via UART, however whenever the Argon looses wifi connection and try to reconnect the some of the data is lost, so is there a way to store data in Argon while it reconnects to Wi-Fi?

Thanks in Advance

Make sure you are using SYSTEM_THREAD(ENABLED). Without it loop() stops running when not connected to the cloud. With it enabled, loop() runs all the time.

1 Like

Thanks you for your reply rickkas7, I am using SYSTEM_THREAD(ENABLED) in my code still it misses data for 20 secs while reconnecting to Wi-Fi.

It’s possible that loop can be delayed for a period of time on the Argon in particular during connection. The best way to get around this is to handle the UART for a worker thread.

The SerialBufferRK library is an example of this. You don’t want to use the library itself, but rather copy out the code to create the thread and move all of your UART handling code in to the thread.

Make sure you don’t do things like Particle.publish from the worker thread, or that can end up blocking the worker thread.

1 Like

Thanks for your quick response.
In my case I am receiving data in every 3 seconds and transferring to Argon via UART so my question is while the Argon is searching for Wi-Fi will the data coming in that 20 seconds (almost 6 packets) get published or do I have to buffer it inside the thread?
Thanks in advance.

You should avoid doing a Particle.publish() when Particle.connected() is false. That will occur during connection, and is actually the most common cause of blocking the loop thread. If you don’t want to discard data during connection, you’ll need to buffer it somewhere, either in RAM or in the flash file system.

One option is to use the PublishQueuePosixRK library instead of directly calling Particle.publish. The library will buffer a few publishes in RAM (configurable), then will write them to the flash file system until connected to the Particle cloud.

3 Likes