Skip to content

An OpenPicus Flyport - EVRYTHNG API integration library (HTTP)

Notifications You must be signed in to change notification settings

evrythng/evrythng-openpicus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

EVRYTHNG API - OpenPicus Flyport integration.

With the EVRYTHNG API wrapper for Open Picus you can easily integrate the EVRYTHNG platform in your Open Picus applications!

Installation

To use the wrapper, add the content of openpicus-evrythng-libs to your project as external libraries.

Services Selection

From the Open Picus Services (configured through the network wizard in the IDE) you must include at least the following:

  • DHCP Client
  • RTCC library
  • SNTP Client

SSL

The library uses SSL to communicate with the EVRYTHNG API. Remember to configure your Open Picus project to support SSL. SSL Configuration

Included libraries


Usage

The EVRYTHNG wrapper for Open Picus is based on a set of structures and functions that let you invoke the EVRYTHNG engine API easily from the Open Picus code.

More info about the full API and response codes can be found here.

Currently we support the following functionality out of the box:

Timestamps

To be able to use timestamps in the format needed by the EVRYTHNG engine (epoch milliseconds), you need to initialize first the timestamp library. Just call the initializeTime method with a parameter defining how many hours to add to the GMT +0 standard zone (summer time should be considered too). You need to do this only once.

//To configure GMT+1 zone
int GMT_add_hours = 1;

initializeTime(GMT_add_hours);

//API CALLS
....

Get Properties of Thngs

Retrieves the last update of a property value of a Thng.

Property property;
    
int responseCode = evt_GetPropertyValue("YOUR API KEY", "YOUR THNG ID", "YOUR PROPERTY NAME", &property);
    
if (responseCode == 200)
{
    //Property was read successfully, values can be read from the property struct
}
else
{
    //Check response code for error
}

Update Properties of Thngs

Updates a property value of a Thng.

Property property;
property.value = "10";
property.timestamp = atof(getTimeStamp());
    
int responseCode = evt_UpdatePropertyValue("YOUR API KEY", "YOUR THNG ID", "YOUR PROPERTY NAME", &property);
    
if (responseCode == 200)
{
    //Property was updated successfully
}
else
{
    //Check response code for error
}

Post actions on Thngs

For predefined actions, you can use:

  • ACTION_CHECKINS
  • ACTION_SCANS
  • ACTION_IMPLICIT_SCANS

to set the predefined action types or use your own for custom actions.

Action checkinAction;
//
checkinAction.type = ACTION_CHECKINS;
checkinAction.thng = "YOUR THNG ID";

int responseCode = evt_PostAction("YOUR API KEY", &checkinAction);

if (responseCode == 201)
{
    //Action was posted successfully
}
else
{
    //Check response code for error
}

Get last action on Thngs

Retrieves the last action performed on a thng.

Action lastAction;
lastAction.thng = "YOUR THNG ID";
    
int responseCode = evt_GetLastAction(API_KEY, &lastAction);

if (responseCode == 200)
{
    //Action was read successfully, values can be read from the action struct
}
else
{
    //Check response code for error
}

Test application

You can find a test application on how to use the functionality of the wrapper in the test-app folder.

About

An OpenPicus Flyport - EVRYTHNG API integration library (HTTP)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published