I’m trying to understand how the tinker app works across the system.
From reference, the function can be called by POST /v1/devices/{DEVICE_ID}/{FUNCTION}.
Particle.function(“FUNCTION”, funcName);
I got confused.
There are 3 parts in the whole system --> Photon, Particle Cloud, Android phone client.
Android phone client POST /v1/devices/{DEVICE_ID}/{FUNCTION}.
Particle Cloud server get the request, and send a query request to Photon via MQTT?
Photon should have a server running to listening for the request from Cloud server?
I’d like to read the source codes in Photon firmware, Cloud server app and Android client app. I’ve already got and am reading Photon firmware, couldn’t find a clue how the Photon sensor data got sent to Cloud.
The Particle Cloud does not use MQTT. They use a protocol that runs over CoAP, on TCP for Photon and UDP for Electron. That protocol enables a RESTful interface to the cloud with HTTPS GET requests for variables, POST requests for functions, SSE events for published events. The Particle Cloud is optional with Particle devices so you can choose to use it or not.
Tinker is an example application that allows Particle functions and variables to control the GPIO pins on devices. Once you write your own code, it replaces Tinker on your device and you stop using Tinker. Tinker is also a “known good” application for your device that help you find connection issues, etc. You can always reflash Tinker if you need it.
The iOS and Android apps are there to (1) help setup new Particle devices and (2) let you use the Tinker application for examples and (3) learn from the open source code that makes them up. Once your devices are online and setup, you don’t use the iOS and Android apps as much. Once your device is running code that you wrote instead of Tinker, the specific Particle functions and variables that Tinker provides are no longer present, so these are not really useful except as learning vehicles and for checking device status.
The cloud connection is initiated from the device (Photon or Electron or RPi) over CoAP. There is a then a more-or-less continuous connect between device and cloud until your code turns it off. I say more-or-less because Electron over UDP works is a slightly different way trying to minimize cellular data usage. There is not a server per se on the device since the device initiates the connection and I could call the cloud the server and device the client. On Photon there is a continuous TCP connection when the device is connect to the cloud, indicated by the main RGB LED breathing cyan, but you can control the cloud connection–use it or not, disconnect and reconnect as you like.
The best way to learn about these devices is to use them. I am sensing that you don’t have one yet and I would say that a Photon is a small investment to learn about these technologies.
@bko Thanks very much, I just bought a photon, I ran tinker app and other example apps already. Trying to read the firmware codes to understand what’s going on underneath now,