diff --git a/platform/cooja/dev/cooja-radio.c b/platform/cooja/dev/cooja-radio.c index 9a969016d..bb7ad5afd 100644 --- a/platform/cooja/dev/cooja-radio.c +++ b/platform/cooja/dev/cooja-radio.c @@ -55,6 +55,7 @@ const struct simInterface radio_interface; char simReceiving = 0; char simInDataBuffer[COOJA_RADIO_BUFSIZE]; int simInSize = 0; +rtimer_clock_t simLastPacketTimestamp = 0; char simOutDataBuffer[COOJA_RADIO_BUFSIZE]; int simOutSize = 0; char simRadioHWOn = 1; @@ -287,7 +288,13 @@ set_value(radio_param_t param, radio_value_t value) static radio_result_t get_object(radio_param_t param, void *dest, size_t size) { - return RADIO_RESULT_NOT_SUPPORTED; + if(param == RADIO_PARAM_LAST_PACKET_TIMESTAMP) { + if(size != sizeof(rtimer_clock_t) || !dest) { + return RADIO_RESULT_INVALID_VALUE; + } + *(rtimer_clock_t *)dest = (rtimer_clock_t)simLastPacketTimestamp; + return RADIO_RESULT_OK; + } } /*---------------------------------------------------------------------------*/ static radio_result_t diff --git a/tools/cooja/java/org/contikios/cooja/contikimote/interfaces/ContikiRadio.java b/tools/cooja/java/org/contikios/cooja/contikimote/interfaces/ContikiRadio.java index bbc4a2abd..dd0775225 100644 --- a/tools/cooja/java/org/contikios/cooja/contikimote/interfaces/ContikiRadio.java +++ b/tools/cooja/java/org/contikios/cooja/contikimote/interfaces/ContikiRadio.java @@ -62,6 +62,7 @@ import org.contikios.cooja.util.CCITT_CRC; *

*

  • int simInSize (size of received data packet) *
  • byte[] simInDataBuffer (data of received data packet) + *
  • int64_t simLastPacketTimestamp (timestamp of the last received data packet) *

    *

  • int simOutSize (size of transmitted data packet) *
  • byte[] simOutDataBuffer (data of transmitted data packet) @@ -190,6 +191,8 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA lastEventTime = mote.getSimulation().getSimulationTime(); lastEvent = RadioEvent.RECEPTION_STARTED; + myMoteMemory.setInt64ValueOf("simLastPacketTimestamp", lastEventTime); + this.setChanged(); this.notifyObservers(); }