diff --git a/src/lwm/nwk/nwkFrame.h b/src/lwm/nwk/nwkFrame.h index 80623d3..9e5930f 100644 --- a/src/lwm/nwk/nwkFrame.h +++ b/src/lwm/nwk/nwkFrame.h @@ -111,6 +111,7 @@ typedef struct NwkFrame_t { uint8_t lqi; int8_t rssi; + uint32_t timestamp; } rx; struct diff --git a/src/lwm/nwk/nwkRx.c b/src/lwm/nwk/nwkRx.c index 10a221e..71c2ca8 100644 --- a/src/lwm/nwk/nwkRx.c +++ b/src/lwm/nwk/nwkRx.c @@ -124,6 +124,7 @@ void PHY_DataInd(PHY_DataInd_t *ind) if (NULL == (frame = nwkFrameAlloc())) return; + frame->rx.timestamp = ind->timestamp; frame->state = NWK_RX_STATE_RECEIVED; frame->size = ind->size; frame->rx.lqi = ind->lqi; @@ -428,6 +429,7 @@ static bool nwkRxIndicateFrame(NwkFrame_t *frame) if (NULL == nwkIb.endpoint[header->nwkDstEndpoint]) return false; + ind.timestamp = frame->rx.timestamp; ind.srcAddr = header->nwkSrcAddr; ind.dstAddr = header->nwkDstAddr; ind.srcEndpoint = header->nwkSrcEndpoint; diff --git a/src/lwm/nwk/nwkRx.h b/src/lwm/nwk/nwkRx.h index e242acd..cf50d63 100644 --- a/src/lwm/nwk/nwkRx.h +++ b/src/lwm/nwk/nwkRx.h @@ -78,6 +78,7 @@ typedef struct NWK_DataInd_t uint8_t size; uint8_t lqi; int8_t rssi; + uint32_t timestamp; } NWK_DataInd_t; /*- Prototypes -------------------------------------------------------------*/ diff --git a/src/lwm/phy/phy.c b/src/lwm/phy/phy.c index fff052a..c942d2c 100644 --- a/src/lwm/phy/phy.c +++ b/src/lwm/phy/phy.c @@ -311,6 +311,11 @@ void PHY_TaskHandler(void) for (uint8_t i = 0; i < size + 1/*lqi*/; i++) phyRxBuffer[i] = TRX_FRAME_BUFFER(i); + ind.timestamp = SCTSRLL; + ind.timestamp |= (uint32_t)SCTSRLH << 8; + ind.timestamp |= (uint32_t)SCTSRHL << 16; + ind.timestamp |= (uint32_t)SCTSRHH << 24; + ind.data = phyRxBuffer; ind.size = size - PHY_CRC_SIZE; ind.lqi = phyRxBuffer[size]; diff --git a/src/lwm/phy/phy.h b/src/lwm/phy/phy.h index 203ddad..3c66c92 100644 --- a/src/lwm/phy/phy.h +++ b/src/lwm/phy/phy.h @@ -68,6 +68,7 @@ typedef struct PHY_DataInd_t uint8_t size; uint8_t lqi; int8_t rssi; + uint32_t timestamp; } PHY_DataInd_t; enum