PreviousNext
DpaApiRfTxDpaPacket
Help > Custom DPA Handler > DPA API > DpaApiRfTxDpaPacket

void DpaApiRfTxDpaPacket( uns8 dpaValue, uns8 netDepthAndFlags )

 

Available at [N] devices. This function wraps all necessary code to send a DPA message (typically DPA Response) from [N] to [C]. There are only a few global parameters or variables that have to be filled in before the call (see example below). Many other parameters are handled inside the function automatically. The following example shows a typical usage. The parameter dpaValue specifies a DpaValue that is returned with the DPA Request. Because the message is asynchronous its response code the highest bit is set (see STATUS_ASYNC_RESPONSE).

 

If the [C] is addressed by COORDINATOR_ADDRESS = 0x00, then the DPA packet is sent by the addressed [C] to the interface master after it is received.

 

If the [C] is addressed by LOCAL_ADDRESS = 0xFC, then the DPA packet (request) is executed locally at [C].

 

The usage of the parameter netDepthAndFlags is the following. Lower 7 bits specify net depth. Use value 1 if the message should be terminated at the subordinate [C], use value 2 if the message should be terminated at the DPA interface of the same [C] or the [C] above the same [C], etc. If the most significant bit of netDepthAndFlags is set then the message is marked as synchronous otherwise as asynchronous.

 

Calling DpaApiRfTxDpaPacket is allowed only at Idle and AfterRouting events. The function does not take into account any IQMESH timing requirements (e.g. waiting for the end of the routing process) or possible RF signal collision.

 

It is important to make sure that the PID of the message differs from the previously sent message from the same device with the same PCMD, otherwise, the message is regarded as a duplicate. Please note, that the previous same message might have been sent as an ordinary DPA Response. So it is advised to store the PID of such a response and use a different one then. Please see the very first statement in the example below.

 

Example

 

// Generate new packet ID to avoid false detection of duplicate packet

PID = ++pid;

// Number of hops = my VRN

RTHOPS = ntwVRN;

// No DPA Params used

_DpaParams = 0;

// Execute DPA Request at Coordinator

_NADR = LOCAL_ADDRESS;

_NADRhigh = 0;

// We will use an LED peripheral

_PNUM = PNUM_LEDR;

// Pulse the LED

_PCMD = CMD_LED_PULSE;

// HW profile ID

_HWPID = 0x1234;

// Length of the data inside DPA Request message

_DpaDataLength = 0;

// Transmit DPA message with DPA Value equal the lastRSSI (can be any other value)

DpaApiRfTxDpaPacket( lastRSSI, 1 );

 

See example codes CustomDpaHandler-AsyncRequest.c for more details.