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?
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.
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.
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.