Getting Started

This short guide explains how to get started with PSYGIG Mobility IoT SDK. Before you can start developing your IoT applications, you need to download and install the latest version of the SDK.

PSYGIG Mobility IoT SDK Download/Installation Guide

Quick Start

Stream live video from camera

With a simple command, low-latency video can be streamed live directly from a camera using the angelo command line tool.

angelo live

See angelo man page for a complete list of options.

Instrument your existing applications

Without modifying your existing source code, you can instantly add instrumentation and crash reporting capabilities to your application by using the psymon script to run your program. For example:

psymon "/path/to/your/app --arg1 --arg2 --arg3"

By default, psymon enables the most common instrumentation capabilities. To enable selective instrumentation, specify the instrumentation class with the appropriate option.

See psymon man page for a complete list of options.

Sample JSON output generated by psymon

Advanced Setup - Building your application with libpsyiage

The rich feature set of the PSYGIG Mobility IoT SDK can be fully exploited via the C/C++ SDK API. The API can be accessed by including a single header file and linking to the libpsyiage shared library.

Basic example: Collecting system resource metrics

This example enables period polling of system resource metrics and saves the data to a JSON file.

basic-example source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <psyiage/psyiagesdk.h>

int main(int argc, char **argv)
{
    psyiage_handle     pah;  // handle to psyiage instance
    psyiage_sink_cfg   sink; // output sink configuration

    int rc;

    const char* RESULTS_DIR = "results"; // directory to store the output JSON file
    const char* RESULTS_BASE = "sys"; // base filename of the output JSON file

    // Initialize instance
    rc = psyiage_init(&pah); // Ignore return code for simplicity sake

    // Add a file sink for logging metrics to JSON
    sink.type = PSYIAGE_SINK_FILE;
    sink.format = PSYIAGE_DATA_FORMAT_JSON;
    sink.file.dir = RESULTS_DIR;
    sink.file.basename = RESULTS_BASE;
    rc = psyiage_add_sink(pah, &sink);  // Ignore return code for simplicity sake

    // Enable polling of system resources every 500ms
    rc = psyiage_metric_enable_poll_system_resources(pah, 500);

    // Let it run for 15 seconds
    startts = time(NULL);
    endts = startts + 15;

    while (time(NULL) < endts)
    {
        millisleep(1000);
    }

    // We are done. Cleanup PSYIAGE instance.
    rc = psyiage_cleanup(&pah);

    return 0;
}

Building basic-example using gcc

To build basic-example, you need to link with the libpsyiage.so shared object

gcc basic-example.c -o basic-example -lpsyiage

Depending on where libpsyiage was installed, you may need to specify the location of the SDK’s header and library files. With GCC, use the -I and -L options respectively to achieve this.

gcc -I/opt/psygig/psyiage/include basic-example.c -o basic-example -L/opt/psygig/psyiage/lib -lpsyiage

Assuming PSYGIG Mobility IoT SDK was installed under /opt/psygig/psyiage

Building basic-example using cmake

A better alternative for building programs using PSYGIG Mobility IoT SDK is to use cmake, especially if you are developing for several platforms. Assuming the following folder structure:

basic-example\
   |- src\
   |   |- basic-example.c
   |- CMakeLists.txt

CMakeLists.txt file

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
cmake_minimum_required(VERSION 3.1)
project(basic-example)

# Add the source files to the binary
add_executable(basic-example src/basic-example.c)

# Add the psyiagesdk.h folder to include path
target_include_directories(basic-example PRIVATE /opt/psygig/psyiage/include)

# Link the libpsyiage.so folder to the binary
target_link_libraries(basic-example /opt/psygig/psyiage/lib/libpsyiage.so)

Assuming PSYGIG Mobility IoT SDK was installed under /opt/psygig/psyiage

The following sequence of commands create a directory for building (avoid building in the source folder), builds basic-example with cmake and then runs the program:

mkdir build
cd build
cmake ..
make
./basic-example