PreviousNext
FrcValue
Help > Custom DPA Handler > Events > FrcValue

[sync] This event is called whenever the [N] is asked to provide data to be collected by FRC (see Send) and specified FRC Command is not handled by DPA itself (see Predefined FRC Commands). FRC Command value is accessible at the _PCMD variable. FRC data to collect must be stored at the responseFRCvalue IQRF OS variable. If 2 bytes are collected then the data must be stored at responseFRCvalue2B variable instead and at responseFRCvalue4B variable when 4 bytes are collected respectively. If bits are collected then only the lowest 2 bits of responseFRCvalue are used. Before calling the event both variables are prefilled with value 0x01 or with 0x0001 respectively (except Acknowledged broadcast - bytes).

 

The code must take less than 40 ms at all Nodes to keep them synchronized (the event is fired at the same time at all Nodes) and to avoid RF collisions. If 40 ms is not enough to prepare data then use Set FRC Params to set a longer time to prepare data for FRC to return.

 

Important: If the event handler exceeds the selected time then the device does not respond via FRC at all thus “returning” 0 value. The event is raised even at the Nodes that are not addressed by the current FRC command. IQRF OS function amIRecipientOfFRC can be used to find out if the result value is to be returned.

 

User data passed by Send are accessible at DataOutBeforeResponseFRC IQRF OS variable. This event is implemented at [N] devices only.

 

Example

 

case DpaEvent_FrcValue:

{

  switch ( _PCMD )

  {

    // This example is sensitive to the bit FRCommand 0x40

    case FRC_USER_BIT_FROM:

      // Return info about power supply voltage

      if ( getSupplyVoltage() < 40 ) // < 3.00 V?

        // Both bits bit0 and bit1 are set now

        responseFRCvalue.1 = 1;

      break;

 

      // This example is sensitive to the byte FRCommand 0xC0

    case FRC_USER_BYTE_FROM:

      // Just return your logical address as an example

      responseFRCvalue = ntwADDR;

      break;

 

      // This example is sensitive to the byte FRCommand 0xF0

    case FRC_USER_2BYTE_FROM:

      // Return 2 byte value

      responseFRCvalue2B = Measure2Bytes();

      break;

 

      // This example is sensitive to the byte FRCommand 0xF8

    case FRC_USER_4BYTE_FROM:

      // Return 4 byte value

      // Use .low16, .high16, … to access this variable at the free CC5X edition

      responseFRCvalue4B = Measure4Bytes();

      break;

  }

 

  return Carry;

}

 

☼ See example code CustomDpaHandler-FRC.c for more details.