The Toit documentation indicates that one of the advantages of the system is the simplicity and reliability of saving data received by the application from the sensors & etc on the cloud. There is even a special SDK for this. True, I did not find anything about this in the examples, so the question is: how to do this? Below is a small application that generates a list of numbers. I want to save it on the cloud. How update saveDataOnCloud procedure to solve the problem?
import math
getData points -> List :
list := []
period := 4*math.PI
step := period/points
for i := 0; i < points; i++ :
list.add (2*(math.sin i*step))
return list
saveDataOnCloud data/List :
log("save on cloud -> $data")
main :
data := getData 128
saveDataOnCloud data
To transfer the data to the cloud in would use the PubSub library to transfer the data and json to encode it:
saveDataOnCloud data/List:
pubsub.publish "cloud:myPoints"
json.encode data
Then you can fetch it using the GRPC PubSub API: https://github.com/toitware/api/blob/master/proto/toit/api/pubsub/subscribe.proto
Note: toit does not offer long-term storage but only transient transfers of data to/from your devices and server applications.