The event is called when a DPA Request (except Get information for more peripherals and Remove bond) is received from the network or from the interface master (if applicable). If the event handler returns TRUE, then the request is not passed to the default handling by the DPA Request event. In this case, the programmer is fully responsible for preparing a valid DPA Response that will be returned to the device that sent the original DPA Request. Also, the BeforeSendingDpaResponse event is skipped. The event is raised even when HWPID does not match.
Example #1
case DpaEvent_ReceiveDpaRequest:
// Returns error when there is an attempt to write to the address 0 of RAM peripheral
if ( _PNUM==PNUM_RAM && _PCMD==CMD_RAM_WRITE && _DpaMessage.MemoryRequest.Address==0)
{
_PCMD |= RESPONSE_FLAG;
DpaApiSetPeripheralError( ERROR_FAIL );
return TRUE;
}
return FALSE;
Example #2
case DpaEvent_ReceiveDpaRequest:
// Do not allow DPA Request from Interface
if ( TX == LOCAL_ADDRESS )
{
_PCMD |= RESPONSE_FLAG;
DpaApiSetPeripheralError( ERROR_NADR );
return TRUE;
}
return FALSE;
Example #3
case DpaEvent_ReceiveDpaRequest:
// Beaming packet received and beaming command we understand?
if ( !_ROUTEF &&
_PNUM == PNUM_STD_SENSORS &&
_PCMD == ( PCMD_STD_SENSORS_READ_TYPES_AND_FRC_VALUES | RESPONSE_FLAG ) )
{
…
}
return FALSE;
☼ See example codes CustomDpaHandler-PeripheralMemoryMapping.c, CustomDpaHandler-HookDpa.c and CustomDpaHandler-BeamingAggregation.c for more details.