decoder.js
/*
 * Decoder for Adeunis field test device ARF8112AA
 * 
 * Jonas Schwartze - j.schwartze@nibelungen-wohnbau.de
 *
 * This file can be used under any terms and conditions of the MIT Licence.
 * See LICENCE file for details. 
 */
Decoder for Adeunis field test device ARF8112AA



This file can be used under any terms and conditions of the MIT Licence.
See LICENCE file for details.
Decoder for Adeunis field test device ARF8112AA This file can be used under any terms and conditions of the MIT Licence . See LICENCE file for details .
function Decoder(b, fport) {
	var decoded = {};
	var bytes = [];
	var current_bit = 0;
	for (var i in b) {
		bytes.push(b[i]);
	}
	decoded = merge(decoded, decode_status(b[ current_bit ]));
	current_bit++;
	if ( decoded.temperature_reported ) {
		decoded = merge( decoded, decode_temperature( b[ current_bit ] ) );
		current_bit++;
	}
	if ( decoded.gps_reported ) {
		merge( decoded, decode_gps( b.slice( current_bit , current_bit + 9) ) );
		current_bit+=9;
	}
	if ( decoded.uplink_counter_reported ) {
		decoded.uplink_frame_count = b[ current_bit ];
		current_bit++;
	}
	if ( decoded.downlink_counter_reported ) {
		decoded.downlink_frame_count = b[ current_bit ];
		current_bit++;
	}
	if ( decoded.battery_level_reported ) {
		decoded.battery_level = ( b[ current_bit ]  << 8  ) + b[ current_bit + 1 ];
		current_bit +=2;
	}
	if ( decoded.rssi_snr_reported ) {
		decoded.rssi = b[ current_bit ] * -1;
		current_bit++;
		decoded.snr = b[ current_bit ];
		current_bit++;
	}
	decoded.bytes = "0x"+ bufferToHex(b);
	decoded.size = b.length;
	decoded.fport = fport;
	return decoded;
}
function Decoder ( b , fport ) { var decoded = { } ; var bytes = [ ] ; var current_bit = 0 ; for ( var i in b ) { bytes . push ( b [ i ] ) ; } decoded = merge ( decoded , decode_status ( b [ current_bit ] ) ) ; current_bit ++ ; if ( decoded . temperature_reported ) { decoded = merge ( decoded , decode_temperature ( b [ current_bit ] ) ) ; current_bit ++ ; } if ( decoded . gps_reported ) { merge ( decoded , decode_gps ( b . slice ( current_bit , current_bit + 9 ) ) ) ; current_bit += 9 ; } if ( decoded . uplink_counter_reported ) { decoded . uplink_frame_count = b [ current_bit ] ; current_bit ++ ; } if ( decoded . downlink_counter_reported ) { decoded . downlink_frame_count = b [ current_bit ] ; current_bit ++ ; } if ( decoded . battery_level_reported ) { decoded . battery_level = ( b [ current_bit ] << 8 ) + b [ current_bit + 1 ] ; current_bit += 2 ; } if ( decoded . rssi_snr_reported ) { decoded . rssi = b [ current_bit ] * - 1 ; current_bit ++ ; decoded . snr = b [ current_bit ] ; current_bit ++ ; } decoded . bytes = "0x" + bufferToHex ( b ) ; decoded . size = b . length ; decoded . fport = fport ; return decoded ; }
Decoder for Adeunis field test device ARF8112AA
Decoder for Adeunis field test device ARF8112AA