lib/binarypacketdecoder.js
/**
 * Decode a single transmitter frame from the given buffer and offset.
 * @param {Buffer} data The binary packet as a buffer.
 * @param {Number} index The byte index of the start of the transmitter frame.
 * @param {Array} raddecs The array of raddecs.
 * @param {String} receiverId The identifier of the receiver.
 * @param {Number} timestamp The optional timestamp override of the decoding.
 */
Decode a single transmitter frame from the given buffer and offset.
@param {Buffer} data The binary packet as a buffer.
@param {Number} index The byte index of the start of the transmitter frame.
@param {Array} raddecs The array of raddecs.
@param {String} receiverId The identifier of the receiver.
@param {Number} timestamp The optional timestamp override of the decoding.
Decode a single transmitter frame from the given buffer and offset . @param { Buffer } data The binary packet as a buffer . @param { Number } index The byte index of the start of the transmitter frame . @param { Array } raddecs The array of raddecs . @param { String } receiverId The identifier of the receiver . @param { Number } timestamp The optional timestamp override of the decoding .
function decodeTransmitterFrame(data, index, raddecs, receiverId, timestamp) {
  timestamp = timestamp || data.readUInt32BE(index + 6) * 1000;
  let transmitterId = ('00000000000' +
                       data.readUIntBE(index, 6).toString(16)).substr(-12);
  let transmitterIdLittleEndian = data.readUIntLE(index, 6).toString(16);
  let rssi = data.readInt8(index + 10);
  let packetLength = data.readUInt8(index + 13);
  let packetFrameIndex = index + 14 + packetLength;
  let raddec = new Raddec({
      transmitterId: transmitterId,
      transmitterIdType: Raddec.identifiers.TYPE_EUI48, 
      timestamp: timestamp
  });
  raddec.addDecoding({ receiverId: receiverId,
                       receiverIdType: Raddec.identifiers.TYPE_EUI48,
                       rssi: rssi });
  if(packetLength > 0) {
    let packet = ('000' + packetLength.toString(16)).substr(-4);
    packet += transmitterIdLittleEndian;
    packet += data.toString('hex', index + 14, packetFrameIndex);
    raddec.addPacket(packet);
  }
  raddecs.push(raddec);
  return packetFrameIndex;
}
function decodeTransmitterFrame ( data , index , raddecs , receiverId , timestamp ) { timestamp = timestamp || data . readUInt32BE ( index + 6 ) * 1000 ; let transmitterId = ( '00000000000' + data . readUIntBE ( index , 6 ) . toString ( 16 ) ) . substr ( - 12 ) ; let transmitterIdLittleEndian = data . readUIntLE ( index , 6 ) . toString ( 16 ) ; let rssi = data . readInt8 ( index + 10 ) ; let packetLength = data . readUInt8 ( index + 13 ) ; let packetFrameIndex = index + 14 + packetLength ; let raddec = new Raddec ( { transmitterId : transmitterId , transmitterIdType : Raddec . identifiers . TYPE_EUI48 , timestamp : timestamp } ) ; raddec . addDecoding ( { receiverId : receiverId , receiverIdType : Raddec . identifiers . TYPE_EUI48 , rssi : rssi } ) ; if ( packetLength > 0 ) { let packet = ( '000' + packetLength . toString ( 16 ) ) . substr ( - 4 ) ; packet += transmitterIdLittleEndian ; packet += data . toString ( 'hex' , index + 14 , packetFrameIndex ) ; raddec . addPacket ( packet ) ; } raddecs . push ( raddec ) ; return packetFrameIndex ; }
Decode a single transmitter frame from the given buffer and offset.
Decode a single transmitter frame from the given buffer and offset .
// TODO: unknown