Skip to content

The Development Process

To get started, you first need to determine which of the two connections you want to use:

  • either CAN,
  • or UART

Next, if either of both has been chosen, you need to establish the connection between your device and the Cloud Module ☁️. Then, When everything is up and running, you should be able to configure the data set you want to send to the cloud. At last, you are able to send your data to the cloud by sending one last message to the Cloud Module ☁️. You should now be able see your data in the Cloud Studio App 📟!

Cloud Studio 📟 Access

With the purchase of your first Cloud Module ☁️, you will also receive access the Cloud Studio 📟 Dashboard. For this, you will receive two accounts: one supervisor, and one device account.

The supervisor account matches your personal email address, and is intended to access the App 📟 through a browser. You will get an invite over email to create this account.

The device account is intended to be used by the Cloud Module ☁️ to store your data into a Collection 🪣. Instead of using an email and password combination, it will be using an access token to verify access to the App 📟. In addition to the URL, you need both the Collection 🪣 and the access token to create the connection string, which you need to provide to the Cloud Module ☁️. Below you can find an example of such a connection string:

yaml
dashboard:
  url: https://example.dev
  collection: telemetry
  access-token: DoT
  connection-string: https://example.dev/items/telemetry?access_token=DoT

Establish the Connection

To establish the connection, you need to make sure to use the proper configuration for each of the communication interfaces:

yaml
CAN:
  bitrate: 500000
  extended-id: false

UART:
  baudrate: 115200

At boot-up, the Cloud Module ☁️ will inform your device whether the system is ready for use by sending a message over CAN; the CAN communication is properly established if you're able to receive this message.

WARNING

Receiving handshake messages from the Cloud Module ☁️ is yet to be supported for the UART communication; the feature is included in roadmap.

Configure Your Data

The Cloud Module ☁️ makes use of the custom Toast markup language 🍞 to configure the data send to the cloud. The easiest way to configure your data is by making use of the Cloud Module SDK, which you can include into your project as a single header file. let's first focus on the data we want to send. The Cloud Module will make use of the API provided by the App 📟. The API expects a JSON object which matches the fields described by your Collection 🪣. For our example, let's assume that we have two fields: one for the current called cur, and one for the voltage called volt. The body of the API required to add new entries to your Collection 🪣 looks something like this:

json
{
  "cur": 42, /* current */
  "volt": 6.9 /* voltage */
}

Any Toast 🍞 object can be parsed to a JSON object, and vice versa. This property is reflected in the Cloud Module SDK. If you want to construct a Toast 🍞 configuration object, you can equally thing about constructing a JSON one. The SDK provides you with methods like Add() to add a JSON key-value pair. For our example, the main.c file could look something like this:

c
/* Include the Cloud Module SDK. */
#include <cloudmodule.h>

/* Make sure the cloudmodule structure is declared. */
CloudModule cloudmodule = CloudModule();

/* Provide a custom interface to send a CANOpen or UART message. */
void SendCan(uint16_t index, uint8_t subindex, uint32_t data) {
  /* TODO by you. */
}

/* Some example data. */
static uint32_t current = 42;

int main(void) {
  /* Initialise the Cloud Module. */
  const CloudJson *json = cloudmodule.InitCan(SendCan);

  /* Provide the connection string to the Cloud Module */
  json->SetUrl("https://example.dev/items/telemetry?access_token=AbcD")

  /* Optionally, you can keep store a reference of a value to change it later. */
  uint16_t ref = 0;

  /* Provide the data set to the Cloud Module. */
  json->Add("volt", 6.9)
      ->Add("cur", current, &ref);

  /* Send data to the cloud every five minutes. */
  while(true) {
    
    /* you can change a value by using the Change method. */
    json->Change(ref, ++current);

    /* Finally, you can upload the data to cloud by calling the Upload method. */
    json->Upload();

    wait_sec(300);
  }
  return 0;
}

The moment the line json->upload() has passed, is also the moment the data is send to the cloud. If you now visit the App 📟 using your supervisor account, you should be able to see the data in the telemetry Collection 🪣.

Congratulations, your device is now connected to the cloud! 🎉