Skip to content

Latest commit

 

History

History
150 lines (105 loc) · 5.3 KB

CC3200.md

File metadata and controls

150 lines (105 loc) · 5.3 KB

Using iobeam on TI CC3200

iobeam is a data platform for connected devices.

These instructions are about connecting to the iobeam Cloud on the Arduino platform. For more information on the iobeam Cloud, please read our full API documentation.

Please note that we are currently invite-only. You will need an invite to generate a valid token and use our APIs. (Sign up here for an invite.)

Before you start

Before you can start sending data to the iobeam Cloud, you'll need a project_id and project_token (with write-access enabled) for a valid iobeam account. You can get these easily with our command-line interface tool.

You'll also need to setup the Code Composer Studio (CCS) development environment for the TI CC3200.

Installation

This library has been designed to work with CCSv6.

First, you'll want to clone this repo into your workspace for CCSv6:

git clone https://github.com/iobeam/iobeam-client-embedded.git iobeam

You'll then want to make sure your project has that directory listed in its include search path. Then you can include the library:

#include "include/cc3200/iobeam.h"

Getting Started

This section deals with actually writing a program using the iobeam library, including configuring the client for your project, initializing the client and registering the device, and sending data.

Not covered in this README are how to setup your device to connect to the network -- TI offers instructions in their Getting Started guide and that is outside the scope of this document.

Project configuration

As mentioned above, you'll need a project_id and project_token to send data to iobeam. We will assume you have signed up and gotten those via the CLI. Now, you'll want to set some useful constants for iobeam:

const char *PROJECT_TOKEN = ...;  // your `project_token`
const uint32_t PROJECT_ID = ...;  // your `project_id`
const char *DEVICE_ID = NULL;

// if you pre-registered a `device_id` using the CLI:
// const char *DEVICE_ID = ...;

These constants will be used the iobeam client to communicate with our servers and match your data to the correct project. The only two that are required are PROJECT_TOKEN and PROJECT_ID.

DEVICE_ID can be set to NULL meaning you will register the device from our client API. If you've registered for a device id using the CLI, you can fill it in and skip the registration step.

Initializing and registration

Once you are ready to start using the iobeam client in your code (e.g. in your main() function), you'll need to initialize it with your credentials. At this point the device should be connected to the network so it can reach the iobeam cloud.

Your initialization will look something like this:

Iobeam iobeam;  // iobeam client object
iobeam_Init(&iobeam, PROJECT_ID, PROJECT_TOKEN, DEVICE_ID);
iobeam.RegisterDevice();  // optional if DEVICE_ID is non-NULL
iobeam.StartTimeKeeping();  // optional

First you create a Iobeam struct that exposes our client API. You initialize it with your credentials by passing them to iobeam_Init(). These are the credentials you defined in the previous step.

After initializing, we register the device with our service. This step is not needed if you specified DEVICE_ID previously; otherwise, one will be created and set for you.

Finally, StartTimeKeeping() has the iobeam client approximate itself to global time by contacting the iobeam cloud for the current time. This is only necessary if you are interested in your timestamps being expressed relative to global time. This method is a rough approximation so if you need something more precise, you will have to manage and provide timestamps with your data yourself.

Now we're ready to start sending data.

Sending data points

Sending data to the iobeam cloud is very simple:

uint64_t timestamp = ...;
int intData = ...;
double floatData = ...;

// if iobeam is handling timestamps:
iobeam.SendInt("series1", intData);
iobeam.SendFloat("series2", floatData);

// if you are providing timestamps:
iobeam.SendIntWithTime("series1", timestamp, intData);
iobeam.SendFloatWithTime("series2", timestamp, floatData);

The data you can send can either be an integer or a floating type. If the client is tracking time for you, you use SendInt() to send integral data and a timestamp will be transparently set; similarly use SendFloat() for float/real data.

If you are tracking timestamps yourself, you can provide them with alternate forms of the above functions called SendIntWithTime() and SendFloatWithTime().

Full Example

Here's the full source code for our example:

#include "include/cc3200/iobeam.h"
// [other includes and setup here]

const char *PROJECT_TOKEN = ...;  // your `project_token`
const uint32_t PROJECT_ID = ...;  // your `project_id`
const char *DEVICE_ID = NULL;

...

void main() {
	// iobeam initialization
	Iobeam iobeam;
	iobeam_Init(&iobeam, PROJECT_ID, PROJECT_TOKEN, DEVICE_ID);
	iobeam.RegisterDevice();
	iobeam.StartTimeKeeping();

	int intData = ...;
	double floatData = ...;

	// if iobeam is handling timestamps:
	iobeam.SendInt("series1", intData);
	iobeam.SendFloat("series2", floatData);    	
}