Commit 8372163d authored by Hynek Syrovátka's avatar Hynek Syrovátka 🇨🇿
Browse files

Fixed FRC error values handling

parent 298ae025
......@@ -1043,6 +1043,41 @@ Returns:
*/
iqrf.sensor.Frc_ConvertValue = function ( sensorType, frcValue, frcCommand )
{
if ( frcCommand !== iqrf.sensor.STD_SENSOR_FRC_2BITS )
switch ( frcValue )
{
case 0:
throw new Error( 'iqrf.sensor.Frc_ConvertValue: Unsupported FRC value 0' );
case 1:
return undefined;
case 2:
return NaN;
case 3:
throw new Error( 'iqrf.sensor.Frc_ConvertValue: Unsupported FRC value 3' );
default:
break;
}
else
switch ( frcValue )
{
case 0:
throw new Error( 'iqrf.sensor.Frc_ConvertValue: Unsupported FRC value 0' );
case 1:
return undefined;
case 2:
case 3:
break;
default:
throw new Error( 'iqrf.sensor.Frc_ConvertValue: Error FRC value ' + frcValue );
}
var value;
switch ( sensorType )
{
......@@ -1275,45 +1310,7 @@ iqrf.sensor.Frc_Response = function ( sensorType, frcCommand, responseFrcSend, r
result[index] = null;
else
{
var value;
var decodeValue = false;
if ( frcCommand !== iqrf.sensor.STD_SENSOR_FRC_2BITS )
switch ( frcValue )
{
case 1:
value = undefined;
break;
case 2:
value = NaN;
break;
case 3:
throw new Error( 'iqrf.sensor.Frc_Response: Unsupported FRC value 3 at index ' + index );
default:
decodeValue = true;
break;
}
else
switch ( frcValue )
{
case 1:
value = undefined;
break;
case 2:
case 3:
decodeValue = true;
break;
default:
throw new Error( 'iqrf.sensor.Frc_Response: Error FRC value ' + frcValue + ' at index ' + index );
}
if ( decodeValue )
value = iqrf.sensor.Frc_ConvertValue( sensorType, frcValue, frcCommand );
var value = iqrf.sensor.Frc_ConvertValue( sensorType, frcValue, frcCommand );
if ( value !== undefined )
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment