Trndi - CGM Data on Desktop & Raspberry Pi

API Support

Trndi supports multiple backends via its API specification.

The TrndiAPI

Location: units/trndi/api/trndi.api.pp

TrndiAPI is the base class that API drivers inherit. Each API driver must implement:

Constructor

constructor create(user, pass, extra: string);

Trndi always passes user and pass. extra defaults to empty unless needed.

Connection

function connect: boolean;

Establish connectivity and perform any initial probing.

Getting data

function getReadings(minNum, maxNum: integer; extras: string = ''): BGResults;

Advanced overload (used by the base class and some drivers):

function getReadings(minNum, maxNum: integer; extras: string; out res: string): BGResults;

This variant also returns the raw response via res.

If these three functions are provided, the API driver will work.

Native

TrndiNative provides platform-specific features under a common API. It’s often used for HTTP(S) so requests run via native APIs (WinHTTP, NS, etc.) instead of third-party libs.

Call inherited; in your constructor. You’ll have access to the native field.

Set a user agent and base URL in your constructor:

baseUrl := 'https://service.net/API/';
ua := 'Uploader/3.0.2.11 Darwin/14.0.0';

Request

request makes an HTTP/S request.

function request(const post: boolean; const endpoint: string;
  const params: array of string; const jsondata: string = '';
  const header: string = ''): string;

Properties

You should set these thresholds (see CGMCore):

Helpers:

Utility functions:

Summary

Inherit TrndiAPI, implement create, connect, and getReadings. Use the native helper for HTTP.