Fix RX callback

This commit is contained in:
Nanosonde 2020-11-08 18:15:37 +01:00
parent 2b74cf2b5e
commit 08cc2fff11

View File

@ -46,8 +46,13 @@ static volatile int err;
static void RxCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e) static void RxCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{ {
if ((e & RF_EventNDataWritten) && (packetStartTime == 0)) if (e & RF_EventNDataWritten)
{ {
// Make sure sure we are at the beginning of the packet
if (packetStartTime == 0)
{
packetStartTime = millis();
// pDataEntry->rxData contains the first byte of the received packet. // pDataEntry->rxData contains the first byte of the received packet.
// Just get the address to get the start address of the receive buffer // Just get the address to get the start address of the receive buffer
uint8_t *pData = &pDataEntry->rxData; uint8_t *pData = &pDataEntry->rxData;
@ -72,15 +77,13 @@ static void RxCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{ {
println("RF CMD_PROP_SET_LEN failed!"); println("RF CMD_PROP_SET_LEN failed!");
} }
}
packetStartTime = millis();
} }
else if (e & RF_TERMINATION_EVENT_MASK) else if (e & RF_TERMINATION_EVENT_MASK)
{ {
rfDone = true; rfDone = true;
rfErr = e & (RF_EventCmdStopped | RF_EventCmdAborted | RF_EventCmdCancelled); rfErr = e & (RF_EventCmdStopped | RF_EventCmdAborted | RF_EventCmdCancelled);
} }
else /* unknown reason - should not occure */ else /* unknown reason - should not occure */
{ {
pDataEntry->status = DATA_ENTRY_PENDING; pDataEntry->status = DATA_ENTRY_PENDING;
@ -88,7 +91,6 @@ static void RxCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
} }
} }
RfPhysicalLayerCC1310::RfPhysicalLayerCC1310(RfDataLinkLayer& rfDataLinkLayer, Platform& platform) RfPhysicalLayerCC1310::RfPhysicalLayerCC1310(RfDataLinkLayer& rfDataLinkLayer, Platform& platform)
: RfPhysicalLayer(rfDataLinkLayer, platform) : RfPhysicalLayer(rfDataLinkLayer, platform)
{ {