Commit 1541ee95 authored by Hynek Syrovátka's avatar Hynek Syrovátka 🇨🇿
Browse files

Sensor types:

* pH - fully implemented
* Ammonia - partly implemented (full specification is not finished yet)
parent 4ceaa170
......@@ -118,6 +118,10 @@ iqrf.sensor.STD_SENSOR_TYPE_ALTITUDE = 0x14;
Acceleration sensor.
*/
iqrf.sensor.STD_SENSOR_TYPE_ACCELERATION = 0x15;
/* Const: iqrf.sensor.STD_SENSOR_TYPE_NH3
Ammonia sensor. _Note: not fully implemented yet_
*/
iqrf.sensor.STD_SENSOR_TYPE_NH3 = 0x16;
// 1 byte
/* Const: iqrf.sensor.STD_SENSOR_TYPE_RELATIVE_HUMIDITY
......@@ -136,6 +140,10 @@ iqrf.sensor.STD_SENSOR_TYPE_POWER_FACTOR = 0x82;
UV index sensor.
*/
iqrf.sensor.STD_SENSOR_TYPE_UV_INDEX = 0x83;
/* Const: iqrf.sensor.STD_SENSOR_TYPE_PH
pH sensor.
*/
iqrf.sensor.STD_SENSOR_TYPE_PH = 0x84;
// 4 bytes
/* Const: iqrf.sensor.STD_SENSOR_TYPE_BINARYDATA30
......@@ -181,6 +189,7 @@ iqrf.sensor.STD_SENSOR_FRC_4BYTES = 0xF9;
// Sensor types
iqrf.sensor.SensorTypes = [];
// 2 bytes
iqrf.sensor.SensorTypes[iqrf.sensor.STD_SENSOR_TYPE_TEMPERATURE] =
{
name: 'Temperature',
......@@ -328,6 +337,17 @@ iqrf.sensor.SensorTypes[iqrf.sensor.STD_SENSOR_TYPE_ACCELERATION] =
unit: 'm/s²',
frcs: [iqrf.sensor.STD_SENSOR_FRC_2BYTES]
};
/* ToDo
iqrf.sensor.SensorTypes[iqrf.sensor.STD_SENSOR_TYPE_NH3] =
{
name: 'Ammonia',
shortName: 'NH3',
unit: '?',
frcs: [iqrf.sensor.STD_SENSOR_FRC_2BYTES]
};
*/
// 1 byte
iqrf.sensor.SensorTypes[iqrf.sensor.STD_SENSOR_TYPE_RELATIVE_HUMIDITY] =
{
name: 'Relative humidity',
......@@ -356,6 +376,15 @@ iqrf.sensor.SensorTypes[iqrf.sensor.STD_SENSOR_TYPE_UV_INDEX] =
unit: '',
frcs: [iqrf.sensor.STD_SENSOR_FRC_1BYTE]
};
iqrf.sensor.SensorTypes[iqrf.sensor.STD_SENSOR_TYPE_PH] =
{
name: 'pH',
shortName: 'pH',
unit: '',
frcs: [iqrf.sensor.STD_SENSOR_FRC_1BYTE]
};
// 4 bytes
iqrf.sensor.SensorTypes[iqrf.sensor.STD_SENSOR_TYPE_BINARYDATA30] =
{
name: 'Binary data30',
......@@ -384,6 +413,8 @@ iqrf.sensor.SensorTypes[iqrf.sensor.STD_SENSOR_TYPE_TIMESPAN_LONG] =
unit: 's',
frcs: [iqrf.sensor.STD_SENSOR_FRC_4BYTES]
};
// Multiple bytes
iqrf.sensor.SensorTypes[iqrf.sensor.STD_SENSOR_TYPE_DATA_BLOCK] =
{
name: 'Data block',
......@@ -432,18 +463,18 @@ iqrf.sensor.Enumerate_Response = function ( response )
if ( sensorObj === undefined )
throw new Error( 'iqrf.sensor.Enumerate_Response: Unknown sensor type ' + sensorType );
var sensorOut =
var sensorOut =
{
type: sensorType,
name: sensorObj.name,
shortName: sensorObj.shortName,
unit: sensorObj.unit,
frcs: sensorObj.frcs
};
type: sensorType,
name: sensorObj.name,
shortName: sensorObj.shortName,
unit: sensorObj.unit,
frcs: sensorObj.frcs
};
var sensorOutIndex = result.length;
result[sensorOutIndex] = sensorOut;
if ( iqrf.sensor.FinalizeSensor !== undefined )
iqrf.sensor.FinalizeSensor( sensorOut, sensorOutIndex );
}
......@@ -673,6 +704,10 @@ iqrf.sensor.ReadSensorsWithTypes_Response = function ( response, request )
sensorValue = sensorValue === 0x8000 ? NaN : iqrf.UInt16toInt16( sensorValue ) / 256.0;
break;
/* ToDo
case iqrf.sensor.STD_SENSOR_TYPE_NH3:
*/
// 1 byte
// ----------------
case iqrf.sensor.STD_SENSOR_TYPE_RELATIVE_HUMIDITY:
......@@ -691,6 +726,10 @@ iqrf.sensor.ReadSensorsWithTypes_Response = function ( response, request )
sensorValue = responseData[index] === 0xFF ? NaN : responseData[index] / 8.0;
break;
case iqrf.sensor.STD_SENSOR_TYPE_PH:
sensorValue = responseData[index] === 0xFF ? NaN : responseData[index] / 16.0;
break;
// 4 bytes
// ----------------
case iqrf.sensor.STD_SENSOR_TYPE_BINARYDATA30:
......@@ -989,6 +1028,10 @@ iqrf.sensor.Frc_Response = function ( sensorType, frcCommand, responseFrcSend, r
value = ( iqrf.UInt16toInt16( frcValue ) - 4 ) / 256.0;
break;
/* ToDo
case iqrf.sensor.STD_SENSOR_TYPE_NH3:
*/
case iqrf.sensor.STD_SENSOR_TYPE_RELATIVE_HUMIDITY:
value = ( frcValue - 4 ) / 2.0;
break;
......@@ -1014,6 +1057,10 @@ iqrf.sensor.Frc_Response = function ( sensorType, frcCommand, responseFrcSend, r
value = ( frcValue - 4 ) / 8.0;
break;
case iqrf.sensor.STD_SENSOR_TYPE_PH:
value = ( frcValue - 4 ) / 16.0;
break;
case iqrf.sensor.STD_SENSOR_TYPE_BINARYDATA30:
switch ( frcCommand )
{
......
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