lib/binarypacketdecoder.js
/**
 * Decode all the serial packets from the hex string.
 * @param {Buffer} data The binary packet as a buffer.
 * @param {String} origin Origin of the data stream.
 * @param {Number} time The time of the data capture.
 * @param {Object} options The packet decoding options.
 */
Decode all the serial packets from the hex string.
@param {Buffer} data The binary packet as a buffer.
@param {String} origin Origin of the data stream.
@param {Number} time The time of the data capture.
@param {Object} options The packet decoding options.
Decode all the serial packets from the hex string . @param { Buffer } data The binary packet as a buffer . @param { String } origin Origin of the data stream . @param { Number } time The time of the data capture . @param { Object } options The packet decoding options .
function decode(data, origin, time, options) {
  let raddecs = [];
  let isTooShort = (data.length < MINIMUM_FRAME_LENGTH);
  if(isTooShort || !isValidHuawei(data)) {
    return raddecs;
  }
  let receiverId = data.readUIntBE(3,6).toString(16);
  let numberOfTransmitters = data.readUInt8(11);
  let transmitterFrameIndex = 12;
  let timestamp = (options.timestampOnArrival ? time : null);
  for(let cTransmitter = 0; cTransmitter < numberOfTransmitters;
      cTransmitter++) {
    transmitterFrameIndex = decodeTransmitterFrame(data, transmitterFrameIndex,
                                                   raddecs, receiverId,
                                                   timestamp);
  }
  return raddecs;
}
function decode ( data , origin , time , options ) { let raddecs = [ ] ; let isTooShort = ( data . length < MINIMUM_FRAME_LENGTH ) ; if ( isTooShort || ! isValidHuawei ( data ) ) { return raddecs ; } let receiverId = data . readUIntBE ( 3 , 6 ) . toString ( 16 ) ; let numberOfTransmitters = data . readUInt8 ( 11 ) ; let transmitterFrameIndex = 12 ; let timestamp = ( options . timestampOnArrival ? time : null ) ; for ( let cTransmitter = 0 ; cTransmitter < numberOfTransmitters ; cTransmitter ++ ) { transmitterFrameIndex = decodeTransmitterFrame ( data , transmitterFrameIndex , raddecs , receiverId , timestamp ) ; } return raddecs ; }
Decode all the serial packets from the hex string.
Decode all the serial packets from the hex string .