Module: decoding

Provides a generic decoding interface into which multiple decoding profiles may be hooked. Implemented profiles are lora-serialization, sensebox/home, debug
License:
  • MIT
Source:

Methods

(private, inner) bufferToMeasurements(buffer, bufferTransformer) → {Array}

Decodes a Buffer to an array of measurements according to a bufferTransformer
Parameters:
Name Type Description
buffer Buffer the data to decode
bufferTransformer Array defines how the data is transformed. Each element specifies a transformation for one measurement.
Source:
Returns:
decoded measurements
Type
Array
Example

Interface of bufferTransformer elements

{
  bytes: Number,        // amount of bytes to consume for this measurement
  sensorId: String,     // corresponding sensor_id for this measurement
  transformer: Function // function that accepts an Array of bytes and
                        // returns the measurement value
  onResult: Function    // hook that recieves the all decoded measurements
                        // once decoding has finished. may modify the
                        // measurement array.
}

(inner) decodeBase64(base64String, box, timestampopt) → {Promise}

proxy for decodeBuffer, which converts the input data from base64 to a buffer first
Parameters:
Name Type Attributes Default Description
base64String String
box Box
timestamp String <optional>
new Date()
Source:
See:
Returns:
Once fulfilled returns a validated array of measurements (no actual async ops are happening)
Type
Promise

(inner) decodeBuffer(buffer, box, timestampopt) → {Promise}

Transforms a buffer to a validated set of measurements according to a boxes TTN configuration.
Parameters:
Name Type Attributes Default Description
buffer Buffer The data to be decoded
box Box A box from the DB for lookup of TTN config & sensors
timestamp String <optional>
new Date() Timestamp to attach to the measurements.
Source:
Returns:
Once fulfilled returns a validated array of measurements (no actual async ops are happening)
Type
Promise