IQRF standard
1. What is FRC
Patented method how to send a command from the Coordinator to all or selected Nodes and receive answer (including data collected by individual Nodes) in outstandingly short time.
2. Format of FRC Command
NADR |
PNUM |
PCMD |
HWPID |
PDATA |
where
NADR = 0x0000 Coordinator address
PNUM = 0x0D Predefined Peripherals – FRC
PCMD = 0x00 Command Send
HWPID = 0xFFFF
PDATA including these information’s:
PDATA[0] |
PDATA[1] |
PDATA[2] |
PDATA[3] |
_PCMD [type of FRC] |
[type of peripherals] |
[typ of sensors] |
[index] |
DataOutBeforeResponseFRC[0] |
DataOutBeforeResponseFRC[1] |
DataOutBeforeResponseFRC[2] |
PDATA[0] type of FRC
0x10 2– bit FRC_STD_SENSORS_BIT responseFRCvalue.1 = value (1 bit)
0x90 1 byte FRC_STD_SENSORS_1B responseFRCvalue = value
(1 byte)
0xE0 2 bytes FRC_STD_SENSORS_2B responseFRCvalue2B = value (2 byte)
0xF9 4 bytes FRC_STD_SENSORS_4B responseFRCvalue4B = value (4 byte)
PDATA[1] = DataOutBeforeResponseFRC[0] type of peripheral
0x5E PNUM_STD_SENSORS
PDATA[2] = DataOutBeforeResponseFRC[1] typ of sensor, f.e.:
0x01 2 bytes STD_SENSOR_TYPE_TEMPERATURE FRC standard: 1byte, 2byte
0x04 2 bytes STD_SENSOR_TYPE_EXTRA_LOW_VOLTAGE FRC standard: 2byte
0x81 1 byte STD_SENSOR_TYPE_BINARYDATA7 FRC standard: 2-bits-1byte
PDATA[3] = DataOutBeforeResponseFRC[2] index
PDATA [3] |
|||||||
bit 7 |
bit 6 |
bit 5 |
bit 4 |
bit 3 |
bit 2 |
bit 1 |
bit 0 |
bit index |
sensor index |
||||||
where
bit index – is a index of bit, which i asking by FRC, used in 2-bit FRC
sensor index – is a index of sensor if I have few sensors of the same type, f.e. 3x temperature
More info: https://www.iqrfalliance.org/techdoc_files/IQRF-StandardSensor_V015.pdf
3. Example: Implemented FRC and IQRF standard for 3 types of sensors
uns16 temperature;
uns16 e_low_voltage;
uns8 binary_data;
//random values for test
temperature= 0x0640; // 100 °C
e_low_voltage=0x3039; // 0x3039 = 12345d = 12345mV = 12,345 V
binary_data=5; // 00000101 position 0 = log.1, position 1 = log.0, position 2 = log.1,
case DpaEvent_FrcValue:
//first part – process the FRC request
if ( DataOutBeforeResponseFRC[0] == PNUM_STD_SENSORS ) //Check PDATA[1], if 0x5
{
uns8 sensorIndex = DataOutBeforeResponseFRC[2] & 0x1f; //save sensor index from PDATA[3]
uns8 bitIndex = DataOutBeforeResponseFRC[2] & 0xe0; // save bit index from PDATA[3]
bitIndex = bitIndex >> 5; // rotate 5x right
switch ( DataOutBeforeResponseFRC[1] // Check PDATA[2], type of sensor
)
{
default: //DPA handler return false
goto DpaHandleReturnFALSE;
case 0x00: //if 0x00 => type of sensor isn’t defined
goto _KeepSensorIndex; //save sensor index
case STD_SENSOR_TYPE_BINARYDATA7: // 0x81
if ( sensorIndex > 1 ) // only one sensor of this type
goto DpaHandleReturnFALSE;
W = 0 + sensorIndex;
break;
case STD_SENSOR_TYPE_EXTRA_LOW_VOLTAGE: // 0x04
if ( sensorIndex > 1 )
goto DpaHandleReturnFALSE;
W = 1 + sensorIndex;
break;
case STD_SENSOR_TYPE_TEMPERATURE: // 0x01
if ( sensorIndex > 1 )
goto DpaHandleReturnFALSE;
W = 2 + sensorIndex;
break;
}
sensorIndex = W; // new sensor index, depends on type and quantity of sensors
_KeepSensorIndex:
//second part – send the FRC answer
switch ( _PCMD) //Check PDATA[0], type of FRC
{
default: //if empty => DPA handler returns false
goto DpaHandleReturnFALSE;
case FRC_STD_SENSORS_BIT: //2-bit FRC, FRCommand 0x10
switch ( sensorIndex ) //send answer based on index of sensor
{
default:
gotoDpaHandleReturnFALSE;
case 0:
switch ( bitIndex) // send answer based on index of bit position
{
default:
gotoDpaHandleReturnFALSE;
case 0:
responseFRCvalue.1 = binary_data.0;
break;
case 1:
responseFRCvalue.1 = binary_data.1;
break;
case 2:
responseFRCvalue.1 = binary_data.2;
break;
}
break;
case 1:
responseFRCvalue.0 = 1; // 2- bit FRC Extra_Low_Voltage not implemented
responseFRCvalue.1 = 0;
break;
case 2:
responseFRCvalue.0 = 1; // 2- bit Temperature not implemented
responseFRCvalue.1 = 0;
break;
}
break;
case FRC_STD_SENSORS_1B: //1- byte FRC, FRCommand 0x90
switch ( sensorIndex ) //send answer based on index of sensor
{
default:
goto DpaHandleReturnFALSE;
case 0:
responseFRCvalue = binary_data; // return 1- byte FRC BinaryData7
break;
case 1:
responseFRCvalue = 0x01; // 1- byte FRC Extra_Low_Voltage not implemented
break;
case 2:
// Convert to the “F = ( T + 22 ) * 2 ” from 1/16 resolution
uns16_temp = temperature + 4; // Note: do rounding when /8
responseFRCvalue = (uns8)( _temp /8 ) + 44; // return 1- byte FRC Temperature
break;
}
break;
case FRC_STD_SENSORS_2B: // 2- byte FRC, FRCommand 0xE0
switch ( sensorIndex )
{
default:
goto DpaHandleReturnFALSE;
case 0:
responseFRCvalue2B = 0x0001; // 2- byte FRC BinaryData7 not implemented
break;
case 1:
responseFRCvalue2B = e_low_voltage ^ 0x8000; // return 2- byte FRC Extra_Low_Voltage
break;
case 2:
responseFRCvalue2B = temperature ^ 0x8000; // return 2- byte FRC Temperature
break;
}
break;
}
}
break;
4. FRC commands from example
For BinaryData7:
NADR PNUM PCMD HWPID PDATA
00.00 0D 00 FF.FF 10.5E.81.00 return 2-bit FRC, value of bit #0
00.00 0D 00 FF.FF 10.5E.81.20 return 2-bit FRC, value of bit #1
00.00 0D 00 FF.FF 10.5E.81.40 return 2-bit FRC, value of bit #2
00.00 0D 00 FF.FF 90.5E.81.00 return 1-byte FRC
00.00 0D 00 FF.FF E0.5E.81.00 return 2-bytes FRC (not implemented)
For Extra_Low_Voltage:
NADR PNUM PCMD HWPID PDATA
00.00 0D 00 FF.FF 10.5E.04.00 return 2-bit FRC (not implemented)
00.00 0D 00 FF.FF 90.5E.04.00 return 1-byte FRC (not implemented)
00.00 0D 00 FF.FF E0.5E.04.00 return 2-byte FRC
For Temperature:
NADR PNUM PCMD HWPID PDATA
00.00 0D 00 FF.FF 10.5E.01.00 return 2-bit FRC (not implemented)
00.00 0D 00 FF.FF 90.5E.01.00 return 1-byte FRC
00.00 0D 00 FF.FF E0.5E.01.00 return 2-byte FRC