Show:
Defined in: src/device.js:4
Module: Hive

Device class.

Represents a the current device running the code.

Constructor

Device

()

Defined in src/device.js:4

Methods

executeAction

(
  • label
)
Object

Defined in src/device.js:74

Execute an action given a label

Parameters:

  • label String
    • the Measurement label to post.

Returns:

Object:

the result of executing the action.

postMeasurement

(
  • label
  • base
  • data
)
Object

Defined in src/device.js:89

Post a measurement to the Hive Server.

Parameters:

  • label String
    • the Measurement label to post.
  • base String
    • the url to the Hive server.
  • data Object
    • the data to be posted like { name: ..., value:... }.

Returns:

Object:

the response from the API.

registerAction

(
  • label
  • action
)
Array

Defined in src/device.js:53

Register an action by the device

Parameters:

  • label String
    • the Measurement label to post.
  • action Function
    • the action to be carried out on the device action label, with an optional input argument, (input) => {}.

Returns:

Array:

the list of all current actions.

registerMeasurement

(
  • label
  • base
  • interval
  • action
  • callback
)
Array

Defined in src/device.js:22

Register a measurement taken by the device

Parameters:

  • label String
    • the Measurement label to post.
  • base String
    • the base URL of where to post.
  • interval Number
    • the interval to execute the measurement at.
  • action Function
    • the action used to calculate the measurement (must return a valid {@link Measurement}).
  • callback Function
    • the callback to execute after the measurement has been posted.

Returns:

Array:

the list of all current actions.