Better than a thousand hollow words is one word that brings peace.

Overview

Device

Device represents the physical hardware that are nodes on the network.

Device Model

Written in CoffeeScript

Device = {
  timestamp  : Number, # epoch timestamp in msec
  name       : String,
  mac        : String,
  private_key : String, # AES, unrelated to MAC.
  is_online  : Boolean, # true => online, false => offline
  is_paired  : Boolean, # true => paired, false => orphan
  gateway : Schema.Types.ObjectId, # point to the parent of this device
  user: Schema.Types.ObjectId, # point to the owner of this device
  is_frozen: {
    type: Boolean,
    default: false
  },
  coordinates: {
    # For mapping the devices on a map, for positioning applications
    x: {
      type: Number,
      default: null
    },
    y: {
      type: Number,
      default: null
    } 
  },
  type: {
      type: Number, # ENUM, 0 => none, 1 => person, 2 => property, 3 => sensor only
      default: 0
  },
  is_mobile : {
    type: Boolean,  # false => this device does not move around, so no need to be tracked.
    default: false
  },
  is_tracked : {
    type: Boolean,  # true => this device is tracked in bultrack in position. # false = not used for positioning.
    default: false
  },
  plot : {
    type: Schema.Types.ObjectId,  
    ref: 'Plot'
  },
  groups: [Schema.Types.ObjectId] #The various groups that the device belongs to.
}

List All User Devices

List devices of the user and the users's children

GET /api/1/devices/list/:userId

userId: user's ID

Authentication required: YES

RETURNS array of devices

List Stationary Devices

List stationary devices of the user

GET /api/1/devices/list/stationary/:userId

userId: user's ID

Authentication required: YES

RETURNS array of stationary devices

List Mobile Devices

List mobile devices of the user

GET /api/1/devices/list/mobile/:userId

userId: user's ID

Authentication required: YES

RETURNS array of stationary devices


Stream

Stream represents the time series database that keeps an ongoing record of data.

Stream Model

Written in CoffeeScript.

Stream = {
  timestamp_hour: Number   # epoch timestamp in msec indicating the start of the hour.
  cmd: String
  device:
    type: Schema.Types.ObjectId # links to the device.
    ref: 'Device'
  sensor:
    _id: String
    function_type: Number  # function of the sensor i.e. temp or illumination 0 => positioning
  sample:  #used for averaging
    total: Number 
    count: Number
  latest:
    timestamp: Number
    data: Schema.Types.Mixed
  timestamp_data:  
    #timestamp data contains min.sec.data: array of values; and (optional) min.sec.anchor: array of objectID for anchor points.
    '0':
      '0': Schema.Types.Mixed
      '1': Schema.Types.Mixed
      '2': Schema.Types.Mixed
      '3': Schema.Types.Mixed
      '4': Schema.Types.Mixed
      '5': Schema.Types.Mixed
      '6': Schema.Types.Mixed
  ...
}

List by User

Generates a list of data for the user

GET /api/1/streams/listByUser/:user_id

userId: user's ID

from_time: query start time in unix time in milliseconds.

to_time: query end time in unix time in milliseconds

Authentication required: YES

RETURNS array of stream objects, each cotaining an hour of data per sensor per device

List by Device

Generates a list of data for the device

GET /api/1/streams/listByDevice/:device_id

device_id: the device's ID

from_time: query start time in unix time in milliseconds.

to_time: query end time in unix time in milliseconds

Authentication required: YES

RETURNS array of stream objects, each cotaining an hour of data per sensor per device

Show Latest

Shows the latest data for a specific device

GET /api/1/streams/latest/:device_id

device_id: the device's ID

sensor_id: (optional) a sensor specific to the device

function_type: (optional) the sensor type that is attached to the device

Authentication required: YES

RETURNS an object containing the latest data

device: // device object
sensor:
  _id: // sensor id
  function_type: // sensor function type
latest:
  timestamp: // latest data timestamp
  data: // latest data

Plot

Plot represents and stores maps uploaded to the site.

Plot Model

Written in CoffeeScript.

Plot = {
  owner      : Schema.Types.ObjectId, # point to a user id.  
  name       : String,
  file       : String,                #holds the file.
  coordinates: {
    # For plotting the devices on a plot, for positioning applications
    top_left: {
      x: {
        type: Number,
        default: null
      },
      y: {
        type: Number,
        default: null
      }
    },
    bottom_right: {
      x: {
        type: Number,
        default: null
      },
      y: {
        type: Number,
        default: null
      }
    }
  }
}

List by User

Generates a list of plots for the user

GET /plots/list/:userId

userId: user's ID

Authentication required: YES

RETURNS array of plots, excluding the "file" field, so that it does not take forever.

Show by Plot ID

Generates a single plot file

GET /plots/:plot_id

plot_id: Plot's ID

Authentication required: YES

RETURNS an object of a single plot file, including the image uploaded in Base64 format.