Hi,
I have begun working on concepts for firmware design. I am trying to understand how Particle.function()
and Particle.subscribe()
works in the background.
Are calls from the Cloud being executed asynchronically through the FreeRTOS on the Particle Device? I am working with Serial and multiple clients can access the Device. Currently there are two concepts:
-
Having a Cloud services in the Background that acts as a gateway between multiple clients and the Particle Device. When a client requests data from the device or runs a command on the device it will be queued by the gateway so that only one active connection will be made to the particle device.
-
Since working with Serial on the Device I am using
WITH_LOCK(Serial)
on the device to make sure that a call / request will only access serial when it’s not already being accessed.
No. 2 is by far the most elegant since this does not require an additional background server running that gateway. BUT …
This means that both Particle.function()
and Particle.subscribe()
will be called asynchronically. Is this the case? I cannot find any info in the docs!
Thanks,
Simon
EDIT:
I was just thinking that maybe the Particle Cloud Backend is already acting as a Gateway. This is the case when multiple clients to subscribe to an event published by a device.
But what happens when multiple clients call a function on a device and this function has blocking code? Is this function executed asynchronically or does the Particle Cloud Backend queue this call up?
And what happens when a device subscribes to a topic that is being publish by multiple devices? Is this also being executed asynchronically?